Compare commits
163 Commits
v1.0.1
...
githubActi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb03267275 | ||
|
|
9de5ad0157 | ||
|
|
61df613cd2 | ||
|
|
b70d6ca9ca | ||
|
|
0e15676cb7 | ||
|
|
5f419a0d02 | ||
|
|
a0efe7dd26 | ||
|
|
21afb5adcd | ||
|
|
7d0d73cd51 | ||
|
|
e8a51345a8 | ||
|
|
f471774da9 | ||
|
|
0facccf009 | ||
|
|
835c8fec03 | ||
|
|
eea093acd4 | ||
|
|
b32bfb3e54 | ||
|
|
65f330baae | ||
|
|
b43a677744 | ||
|
|
4b69d6a150 | ||
|
|
4a3ee6c5ca | ||
|
|
69baeb6339 | ||
|
|
f7fe2b0cca | ||
|
|
f853550748 | ||
|
|
75fa8f788c | ||
|
|
7a86fdaba3 | ||
|
|
1566b22489 | ||
|
|
ed026f3587 | ||
|
|
6e8e4ce780 | ||
|
|
60b7d90ad2 | ||
|
|
da83465f19 | ||
|
|
7ae0b64d8e | ||
|
|
f8cbf7801d | ||
|
|
7fbd49c5ea | ||
|
|
8717e26f76 | ||
|
|
483d6c3d17 | ||
|
|
03fb52fb8e | ||
|
|
e574f0e65f | ||
|
|
e9b04c712d | ||
|
|
b4c7c8860c | ||
|
|
815c161b7e | ||
|
|
ecaaaeb049 | ||
|
|
647846762d | ||
|
|
655a15c722 | ||
|
|
6297b859dd | ||
|
|
19f05c68f8 | ||
|
|
5a12bd9cce | ||
|
|
e22b374bdd | ||
|
|
fe3749d499 | ||
|
|
85ef7f252d | ||
|
|
f16b563a82 | ||
|
|
8e22dd817e | ||
|
|
569f3c02cd | ||
|
|
e8c2099e4c | ||
|
|
1646fefd56 | ||
|
|
aad387802e | ||
|
|
034d0a2f50 | ||
|
|
d2c78304c6 | ||
|
|
247857a843 | ||
|
|
038ff3a40e | ||
|
|
6d8776332f | ||
|
|
4ea24b0297 | ||
|
|
12570ecb00 | ||
|
|
7b68aecbd7 | ||
|
|
7ce62a8a3d | ||
|
|
d8c3cf725d | ||
|
|
aecc531d84 | ||
|
|
f107779542 | ||
|
|
70bf17011c | ||
|
|
86ae19fe2a | ||
|
|
e8235c4c35 | ||
|
|
63b5cd3bfb | ||
|
|
12e851c127 | ||
|
|
20fa72b613 | ||
|
|
36bee8070a | ||
|
|
9a85612b8a | ||
|
|
2bc18f7d90 | ||
|
|
6f6428543d | ||
|
|
d03087c1b8 | ||
|
|
d2d47cf8ee | ||
|
|
7a0f4490de | ||
|
|
d2b3c9472a | ||
|
|
3a0b9a00a3 | ||
|
|
d5cf4ad9e5 | ||
|
|
2899b2f263 | ||
|
|
7475321e97 | ||
|
|
88a24d7bdd | ||
|
|
f798a51edc | ||
|
|
81edab38f3 | ||
|
|
039607a294 | ||
|
|
2f33522e6d | ||
|
|
76c54a713a | ||
|
|
dcebed2d42 | ||
|
|
dbf9afa8da | ||
|
|
f7f397b5f2 | ||
|
|
44f852ad42 | ||
|
|
e1be2f2130 | ||
|
|
8468607703 | ||
|
|
f981318142 | ||
|
|
e1d0d7b293 | ||
|
|
d118a0cf74 | ||
|
|
7cb1095465 | ||
|
|
595b885b9a | ||
|
|
b1c219bc1b | ||
|
|
852b2ac3b4 | ||
|
|
937cded2aa | ||
|
|
022d2453d2 | ||
|
|
e5a187cc24 | ||
|
|
83bb63321a | ||
|
|
cd5b5c9240 | ||
|
|
2096ec0d5d | ||
|
|
25d4311237 | ||
|
|
7e07c2fc81 | ||
|
|
5a8a618e6b | ||
|
|
f072fc99b9 | ||
|
|
54e881fc58 | ||
|
|
cd6a3ed724 | ||
|
|
5a00dde912 | ||
|
|
876d7b2f7b | ||
|
|
4b74ec0e54 | ||
|
|
a719e33332 | ||
|
|
86a727f097 | ||
|
|
2670780076 | ||
|
|
ebf9912269 | ||
|
|
11549ab64e | ||
|
|
d128146952 | ||
|
|
686abd8842 | ||
|
|
551aeed835 | ||
|
|
5b1a1a2bcf | ||
|
|
09d2474a9a | ||
|
|
5c00e5493c | ||
|
|
c343af8f5a | ||
|
|
4af7eb5b89 | ||
|
|
aa9a340144 | ||
|
|
35ae68ceee | ||
|
|
560fb4ece6 | ||
|
|
8eb494cd5b | ||
|
|
0766336a56 | ||
|
|
24352f4d1c | ||
|
|
adb0fee973 | ||
|
|
13a7113aa7 | ||
|
|
e882975726 | ||
|
|
12209fe923 | ||
|
|
8a63744198 | ||
|
|
5871f0c9b0 | ||
|
|
908f524c64 | ||
|
|
9fa0ee3def | ||
|
|
35e9450f74 | ||
|
|
6033ea5a98 | ||
|
|
6f24c3cb39 | ||
|
|
e975e49d3e | ||
|
|
c5cfe10fa6 | ||
|
|
7c988460f0 | ||
|
|
21f1892de0 | ||
|
|
b97344849d | ||
|
|
935d48d4cc | ||
|
|
73ba233f9e | ||
|
|
ff955d392b | ||
|
|
19fde31f67 | ||
|
|
b3f368ac37 | ||
|
|
c5efb401b4 | ||
|
|
f386e6ed91 | ||
|
|
55b323c063 | ||
|
|
6f286b52d8 | ||
|
|
4850673b96 |
82
.github/workflows/gradle-build.yml
vendored
Normal file
82
.github/workflows/gradle-build.yml
vendored
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
# This workflow will build a Java project with Gradle
|
||||||
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
||||||
|
name: Build
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
jobs:
|
||||||
|
validation:
|
||||||
|
name: "Gradle wrapper validation"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2.3.5
|
||||||
|
- uses: gradle/wrapper-validation-action@v1.0.4
|
||||||
|
build:
|
||||||
|
name: "Build and publish"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2.3.5
|
||||||
|
with:
|
||||||
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
java-version: '11'
|
||||||
|
distribution: 'temurin'
|
||||||
|
- name: Cache SonarCloud packages
|
||||||
|
uses: actions/cache@v2.1.6
|
||||||
|
if: env.SONAR_TOKEN != null && env.SONAR_TOKEN != ''
|
||||||
|
env:
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
with:
|
||||||
|
path: ~/.sonar/cache
|
||||||
|
key: ${{ runner.os }}-sonar
|
||||||
|
restore-keys: ${{ runner.os }}-sonar
|
||||||
|
- name: Build
|
||||||
|
id: gradle
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
with:
|
||||||
|
arguments: check
|
||||||
|
wrapper-cache-enabled: true
|
||||||
|
dependencies-cache-enabled: true
|
||||||
|
configuration-cache-enabled: true
|
||||||
|
- name: "Comment build scan url"
|
||||||
|
uses: actions/github-script@v5
|
||||||
|
if: github.event_name == 'pull_request' && failure()
|
||||||
|
with:
|
||||||
|
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
script: |
|
||||||
|
github.issues.createComment({
|
||||||
|
issue_number: context.issue.number,
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
body: '❌ ${{ github.workflow }} failed: ${{ steps.gradle.outputs.build-scan-url }}'
|
||||||
|
})
|
||||||
|
- name: Publish Unit Test Results
|
||||||
|
uses: EnricoMi/publish-unit-test-result-action/composite@v1
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
files: '**/test-results/**/*.xml'
|
||||||
|
- name: Analyze with SonarCloud
|
||||||
|
continue-on-error: true
|
||||||
|
if: env.SONAR_TOKEN != null && env.SONAR_TOKEN != ''
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
with:
|
||||||
|
arguments: sonarqube -Psonar.organization=swagger2markup
|
||||||
|
dependencies-cache-enabled: true
|
||||||
|
configuration-cache-enabled: true
|
||||||
|
- name: Publish to Sonatype
|
||||||
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
|
||||||
|
uses: eskatos/gradle-command-action@v1
|
||||||
|
env:
|
||||||
|
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USER }}
|
||||||
|
ORG_GRADLE_PROJECT_sonatypePassword : ${{ secrets.SONATYPE_PASSWORD }}
|
||||||
|
with:
|
||||||
|
arguments: publishToSonatype
|
||||||
|
dependencies-cache-enabled: true
|
||||||
|
configuration-cache-enabled: true
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
language: java
|
language: java
|
||||||
jdk:
|
jdk:
|
||||||
- oraclejdk8
|
- openjdk8
|
||||||
before_install:
|
before_install:
|
||||||
- chmod +x gradlew
|
- chmod +x gradlew
|
||||||
after_success:
|
after_success:
|
||||||
|
|||||||
19
README.adoc
19
README.adoc
@@ -7,6 +7,17 @@ image:https://travis-ci.org/Swagger2Markup/swagger2markup.svg?branch=master["Bui
|
|||||||
|
|
||||||
== Overview
|
== Overview
|
||||||
|
|
||||||
|
|
||||||
|
NOTE: Dear community,
|
||||||
|
unfortunately I can't maintain Swagger2Markup alone anymore. There are many interesting new topics:
|
||||||
|
1) Swagger v3 support
|
||||||
|
2) Fixing bugs
|
||||||
|
2) Merge Swagger2Markup repositories and create a new multi-module repository.
|
||||||
|
Any help is welcome.
|
||||||
|
Kind regards,
|
||||||
|
Robert
|
||||||
|
|
||||||
|
|
||||||
The primary goal of this project is to *simplify the generation of an up-to-date RESTful API documentation by combining documentation that's been hand-written with auto-generated API documentation* produced by https://github.com/swagger-api[Swagger]. The result is intended to be an *up-to-date, easy-to-read, on- and offline user guide*, comparable to https://developer.github.com/v3/[GitHub's API documentation]. The output of Swagger2Markup can be used as an alternative to https://github.com/swagger-api/swagger-ui[swagger-ui] and can be served as static content.
|
The primary goal of this project is to *simplify the generation of an up-to-date RESTful API documentation by combining documentation that's been hand-written with auto-generated API documentation* produced by https://github.com/swagger-api[Swagger]. The result is intended to be an *up-to-date, easy-to-read, on- and offline user guide*, comparable to https://developer.github.com/v3/[GitHub's API documentation]. The output of Swagger2Markup can be used as an alternative to https://github.com/swagger-api/swagger-ui[swagger-ui] and can be served as static content.
|
||||||
NOTE: The Swagger Specification has been donated to to the https://openapis.org/[Open API Initiative (OAI)] and has been renamed to the https://github.com/OAI/OpenAPI-Specification[OpenAPI Specification].
|
NOTE: The Swagger Specification has been donated to to the https://openapis.org/[Open API Initiative (OAI)] and has been renamed to the https://github.com/OAI/OpenAPI-Specification[OpenAPI Specification].
|
||||||
|
|
||||||
@@ -22,12 +33,12 @@ The project requires at least JDK 8.
|
|||||||
|
|
||||||
== Example
|
== Example
|
||||||
|
|
||||||
image::src/docs/asciidoc/images/Swagger2Markup.PNG[]
|
image::swagger2markup-documentation/src/docs/asciidoc/images/Swagger2Markup.PNG[]
|
||||||
|
|
||||||
image::src/docs/asciidoc/images/Swagger2Markup_definitions.PNG[]
|
image::swagger2markup-documentation/src/docs/asciidoc/images/Swagger2Markup_definitions.PNG[]
|
||||||
|
|
||||||
== Reference documentation
|
== Reference documentation
|
||||||
- http://swagger2markup.github.io/swagger2markup/1.0.1/[Reference Documentation]
|
- http://swagger2markup.github.io/swagger2markup/1.3.3/[Reference Documentation]
|
||||||
- https://github.com/Swagger2Markup/swagger2markup/blob/master/RELEASENOTES.adoc[Release notes]
|
- https://github.com/Swagger2Markup/swagger2markup/blob/master/RELEASENOTES.adoc[Release notes]
|
||||||
- https://github.com/Swagger2Markup/spring-swagger2markup-demo[Demo using Swagger2Markup, Spring Boot, Springfox and spring-restdocs]
|
- https://github.com/Swagger2Markup/spring-swagger2markup-demo[Demo using Swagger2Markup, Spring Boot, Springfox and spring-restdocs]
|
||||||
|
|
||||||
@@ -54,6 +65,8 @@ If you’d like an enhancement to be made to Swagger2Markup, pull requests are m
|
|||||||
* http://www.appdirect.com/[AppDirect] -- The leading commerce platform for selling cloud services.
|
* http://www.appdirect.com/[AppDirect] -- The leading commerce platform for selling cloud services.
|
||||||
* http://www.wescale.com[wescale]
|
* http://www.wescale.com[wescale]
|
||||||
* http://taskassure.com[TaskAssure]
|
* http://taskassure.com[TaskAssure]
|
||||||
|
* https://www.isaac.nl[ISAAC]
|
||||||
|
* https://www.spreadshirt.de[Spreadshirt]
|
||||||
|
|
||||||
== License
|
== License
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,21 @@
|
|||||||
== Version 0.1.0
|
== Version 0.1.0
|
||||||
* Initial version with support for AsciiDoc and Markdown
|
* Initial version with support for AsciiDoc and Markdown
|
||||||
|
|
||||||
|
=== Version 0.1.1
|
||||||
|
* Signed jar files
|
||||||
|
|
||||||
|
=== Version 0.1.2
|
||||||
|
* Removed logback from compile dependency
|
||||||
|
|
||||||
|
=== Version 0.1.3
|
||||||
|
* Removed commons.io from compile dependency
|
||||||
|
|
||||||
|
=== Version 0.1.4
|
||||||
|
* Fixed SECTION_TITLE_LEVEL3 in Markdown enum
|
||||||
|
|
||||||
|
=== Version 0.1.5
|
||||||
|
* Added SECTION_TITLE_LEVEL4
|
||||||
|
|
||||||
== Version 0.2.0
|
== Version 0.2.0
|
||||||
* This version is not downward compatible. This version supports includes of example files and JSON/XML Schema files. See documentation.
|
* This version is not downward compatible. This version supports includes of example files and JSON/XML Schema files. See documentation.
|
||||||
|
|
||||||
@@ -95,3 +110,60 @@
|
|||||||
=== Version 1.0.1
|
=== Version 1.0.1
|
||||||
* Enhancement: Support to render validation constraints of properties
|
* Enhancement: Support to render validation constraints of properties
|
||||||
* Enhancement: Possibility to disable rendering of the security chapter below operations
|
* Enhancement: Possibility to disable rendering of the security chapter below operations
|
||||||
|
|
||||||
|
== Version 1.1.0
|
||||||
|
* PR #177: Fixed rendering of recursive examples
|
||||||
|
* PR #186: Add support for Chinese language
|
||||||
|
* PR #190: Add support for Spanish language
|
||||||
|
* PR #192: Updated min/max value to format correctly based on the data type
|
||||||
|
* PR #193: Added support for exclusiveMin and exclusiveMax
|
||||||
|
* Changed bold to ** and italic to __ so that special chars in the text are possible
|
||||||
|
|
||||||
|
=== Version 1.1.1
|
||||||
|
* Issue #194: Added a config parameter which allows to prepend the basePath to all paths.
|
||||||
|
* Updated swagger-parser from v1.0.16 to v1.0.23
|
||||||
|
* Added javslang v2.0.4 as a dependency
|
||||||
|
* Added paleo-core v0.10.1 as a dependency
|
||||||
|
* Updated markup-document-builder from 1.0.0 to 1.1.0
|
||||||
|
* PR #201: Add support for Brazilian Portuguese language
|
||||||
|
* PR #202: Add support for Japanese language
|
||||||
|
* Issue #205: Fixed the option to influence resource ordering
|
||||||
|
* Issue #198: Chinese chinese language encoding
|
||||||
|
* Issue #207: Properties that start with an underscore are displayed correctly now
|
||||||
|
* Refactored Swagger2Markup to use a Component-Based design. A document can be composed of components and components can be composed of other components.
|
||||||
|
* Added a method to add page breaks.
|
||||||
|
|
||||||
|
== Version 1.1.2
|
||||||
|
* Improve code blocks in markdown
|
||||||
|
|
||||||
|
== Version 1.2.0
|
||||||
|
* Issue #214: Add page break locations
|
||||||
|
* Issue #223: Improve example rendering
|
||||||
|
* Issue #215: Add ability to group operations by RegEx
|
||||||
|
* Added new configuration options: pageBreakLocations, headerRegex
|
||||||
|
* Added new valid value for configuration headerRegex: REGEX
|
||||||
|
* Updated markup-document-builder from 1.1.0 to 1.1.1
|
||||||
|
|
||||||
|
== Version 1.3.0
|
||||||
|
* Updated javslang from 2.0.4 to 2.0.5
|
||||||
|
* Updated paleo-core from 0.10.1 to 0.10.2
|
||||||
|
* Updated swagger-parser from v1.0.23 to v1.0.25
|
||||||
|
* Decimal numbers are formatted into locale-specific strings
|
||||||
|
|
||||||
|
=== Version 1.3.1
|
||||||
|
* PR #247: Fix request path and query params example support.
|
||||||
|
|
||||||
|
=== Version 1.3.2
|
||||||
|
* PR #290: Fixed list parsing in properties file
|
||||||
|
* PR #293: Fixed crash on empty tables
|
||||||
|
* Updated markup-document-builder from 1.1.1 to 1.1.2
|
||||||
|
|
||||||
|
=== Version 1.3.3
|
||||||
|
* Updated swagger-parser from v1.0.25 to 1.0.35
|
||||||
|
* PR #294: Examples always start with a newline if there is other content in the same cell
|
||||||
|
* PR 307: Include required parameters in example request
|
||||||
|
|
||||||
|
=== Version 2.0.0
|
||||||
|
* Added openapi2markup to support OpenAPI v3
|
||||||
|
* Issue #409: Fixed JSON response example
|
||||||
|
|
||||||
|
|||||||
183
build.gradle
183
build.gradle
@@ -1,67 +1,142 @@
|
|||||||
buildscript {
|
plugins {
|
||||||
repositories {
|
id "org.sonarqube" version "2.7"
|
||||||
|
id "com.jfrog.bintray" version "1.8.4"
|
||||||
|
id "me.champeau.gradle.jmh" version "0.4.8"
|
||||||
|
id 'org.asciidoctor.convert' version '1.6.0'
|
||||||
|
id "com.jfrog.artifactory" version "4.9.5"
|
||||||
|
id "org.ajoberstar.github-pages" version "1.7.2"
|
||||||
|
}
|
||||||
|
apply plugin: 'idea'
|
||||||
|
apply from: "${rootDir}/libraries.gradle"
|
||||||
|
|
||||||
|
ext {
|
||||||
|
releaseVersion = '1.3.3'
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
apply plugin: 'jacoco'
|
||||||
|
apply plugin: 'me.champeau.gradle.jmh'
|
||||||
|
apply plugin: 'com.jfrog.artifactory'
|
||||||
|
|
||||||
|
version = '2.0.0-SNAPSHOT'
|
||||||
|
group 'io.github.swagger2markup'
|
||||||
|
description = 'swagger2markup Build'
|
||||||
|
|
||||||
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
maven {
|
||||||
dependencies {
|
name "OSS Snapshots"
|
||||||
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.3'
|
url "https://oss.jfrog.org/artifactory/oss-snapshot-local"
|
||||||
classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.10.1'
|
}
|
||||||
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.1'
|
|
||||||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
|
|
||||||
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.0.0"
|
|
||||||
classpath "org.ajoberstar:gradle-git:1.3.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
description = 'swagger2markup Build'
|
artifactoryPublish.skip = true // apply to all projects except the root
|
||||||
version = '1.0.1'
|
|
||||||
group = 'io.github.swagger2markup'
|
|
||||||
|
|
||||||
apply plugin: 'java'
|
ext {
|
||||||
apply plugin: 'eclipse'
|
coreProjects = subprojects.findAll {
|
||||||
apply from: 'gradle/publishing.gradle'
|
p -> !p.name.contains("documentation") && !p.name.endsWith("-bom")
|
||||||
apply from: 'gradle/coverage.gradle'
|
|
||||||
apply from: 'gradle/documentation.gradle'
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
|
||||||
sourceCompatibility = "1.8"
|
|
||||||
targetCompatibility = "1.8"
|
|
||||||
options.deprecation = true
|
|
||||||
options.encoding = 'UTF-8'
|
|
||||||
options.compilerArgs << "-Xlint:unchecked"
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
url "https://oss.jfrog.org/artifactory/oss-snapshot-local"
|
|
||||||
}
|
}
|
||||||
jcenter()
|
|
||||||
mavenCentral()
|
|
||||||
//mavenLocal()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
configure(project.coreProjects) {
|
||||||
compile 'io.github.swagger2markup:markup-document-builder:1.0.0'
|
apply plugin: 'java'
|
||||||
compile 'io.swagger:swagger-compat-spec-parser:1.0.18'
|
apply plugin: 'maven'
|
||||||
compile 'org.apache.commons:commons-configuration2:2.0'
|
apply plugin: 'maven-publish'
|
||||||
compile 'commons-beanutils:commons-beanutils:1.9.2'
|
apply plugin: 'com.jfrog.bintray'
|
||||||
compile 'org.apache.commons:commons-collections4:4.1'
|
apply from: "${rootDir}/publishing.gradle"
|
||||||
testCompile 'junit:junit:4.11'
|
apply plugin: 'jacoco'
|
||||||
testCompile 'org.asciidoctor:asciidoctorj:1.5.4'
|
|
||||||
testCompile 'ch.qos.logback:logback-classic:1.1.2'
|
tasks.withType(JavaCompile) {
|
||||||
testCompile 'org.assertj:assertj-core:3.4.0'
|
sourceCompatibility = "1.8"
|
||||||
testCompile 'io.github.robwin:assertj-diff:0.1.1'
|
targetCompatibility = "1.8"
|
||||||
|
options.deprecation = true
|
||||||
|
options.encoding = 'UTF-8'
|
||||||
|
options.compilerArgs += ["-Xlint:unchecked", "-parameters"]
|
||||||
|
}
|
||||||
|
tasks.withType(Javadoc){
|
||||||
|
options.encoding = 'UTF-8'
|
||||||
|
}
|
||||||
|
jmh {
|
||||||
|
duplicateClassesStrategy = 'warn'
|
||||||
|
}
|
||||||
|
configurations.all {
|
||||||
|
resolutionStrategy {
|
||||||
|
failOnVersionConflict()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sonarqube {
|
||||||
|
properties {
|
||||||
|
property "sonar.projectName", "swagger2markup"
|
||||||
|
property "sonar.projectKey", "swagger2markup_swagger2markup"
|
||||||
|
property "sonar.links.homepage", "https://github.com/Swagger2Markup/swagger2markup"
|
||||||
|
property "sonar.links.ci", "https://travis-ci.org/Swagger2Markup/swagger2markup"
|
||||||
|
property "sonar.links.scm", "https://github.com/Swagger2Markup/swagger2markup"
|
||||||
|
property "sonar.links.issue", "https://github.com/Swagger2Markup/swagger2markup/issues"
|
||||||
|
property "sonar.language", "java"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
def allTestCoverageFile = "$buildDir/jacoco/allTestCoverage.exec"
|
||||||
|
|
||||||
|
task jacocoMergeTest(type: JacocoMerge) {
|
||||||
|
destinationFile = file(allTestCoverageFile)
|
||||||
|
executionData = project.fileTree(dir: '.', include: '**/build/jacoco/test.exec')
|
||||||
|
}
|
||||||
|
|
||||||
|
task jacocoMerge(dependsOn: ['jacocoMergeTest']) {
|
||||||
|
// used to run the other merge tasks
|
||||||
|
}
|
||||||
|
|
||||||
|
subprojects {
|
||||||
|
sonarqube {
|
||||||
|
properties {
|
||||||
|
property "sonar.jacoco.reportPaths", allTestCoverageFile
|
||||||
|
}
|
||||||
|
}
|
||||||
|
afterEvaluate {
|
||||||
|
// exclude subprojects that don't produce a jar file or by design.
|
||||||
|
if (!project.name.equals('swagger2markup-bom') && !project.name.equals('swagger2markup-documentation')) {
|
||||||
|
jar {
|
||||||
|
inputs.property('moduleName', moduleName)
|
||||||
|
manifest.attributes(
|
||||||
|
'Automatic-Module-Name': moduleName
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.check.dependsOn tasks.jacocoTestReport
|
||||||
|
|
||||||
|
|
||||||
test {
|
test {
|
||||||
if (System.properties['http.proxyHost']) {
|
dependsOn(subprojects.test) // required by cobertura to aggregate report
|
||||||
systemProperty 'http.proxyHost', System.properties['http.proxyHost']
|
}
|
||||||
systemProperty 'http.proxyPort', System.properties['http.proxyPort']
|
|
||||||
systemProperty 'http.nonProxyHosts', System.properties['http.nonProxyHosts']
|
artifactory {
|
||||||
|
contextUrl = 'https://oss.jfrog.org'
|
||||||
|
resolve {
|
||||||
|
repository {
|
||||||
|
repoKey = 'libs-release'
|
||||||
|
maven = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
publish {
|
||||||
|
repository {
|
||||||
|
repoKey = 'oss-snapshot-local' //The Artifactory repository key to publish to
|
||||||
|
//when using oss.jfrog.org the credentials are from Bintray. For local build we expect them to be found in
|
||||||
|
//~/.gradle/gradle.properties, otherwise to be set in the build server
|
||||||
|
username = project.hasProperty('bintrayUsername') ? project.bintrayUsername : System.getenv('BINTRAY_USER')
|
||||||
|
password = project.hasProperty('bintrayApiKey') ? project.bintrayApiKey : System.getenv('BINTRAY_KEY')
|
||||||
|
}
|
||||||
|
defaults {
|
||||||
|
publications('mavenJava')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (System.properties['https.proxyHost']) {
|
||||||
|
clientConfig.proxy.host = System.properties['https.proxyHost']
|
||||||
|
clientConfig.proxy.port = System.properties['https.proxyPort'].toInteger()
|
||||||
}
|
}
|
||||||
systemProperty 'file.encoding', 'UTF-8'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
task wrapper(type: Wrapper) {
|
|
||||||
gradleVersion = '2.12'
|
|
||||||
}
|
}
|
||||||
|
|||||||
2
gradle.properties
Normal file
2
gradle.properties
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
systemProp.file.encoding=UTF-8
|
||||||
|
systemProp.sun.jnu.encoding=UTF-8
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
apply plugin: 'jacoco'
|
|
||||||
apply plugin: 'com.github.kt3k.coveralls'
|
|
||||||
|
|
||||||
jacocoTestReport {
|
|
||||||
reports {
|
|
||||||
xml.enabled = true // coveralls plugin depends on xml format report
|
|
||||||
html.enabled = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.coveralls {
|
|
||||||
dependsOn 'check'
|
|
||||||
}
|
|
||||||
@@ -1,151 +0,0 @@
|
|||||||
import java.text.SimpleDateFormat
|
|
||||||
|
|
||||||
apply plugin: 'maven-publish'
|
|
||||||
apply plugin: 'com.jfrog.bintray'
|
|
||||||
apply plugin: "com.jfrog.artifactory"
|
|
||||||
|
|
||||||
Date buildTimeAndDate = new Date()
|
|
||||||
ext {
|
|
||||||
buildDate = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate)
|
|
||||||
buildTime = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate)
|
|
||||||
projectUrl = 'https://github.com/Swagger2Markup/swagger2markup'
|
|
||||||
licenseUrl = 'https://github.com/Swagger2Markup/swagger2markup/blob/master/LICENSE.txt'
|
|
||||||
scmUrl = 'https://github.com/Swagger2Markup/swagger2markup.git'
|
|
||||||
issuesUrl = 'https://github.com/Swagger2Markup/swagger2markup/issues'
|
|
||||||
}
|
|
||||||
|
|
||||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
||||||
classifier = 'sources'
|
|
||||||
from sourceSets.main.allSource
|
|
||||||
}
|
|
||||||
|
|
||||||
task javadocJar(type: Jar, dependsOn: javadoc) {
|
|
||||||
classifier = 'javadoc'
|
|
||||||
from javadoc.destinationDir
|
|
||||||
}
|
|
||||||
|
|
||||||
artifacts {
|
|
||||||
archives sourcesJar
|
|
||||||
archives javadocJar
|
|
||||||
}
|
|
||||||
|
|
||||||
jar {
|
|
||||||
manifest {
|
|
||||||
attributes(
|
|
||||||
'Created-By': System.properties['java.version'] + " (" + System.properties['java.vendor'] + " " + System.properties['java.vm.version'] + ")",
|
|
||||||
'Built-With': "gradle-${project.getGradle().getGradleVersion()}, groovy-${GroovySystem.getVersion()}",
|
|
||||||
'Build-Time': "${new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")}",
|
|
||||||
'Specification-Title': "${project.name}",
|
|
||||||
'Specification-Version': project.version.toString(),
|
|
||||||
'Implementation-Title': "${project.name}",
|
|
||||||
'Implementation-Version': project.version.toString()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!project.hasProperty('bintrayUsername')) ext.bintrayUsername = ''
|
|
||||||
if (!project.hasProperty('bintrayApiKey')) ext.bintrayApiKey = ''
|
|
||||||
if (!project.hasProperty('gpgPassphrase')) ext.gpgPassphrase = ''
|
|
||||||
if (!project.hasProperty('ossUser')) ext.ossUser = ''
|
|
||||||
if (!project.hasProperty('ossPassword')) ext.ossPassword = ''
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
mavenJava(MavenPublication) {
|
|
||||||
from components.java
|
|
||||||
pom.withXml {
|
|
||||||
def devs = ['RobWin': 'Robert Winkler']
|
|
||||||
def root = asNode()
|
|
||||||
|
|
||||||
root.dependencies.'*'.findAll() {
|
|
||||||
it.scope.text() == 'runtime' && project.configurations.compile.allDependencies.find { dep ->
|
|
||||||
dep.name == it.artifactId.text()
|
|
||||||
}
|
|
||||||
}.each() {
|
|
||||||
it.scope*.value = 'compile'
|
|
||||||
}
|
|
||||||
|
|
||||||
root.appendNode('name', project.name)
|
|
||||||
root.appendNode('packaging', 'jar')
|
|
||||||
root.appendNode('url', projectUrl)
|
|
||||||
root.appendNode('description', project.description)
|
|
||||||
|
|
||||||
def license = root.appendNode('licenses').appendNode('license')
|
|
||||||
license.appendNode('name', 'Apache-2.0')
|
|
||||||
license.appendNode('url', licenseUrl)
|
|
||||||
license.appendNode('distribution', 'repo')
|
|
||||||
|
|
||||||
root.appendNode('scm').appendNode('url', scmUrl)
|
|
||||||
|
|
||||||
def developers = root.appendNode('developers')
|
|
||||||
devs.each {
|
|
||||||
def d = developers.appendNode('developer')
|
|
||||||
d.appendNode('id', it.key)
|
|
||||||
d.appendNode('name', it.value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
artifact sourcesJar
|
|
||||||
artifact javadocJar
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bintray {
|
|
||||||
user = project.bintrayUsername
|
|
||||||
key = project.bintrayApiKey
|
|
||||||
dryRun = false //Whether to run this as dry-run, without deploying
|
|
||||||
publish = true //If version should be auto published after an upload
|
|
||||||
publications = ['mavenJava']
|
|
||||||
pkg {
|
|
||||||
repo = 'Maven'
|
|
||||||
name = 'swagger2markup'
|
|
||||||
userOrg = 'swagger2markup'
|
|
||||||
websiteUrl = projectUrl
|
|
||||||
issueTrackerUrl = issuesUrl
|
|
||||||
vcsUrl = scmUrl
|
|
||||||
desc = rootProject.description
|
|
||||||
licenses = ['Apache-2.0']
|
|
||||||
version {
|
|
||||||
vcsTag = rootProject.version
|
|
||||||
gpg {
|
|
||||||
sign = true //Determines whether to GPG sign the files. The default is false
|
|
||||||
passphrase = project.gpgPassphrase //Optional. The passphrase for GPG signing'
|
|
||||||
}
|
|
||||||
mavenCentralSync {
|
|
||||||
sync = true //Optional (true by default). Determines whether to sync the version to Maven Central.
|
|
||||||
user = ossUser //OSS user token
|
|
||||||
password = ossPassword //OSS user password
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
artifactory {
|
|
||||||
contextUrl = 'https://oss.jfrog.org'
|
|
||||||
resolve {
|
|
||||||
repository {
|
|
||||||
repoKey = 'libs-release'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
publish {
|
|
||||||
repository {
|
|
||||||
repoKey = 'oss-snapshot-local' //The Artifactory repository key to publish to
|
|
||||||
//when using oss.jfrog.org the credentials are from Bintray. For local build we expect them to be found in
|
|
||||||
//~/.gradle/gradle.properties, otherwise to be set in the build server
|
|
||||||
username = project.hasProperty('bintrayUsername') ? project.bintrayUsername : System.getenv('BINTRAY_USER')
|
|
||||||
password = project.hasProperty('bintrayApiKey') ? project.bintrayApiKey : System.getenv('BINTRAY_KEY')
|
|
||||||
}
|
|
||||||
defaults {
|
|
||||||
publications('mavenJava')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (System.properties['https.proxyHost']) {
|
|
||||||
clientConfig.proxy.host = System.properties['https.proxyHost']
|
|
||||||
clientConfig.proxy.port = System.properties['https.proxyPort'].toInteger()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.artifactoryPublish {
|
|
||||||
dependsOn 'check'
|
|
||||||
}
|
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Thu Mar 31 16:29:35 CEST 2016
|
#Mon Oct 21 16:35:38 BST 2019
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-all.zip
|
||||||
|
|||||||
100
gradlew
vendored
100
gradlew
vendored
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
##
|
||||||
@@ -6,42 +6,6 @@
|
|||||||
##
|
##
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
DEFAULT_JVM_OPTS=""
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=`basename "$0"`
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
||||||
MAX_FD="maximum"
|
|
||||||
|
|
||||||
warn ( ) {
|
|
||||||
echo "$*"
|
|
||||||
}
|
|
||||||
|
|
||||||
die ( ) {
|
|
||||||
echo
|
|
||||||
echo "$*"
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
|
||||||
cygwin=false
|
|
||||||
msys=false
|
|
||||||
darwin=false
|
|
||||||
case "`uname`" in
|
|
||||||
CYGWIN* )
|
|
||||||
cygwin=true
|
|
||||||
;;
|
|
||||||
Darwin* )
|
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
PRG="$0"
|
PRG="$0"
|
||||||
@@ -60,6 +24,46 @@ cd "`dirname \"$PRG\"`/" >/dev/null
|
|||||||
APP_HOME="`pwd -P`"
|
APP_HOME="`pwd -P`"
|
||||||
cd "$SAVED" >/dev/null
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS=""
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD="maximum"
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "`uname`" in
|
||||||
|
CYGWIN* )
|
||||||
|
cygwin=true
|
||||||
|
;;
|
||||||
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
@@ -85,7 +89,7 @@ location of your Java installation."
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
if [ $? -eq 0 ] ; then
|
if [ $? -eq 0 ] ; then
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
@@ -150,11 +154,19 @@ if $cygwin ; then
|
|||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
# Escape application args
|
||||||
function splitJvmOpts() {
|
save () {
|
||||||
JVM_OPTS=("$@")
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
}
|
}
|
||||||
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
APP_ARGS=$(save "$@")
|
||||||
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
|
||||||
|
|
||||||
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
|
|||||||
14
gradlew.bat
vendored
14
gradlew.bat
vendored
@@ -8,14 +8,14 @@
|
|||||||
@rem Set local scope for the variables with windows NT shell
|
@rem Set local scope for the variables with windows NT shell
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
set DEFAULT_JVM_OPTS=
|
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS=
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
@@ -46,10 +46,9 @@ echo location of your Java installation.
|
|||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:init
|
:init
|
||||||
@rem Get command-line arguments, handling Windowz variants
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
if "%@eval[2+2]" == "4" goto 4NT_args
|
|
||||||
|
|
||||||
:win9xME_args
|
:win9xME_args
|
||||||
@rem Slurp the command line arguments.
|
@rem Slurp the command line arguments.
|
||||||
@@ -60,11 +59,6 @@ set _SKIP=2
|
|||||||
if "x%~1" == "x" goto execute
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
set CMD_LINE_ARGS=%*
|
||||||
goto execute
|
|
||||||
|
|
||||||
:4NT_args
|
|
||||||
@rem Get arguments from the 4NT Shell from JP Software
|
|
||||||
set CMD_LINE_ARGS=%$
|
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|||||||
52
libraries.gradle
Normal file
52
libraries.gradle
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
// Allows centralized definition of the version of artifacts to
|
||||||
|
// use. In that respect it serves a role similar to <dependencyManagement> in Maven
|
||||||
|
ext {
|
||||||
|
implLibraries = [:]
|
||||||
|
testLibraries = [:]
|
||||||
|
dependencyOverrides = [:]
|
||||||
|
}
|
||||||
|
implLibraries = [
|
||||||
|
asciiDocJApi : "org.asciidoctor:asciidoctorj-api:2.2.0",
|
||||||
|
commonsBeanUtils : "commons-beanutils:commons-beanutils:1.9.4",
|
||||||
|
commonsCodec : "commons-codec:commons-codec:1.13",
|
||||||
|
commonsCollections4: "org.apache.commons:commons-collections4:4.4",
|
||||||
|
commonsConf2 : "org.apache.commons:commons-configuration2:2.6",
|
||||||
|
commonsLang3 : "org.apache.commons:commons-lang3:3.9",
|
||||||
|
commonsIO : "commons-io:commons-io:2.6",
|
||||||
|
commonsText : "org.apache.commons:commons-text:1.8",
|
||||||
|
guava : 'com.google.guava:guava:27.0.1-android',
|
||||||
|
jacksonDatabind : 'com.fasterxml.jackson.core:jackson-databind:2.9.10',
|
||||||
|
mark2Ascii : "nl.jworks.markdown_to_asciidoc:markdown_to_asciidoc:1.1",
|
||||||
|
paleo : "ch.netzwerg:paleo-core:0.14.0",
|
||||||
|
pegdown : "org.pegdown:pegdown:1.6.0",
|
||||||
|
slf4j : "org.slf4j:slf4j-api:1.7.28",
|
||||||
|
swaggerV2 : "io.swagger:swagger-parser:1.0.47",
|
||||||
|
swaggerV2Converter : "io.swagger.parser.v3:swagger-parser-v2-converter:2.0.15",
|
||||||
|
swaggerV3 : "io.swagger.parser.v3:swagger-parser:2.0.15",
|
||||||
|
vavr : "io.vavr:vavr:0.10.2"
|
||||||
|
]
|
||||||
|
|
||||||
|
testLibraries = [
|
||||||
|
asciiDocJ : "org.asciidoctor:asciidoctorj:2.2.0",
|
||||||
|
assertj : "org.assertj:assertj-core:3.13.2",
|
||||||
|
assertjDiff: "io.github.robwin:assertj-diff:0.1.1",
|
||||||
|
junit : "junit:junit:4.12",
|
||||||
|
logback : "ch.qos.logback:logback-classic:1.2.3",
|
||||||
|
mockito : "org.mockito:mockito-core:3.1.0"
|
||||||
|
]
|
||||||
|
|
||||||
|
dependencyOverrides = [
|
||||||
|
assertj : testLibraries.assertj,
|
||||||
|
commonsCodec : implLibraries.commonsCodec,
|
||||||
|
commonsIO : implLibraries.commonsIO,
|
||||||
|
commonsLang3 : implLibraries.commonsLang3,
|
||||||
|
findBugs : 'com.google.code.findbugs:jsr305:3.0.2',
|
||||||
|
guava : implLibraries.guava,
|
||||||
|
jaksonCore : 'com.github.fge:jackson-coreutils:1.8',
|
||||||
|
jacksonDatabind: implLibraries.jacksonDatabind,
|
||||||
|
jnrConstants : 'com.github.jnr:jnr-constants:0.9.12',
|
||||||
|
jnrEnxio : 'com.github.jnr:jnr-enxio:0.19',
|
||||||
|
jnrPosix : 'com.github.jnr:jnr-posix:3.0.49',
|
||||||
|
jodaTime : 'joda-time:joda-time:2.9.9',
|
||||||
|
slf4j : implLibraries.slf4j,
|
||||||
|
]
|
||||||
34
openapi2markup/build.gradle
Normal file
34
openapi2markup/build.gradle
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
ext.moduleName="io.github.swagger2markup.openapi2markup"
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
configurations.all {
|
||||||
|
resolutionStrategy.force dependencyOverrides.commonsCodec
|
||||||
|
resolutionStrategy.force dependencyOverrides.commonsIO
|
||||||
|
resolutionStrategy.force dependencyOverrides.commonsLang3
|
||||||
|
resolutionStrategy.force dependencyOverrides.jnrConstants
|
||||||
|
resolutionStrategy.force dependencyOverrides.jnrEnxio
|
||||||
|
resolutionStrategy.force dependencyOverrides.jnrPosix
|
||||||
|
resolutionStrategy.force dependencyOverrides.jodaTime
|
||||||
|
resolutionStrategy.force dependencyOverrides.slf4j
|
||||||
|
resolutionStrategy.force dependencyOverrides.jacksonDatabind
|
||||||
|
resolutionStrategy.force dependencyOverrides.guava
|
||||||
|
resolutionStrategy.force dependencyOverrides.findBugs
|
||||||
|
resolutionStrategy.force dependencyOverrides.jaksonCore
|
||||||
|
resolutionStrategy.force dependencyOverrides.assertj
|
||||||
|
}
|
||||||
|
// implementation implLibraries.swaggerV2Converter
|
||||||
|
compile project(':swagger2markup-asciidoc')
|
||||||
|
compile project(':swagger2markup-core')
|
||||||
|
implementation implLibraries.asciiDocJApi
|
||||||
|
implementation implLibraries.commonsText
|
||||||
|
implementation implLibraries.commonsBeanUtils
|
||||||
|
implementation implLibraries.slf4j
|
||||||
|
implementation implLibraries.swaggerV3
|
||||||
|
implementation implLibraries.commonsCollections4
|
||||||
|
implementation implLibraries.commonsConf2
|
||||||
|
implementation implLibraries.vavr
|
||||||
|
testImplementation testLibraries.assertj
|
||||||
|
testImplementation testLibraries.assertjDiff
|
||||||
|
testImplementation testLibraries.junit
|
||||||
|
testImplementation testLibraries.logback
|
||||||
|
}
|
||||||
@@ -0,0 +1,378 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package io.github.swagger2markup;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.DocumentImpl;
|
||||||
|
import io.github.swagger2markup.config.OpenAPILabels;
|
||||||
|
import io.github.swagger2markup.config.builder.OpenAPI2MarkupConfigBuilder;
|
||||||
|
import io.github.swagger2markup.extension.OpenAPI2MarkupExtensionRegistry;
|
||||||
|
import io.github.swagger2markup.extension.builder.OpenAPI2MarkupExtensionRegistryBuilder;
|
||||||
|
import io.github.swagger2markup.internal.document.ComponentsDocument;
|
||||||
|
import io.github.swagger2markup.internal.document.OverviewDocument;
|
||||||
|
import io.github.swagger2markup.internal.document.PathsDocument;
|
||||||
|
import io.github.swagger2markup.internal.document.SecurityDocument;
|
||||||
|
import io.github.swagger2markup.utils.URIUtils;
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
import io.swagger.v3.parser.OpenAPIV3Parser;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.asciidoctor.ast.Document;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
public class OpenAPI2MarkupConverter extends AbstractSchema2MarkupConverter<OpenAPI> {
|
||||||
|
private final OverviewDocument overviewDocument;
|
||||||
|
private final PathsDocument pathsDocument;
|
||||||
|
private final ComponentsDocument componentsDocument;
|
||||||
|
private final SecurityDocument securityDocument;
|
||||||
|
private final OpenAPIContext openAPIContext;
|
||||||
|
|
||||||
|
|
||||||
|
public OpenAPI2MarkupConverter(OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
this.openAPIContext = context;
|
||||||
|
this.overviewDocument = new OverviewDocument(context);
|
||||||
|
this.pathsDocument = new PathsDocument(context);
|
||||||
|
this.componentsDocument = new ComponentsDocument(context);
|
||||||
|
this.securityDocument = new SecurityDocument(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a OpenAPI2MarkupConverter.Builder from a URI.
|
||||||
|
*
|
||||||
|
* @param swaggerUri the URI
|
||||||
|
* @return a OpenAPI2MarkupConverter
|
||||||
|
*/
|
||||||
|
public static Builder from(URI swaggerUri) {
|
||||||
|
Validate.notNull(swaggerUri, "swaggerUri must not be null");
|
||||||
|
String scheme = swaggerUri.getScheme();
|
||||||
|
if (scheme != null && swaggerUri.getScheme().startsWith("http")) {
|
||||||
|
try {
|
||||||
|
return from(swaggerUri.toURL());
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
throw new RuntimeException("Failed to convert URI to URL", e);
|
||||||
|
}
|
||||||
|
} else if (scheme != null && swaggerUri.getScheme().startsWith("file")) {
|
||||||
|
return from(Paths.get(swaggerUri));
|
||||||
|
} else {
|
||||||
|
return from(URIUtils.convertUriWithoutSchemeToFileScheme(swaggerUri));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a OpenAPI2MarkupConverter.Builder using a remote URL.
|
||||||
|
*
|
||||||
|
* @param swaggerURL the remote URL
|
||||||
|
* @return a OpenAPI2MarkupConverter
|
||||||
|
*/
|
||||||
|
public static Builder from(URL swaggerURL) {
|
||||||
|
Validate.notNull(swaggerURL, "swaggerURL must not be null");
|
||||||
|
return new Builder(swaggerURL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a OpenAPI2MarkupConverter.Builder using a local Path.
|
||||||
|
*
|
||||||
|
* @param swaggerPath the local Path
|
||||||
|
* @return a OpenAPI2MarkupConverter
|
||||||
|
*/
|
||||||
|
public static Builder from(Path swaggerPath) {
|
||||||
|
Validate.notNull(swaggerPath, "swaggerPath must not be null");
|
||||||
|
if (Files.notExists(swaggerPath)) {
|
||||||
|
throw new IllegalArgumentException(String.format("swaggerPath does not exist: %s", swaggerPath));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (Files.isHidden(swaggerPath)) {
|
||||||
|
throw new IllegalArgumentException("swaggerPath must not be a hidden file");
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("Failed to check if swaggerPath is a hidden file", e);
|
||||||
|
}
|
||||||
|
return new Builder(swaggerPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a OpenAPI2MarkupConverter.Builder from a given Swagger model.
|
||||||
|
*
|
||||||
|
* @param openAPI the Swagger source.
|
||||||
|
* @return a OpenAPI2MarkupConverter
|
||||||
|
*/
|
||||||
|
public static Builder from(OpenAPI openAPI) {
|
||||||
|
Validate.notNull(openAPI, "schema must not be null");
|
||||||
|
return new Builder(openAPI);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a OpenAPI2MarkupConverter.Builder from a given Swagger YAML or JSON String.
|
||||||
|
*
|
||||||
|
* @param swaggerString the Swagger YAML or JSON String.
|
||||||
|
* @return a OpenAPI2MarkupConverter
|
||||||
|
*/
|
||||||
|
public static Builder from(String swaggerString) {
|
||||||
|
Validate.notEmpty(swaggerString, "swaggerString must not be null");
|
||||||
|
return from(new StringReader(swaggerString));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a OpenAPI2MarkupConverter.Builder from a given Swagger YAML or JSON reader.
|
||||||
|
*
|
||||||
|
* @param schemaReader the schema YAML or JSON reader.
|
||||||
|
* @return a OpenAPI2MarkupConverter
|
||||||
|
*/
|
||||||
|
public static Builder from(Reader schemaReader) {
|
||||||
|
Validate.notNull(schemaReader, "swaggerReader must not be null");
|
||||||
|
OpenAPI openAPI;
|
||||||
|
try {
|
||||||
|
//TODO
|
||||||
|
openAPI = new OpenAPIV3Parser().read(IOUtils.toString(schemaReader));
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("Swagger source can not be parsed", e);
|
||||||
|
}
|
||||||
|
if (openAPI == null)
|
||||||
|
throw new IllegalArgumentException("Swagger source is in a wrong format");
|
||||||
|
|
||||||
|
return new Builder(openAPI);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toFolder(Path outputDirectory) {
|
||||||
|
Validate.notNull(outputDirectory, "outputDirectory must not be null");
|
||||||
|
openAPIContext.setOutputPath(outputDirectory);
|
||||||
|
writeToFile(applyOverviewDocument(), outputDirectory.resolve(openAPIContext.config.getOverviewDocument()));
|
||||||
|
writeToFile(applyPathsDocument(), outputDirectory.resolve(openAPIContext.config.getPathsDocument()));
|
||||||
|
writeToFile(applyComponentsDocument(), outputDirectory.resolve(openAPIContext.config.getDefinitionsDocument()));
|
||||||
|
writeToFile(applySecurityDocument(), outputDirectory.resolve(openAPIContext.config.getSecurityDocument()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toFile(Path outputFile) {
|
||||||
|
Validate.notNull(outputFile, "outputFile must not be null");
|
||||||
|
|
||||||
|
writeToFile(applyOverviewDocument(), outputFile);
|
||||||
|
writeToFile(applyPathsDocument(), outputFile);
|
||||||
|
writeToFile(applyComponentsDocument(), outputFile);
|
||||||
|
writeToFile(applySecurityDocument(), outputFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void toFileWithoutExtension(Path outputFile) {
|
||||||
|
Validate.notNull(outputFile, "outputFile must not be null");
|
||||||
|
|
||||||
|
writeToFileWithoutExtension(applyOverviewDocument(), outputFile);
|
||||||
|
writeToFileWithoutExtension(applyPathsDocument(), outputFile);
|
||||||
|
writeToFileWithoutExtension(applyComponentsDocument(), outputFile);
|
||||||
|
writeToFileWithoutExtension(applySecurityDocument(), outputFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return applyOverviewDocument().convert() +
|
||||||
|
applyPathsDocument().convert() +
|
||||||
|
applyComponentsDocument().convert() +
|
||||||
|
applySecurityDocument().convert();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Document applyOverviewDocument() {
|
||||||
|
return overviewDocument.apply(
|
||||||
|
openAPIContext.createDocument(),
|
||||||
|
OverviewDocument.parameters(openAPIContext.getSchema()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Document applyPathsDocument() {
|
||||||
|
return pathsDocument.apply(
|
||||||
|
openAPIContext.createDocument(),
|
||||||
|
PathsDocument.parameters(openAPIContext.getSchema()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Document applyComponentsDocument() {
|
||||||
|
return componentsDocument.apply(
|
||||||
|
openAPIContext.createDocument(),
|
||||||
|
ComponentsDocument.parameters(openAPIContext.getSchema().getComponents()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Document applySecurityDocument() {
|
||||||
|
return securityDocument.apply(
|
||||||
|
openAPIContext.createDocument(),
|
||||||
|
SecurityDocument.parameters(openAPIContext.getSchema()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeToFile(Document document, Path path) {
|
||||||
|
MarkupLanguage markupLanguage = openAPIContext.config.getMarkupLanguage();
|
||||||
|
if (isMarkupLanguageSupported(markupLanguage)) {
|
||||||
|
String fileExtension = markupLanguage.getFileNameExtensions().get(0);
|
||||||
|
writeToFileWithoutExtension(document, path.resolveSibling(path.getFileName().toString() + fileExtension));
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("Given Markup language '"+markupLanguage+"' is not supported by "+getClass().getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isMarkupLanguageSupported(MarkupLanguage markupLanguage) {
|
||||||
|
return markupLanguage == MarkupLanguage.ASCIIDOC;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeToFileWithoutExtension(Document document, Path file) {
|
||||||
|
if (file.getParent() != null) {
|
||||||
|
try {
|
||||||
|
Files.createDirectories(file.getParent());
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("Failed create directory", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try (BufferedWriter writer = Files.newBufferedWriter(file, StandardCharsets.UTF_8)) {
|
||||||
|
writer.write(document.convert());
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("Failed to write file", e);
|
||||||
|
}
|
||||||
|
if (logger.isInfoEnabled()) {
|
||||||
|
logger.info("Markup document written to: {}", file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class OpenAPIContext extends Context<OpenAPI> {
|
||||||
|
private OpenSchema2MarkupConfig config;
|
||||||
|
private OpenAPI2MarkupExtensionRegistry extensionRegistry;
|
||||||
|
|
||||||
|
public OpenAPIContext(OpenSchema2MarkupConfig config,
|
||||||
|
OpenAPI2MarkupExtensionRegistry extensionRegistry,
|
||||||
|
OpenAPI schema, URI swaggerLocation, Labels labels) {
|
||||||
|
super(config, extensionRegistry, schema, swaggerLocation, labels);
|
||||||
|
this.config = config;
|
||||||
|
this.extensionRegistry = extensionRegistry;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OpenSchema2MarkupConfig getConfig() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OpenAPI2MarkupExtensionRegistry getExtensionRegistry() {
|
||||||
|
return extensionRegistry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Document createDocument() {
|
||||||
|
return new DocumentImpl();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private final OpenAPI openAPI;
|
||||||
|
private final URI schemaLocation;
|
||||||
|
private OpenSchema2MarkupConfig config;
|
||||||
|
private OpenAPI2MarkupExtensionRegistry extensionRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Builder from a remote URL.
|
||||||
|
*
|
||||||
|
* @param schemaUrl the remote URL
|
||||||
|
*/
|
||||||
|
Builder(URL schemaUrl) {
|
||||||
|
try {
|
||||||
|
this.schemaLocation = schemaUrl.toURI();
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
throw new IllegalArgumentException("swaggerURL is in a wrong format", e);
|
||||||
|
}
|
||||||
|
this.openAPI = readSchema(schemaUrl.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Builder from a local Path.
|
||||||
|
*
|
||||||
|
* @param swaggerPath the local Path
|
||||||
|
*/
|
||||||
|
Builder(Path swaggerPath) {
|
||||||
|
this.schemaLocation = swaggerPath.toAbsolutePath().toUri();
|
||||||
|
this.openAPI = readSchema(swaggerPath.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a Builder using a given Swagger model.
|
||||||
|
*
|
||||||
|
* @param openAPI the Swagger source.
|
||||||
|
*/
|
||||||
|
Builder(OpenAPI openAPI) {
|
||||||
|
this.openAPI = openAPI;
|
||||||
|
this.schemaLocation = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses the SwaggerParser to read the Swagger source.
|
||||||
|
*
|
||||||
|
* @param schemaLocation the location of the Swagger source
|
||||||
|
* @return the Swagger model
|
||||||
|
*/
|
||||||
|
private OpenAPI readSchema(String schemaLocation) {
|
||||||
|
OpenAPI openAPI = new OpenAPIV3Parser().read(schemaLocation);
|
||||||
|
if (openAPI == null) {
|
||||||
|
throw new IllegalArgumentException("Failed to read the schema");
|
||||||
|
}
|
||||||
|
return openAPI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder withConfig(OpenSchema2MarkupConfig config) {
|
||||||
|
Validate.notNull(config, "config must not be null");
|
||||||
|
this.config = config;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder withExtensionRegistry(OpenAPI2MarkupExtensionRegistry registry) {
|
||||||
|
Validate.notNull(registry, "registry must not be null");
|
||||||
|
this.extensionRegistry = registry;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenAPI2MarkupConverter build() {
|
||||||
|
if (config == null)
|
||||||
|
config = new OpenAPI2MarkupConfigBuilder().build();
|
||||||
|
|
||||||
|
if (extensionRegistry == null)
|
||||||
|
extensionRegistry = new OpenAPI2MarkupExtensionRegistryBuilder().build();
|
||||||
|
OpenAPILabels openApiLabels = new OpenAPILabels(config);
|
||||||
|
OpenAPIContext context = new OpenAPIContext(config, extensionRegistry, openAPI, schemaLocation, openApiLabels);
|
||||||
|
|
||||||
|
initExtensions(context);
|
||||||
|
|
||||||
|
applySwaggerExtensions(context);
|
||||||
|
|
||||||
|
return new OpenAPI2MarkupConverter(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initExtensions(OpenAPIContext context) {
|
||||||
|
extensionRegistry.getSwaggerModelExtensions().forEach(extension -> extension.setGlobalContext(context));
|
||||||
|
extensionRegistry.getOverviewDocumentExtensions().forEach(extension -> extension.setGlobalContext(context));
|
||||||
|
extensionRegistry.getDefinitionsDocumentExtensions().forEach(extension -> extension.setGlobalContext(context));
|
||||||
|
extensionRegistry.getPathsDocumentExtensions().forEach(extension -> extension.setGlobalContext(context));
|
||||||
|
extensionRegistry.getSecurityDocumentExtensions().forEach(extension -> extension.setGlobalContext(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applySwaggerExtensions(OpenAPIContext context) {
|
||||||
|
extensionRegistry.getSwaggerModelExtensions().forEach(extension -> extension.apply(context.getSchema()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package io.github.swagger2markup;
|
||||||
|
|
||||||
|
import org.apache.commons.configuration2.Configuration;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class OpenAPI2MarkupProperties extends Schema2MarkupProperties {
|
||||||
|
|
||||||
|
public OpenAPI2MarkupProperties(Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenAPI2MarkupProperties(Map<String, String> map) {
|
||||||
|
super(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenAPI2MarkupProperties(Configuration configuration) {
|
||||||
|
super(configuration);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package io.github.swagger2markup;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.config.builder.Schema2MarkupConfigBuilder;
|
||||||
|
|
||||||
|
public class OpenSchema2MarkupConfig extends Schema2MarkupConfigBuilder.DefaultSchema2MarkupConfig {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
package io.github.swagger2markup.config;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.Labels;
|
||||||
|
import io.github.swagger2markup.OpenSchema2MarkupConfig;
|
||||||
|
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
public class OpenAPILabels extends Labels {
|
||||||
|
|
||||||
|
public static final String LABEL_CONTENT = "label_content";
|
||||||
|
public static final String LABEL_DEFAULT = "label_default";
|
||||||
|
public static final String LABEL_DEPRECATED = "label_deprecated";
|
||||||
|
public static final String LABEL_EXAMPLE = "label_example";
|
||||||
|
public static final String LABEL_EXAMPLES = "label_examples";
|
||||||
|
public static final String LABEL_EXCLUSIVE_MAXIMUM = "label_exclusive_maximum";
|
||||||
|
public static final String LABEL_EXCLUSIVE_MINIMUM = "label_exclusive_minimum";
|
||||||
|
public static final String LABEL_EXTERNAL_VALUE = "label_external_value";
|
||||||
|
public static final String LABEL_FORMAT = "label_format";
|
||||||
|
public static final String LABEL_MAXIMUM = "label_maximum";
|
||||||
|
public static final String LABEL_MAX_ITEMS = "label_max_items";
|
||||||
|
public static final String LABEL_MAX_LENGTH = "label_max_length";
|
||||||
|
public static final String LABEL_MAX_PROPERTIES = "label_max_properties";
|
||||||
|
public static final String LABEL_MINIMUM = "label_minimum";
|
||||||
|
public static final String LABEL_MIN_ITEMS = "label_min_items";
|
||||||
|
public static final String LABEL_MIN_LENGTH = "label_min_length";
|
||||||
|
public static final String LABEL_MIN_PROPERTIES = "label_min_properties";
|
||||||
|
public static final String LABEL_MULTIPLE_OF = "label_multiple_of";
|
||||||
|
public static final String LABEL_NO_LINKS = "label_no_links";
|
||||||
|
public static final String LABEL_NULLABLE = "label_nullable";
|
||||||
|
public static final String LABEL_OPERATION = "label_operation";
|
||||||
|
public static final String LABEL_OPTIONAL = "label_optional";
|
||||||
|
public static final String LABEL_PARAMETERS = "label_parameters";
|
||||||
|
public static final String LABEL_READ_ONLY = "label_read_only";
|
||||||
|
public static final String LABEL_REQUIRED = "label_required";
|
||||||
|
public static final String LABEL_SERVER = "label_server";
|
||||||
|
public static final String LABEL_TERMS_OF_SERVICE = "label_terms_of_service";
|
||||||
|
public static final String LABEL_TITLE = "label_title";
|
||||||
|
public static final String LABEL_TYPE = "label_type";
|
||||||
|
public static final String LABEL_UNIQUE_ITEMS = "label_unique_items";
|
||||||
|
public static final String LABEL_WRITE_ONLY = "label_write_only";
|
||||||
|
public static final String SECTION_TITLE_COMPONENTS = "section_title_components";
|
||||||
|
public static final String SECTION_TITLE_PARAMETERS = "section_title_parameters";
|
||||||
|
public static final String SECTION_TITLE_PATHS = "section_title_paths";
|
||||||
|
public static final String SECTION_TITLE_SCHEMAS = "section_title_schemas";
|
||||||
|
public static final String SECTION_TITLE_SECURITY = "section_title_security";
|
||||||
|
public static final String SECTION_TITLE_SERVERS = "section_title_servers";
|
||||||
|
public static final String SECTION_TITLE_OVERVIEW = "section_title_overview";
|
||||||
|
public static final String SECTION_TITLE_TAGS = "section_title_tags";
|
||||||
|
public static final String SECTION_TITLE_RESPONSES = "section_title_responses";
|
||||||
|
public static final String SECTION_TITLE_HEADERS = "section_title_headers";
|
||||||
|
public static final String SECTION_TITLE_LINKS = "section_title_links";
|
||||||
|
public static final String TABLE_HEADER_DEFAULT = "table_header_default";
|
||||||
|
public static final String TABLE_HEADER_DESCRIPTION = "table_header_description";
|
||||||
|
public static final String TABLE_HEADER_HTTP_CODE = "table_header_http_code";
|
||||||
|
public static final String TABLE_HEADER_LINKS = "table_header_links";
|
||||||
|
public static final String TABLE_HEADER_NAME = "table_header_name";
|
||||||
|
public static final String TABLE_HEADER_POSSIBLE_VALUES = "table_header_possible_values";
|
||||||
|
public static final String TABLE_HEADER_SCHEMA = "table_header_schema";
|
||||||
|
public static final String TABLE_HEADER_SCOPES = "table_header_scopes";
|
||||||
|
public static final String TABLE_HEADER_TYPE = "table_header_type";
|
||||||
|
public static final String TABLE_HEADER_VARIABLE = "table_header_variable";
|
||||||
|
public static final String TABLE_TITLE_HEADERS = "table_title_headers";
|
||||||
|
public static final String TABLE_TITLE_PARAMETERS = "table_title_parameters";
|
||||||
|
public static final String TABLE_TITLE_PROPERTIES = "table_title_properties";
|
||||||
|
public static final String TABLE_TITLE_RESPONSES = "table_title_responses";
|
||||||
|
public static final String TABLE_TITLE_SECURITY = "table_title_security";
|
||||||
|
public static final String TABLE_TITLE_SERVER_VARIABLES = "table_title_server_variables";
|
||||||
|
|
||||||
|
public OpenAPILabels(OpenSchema2MarkupConfig config) {
|
||||||
|
super(ResourceBundle.getBundle("io/github/swagger2markup/lang/labels", config.getLanguage().toLocale()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package io.github.swagger2markup.config.builder;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupProperties;
|
||||||
|
import io.github.swagger2markup.OpenSchema2MarkupConfig;
|
||||||
|
import org.apache.commons.configuration2.Configuration;
|
||||||
|
import org.apache.commons.configuration2.ConfigurationConverter;
|
||||||
|
import org.apache.commons.configuration2.MapConfiguration;
|
||||||
|
import org.apache.commons.configuration2.PropertiesConfiguration;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class OpenAPI2MarkupConfigBuilder extends Schema2MarkupConfigBuilder<OpenAPI2MarkupConfigBuilder, OpenSchema2MarkupConfig> {
|
||||||
|
|
||||||
|
public OpenAPI2MarkupConfigBuilder() {
|
||||||
|
this(new PropertiesConfiguration());
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenAPI2MarkupConfigBuilder(Properties properties) {
|
||||||
|
this(ConfigurationConverter.getConfiguration(properties));
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenAPI2MarkupConfigBuilder(Map<String, String> map) {
|
||||||
|
this(new MapConfiguration(map));
|
||||||
|
}
|
||||||
|
|
||||||
|
private OpenAPI2MarkupConfigBuilder(Configuration configuration) {
|
||||||
|
super(OpenAPI2MarkupConfigBuilder.class,
|
||||||
|
new OpenSchema2MarkupConfig(),
|
||||||
|
new OpenAPI2MarkupProperties(getCompositeConfiguration(configuration)), configuration);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OpenSchema2MarkupConfig build() {
|
||||||
|
buildNaturalOrdering();
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.github.swagger2markup.extension;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter.OpenAPIContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An abstract OpenAPI extension which must be extended by an other OpenAPI extensions
|
||||||
|
*/
|
||||||
|
abstract class AbstractExtension implements Extension {
|
||||||
|
|
||||||
|
protected OpenAPIContext globalContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Global context lazy initialization
|
||||||
|
*
|
||||||
|
* @param globalContext Global context
|
||||||
|
*/
|
||||||
|
public void setGlobalContext(OpenAPIContext globalContext) {
|
||||||
|
this.globalContext = globalContext;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package io.github.swagger2markup.extension;
|
||||||
|
|
||||||
|
import org.asciidoctor.ast.Document;
|
||||||
|
|
||||||
|
public class ContentContext {
|
||||||
|
private Document document;
|
||||||
|
|
||||||
|
public ContentContext(Document document) {
|
||||||
|
this.document = document;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Document getDocument() {
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.github.swagger2markup.extension;
|
||||||
|
|
||||||
|
import io.swagger.models.Model;
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.asciidoctor.ast.Document;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DefinitionsDocumentExtension extension point can be used to extend the definitions document content.
|
||||||
|
*/
|
||||||
|
public abstract class DefinitionsDocumentExtension extends AbstractExtension {
|
||||||
|
|
||||||
|
|
||||||
|
public abstract void apply(Context context);
|
||||||
|
|
||||||
|
public enum Position {
|
||||||
|
DOCUMENT_BEFORE,
|
||||||
|
DOCUMENT_BEGIN,
|
||||||
|
DOCUMENT_END,
|
||||||
|
DOCUMENT_AFTER,
|
||||||
|
DEFINITION_BEFORE,
|
||||||
|
DEFINITION_BEGIN,
|
||||||
|
DEFINITION_END,
|
||||||
|
DEFINITION_AFTER
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Context extends ContentContext {
|
||||||
|
private Position position;
|
||||||
|
/**
|
||||||
|
* null if position == DOCUMENT_*
|
||||||
|
*/
|
||||||
|
private String definitionName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* null if position == DOCUMENT_*
|
||||||
|
*/
|
||||||
|
private Model model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param position the current position
|
||||||
|
* @param document document object
|
||||||
|
*/
|
||||||
|
public Context(Position position, Document document) {
|
||||||
|
super(document);
|
||||||
|
Validate.inclusiveBetween(Position.DOCUMENT_BEFORE, Position.DOCUMENT_AFTER, position);
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param position the current position
|
||||||
|
* @param document document object
|
||||||
|
* @param definitionName the name of the current definition
|
||||||
|
* @param model the current Model of the definition
|
||||||
|
*/
|
||||||
|
public Context(Position position, Document document, String definitionName, Model model) {
|
||||||
|
super(document);
|
||||||
|
Validate.inclusiveBetween(Position.DEFINITION_BEFORE, Position.DEFINITION_AFTER, position);
|
||||||
|
Validate.notNull(definitionName);
|
||||||
|
Validate.notNull(model);
|
||||||
|
this.position = position;
|
||||||
|
this.definitionName = definitionName;
|
||||||
|
this.model = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<String> getDefinitionName() {
|
||||||
|
return Optional.ofNullable(definitionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<Model> getModel() {
|
||||||
|
return Optional.ofNullable(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.github.swagger2markup.extension;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.OpenAPI2MarkupConverter.OpenAPIContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension interface which must be implemented by an OpenAPI extension
|
||||||
|
*/
|
||||||
|
interface Extension {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Global context lazy initialization
|
||||||
|
*
|
||||||
|
* @param globalContext Global context
|
||||||
|
*/
|
||||||
|
void setGlobalContext(OpenAPIContext globalContext);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.github.swagger2markup.extension;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenSchema2MarkupConfig;
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.Labels;
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
import io.vavr.Function2;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public abstract class MarkupComponent<D, T, R> implements Function2<D, T, R> {
|
||||||
|
|
||||||
|
protected Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
protected OpenAPI2MarkupConverter.Context<OpenAPI> context;
|
||||||
|
protected Labels labels;
|
||||||
|
protected OpenSchema2MarkupConfig config;
|
||||||
|
protected OpenAPI2MarkupExtensionRegistry extensionRegistry;
|
||||||
|
|
||||||
|
public MarkupComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
this.context = context;
|
||||||
|
this.config = context.getConfig();
|
||||||
|
this.extensionRegistry = context.getExtensionRegistry();
|
||||||
|
this.labels = context.getLabels();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package io.github.swagger2markup.extension;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extension points registry interface.
|
||||||
|
*/
|
||||||
|
public interface OpenAPI2MarkupExtensionRegistry extends Schema2MarkupExtensionRegistry {
|
||||||
|
/**
|
||||||
|
* OpenAPIModelExtension extension point can be used to preprocess the Swagger model.
|
||||||
|
*
|
||||||
|
* @return registered extensions extending OpenAPIModelExtension extension point
|
||||||
|
*/
|
||||||
|
List<OpenAPIModelExtension> getSwaggerModelExtensions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OverviewDocumentExtension extension point can be used to extend the overview document content.
|
||||||
|
*
|
||||||
|
* @return registered extensions extending OverviewDocumentExtension extension point
|
||||||
|
*/
|
||||||
|
List<OverviewDocumentExtension> getOverviewDocumentExtensions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DefinitionsDocumentExtension extension point can be used to extend the definitions document content.
|
||||||
|
*
|
||||||
|
* @return registered extensions extending DefinitionsDocumentExtension extension point
|
||||||
|
*/
|
||||||
|
List<DefinitionsDocumentExtension> getDefinitionsDocumentExtensions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SecurityContentExtension extension point can be used to extend the security document content.
|
||||||
|
*
|
||||||
|
* @return registered extensions extending SecurityContentExtension extension point
|
||||||
|
*/
|
||||||
|
List<SecurityDocumentExtension> getSecurityDocumentExtensions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PathsDocumentExtension extension point can be used to extend the paths document content.
|
||||||
|
*
|
||||||
|
* @return registered extensions extending PathsDocumentExtension extension point
|
||||||
|
*/
|
||||||
|
List<PathsDocumentExtension> getPathsDocumentExtensions();
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.github.swagger2markup.extension;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OpenAPIModelExtension extension point can be used to preprocess the Swagger model.
|
||||||
|
*/
|
||||||
|
public abstract class OpenAPIModelExtension extends AbstractExtension {
|
||||||
|
|
||||||
|
public abstract void apply(OpenAPI openAPI);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.github.swagger2markup.extension;
|
||||||
|
|
||||||
|
import org.asciidoctor.ast.Document;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OverviewDocumentExtension extension point can be used to extend the overview document content.
|
||||||
|
*/
|
||||||
|
public abstract class OverviewDocumentExtension extends AbstractExtension {
|
||||||
|
|
||||||
|
public abstract void apply(Context context);
|
||||||
|
|
||||||
|
public enum Position {
|
||||||
|
DOCUMENT_BEFORE,
|
||||||
|
DOCUMENT_AFTER,
|
||||||
|
DOCUMENT_BEGIN,
|
||||||
|
DOCUMENT_END
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Context extends ContentContext {
|
||||||
|
private Position position;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param position the current position
|
||||||
|
* @param document document object
|
||||||
|
*/
|
||||||
|
public Context(Position position, Document document) {
|
||||||
|
super(document);
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.github.swagger2markup.extension;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.model.PathOperation;
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.asciidoctor.ast.Document;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PathsDocumentExtension extension point can be used to extend the paths document content.
|
||||||
|
*/
|
||||||
|
public abstract class PathsDocumentExtension extends AbstractExtension {
|
||||||
|
|
||||||
|
public abstract void apply(Context context);
|
||||||
|
|
||||||
|
public enum Position {
|
||||||
|
DOCUMENT_BEFORE,
|
||||||
|
DOCUMENT_BEGIN,
|
||||||
|
DOCUMENT_END,
|
||||||
|
DOCUMENT_AFTER,
|
||||||
|
OPERATION_BEFORE,
|
||||||
|
OPERATION_BEGIN,
|
||||||
|
OPERATION_END,
|
||||||
|
OPERATION_AFTER,
|
||||||
|
OPERATION_DESCRIPTION_BEFORE,
|
||||||
|
OPERATION_DESCRIPTION_BEGIN,
|
||||||
|
OPERATION_DESCRIPTION_END,
|
||||||
|
OPERATION_DESCRIPTION_AFTER,
|
||||||
|
OPERATION_PARAMETERS_BEFORE,
|
||||||
|
OPERATION_PARAMETERS_BEGIN,
|
||||||
|
OPERATION_PARAMETERS_END,
|
||||||
|
OPERATION_PARAMETERS_AFTER,
|
||||||
|
OPERATION_RESPONSES_BEFORE,
|
||||||
|
OPERATION_RESPONSES_BEGIN,
|
||||||
|
OPERATION_RESPONSES_END,
|
||||||
|
OPERATION_RESPONSES_AFTER,
|
||||||
|
OPERATION_SECURITY_BEFORE,
|
||||||
|
OPERATION_SECURITY_BEGIN,
|
||||||
|
OPERATION_SECURITY_END,
|
||||||
|
OPERATION_SECURITY_AFTER
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Context extends ContentContext {
|
||||||
|
private Position position;
|
||||||
|
/**
|
||||||
|
* null if position == DOCUMENT_*
|
||||||
|
*/
|
||||||
|
private PathOperation operation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context for positions DOCUMENT_*
|
||||||
|
*
|
||||||
|
* @param position the current position
|
||||||
|
* @param document document object
|
||||||
|
*/
|
||||||
|
public Context(Position position, Document document) {
|
||||||
|
super(document);
|
||||||
|
Validate.inclusiveBetween(Position.DOCUMENT_BEFORE, Position.DOCUMENT_AFTER, position);
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context for all other positions
|
||||||
|
*
|
||||||
|
* @param position the current position
|
||||||
|
* @param document document object
|
||||||
|
* @param operation the current path operation
|
||||||
|
*/
|
||||||
|
public Context(Position position, Document document, PathOperation operation) {
|
||||||
|
super(document);
|
||||||
|
Validate.inclusiveBetween(Position.OPERATION_BEFORE, Position.OPERATION_SECURITY_AFTER, position);
|
||||||
|
Validate.notNull(operation);
|
||||||
|
this.position = position;
|
||||||
|
this.operation = operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<PathOperation> getOperation() {
|
||||||
|
return Optional.ofNullable(operation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.github.swagger2markup.extension;
|
||||||
|
|
||||||
|
import io.swagger.models.auth.SecuritySchemeDefinition;
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.asciidoctor.ast.Document;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SecurityContentExtension extension point can be used to extend the security document content.
|
||||||
|
*/
|
||||||
|
public abstract class SecurityDocumentExtension extends AbstractExtension {
|
||||||
|
|
||||||
|
|
||||||
|
public abstract void apply(Context context);
|
||||||
|
|
||||||
|
public enum Position {
|
||||||
|
DOCUMENT_BEFORE,
|
||||||
|
DOCUMENT_BEGIN,
|
||||||
|
DOCUMENT_END,
|
||||||
|
DOCUMENT_AFTER,
|
||||||
|
SECURITY_SCHEME_BEFORE,
|
||||||
|
SECURITY_SCHEME_BEGIN,
|
||||||
|
SECURITY_SCHEME_END,
|
||||||
|
SECURITY_SCHEME_AFTER
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Context extends ContentContext {
|
||||||
|
private Position position;
|
||||||
|
/**
|
||||||
|
* null if position == DOCUMENT_*
|
||||||
|
*/
|
||||||
|
private String securitySchemeName;
|
||||||
|
/**
|
||||||
|
* null if position == DOCUMENT_*
|
||||||
|
*/
|
||||||
|
private SecuritySchemeDefinition securityScheme;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param position the current position
|
||||||
|
* @param document the MarkupDocBuilder
|
||||||
|
*/
|
||||||
|
public Context(Position position, Document document) {
|
||||||
|
super(document);
|
||||||
|
Validate.inclusiveBetween(Position.DOCUMENT_BEFORE, Position.DOCUMENT_AFTER, position);
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param position the current position
|
||||||
|
* @param document the MarkupDocBuilder
|
||||||
|
* @param securitySchemeName the name of the current securityScheme
|
||||||
|
* @param securityScheme the current security scheme securityScheme
|
||||||
|
*/
|
||||||
|
public Context(Position position, Document document, String securitySchemeName, SecuritySchemeDefinition securityScheme) {
|
||||||
|
super(document);
|
||||||
|
Validate.inclusiveBetween(Position.SECURITY_SCHEME_BEFORE, Position.SECURITY_SCHEME_AFTER, position);
|
||||||
|
Validate.notNull(securitySchemeName);
|
||||||
|
Validate.notNull(securityScheme);
|
||||||
|
this.position = position;
|
||||||
|
this.securitySchemeName = securitySchemeName;
|
||||||
|
this.securityScheme = securityScheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Position getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<String> getSecuritySchemeName() {
|
||||||
|
return Optional.ofNullable(securitySchemeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<SecuritySchemeDefinition> getSecurityScheme() {
|
||||||
|
return Optional.ofNullable(securityScheme);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.github.swagger2markup.extension.builder;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.extension.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.util.ServiceLoader.load;
|
||||||
|
import static org.apache.commons.collections4.IteratorUtils.toList;
|
||||||
|
|
||||||
|
public class OpenAPI2MarkupExtensionRegistryBuilder {
|
||||||
|
|
||||||
|
private final Context context;
|
||||||
|
|
||||||
|
public OpenAPI2MarkupExtensionRegistryBuilder() {
|
||||||
|
List<OpenAPIModelExtension> openAPIModelExtensions = toList(load(OpenAPIModelExtension.class).iterator());
|
||||||
|
List<OverviewDocumentExtension> overviewDocumentExtensions = toList(load(OverviewDocumentExtension.class).iterator());
|
||||||
|
List<DefinitionsDocumentExtension> definitionsDocumentExtensions = toList(load(DefinitionsDocumentExtension.class).iterator());
|
||||||
|
List<PathsDocumentExtension> pathsDocumentExtensions = toList(load(PathsDocumentExtension.class).iterator());
|
||||||
|
List<SecurityDocumentExtension> securityDocumentExtensions = toList(load(SecurityDocumentExtension.class).iterator());
|
||||||
|
context = new Context(
|
||||||
|
openAPIModelExtensions,
|
||||||
|
overviewDocumentExtensions,
|
||||||
|
definitionsDocumentExtensions,
|
||||||
|
pathsDocumentExtensions,
|
||||||
|
securityDocumentExtensions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenAPI2MarkupExtensionRegistry build() {
|
||||||
|
return new DefaultOpenAPI2MarkupExtensionRegistry(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenAPI2MarkupExtensionRegistryBuilder withSwaggerModelExtension(OpenAPIModelExtension extension) {
|
||||||
|
context.openAPIModelExtensions.add(extension);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenAPI2MarkupExtensionRegistryBuilder withOverviewDocumentExtension(OverviewDocumentExtension extension) {
|
||||||
|
context.overviewDocumentExtensions.add(extension);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenAPI2MarkupExtensionRegistryBuilder withDefinitionsDocumentExtension(DefinitionsDocumentExtension extension) {
|
||||||
|
context.definitionsDocumentExtensions.add(extension);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenAPI2MarkupExtensionRegistryBuilder withPathsDocumentExtension(PathsDocumentExtension extension) {
|
||||||
|
context.pathsDocumentExtensions.add(extension);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OpenAPI2MarkupExtensionRegistryBuilder withSecurityDocumentExtension(SecurityDocumentExtension extension) {
|
||||||
|
context.securityDocumentExtensions.add(extension);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class DefaultOpenAPI2MarkupExtensionRegistry implements OpenAPI2MarkupExtensionRegistry {
|
||||||
|
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
DefaultOpenAPI2MarkupExtensionRegistry(Context context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OpenAPIModelExtension> getSwaggerModelExtensions() {
|
||||||
|
return context.openAPIModelExtensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OverviewDocumentExtension> getOverviewDocumentExtensions() {
|
||||||
|
return context.overviewDocumentExtensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DefinitionsDocumentExtension> getDefinitionsDocumentExtensions() {
|
||||||
|
return context.definitionsDocumentExtensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SecurityDocumentExtension> getSecurityDocumentExtensions() {
|
||||||
|
return context.securityDocumentExtensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PathsDocumentExtension> getPathsDocumentExtensions() {
|
||||||
|
return context.pathsDocumentExtensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Context {
|
||||||
|
final List<OpenAPIModelExtension> openAPIModelExtensions;
|
||||||
|
final List<OverviewDocumentExtension> overviewDocumentExtensions;
|
||||||
|
final List<DefinitionsDocumentExtension> definitionsDocumentExtensions;
|
||||||
|
final List<PathsDocumentExtension> pathsDocumentExtensions;
|
||||||
|
final List<SecurityDocumentExtension> securityDocumentExtensions;
|
||||||
|
|
||||||
|
Context(List<OpenAPIModelExtension> openAPIModelExtensions,
|
||||||
|
List<OverviewDocumentExtension> overviewDocumentExtensions,
|
||||||
|
List<DefinitionsDocumentExtension> definitionsDocumentExtensions,
|
||||||
|
List<PathsDocumentExtension> pathsDocumentExtensions,
|
||||||
|
List<SecurityDocumentExtension> securityDocumentExtensions) {
|
||||||
|
this.openAPIModelExtensions = openAPIModelExtensions;
|
||||||
|
this.overviewDocumentExtensions = overviewDocumentExtensions;
|
||||||
|
this.definitionsDocumentExtensions = definitionsDocumentExtensions;
|
||||||
|
this.pathsDocumentExtensions = pathsDocumentExtensions;
|
||||||
|
this.securityDocumentExtensions = securityDocumentExtensions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package io.github.swagger2markup.internal.component;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.DescriptionListEntryImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.DescriptionListImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.ListItemImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.ParagraphBlockImpl;
|
||||||
|
import io.github.swagger2markup.extension.MarkupComponent;
|
||||||
|
import io.swagger.v3.oas.models.media.Encoding;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.LINE_SEPARATOR;
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.LABEL_EXAMPLES;
|
||||||
|
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.italicUnconstrained;
|
||||||
|
|
||||||
|
public class EncodingComponent extends MarkupComponent<StructuralNode, EncodingComponent.Parameters, StructuralNode> {
|
||||||
|
|
||||||
|
private final HeadersComponent headersComponent;
|
||||||
|
|
||||||
|
public EncodingComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
this.headersComponent = new HeadersComponent(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static EncodingComponent.Parameters parameters(Map<String, Encoding> encodings) {
|
||||||
|
return new EncodingComponent.Parameters(encodings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructuralNode apply(StructuralNode node, Map<String, Encoding> encodings) {
|
||||||
|
return apply(node, parameters(encodings));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StructuralNode apply(StructuralNode node, EncodingComponent.Parameters parameters) {
|
||||||
|
Map<String, Encoding> encodings = parameters.encodings;
|
||||||
|
if (encodings == null || encodings.isEmpty()) return node;
|
||||||
|
|
||||||
|
DescriptionListImpl encodingList = new DescriptionListImpl(node);
|
||||||
|
encodingList.setTitle(labels.getLabel(LABEL_EXAMPLES));
|
||||||
|
|
||||||
|
encodings.forEach((name, encoding) -> {
|
||||||
|
DescriptionListEntryImpl encodingEntry = new DescriptionListEntryImpl(encodingList, Collections.singletonList(new ListItemImpl(encodingList, name)));
|
||||||
|
ListItemImpl tagDesc = new ListItemImpl(encodingEntry, "");
|
||||||
|
ParagraphBlockImpl encodingBlock = new ParagraphBlockImpl(tagDesc);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
String contentType = encoding.getContentType();
|
||||||
|
if(StringUtils.isNotBlank(contentType)){
|
||||||
|
sb.append("Content-Type:").append(contentType).append(LINE_SEPARATOR);
|
||||||
|
}
|
||||||
|
if(encoding.getAllowReserved()){
|
||||||
|
sb.append(italicUnconstrained("Allow Reserved").toLowerCase()).append(LINE_SEPARATOR);
|
||||||
|
}
|
||||||
|
if(encoding.getExplode()){
|
||||||
|
sb.append(italicUnconstrained("Explode").toLowerCase()).append(LINE_SEPARATOR);
|
||||||
|
}
|
||||||
|
Encoding.StyleEnum style = encoding.getStyle();
|
||||||
|
if(style != null){
|
||||||
|
sb.append("style").append(style).append(LINE_SEPARATOR);
|
||||||
|
}
|
||||||
|
encodingBlock.setSource(sb.toString());
|
||||||
|
tagDesc.append(encodingBlock);
|
||||||
|
headersComponent.apply(tagDesc, encoding.getHeaders());
|
||||||
|
|
||||||
|
encodingEntry.setDescription(tagDesc);
|
||||||
|
|
||||||
|
encodingList.addEntry(encodingEntry);
|
||||||
|
});
|
||||||
|
node.append(encodingList);
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Parameters {
|
||||||
|
|
||||||
|
private final Map<String, Encoding> encodings;
|
||||||
|
|
||||||
|
public Parameters(Map<String, Encoding> encodings) {
|
||||||
|
this.encodings = encodings;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package io.github.swagger2markup.internal.component;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.DescriptionListEntryImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.DescriptionListImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.ListItemImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.ParagraphBlockImpl;
|
||||||
|
import io.github.swagger2markup.extension.MarkupComponent;
|
||||||
|
import io.swagger.v3.oas.models.examples.Example;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.LINE_SEPARATOR;
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.LABEL_EXAMPLES;
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.LABEL_EXTERNAL_VALUE;
|
||||||
|
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.appendDescription;
|
||||||
|
|
||||||
|
public class ExamplesComponent extends MarkupComponent<StructuralNode, ExamplesComponent.Parameters, StructuralNode> {
|
||||||
|
|
||||||
|
private final MediaTypeExampleComponent mediaTypeExampleComponent;
|
||||||
|
|
||||||
|
public ExamplesComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
this.mediaTypeExampleComponent = new MediaTypeExampleComponent(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ExamplesComponent.Parameters parameters(Map<String, Example> examples) {
|
||||||
|
return new ExamplesComponent.Parameters(examples);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructuralNode apply(StructuralNode node, Map<String, Example> examples) {
|
||||||
|
return apply(node, parameters(examples));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StructuralNode apply(StructuralNode node, ExamplesComponent.Parameters parameters) {
|
||||||
|
Map<String, Example> examples = parameters.examples;
|
||||||
|
if (examples == null || examples.isEmpty()) return node;
|
||||||
|
|
||||||
|
DescriptionListImpl examplesList = new DescriptionListImpl(node);
|
||||||
|
examplesList.setTitle(labels.getLabel(LABEL_EXAMPLES));
|
||||||
|
|
||||||
|
examples.forEach((name, example) -> {
|
||||||
|
DescriptionListEntryImpl exampleEntry = new DescriptionListEntryImpl(examplesList, Collections.singletonList(new ListItemImpl(examplesList, name)));
|
||||||
|
ListItemImpl tagDesc = new ListItemImpl(exampleEntry, "");
|
||||||
|
|
||||||
|
ParagraphBlockImpl exampleBlock = new ParagraphBlockImpl(tagDesc);
|
||||||
|
|
||||||
|
appendDescription(exampleBlock, example.getSummary());
|
||||||
|
appendDescription(exampleBlock, example.getDescription());
|
||||||
|
mediaTypeExampleComponent.apply(tagDesc, example.getValue());
|
||||||
|
|
||||||
|
ParagraphBlockImpl paragraphBlock = new ParagraphBlockImpl(tagDesc);
|
||||||
|
String source = "";
|
||||||
|
generateRefLink(source, example.getExternalValue(), labels.getLabel(LABEL_EXTERNAL_VALUE));
|
||||||
|
generateRefLink(source, example.get$ref(), "");
|
||||||
|
if(StringUtils.isNotBlank(source)){
|
||||||
|
paragraphBlock.setSource(source);
|
||||||
|
tagDesc.append(paragraphBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
exampleEntry.setDescription(tagDesc);
|
||||||
|
|
||||||
|
examplesList.addEntry(exampleEntry);
|
||||||
|
});
|
||||||
|
node.append(examplesList);
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String generateRefLink(String source, String ref, String alt) {
|
||||||
|
if (StringUtils.isNotBlank(ref)) {
|
||||||
|
if (StringUtils.isBlank(alt)) {
|
||||||
|
alt = ref.substring(ref.lastIndexOf('/') + 1);
|
||||||
|
}
|
||||||
|
String anchor = ref.replaceFirst("#", "").replaceAll("/", "_");
|
||||||
|
source += "<<" + anchor + "," + alt + ">>" + LINE_SEPARATOR;
|
||||||
|
}
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Parameters {
|
||||||
|
|
||||||
|
private final Map<String, Example> examples;
|
||||||
|
|
||||||
|
public Parameters(Map<String, Example> examples) {
|
||||||
|
this.examples = examples;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package io.github.swagger2markup.internal.component;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.extension.MarkupComponent;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.ParagraphBlockImpl;
|
||||||
|
import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.asciidoctor.ast.Block;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
|
|
||||||
|
|
||||||
|
public class ExternalDocumentationComponent extends MarkupComponent<StructuralNode, ExternalDocumentationComponent.Parameters, StructuralNode> {
|
||||||
|
|
||||||
|
public ExternalDocumentationComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Parameters parameters(ExternalDocumentation externalDocs) {
|
||||||
|
return new Parameters(externalDocs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructuralNode apply(StructuralNode node, ExternalDocumentation externalDocs) {
|
||||||
|
return apply(node, parameters(externalDocs));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StructuralNode apply(StructuralNode node, Parameters params) {
|
||||||
|
ExternalDocumentation externalDocs = params.externalDocs;
|
||||||
|
if (externalDocs == null) return node;
|
||||||
|
|
||||||
|
String url = externalDocs.getUrl();
|
||||||
|
if (StringUtils.isNotBlank(url)) {
|
||||||
|
Block paragraph = new ParagraphBlockImpl(node);
|
||||||
|
String desc = externalDocs.getDescription();
|
||||||
|
paragraph.setSource(url + (StringUtils.isNotBlank(desc) ? "[" + desc + "]" : ""));
|
||||||
|
node.append(paragraph);
|
||||||
|
}
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Parameters {
|
||||||
|
private final ExternalDocumentation externalDocs;
|
||||||
|
|
||||||
|
public Parameters(ExternalDocumentation externalDocs) {
|
||||||
|
this.externalDocs = externalDocs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package io.github.swagger2markup.internal.component;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.TableImpl;
|
||||||
|
import io.github.swagger2markup.extension.MarkupComponent;
|
||||||
|
import io.swagger.v3.oas.models.headers.Header;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.*;
|
||||||
|
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.generateInnerDoc;
|
||||||
|
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.getSchemaTypeAsString;
|
||||||
|
|
||||||
|
public class HeadersComponent extends MarkupComponent<StructuralNode, HeadersComponent.Parameters, StructuralNode> {
|
||||||
|
|
||||||
|
private final SchemaComponent schemaComponent;
|
||||||
|
|
||||||
|
public HeadersComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
this.schemaComponent = new SchemaComponent(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HeadersComponent.Parameters parameters(Map<String, Header> headers) {
|
||||||
|
return new HeadersComponent.Parameters(headers);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructuralNode apply(StructuralNode node, Map<String, Header> headers) {
|
||||||
|
return apply(node, parameters(headers));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StructuralNode apply(StructuralNode node, HeadersComponent.Parameters parameters) {
|
||||||
|
Map<String, Header> headers = parameters.headers;
|
||||||
|
if (null == headers || headers.isEmpty()) return node;
|
||||||
|
|
||||||
|
TableImpl responseHeadersTable = new TableImpl(node, new HashMap<>(), new ArrayList<>());
|
||||||
|
responseHeadersTable.setOption("header");
|
||||||
|
responseHeadersTable.setAttribute("caption", "", true);
|
||||||
|
responseHeadersTable.setAttribute("cols", ".^2a,.^14a,.^4a", true);
|
||||||
|
responseHeadersTable.setTitle(labels.getLabel(TABLE_TITLE_HEADERS));
|
||||||
|
responseHeadersTable.setHeaderRow(labels.getLabel(TABLE_HEADER_NAME), labels.getLabel(TABLE_HEADER_DESCRIPTION), labels.getLabel(TABLE_HEADER_SCHEMA));
|
||||||
|
headers.forEach((name, header) ->
|
||||||
|
responseHeadersTable.addRow(
|
||||||
|
generateInnerDoc(responseHeadersTable, name),
|
||||||
|
generateInnerDoc(responseHeadersTable, Optional.ofNullable(header.getDescription()).orElse("")),
|
||||||
|
generateInnerDoc(responseHeadersTable, getSchemaTypeAsString(header.getSchema()))
|
||||||
|
));
|
||||||
|
node.append(responseHeadersTable);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Parameters {
|
||||||
|
|
||||||
|
private final Map<String, Header> headers;
|
||||||
|
|
||||||
|
public Parameters(Map<String, Header> headers) {
|
||||||
|
this.headers = headers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package io.github.swagger2markup.internal.component;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.DocumentImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.ParagraphBlockImpl;
|
||||||
|
import io.github.swagger2markup.extension.MarkupComponent;
|
||||||
|
import io.swagger.v3.oas.models.links.Link;
|
||||||
|
import org.asciidoctor.ast.Document;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.LINE_SEPARATOR;
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.*;
|
||||||
|
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.italicUnconstrained;
|
||||||
|
|
||||||
|
public class LinkComponent extends MarkupComponent<StructuralNode, LinkComponent.Parameters, StructuralNode> {
|
||||||
|
|
||||||
|
public LinkComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LinkComponent.Parameters parameters(Map<String, Link> links) {
|
||||||
|
return new LinkComponent.Parameters(links);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Document apply(StructuralNode parent, Map<String, Link> links) {
|
||||||
|
return apply(parent, parameters(links));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Document apply(StructuralNode parent, LinkComponent.Parameters parameters) {
|
||||||
|
DocumentImpl linksDocument = new DocumentImpl(parent);
|
||||||
|
ParagraphBlockImpl linkParagraph = new ParagraphBlockImpl(linksDocument);
|
||||||
|
|
||||||
|
Map<String, Link> links = parameters.links;
|
||||||
|
if (null == links || links.isEmpty()) {
|
||||||
|
linkParagraph.setSource(labels.getLabel(LABEL_NO_LINKS));
|
||||||
|
} else {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
links.forEach((name, link) -> {
|
||||||
|
sb.append(name).append(" +").append(LINE_SEPARATOR);
|
||||||
|
sb.append(italicUnconstrained(labels.getLabel(LABEL_OPERATION))).append(' ')
|
||||||
|
.append(italicUnconstrained(link.getOperationId())).append(" +").append(LINE_SEPARATOR);
|
||||||
|
Map<String, String> linkParameters = link.getParameters();
|
||||||
|
if (null != linkParameters && !linkParameters.isEmpty()) {
|
||||||
|
sb.append(italicUnconstrained(labels.getLabel(LABEL_PARAMETERS))).append(" {").append(" +").append(LINE_SEPARATOR);
|
||||||
|
linkParameters.forEach((param, value) ->
|
||||||
|
sb.append('"').append(param).append("\": \"").append(value).append('"').append(" +").append(LINE_SEPARATOR)
|
||||||
|
);
|
||||||
|
sb.append('}').append(" +").append(LINE_SEPARATOR);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
linkParagraph.setSource(sb.toString());
|
||||||
|
}
|
||||||
|
linksDocument.append(linkParagraph);
|
||||||
|
return linksDocument;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Parameters {
|
||||||
|
private final Map<String, Link> links;
|
||||||
|
|
||||||
|
public Parameters(Map<String, Link> links) {
|
||||||
|
this.links = links;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package io.github.swagger2markup.internal.component;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.DescriptionListEntryImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.DescriptionListImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.ListItemImpl;
|
||||||
|
import io.github.swagger2markup.extension.MarkupComponent;
|
||||||
|
import io.swagger.v3.oas.models.media.Content;
|
||||||
|
import org.asciidoctor.ast.Document;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.LABEL_CONTENT;
|
||||||
|
|
||||||
|
public class MediaContentComponent extends MarkupComponent<StructuralNode, MediaContentComponent.Parameters, StructuralNode> {
|
||||||
|
|
||||||
|
private final MediaTypeExampleComponent mediaTypeExampleComponent;
|
||||||
|
private final ExamplesComponent examplesComponent;
|
||||||
|
private final SchemaComponent schemaComponent;
|
||||||
|
private final EncodingComponent encodingComponent;
|
||||||
|
|
||||||
|
public MediaContentComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
this.mediaTypeExampleComponent = new MediaTypeExampleComponent(context);
|
||||||
|
this.examplesComponent = new ExamplesComponent(context);
|
||||||
|
this.schemaComponent = new SchemaComponent(context);
|
||||||
|
this.encodingComponent = new EncodingComponent(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MediaContentComponent.Parameters parameters(Content content) {
|
||||||
|
return new MediaContentComponent.Parameters(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructuralNode apply(StructuralNode node, Content content) {
|
||||||
|
return apply(node, parameters(content));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StructuralNode apply(StructuralNode node, MediaContentComponent.Parameters parameters) {
|
||||||
|
Content content = parameters.content;
|
||||||
|
if (content == null || content.isEmpty()) return node;
|
||||||
|
|
||||||
|
DescriptionListImpl mediaContentList = new DescriptionListImpl(node);
|
||||||
|
mediaContentList.setTitle(labels.getLabel(LABEL_CONTENT));
|
||||||
|
|
||||||
|
content.forEach((type, mediaType) -> {
|
||||||
|
DescriptionListEntryImpl tagEntry = new DescriptionListEntryImpl(mediaContentList, Collections.singletonList(new ListItemImpl(mediaContentList, type)));
|
||||||
|
ListItemImpl tagDesc = new ListItemImpl(tagEntry, "");
|
||||||
|
|
||||||
|
Document tagDescDocument = schemaComponent.apply(mediaContentList, mediaType.getSchema());
|
||||||
|
mediaTypeExampleComponent.apply(tagDescDocument, mediaType.getExample());
|
||||||
|
examplesComponent.apply(tagDescDocument, mediaType.getExamples());
|
||||||
|
encodingComponent.apply(tagDescDocument, mediaType.getEncoding());
|
||||||
|
tagDesc.append(tagDescDocument);
|
||||||
|
|
||||||
|
tagEntry.setDescription(tagDesc);
|
||||||
|
mediaContentList.addEntry(tagEntry);
|
||||||
|
});
|
||||||
|
node.append(mediaContentList);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Parameters {
|
||||||
|
|
||||||
|
private final Content content;
|
||||||
|
|
||||||
|
public Parameters(Content content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package io.github.swagger2markup.internal.component;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.ParagraphBlockImpl;
|
||||||
|
import io.github.swagger2markup.extension.MarkupComponent;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.DELIMITER_BLOCK;
|
||||||
|
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.LINE_SEPARATOR;
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.LABEL_EXAMPLE;
|
||||||
|
|
||||||
|
public class MediaTypeExampleComponent extends MarkupComponent<StructuralNode, MediaTypeExampleComponent.Parameters, StructuralNode> {
|
||||||
|
|
||||||
|
public MediaTypeExampleComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MediaTypeExampleComponent.Parameters parameters(Object example) {
|
||||||
|
return new MediaTypeExampleComponent.Parameters(example);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructuralNode apply(StructuralNode node, Object example) {
|
||||||
|
return apply(node, parameters(example));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StructuralNode apply(StructuralNode node, MediaTypeExampleComponent.Parameters parameters) {
|
||||||
|
Object example = parameters.example;
|
||||||
|
if (example == null || StringUtils.isBlank(example.toString())) return node;
|
||||||
|
|
||||||
|
ParagraphBlockImpl sourceBlock = new ParagraphBlockImpl(node);
|
||||||
|
sourceBlock.setTitle(labels.getLabel(LABEL_EXAMPLE));
|
||||||
|
sourceBlock.setAttribute("style", "source", true);
|
||||||
|
sourceBlock.setSource(DELIMITER_BLOCK + LINE_SEPARATOR + example + LINE_SEPARATOR + DELIMITER_BLOCK);
|
||||||
|
node.append(sourceBlock);
|
||||||
|
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Parameters {
|
||||||
|
|
||||||
|
private final Object example;
|
||||||
|
|
||||||
|
public Parameters(Object example) {
|
||||||
|
this.example = example;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package io.github.swagger2markup.internal.component;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.TableImpl;
|
||||||
|
import io.github.swagger2markup.extension.MarkupComponent;
|
||||||
|
import io.swagger.v3.oas.models.parameters.Parameter;
|
||||||
|
import org.asciidoctor.ast.Document;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
|
import org.asciidoctor.ast.Table;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.LINE_SEPARATOR;
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.*;
|
||||||
|
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.*;
|
||||||
|
|
||||||
|
public class ParametersComponent extends MarkupComponent<StructuralNode, ParametersComponent.Parameters, StructuralNode> {
|
||||||
|
|
||||||
|
private final SchemaComponent schemaComponent;
|
||||||
|
|
||||||
|
public ParametersComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
this.schemaComponent = new SchemaComponent(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ParametersComponent.Parameters parameters(Map<String, Parameter> parameters) {
|
||||||
|
return new ParametersComponent.Parameters(parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ParametersComponent.Parameters parameters(List<Parameter> parameters) {
|
||||||
|
if(null == parameters) {
|
||||||
|
return new ParametersComponent.Parameters(new HashMap<>());
|
||||||
|
}
|
||||||
|
return new ParametersComponent.Parameters(parameters.stream().collect(Collectors.toMap(Parameter::getName, parameter -> parameter)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructuralNode apply(StructuralNode parent, List<Parameter> params) {
|
||||||
|
return apply(parent, parameters(params));
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructuralNode apply(StructuralNode parent, Map<String, Parameter> params) {
|
||||||
|
return apply(parent, parameters(params));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StructuralNode apply(StructuralNode parent, ParametersComponent.Parameters componentParameters) {
|
||||||
|
Map<String, Parameter> parameters = componentParameters.parameters;
|
||||||
|
if (null == parameters || parameters.isEmpty()) return parent;
|
||||||
|
|
||||||
|
TableImpl pathParametersTable = new TableImpl(parent, new HashMap<>(), new ArrayList<>());
|
||||||
|
pathParametersTable.setOption("header");
|
||||||
|
pathParametersTable.setAttribute("caption", "", true);
|
||||||
|
pathParametersTable.setAttribute("cols", ".^2a,.^3a,.^10a,.^5a", true);
|
||||||
|
pathParametersTable.setTitle(labels.getLabel(TABLE_TITLE_PARAMETERS));
|
||||||
|
pathParametersTable.setHeaderRow(
|
||||||
|
labels.getLabel(TABLE_HEADER_TYPE),
|
||||||
|
labels.getLabel(TABLE_HEADER_NAME),
|
||||||
|
labels.getLabel(TABLE_HEADER_DESCRIPTION),
|
||||||
|
labels.getLabel(TABLE_HEADER_SCHEMA));
|
||||||
|
|
||||||
|
parameters.forEach((alt, parameter) ->
|
||||||
|
pathParametersTable.addRow(
|
||||||
|
generateInnerDoc(pathParametersTable, boldUnconstrained(parameter.getIn()), alt),
|
||||||
|
getParameterNameDocument(pathParametersTable, parameter),
|
||||||
|
generateInnerDoc(pathParametersTable, Optional.ofNullable(parameter.getDescription()).orElse("")),
|
||||||
|
generateInnerDoc(pathParametersTable, getSchemaTypeAsString(parameter.getSchema()))
|
||||||
|
));
|
||||||
|
parent.append(pathParametersTable);
|
||||||
|
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Document getParameterNameDocument(Table table, Parameter parameter) {
|
||||||
|
String documentContent = boldUnconstrained(parameter.getName()) + " +" + LINE_SEPARATOR + requiredIndicator(parameter.getRequired(),
|
||||||
|
labels.getLabel(LABEL_REQUIRED), labels.getLabel(LABEL_OPTIONAL));
|
||||||
|
return generateInnerDoc(table, documentContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Parameters {
|
||||||
|
|
||||||
|
private final Map<String, Parameter> parameters;
|
||||||
|
|
||||||
|
public Parameters(Map<String, Parameter> parameters) {
|
||||||
|
this.parameters = parameters;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package io.github.swagger2markup.internal.component;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.TableImpl;
|
||||||
|
import io.github.swagger2markup.extension.MarkupComponent;
|
||||||
|
import io.swagger.v3.oas.models.media.Schema;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.LINE_SEPARATOR;
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.*;
|
||||||
|
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.*;
|
||||||
|
|
||||||
|
public class PropertiesTableComponent extends MarkupComponent<StructuralNode, PropertiesTableComponent.Parameters, StructuralNode> {
|
||||||
|
|
||||||
|
private final SchemaComponent schemaComponent;
|
||||||
|
|
||||||
|
PropertiesTableComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
this.schemaComponent = new SchemaComponent(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Parameters parameters(@SuppressWarnings("rawtypes") Map<String, Schema> properties, List<String> schemaRequired) {
|
||||||
|
return new Parameters(properties, schemaRequired);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructuralNode apply(StructuralNode parent, @SuppressWarnings("rawtypes") Map<String, Schema> properties, List<String> schemaRequired) {
|
||||||
|
return apply(parent, parameters(properties, schemaRequired));
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructuralNode apply(StructuralNode parent, Parameters params) {
|
||||||
|
@SuppressWarnings("rawtypes") Map<String, Schema> properties = params.properties;
|
||||||
|
List<String> schemaRequired = params.schemaRequired;
|
||||||
|
|
||||||
|
if (null == properties || properties.isEmpty()) return parent;
|
||||||
|
|
||||||
|
List<String> finalSchemaRequired = (null == schemaRequired) ? new ArrayList<>() : schemaRequired;
|
||||||
|
|
||||||
|
TableImpl propertiesTable = new TableImpl(parent, new HashMap<>(), new ArrayList<>());
|
||||||
|
propertiesTable.setOption("header");
|
||||||
|
propertiesTable.setAttribute("caption", "", true);
|
||||||
|
propertiesTable.setAttribute("cols", ".^4a,.^16a,.^4a", true);
|
||||||
|
propertiesTable.setTitle(labels.getLabel(TABLE_TITLE_PROPERTIES));
|
||||||
|
propertiesTable.setHeaderRow(
|
||||||
|
labels.getLabel(TABLE_HEADER_NAME),
|
||||||
|
labels.getLabel(TABLE_HEADER_DESCRIPTION),
|
||||||
|
labels.getLabel(TABLE_HEADER_SCHEMA));
|
||||||
|
|
||||||
|
properties.forEach((name, schema) -> propertiesTable.addRow(
|
||||||
|
generateInnerDoc(propertiesTable, name + LINE_SEPARATOR + requiredIndicator(finalSchemaRequired.contains(name),
|
||||||
|
labels.getLabel(LABEL_REQUIRED), labels.getLabel(LABEL_OPTIONAL))),
|
||||||
|
schemaComponent.apply(propertiesTable, schema),
|
||||||
|
generateInnerDoc(propertiesTable, getSchemaTypeAsString(schema))
|
||||||
|
));
|
||||||
|
parent.append(propertiesTable);
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public static class Parameters {
|
||||||
|
private final Map<String, Schema> properties;
|
||||||
|
private final List<String> schemaRequired;
|
||||||
|
|
||||||
|
public Parameters(Map<String, Schema> properties, List<String> schemaRequired) {
|
||||||
|
|
||||||
|
this.properties = properties;
|
||||||
|
this.schemaRequired = schemaRequired;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package io.github.swagger2markup.internal.component;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.TableImpl;
|
||||||
|
import io.github.swagger2markup.extension.MarkupComponent;
|
||||||
|
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||||
|
import org.asciidoctor.ast.Document;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
|
import org.asciidoctor.ast.Table;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.*;
|
||||||
|
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.generateInnerDoc;
|
||||||
|
|
||||||
|
public class ResponseComponent extends MarkupComponent<StructuralNode, ResponseComponent.Parameters, StructuralNode> {
|
||||||
|
|
||||||
|
private final HeadersComponent headersComponent;
|
||||||
|
private final LinkComponent linkComponent;
|
||||||
|
private final MediaContentComponent mediaContentComponent;
|
||||||
|
|
||||||
|
public ResponseComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
this.headersComponent = new HeadersComponent(context);
|
||||||
|
this.linkComponent = new LinkComponent(context);
|
||||||
|
this.mediaContentComponent = new MediaContentComponent(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Parameters parameters(Map<String, ApiResponse> apiResponses) {
|
||||||
|
return new Parameters(apiResponses);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructuralNode apply(StructuralNode serverSection, Map<String, ApiResponse> apiResponses) {
|
||||||
|
return apply(serverSection, parameters(apiResponses));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StructuralNode apply(StructuralNode serverSection, Parameters params) {
|
||||||
|
Map<String, ApiResponse> apiResponses = params.apiResponses;
|
||||||
|
|
||||||
|
if (null == apiResponses || apiResponses.isEmpty()) return serverSection;
|
||||||
|
|
||||||
|
TableImpl pathResponsesTable = new TableImpl(serverSection, new HashMap<>(), new ArrayList<>());
|
||||||
|
pathResponsesTable.setOption("header");
|
||||||
|
pathResponsesTable.setAttribute("caption", "", true);
|
||||||
|
pathResponsesTable.setAttribute("cols", ".^2a,.^14a,.^4a", true);
|
||||||
|
pathResponsesTable.setTitle(labels.getLabel(TABLE_TITLE_RESPONSES));
|
||||||
|
pathResponsesTable.setHeaderRow(
|
||||||
|
labels.getLabel(TABLE_HEADER_HTTP_CODE),
|
||||||
|
labels.getLabel(TABLE_HEADER_DESCRIPTION),
|
||||||
|
labels.getLabel(TABLE_HEADER_LINKS));
|
||||||
|
|
||||||
|
apiResponses.forEach((httpCode, apiResponse) ->
|
||||||
|
pathResponsesTable.addRow(
|
||||||
|
generateInnerDoc(pathResponsesTable, httpCode),
|
||||||
|
getResponseDescriptionColumnDocument(pathResponsesTable, apiResponse),
|
||||||
|
linkComponent.apply(pathResponsesTable, apiResponse.getLinks())
|
||||||
|
));
|
||||||
|
serverSection.append(pathResponsesTable);
|
||||||
|
return serverSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Document getResponseDescriptionColumnDocument(Table table, ApiResponse apiResponse) {
|
||||||
|
Document document = generateInnerDoc(table, Optional.ofNullable(apiResponse.getDescription()).orElse(""));
|
||||||
|
headersComponent.apply(document, apiResponse.getHeaders());
|
||||||
|
mediaContentComponent.apply(document, apiResponse.getContent());
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Parameters {
|
||||||
|
private final Map<String, ApiResponse> apiResponses;
|
||||||
|
|
||||||
|
public Parameters(Map<String, ApiResponse> apiResponses) {
|
||||||
|
|
||||||
|
this.apiResponses = apiResponses;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package io.github.swagger2markup.internal.component;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.DocumentImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.ParagraphBlockImpl;
|
||||||
|
import io.github.swagger2markup.extension.MarkupComponent;
|
||||||
|
import io.github.swagger2markup.internal.helper.OpenApiHelpers;
|
||||||
|
import io.swagger.v3.oas.models.media.Schema;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.asciidoctor.ast.Document;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.LINE_SEPARATOR;
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.*;
|
||||||
|
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.boldUnconstrained;
|
||||||
|
|
||||||
|
public class SchemaComponent extends MarkupComponent<StructuralNode, SchemaComponent.Parameters, StructuralNode> {
|
||||||
|
|
||||||
|
private final OpenAPI2MarkupConverter.OpenAPIContext context;
|
||||||
|
|
||||||
|
public SchemaComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SchemaComponent.Parameters parameters(@SuppressWarnings("rawtypes") Schema schema) {
|
||||||
|
return new SchemaComponent.Parameters(schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Document apply(StructuralNode parent, @SuppressWarnings("rawtypes") Schema schema) {
|
||||||
|
return apply(parent, parameters(schema));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||||
|
@Override
|
||||||
|
public Document apply(StructuralNode parent, SchemaComponent.Parameters parameters) {
|
||||||
|
Document schemaDocument = new DocumentImpl(parent);
|
||||||
|
Schema schema = parameters.schema;
|
||||||
|
if (null == schema) return schemaDocument;
|
||||||
|
|
||||||
|
OpenApiHelpers.appendDescription(schemaDocument, schema.getDescription());
|
||||||
|
|
||||||
|
Map<String, Boolean> schemasBooleanProperties = new HashMap<String, Boolean>() {{
|
||||||
|
put(labels.getLabel(LABEL_DEPRECATED), schema.getDeprecated());
|
||||||
|
put(labels.getLabel(LABEL_NULLABLE), schema.getNullable());
|
||||||
|
put(labels.getLabel(LABEL_READ_ONLY), schema.getReadOnly());
|
||||||
|
put(labels.getLabel(LABEL_WRITE_ONLY), schema.getWriteOnly());
|
||||||
|
put(labels.getLabel(LABEL_UNIQUE_ITEMS), schema.getUniqueItems());
|
||||||
|
put(labels.getLabel(LABEL_EXCLUSIVE_MAXIMUM), schema.getExclusiveMaximum());
|
||||||
|
put(labels.getLabel(LABEL_EXCLUSIVE_MINIMUM), schema.getExclusiveMinimum());
|
||||||
|
}};
|
||||||
|
|
||||||
|
Map<String, Object> schemasValueProperties = new HashMap<String, Object>() {{
|
||||||
|
put(labels.getLabel(LABEL_TITLE), schema.getTitle());
|
||||||
|
put(labels.getLabel(LABEL_DEFAULT), schema.getDefault());
|
||||||
|
put(labels.getLabel(LABEL_MAXIMUM), schema.getMaximum());
|
||||||
|
put(labels.getLabel(LABEL_MINIMUM), schema.getMinimum());
|
||||||
|
put(labels.getLabel(LABEL_MAX_LENGTH), schema.getMaxLength());
|
||||||
|
put(labels.getLabel(LABEL_MIN_LENGTH), schema.getMinLength());
|
||||||
|
put(labels.getLabel(LABEL_MAX_ITEMS), schema.getMaxItems());
|
||||||
|
put(labels.getLabel(LABEL_MIN_ITEMS), schema.getMinItems());
|
||||||
|
put(labels.getLabel(LABEL_MAX_PROPERTIES), schema.getMaxProperties());
|
||||||
|
put(labels.getLabel(LABEL_MIN_PROPERTIES), schema.getMinProperties());
|
||||||
|
put(labels.getLabel(LABEL_MULTIPLE_OF), schema.getMultipleOf());
|
||||||
|
}};
|
||||||
|
|
||||||
|
Stream<String> schemaBooleanStream = schemasBooleanProperties.entrySet().stream()
|
||||||
|
.filter(e -> null != e.getValue() && e.getValue())
|
||||||
|
.map(e -> OpenApiHelpers.italicUnconstrained(e.getKey().toLowerCase()));
|
||||||
|
Stream<String> schemaValueStream = schemasValueProperties.entrySet().stream()
|
||||||
|
.filter(e -> null != e.getValue() && StringUtils.isNotBlank(e.getValue().toString()))
|
||||||
|
.map(e -> boldUnconstrained(e.getKey()) + ": " + e.getValue());
|
||||||
|
|
||||||
|
ParagraphBlockImpl paragraphBlock = new ParagraphBlockImpl(schemaDocument);
|
||||||
|
String source = Stream.concat(schemaBooleanStream, schemaValueStream).collect(Collectors.joining(" +" + LINE_SEPARATOR));
|
||||||
|
paragraphBlock.setSource(source);
|
||||||
|
|
||||||
|
schemaDocument.append(paragraphBlock);
|
||||||
|
|
||||||
|
Map<String, Schema> properties = schema.getProperties();
|
||||||
|
if (null != properties && !properties.isEmpty()) {
|
||||||
|
PropertiesTableComponent propertiesTableComponent = new PropertiesTableComponent(context);
|
||||||
|
propertiesTableComponent.apply(schemaDocument, properties, schema.getRequired());
|
||||||
|
}
|
||||||
|
|
||||||
|
return schemaDocument;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public static class Parameters {
|
||||||
|
|
||||||
|
private final Schema schema;
|
||||||
|
|
||||||
|
public Parameters(Schema schema) {
|
||||||
|
this.schema = schema;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package io.github.swagger2markup.internal.component;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.TableImpl;
|
||||||
|
import io.github.swagger2markup.extension.MarkupComponent;
|
||||||
|
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.*;
|
||||||
|
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.*;
|
||||||
|
|
||||||
|
public class SecurityRequirementTableComponent extends MarkupComponent<StructuralNode, SecurityRequirementTableComponent.Parameters, StructuralNode> {
|
||||||
|
|
||||||
|
public SecurityRequirementTableComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SecurityRequirementTableComponent.Parameters parameters(List<SecurityRequirement> securityRequirements, boolean addTitle) {
|
||||||
|
return new SecurityRequirementTableComponent.Parameters(securityRequirements, addTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StructuralNode apply(StructuralNode document, List<SecurityRequirement> securityRequirements, boolean addTitle) {
|
||||||
|
return apply(document, parameters(securityRequirements, addTitle));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StructuralNode apply(StructuralNode node, SecurityRequirementTableComponent.Parameters parameters) {
|
||||||
|
List<SecurityRequirement> securityRequirements = parameters.securityRequirements;
|
||||||
|
|
||||||
|
if (securityRequirements == null || securityRequirements.isEmpty()) return node;
|
||||||
|
|
||||||
|
TableImpl securityRequirementsTable = new TableImpl(node, new HashMap<>(), new ArrayList<>());
|
||||||
|
securityRequirementsTable.setOption("header");
|
||||||
|
securityRequirementsTable.setAttribute("caption", "", true);
|
||||||
|
securityRequirementsTable.setAttribute("cols", ".^3a,.^4a,.^13a", true);
|
||||||
|
if (parameters.addTitle) {
|
||||||
|
securityRequirementsTable.setTitle(labels.getLabel(TABLE_TITLE_SECURITY));
|
||||||
|
}
|
||||||
|
securityRequirementsTable.setHeaderRow(
|
||||||
|
labels.getLabel(TABLE_HEADER_TYPE),
|
||||||
|
labels.getLabel(TABLE_HEADER_NAME),
|
||||||
|
labels.getLabel(TABLE_HEADER_SCOPES));
|
||||||
|
|
||||||
|
securityRequirements.forEach(securityRequirement ->
|
||||||
|
securityRequirement.forEach((name, scopes) ->
|
||||||
|
securityRequirementsTable.addRow(
|
||||||
|
generateInnerDoc(securityRequirementsTable, boldUnconstrained(scopes.isEmpty() ? "apiKey" : "oauth2")),
|
||||||
|
generateInnerDoc(securityRequirementsTable, name),
|
||||||
|
generateInnerDoc(securityRequirementsTable, String.join(", ", scopes))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
node.append(securityRequirementsTable);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Parameters {
|
||||||
|
|
||||||
|
private final List<SecurityRequirement> securityRequirements;
|
||||||
|
private final boolean addTitle;
|
||||||
|
|
||||||
|
public Parameters(List<SecurityRequirement> securityRequirements, boolean addTitle) {
|
||||||
|
this.securityRequirements = securityRequirements;
|
||||||
|
this.addTitle = addTitle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package io.github.swagger2markup.internal.component;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.DescriptionListEntryImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.DescriptionListImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.ListItemImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.SectionImpl;
|
||||||
|
import io.github.swagger2markup.extension.MarkupComponent;
|
||||||
|
import io.swagger.v3.oas.models.tags.Tag;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.asciidoctor.ast.Document;
|
||||||
|
import org.asciidoctor.ast.Section;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.SECTION_TITLE_TAGS;
|
||||||
|
|
||||||
|
|
||||||
|
public class TagsComponent extends MarkupComponent<Document, TagsComponent.Parameters, Document> {
|
||||||
|
|
||||||
|
private final ExternalDocumentationComponent externalDocumentationComponent;
|
||||||
|
|
||||||
|
public TagsComponent(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
this.externalDocumentationComponent = new ExternalDocumentationComponent(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TagsComponent.Parameters parameters(List<Tag> tags) {
|
||||||
|
return new TagsComponent.Parameters(tags);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Document apply(Document document, List<Tag> tags) {
|
||||||
|
return apply(document, parameters(tags));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Document apply(Document document, TagsComponent.Parameters parameters) {
|
||||||
|
List<Tag> openAPITags = parameters.tags;
|
||||||
|
if (null == openAPITags || openAPITags.isEmpty()) return document;
|
||||||
|
|
||||||
|
Section tagsSection = new SectionImpl(document);
|
||||||
|
tagsSection.setTitle(labels.getLabel(SECTION_TITLE_TAGS));
|
||||||
|
|
||||||
|
DescriptionListImpl tagsList = new DescriptionListImpl(tagsSection);
|
||||||
|
openAPITags.forEach(tag -> {
|
||||||
|
DescriptionListEntryImpl tagEntry = new DescriptionListEntryImpl(tagsList, Collections.singletonList(new ListItemImpl(tagsList, tag.getName())));
|
||||||
|
String description = tag.getDescription();
|
||||||
|
if(StringUtils.isNotBlank(description)){
|
||||||
|
ListItemImpl tagDesc = new ListItemImpl(tagEntry, "");
|
||||||
|
tagDesc.setSource(description);
|
||||||
|
externalDocumentationComponent.apply(tagDesc, tag.getExternalDocs());
|
||||||
|
tagEntry.setDescription(tagDesc);
|
||||||
|
}
|
||||||
|
tagsList.addEntry(tagEntry);
|
||||||
|
});
|
||||||
|
|
||||||
|
tagsSection.append(tagsList);
|
||||||
|
document.append(tagsSection);
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Parameters {
|
||||||
|
|
||||||
|
private final List<Tag> tags;
|
||||||
|
|
||||||
|
public Parameters(List<Tag> tags) {
|
||||||
|
this.tags = tags;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
package io.github.swagger2markup.internal.document;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.SectionImpl;
|
||||||
|
import io.github.swagger2markup.extension.MarkupComponent;
|
||||||
|
import io.github.swagger2markup.internal.component.*;
|
||||||
|
import io.swagger.v3.oas.models.Components;
|
||||||
|
import io.swagger.v3.oas.models.headers.Header;
|
||||||
|
import io.swagger.v3.oas.models.links.Link;
|
||||||
|
import io.swagger.v3.oas.models.media.Schema;
|
||||||
|
import io.swagger.v3.oas.models.parameters.Parameter;
|
||||||
|
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.asciidoctor.ast.Document;
|
||||||
|
import org.asciidoctor.ast.Section;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.*;
|
||||||
|
|
||||||
|
public class ComponentsDocument extends MarkupComponent<Document, ComponentsDocument.Parameters, Document> {
|
||||||
|
|
||||||
|
private final ParametersComponent parametersComponent;
|
||||||
|
private final ResponseComponent responseComponent;
|
||||||
|
private final HeadersComponent headersComponent;
|
||||||
|
private final SchemaComponent schemaComponent;
|
||||||
|
private final LinkComponent linkComponent;
|
||||||
|
|
||||||
|
public ComponentsDocument(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
this.parametersComponent = new ParametersComponent(context);
|
||||||
|
this.responseComponent = new ResponseComponent(context);
|
||||||
|
this.headersComponent = new HeadersComponent(context);
|
||||||
|
this.schemaComponent = new SchemaComponent(context);
|
||||||
|
this.linkComponent = new LinkComponent(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Parameters parameters(Components components) {
|
||||||
|
return new Parameters(components);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Document apply(Document document, ComponentsDocument.Parameters parameters) {
|
||||||
|
|
||||||
|
appendComponentsSection(document, parameters.components);
|
||||||
|
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Parameters {
|
||||||
|
private final Components components;
|
||||||
|
|
||||||
|
public Parameters(Components components) {
|
||||||
|
this.components = Validate.notNull(components, "Schema must not be null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendComponentsSection(Document document, Components components) {
|
||||||
|
if (null == components) return;
|
||||||
|
|
||||||
|
Section componentsSection = new SectionImpl(document);
|
||||||
|
componentsSection.setTitle(labels.getLabel(SECTION_TITLE_COMPONENTS));
|
||||||
|
String componentSectionId = "_components";
|
||||||
|
componentsSection.setId(componentSectionId);
|
||||||
|
|
||||||
|
appendComponentsSchemasSection(componentsSection, componentSectionId, components.getSchemas());
|
||||||
|
Map<String, Parameter> parameters = components.getParameters();
|
||||||
|
if (null != parameters && !parameters.isEmpty()) {
|
||||||
|
appendSubSection(componentsSection, componentSectionId, parametersComponent, SECTION_TITLE_PARAMETERS,
|
||||||
|
new ParametersComponent.Parameters(parameters));
|
||||||
|
}
|
||||||
|
Map<String, ApiResponse> responses = components.getResponses();
|
||||||
|
if (null != responses && !responses.isEmpty()) {
|
||||||
|
appendSubSection(componentsSection, componentSectionId, responseComponent, SECTION_TITLE_RESPONSES,
|
||||||
|
new ResponseComponent.Parameters(responses));
|
||||||
|
}
|
||||||
|
Map<String, Header> headers = components.getHeaders();
|
||||||
|
if (null != headers && !headers.isEmpty()) {
|
||||||
|
appendSubSection(componentsSection, componentSectionId, headersComponent, SECTION_TITLE_HEADERS,
|
||||||
|
new HeadersComponent.Parameters(headers));
|
||||||
|
}
|
||||||
|
Map<String, Link> links = components.getLinks();
|
||||||
|
if (null != links && !links.isEmpty()) {
|
||||||
|
appendSubSection(componentsSection, componentSectionId, linkComponent, SECTION_TITLE_LINKS,
|
||||||
|
new LinkComponent.Parameters(links));
|
||||||
|
}
|
||||||
|
document.append(componentsSection);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendComponentsSchemasSection(
|
||||||
|
Section componentsSection, String componentSectionId,
|
||||||
|
@SuppressWarnings("rawtypes") Map<String, Schema> schemas) {
|
||||||
|
if (null == schemas || schemas.isEmpty()) return;
|
||||||
|
|
||||||
|
SectionImpl schemasSection = new SectionImpl(componentsSection);
|
||||||
|
String schemasSectionId = componentSectionId + "_schemas";
|
||||||
|
schemasSection.setTitle(labels.getLabel(SECTION_TITLE_SCHEMAS));
|
||||||
|
schemasSection.setId(schemasSectionId);
|
||||||
|
schemas.forEach((name, schema) -> {
|
||||||
|
String schemaDocumentId = schemasSectionId + "_" + name;
|
||||||
|
Document schemaDocument = schemaComponent.apply(schemasSection, schema);
|
||||||
|
schemaDocument.setTitle(name);
|
||||||
|
schemaDocument.setId(schemaDocumentId);
|
||||||
|
schemasSection.append(schemaDocument);
|
||||||
|
});
|
||||||
|
componentsSection.append(schemasSection);
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T> void appendSubSection(Section componentsSection, String componentSectionId,
|
||||||
|
MarkupComponent<StructuralNode, T, StructuralNode> markupComponent,
|
||||||
|
String sectionLabel, T parameters) {
|
||||||
|
SectionImpl parametersSection = new SectionImpl(componentsSection);
|
||||||
|
String parametersSectionId = componentSectionId + "_parameters";
|
||||||
|
parametersSection.setTitle(labels.getLabel(sectionLabel));
|
||||||
|
parametersSection.setId(parametersSectionId);
|
||||||
|
markupComponent.apply(parametersSection, parameters);
|
||||||
|
componentsSection.append(parametersSection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
package io.github.swagger2markup.internal.document;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.BlockImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.DocumentImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.ParagraphBlockImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.SectionImpl;
|
||||||
|
import io.github.swagger2markup.extension.MarkupComponent;
|
||||||
|
import io.github.swagger2markup.extension.OverviewDocumentExtension;
|
||||||
|
import io.github.swagger2markup.internal.component.ExternalDocumentationComponent;
|
||||||
|
import io.github.swagger2markup.internal.component.TagsComponent;
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
import io.swagger.v3.oas.models.info.Contact;
|
||||||
|
import io.swagger.v3.oas.models.info.Info;
|
||||||
|
import io.swagger.v3.oas.models.info.License;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.asciidoctor.ast.Block;
|
||||||
|
import org.asciidoctor.ast.Document;
|
||||||
|
import org.asciidoctor.ast.Section;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.LABEL_TERMS_OF_SERVICE;
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.SECTION_TITLE_OVERVIEW;
|
||||||
|
import static io.github.swagger2markup.extension.OverviewDocumentExtension.Context;
|
||||||
|
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.appendDescription;
|
||||||
|
|
||||||
|
public class OverviewDocument extends MarkupComponent<Document, OverviewDocument.Parameters, Document> {
|
||||||
|
private final TagsComponent tagsComponent;
|
||||||
|
private final ExternalDocumentationComponent externalDocumentationComponent;
|
||||||
|
|
||||||
|
public OverviewDocument(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
tagsComponent = new TagsComponent(context);
|
||||||
|
this.externalDocumentationComponent = new ExternalDocumentationComponent(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OverviewDocument.Parameters parameters(OpenAPI schema) {
|
||||||
|
return new OverviewDocument.Parameters(schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Document apply(Document document, Parameters parameters) {
|
||||||
|
Info apiInfo = parameters.openAPI.getInfo();
|
||||||
|
document.setAttribute("openapi", parameters.openAPI.getOpenapi(), true);
|
||||||
|
addDocumentTitle(document, apiInfo);
|
||||||
|
addAuthorInfo(document, apiInfo);
|
||||||
|
addVersionInfo(document, apiInfo);
|
||||||
|
|
||||||
|
applyOverviewDocumentExtension(new Context(OverviewDocumentExtension.Position.DOCUMENT_BEFORE, document));
|
||||||
|
Document subDocument = new DocumentImpl(document);
|
||||||
|
Section overviewDoc = new SectionImpl(subDocument, "section", new HashMap<>(), new ArrayList<>(),
|
||||||
|
null, new ArrayList<>(), 1, "", new ArrayList<>(),
|
||||||
|
null, null, "", "", false, false);
|
||||||
|
applyOverviewDocumentExtension(new Context(OverviewDocumentExtension.Position.DOCUMENT_BEGIN, subDocument));
|
||||||
|
overviewDoc.setTitle(labels.getLabel(SECTION_TITLE_OVERVIEW));
|
||||||
|
|
||||||
|
appendDescription(overviewDoc, apiInfo.getDescription());
|
||||||
|
appendTermsOfServiceInfo(overviewDoc, apiInfo);
|
||||||
|
appendLicenseInfo(overviewDoc, apiInfo);
|
||||||
|
subDocument.append(overviewDoc);
|
||||||
|
applyOverviewDocumentExtension(new Context(OverviewDocumentExtension.Position.DOCUMENT_END, subDocument));
|
||||||
|
document.append(subDocument);
|
||||||
|
|
||||||
|
externalDocumentationComponent.apply(document, parameters.openAPI.getExternalDocs());
|
||||||
|
tagsComponent.apply(document, parameters.openAPI.getTags());
|
||||||
|
applyOverviewDocumentExtension(new Context(OverviewDocumentExtension.Position.DOCUMENT_AFTER, document));
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyOverviewDocumentExtension(Context context) {
|
||||||
|
extensionRegistry.getOverviewDocumentExtensions().forEach(extension -> extension.apply(context));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addDocumentTitle(Document rootDocument, Info apiInfo) {
|
||||||
|
String title = apiInfo.getTitle();
|
||||||
|
if (StringUtils.isNotBlank(title)) {
|
||||||
|
rootDocument.setTitle(title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addVersionInfo(Document rootDocument, Info info) {
|
||||||
|
String version = info.getVersion();
|
||||||
|
if (StringUtils.isNotBlank(version)) {
|
||||||
|
rootDocument.setAttribute("revnumber", version, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addAuthorInfo(Document rootDocument, Info info) {
|
||||||
|
Contact contact = info.getContact();
|
||||||
|
if (null != contact) {
|
||||||
|
String author = Optional.ofNullable(contact.getName()).orElse("");
|
||||||
|
String email = contact.getEmail();
|
||||||
|
if (StringUtils.isNotBlank(email)) {
|
||||||
|
rootDocument.setAttribute("email", email, true);
|
||||||
|
}
|
||||||
|
rootDocument.setAttribute("author", author, true);
|
||||||
|
rootDocument.setAttribute("authorcount", 1L, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendLicenseInfo(Section overviewDoc, Info info) {
|
||||||
|
License license = info.getLicense();
|
||||||
|
if (null != license) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (StringUtils.isNotBlank(license.getUrl())) {
|
||||||
|
sb.append(license.getUrl()).append("[");
|
||||||
|
}
|
||||||
|
sb.append(license.getName());
|
||||||
|
if (StringUtils.isNotBlank(license.getUrl())) {
|
||||||
|
sb.append("]");
|
||||||
|
}
|
||||||
|
BlockImpl paragraph = new ParagraphBlockImpl(overviewDoc);
|
||||||
|
paragraph.setSource(sb.toString());
|
||||||
|
overviewDoc.append(paragraph);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendTermsOfServiceInfo(Section overviewDoc, Info info) {
|
||||||
|
String termsOfService = info.getTermsOfService();
|
||||||
|
if (StringUtils.isNotBlank(termsOfService)) {
|
||||||
|
Block paragraph = new ParagraphBlockImpl(overviewDoc);
|
||||||
|
paragraph.setSource(termsOfService + "[" + labels.getLabel(LABEL_TERMS_OF_SERVICE) + "]");
|
||||||
|
overviewDoc.append(paragraph);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Parameters {
|
||||||
|
private final OpenAPI openAPI;
|
||||||
|
|
||||||
|
public Parameters(OpenAPI openAPI) {
|
||||||
|
this.openAPI = Validate.notNull(openAPI, "Schema must not be null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
package io.github.swagger2markup.internal.document;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.SectionImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.TableImpl;
|
||||||
|
import io.github.swagger2markup.extension.MarkupComponent;
|
||||||
|
import io.github.swagger2markup.internal.component.ExternalDocumentationComponent;
|
||||||
|
import io.github.swagger2markup.internal.component.ParametersComponent;
|
||||||
|
import io.github.swagger2markup.internal.component.ResponseComponent;
|
||||||
|
import io.github.swagger2markup.internal.component.SecurityRequirementTableComponent;
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
import io.swagger.v3.oas.models.Paths;
|
||||||
|
import io.swagger.v3.oas.models.servers.Server;
|
||||||
|
import io.swagger.v3.oas.models.servers.ServerVariables;
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.asciidoctor.ast.Document;
|
||||||
|
import org.asciidoctor.ast.Section;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.*;
|
||||||
|
import static io.github.swagger2markup.internal.helper.OpenApiHelpers.*;
|
||||||
|
|
||||||
|
public class PathsDocument extends MarkupComponent<Document, PathsDocument.Parameters, Document> {
|
||||||
|
private final ParametersComponent parametersComponent;
|
||||||
|
private final ExternalDocumentationComponent externalDocumentationComponent;
|
||||||
|
private final ResponseComponent responseComponent;
|
||||||
|
private final SecurityRequirementTableComponent securityRequirementTableComponent;
|
||||||
|
|
||||||
|
public PathsDocument(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
this.parametersComponent = new ParametersComponent(context);
|
||||||
|
this.externalDocumentationComponent = new ExternalDocumentationComponent(context);
|
||||||
|
this.responseComponent = new ResponseComponent(context);
|
||||||
|
this.securityRequirementTableComponent = new SecurityRequirementTableComponent(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Parameters parameters(OpenAPI schema) {
|
||||||
|
return new Parameters(schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Document apply(Document document, Parameters parameters) {
|
||||||
|
Paths apiPaths = parameters.schema.getPaths();
|
||||||
|
|
||||||
|
if (null == apiPaths || apiPaths.isEmpty()) return document;
|
||||||
|
|
||||||
|
SectionImpl allPathsSection = new SectionImpl(document);
|
||||||
|
allPathsSection.setTitle(labels.getLabel(SECTION_TITLE_PATHS));
|
||||||
|
|
||||||
|
apiPaths.forEach((name, pathItem) ->
|
||||||
|
pathItem.readOperationsMap().forEach(((httpMethod, operation) -> {
|
||||||
|
SectionImpl operationSection = new SectionImpl(allPathsSection);
|
||||||
|
String summary = Optional.ofNullable(operation.getSummary()).orElse("");
|
||||||
|
operationSection.setTitle((italicUnconstrained(httpMethod.name().toUpperCase()) + " " + monospaced(name) + " " + summary).trim());
|
||||||
|
appendDescription(operationSection, operation.getDescription());
|
||||||
|
externalDocumentationComponent.apply(operationSection, operation.getExternalDocs());
|
||||||
|
parametersComponent.apply(operationSection, operation.getParameters());
|
||||||
|
responseComponent.apply(operationSection, operation.getResponses());
|
||||||
|
appendServersSection(operationSection, operation.getServers());
|
||||||
|
securityRequirementTableComponent.apply(operationSection, operation.getSecurity(), false);
|
||||||
|
allPathsSection.append(operationSection);
|
||||||
|
})));
|
||||||
|
|
||||||
|
document.append(allPathsSection);
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendServersSection(StructuralNode node, List<Server> servers) {
|
||||||
|
if (null == servers || servers.isEmpty()) return;
|
||||||
|
|
||||||
|
Section serversSection = new SectionImpl(node);
|
||||||
|
serversSection.setTitle(labels.getLabel(SECTION_TITLE_SERVERS));
|
||||||
|
|
||||||
|
servers.forEach(server -> {
|
||||||
|
Section serverSection = new SectionImpl(serversSection);
|
||||||
|
serverSection.setTitle(italicUnconstrained(labels.getLabel(LABEL_SERVER)) + ": " + server.getUrl());
|
||||||
|
|
||||||
|
appendDescription(serverSection, server.getDescription());
|
||||||
|
ServerVariables variables = server.getVariables();
|
||||||
|
appendVariables(serverSection, variables);
|
||||||
|
serversSection.append(serverSection);
|
||||||
|
});
|
||||||
|
node.append(serversSection);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendVariables(Section serverSection, ServerVariables variables) {
|
||||||
|
if (null == variables || variables.isEmpty()) return;
|
||||||
|
|
||||||
|
TableImpl serverVariables = new TableImpl(serverSection, new HashMap<String, Object>() {{
|
||||||
|
put("header-option", "");
|
||||||
|
put("cols", ".^2a,.^9a,.^3a,.^4a");
|
||||||
|
}}, new ArrayList<>());
|
||||||
|
serverVariables.setTitle(labels.getLabel(TABLE_TITLE_SERVER_VARIABLES));
|
||||||
|
|
||||||
|
serverVariables.setHeaderRow(labels.getLabel(TABLE_HEADER_VARIABLE), labels.getLabel(TABLE_HEADER_DESCRIPTION),
|
||||||
|
labels.getLabel(TABLE_HEADER_POSSIBLE_VALUES), labels.getLabel(TABLE_HEADER_DEFAULT)
|
||||||
|
);
|
||||||
|
|
||||||
|
variables.forEach((name, variable) -> {
|
||||||
|
String possibleValues = String.join(", ", Optional.ofNullable(variable.getEnum()).orElse(Collections.singletonList("Any")));
|
||||||
|
serverVariables.addRow(name, Optional.ofNullable(variable.getDescription()).orElse(""), possibleValues, variable.getDefault());
|
||||||
|
|
||||||
|
});
|
||||||
|
serverSection.append(serverVariables);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Parameters {
|
||||||
|
private final OpenAPI schema;
|
||||||
|
|
||||||
|
public Parameters(OpenAPI schema) {
|
||||||
|
this.schema = Validate.notNull(schema, "Schema must not be null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package io.github.swagger2markup.internal.document;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.OpenAPI2MarkupConverter;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.SectionImpl;
|
||||||
|
import io.github.swagger2markup.extension.MarkupComponent;
|
||||||
|
import io.github.swagger2markup.internal.component.SecurityRequirementTableComponent;
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.asciidoctor.ast.Document;
|
||||||
|
import org.asciidoctor.ast.Section;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.config.OpenAPILabels.SECTION_TITLE_SECURITY;
|
||||||
|
|
||||||
|
public class SecurityDocument extends MarkupComponent<Document, SecurityDocument.Parameters, Document> {
|
||||||
|
private final SecurityRequirementTableComponent securityRequirementTableComponent;
|
||||||
|
|
||||||
|
public SecurityDocument(OpenAPI2MarkupConverter.OpenAPIContext context) {
|
||||||
|
super(context);
|
||||||
|
this.securityRequirementTableComponent = new SecurityRequirementTableComponent(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Parameters parameters(OpenAPI schema) {
|
||||||
|
return new Parameters(schema);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Document apply(Document document, SecurityDocument.Parameters parameters) {
|
||||||
|
List<SecurityRequirement> securityRequirements = parameters.schema.getSecurity();
|
||||||
|
if (null == securityRequirements || securityRequirements.isEmpty()) return document;
|
||||||
|
|
||||||
|
Section securityRequirementsSection = new SectionImpl(document);
|
||||||
|
securityRequirementsSection.setTitle(labels.getLabel(SECTION_TITLE_SECURITY));
|
||||||
|
securityRequirementTableComponent.apply(securityRequirementsSection, securityRequirements, false);
|
||||||
|
document.append(securityRequirementsSection);
|
||||||
|
|
||||||
|
return document;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Parameters {
|
||||||
|
private final OpenAPI schema;
|
||||||
|
|
||||||
|
public Parameters(OpenAPI schema) {
|
||||||
|
this.schema = Validate.notNull(schema, "Schema must not be null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
package io.github.swagger2markup.internal.helper;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.DocumentImpl;
|
||||||
|
import io.github.swagger2markup.adoc.ast.impl.ParagraphBlockImpl;
|
||||||
|
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||||
|
import io.swagger.v3.oas.models.media.Schema;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.asciidoctor.ast.Block;
|
||||||
|
import org.asciidoctor.ast.Document;
|
||||||
|
import org.asciidoctor.ast.StructuralNode;
|
||||||
|
import org.asciidoctor.ast.Table;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static io.github.swagger2markup.adoc.converter.internal.Delimiters.LINE_SEPARATOR;
|
||||||
|
|
||||||
|
public class OpenApiHelpers {
|
||||||
|
|
||||||
|
public static void appendDescription(StructuralNode node, String description) {
|
||||||
|
if (StringUtils.isNotBlank(description)) {
|
||||||
|
Block paragraph = new ParagraphBlockImpl(node);
|
||||||
|
paragraph.setSource(description);
|
||||||
|
node.append(paragraph);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Document generateInnerDoc(Table table, String documentContent) {
|
||||||
|
return generateInnerDoc(table, documentContent, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Document generateInnerDoc(Table table, String documentContent, String id) {
|
||||||
|
Document innerDoc = new DocumentImpl(table);
|
||||||
|
if (StringUtils.isNotBlank(id)) {
|
||||||
|
innerDoc.setId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
Block paragraph = new ParagraphBlockImpl(innerDoc);
|
||||||
|
paragraph.setSource(documentContent);
|
||||||
|
innerDoc.append(paragraph);
|
||||||
|
return innerDoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String requiredIndicator(boolean isRequired, String labelRequired, String labelOptional) {
|
||||||
|
return italicUnconstrained(isRequired ? labelRequired : labelOptional).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String superScript(String str) {
|
||||||
|
return "^" + str + "^";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String subScript(String str) {
|
||||||
|
return "~" + str + "~";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String italicUnconstrained(String str) {
|
||||||
|
return "__" + str + "__";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String boldUnconstrained(String str) {
|
||||||
|
return "**" + str + "**";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String monospaced(String str) {
|
||||||
|
return "`" + str + "`";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getSchemaTypeAsString(Schema schema) {
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
if (schema instanceof ArraySchema) {
|
||||||
|
stringBuilder.append("< ");
|
||||||
|
Schema<?> items = ((ArraySchema) schema).getItems();
|
||||||
|
stringBuilder.append(getSchemaType(items));
|
||||||
|
stringBuilder.append(" > ");
|
||||||
|
stringBuilder.append(schema.getType());
|
||||||
|
} else {
|
||||||
|
List enumList = schema.getEnum();
|
||||||
|
if (enumList != null) {
|
||||||
|
stringBuilder.append("enum (");
|
||||||
|
for (Object value : enumList) {
|
||||||
|
stringBuilder.append(value.toString());
|
||||||
|
stringBuilder.append(",");
|
||||||
|
}
|
||||||
|
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
|
||||||
|
stringBuilder.append(')');
|
||||||
|
} else {
|
||||||
|
stringBuilder.append(getSchemaType(schema));
|
||||||
|
String format = schema.getFormat();
|
||||||
|
if (format != null) {
|
||||||
|
stringBuilder.append(' ');
|
||||||
|
stringBuilder.append('(');
|
||||||
|
stringBuilder.append(format);
|
||||||
|
stringBuilder.append(')');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stringBuilder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getSchemaType(Schema<?> schema) {
|
||||||
|
String type = schema.getType();
|
||||||
|
if (StringUtils.isNotEmpty(type)) {
|
||||||
|
return type;
|
||||||
|
} else {
|
||||||
|
return generateRefLink(schema.get$ref());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String generateRefLink(String ref) {
|
||||||
|
if (StringUtils.isNotBlank(ref)) {
|
||||||
|
String anchor = ref.toLowerCase().replaceFirst("#", "").replaceAll("/", "_");
|
||||||
|
return "<<" + anchor + ">>" + LINE_SEPARATOR;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
swagger2markup.markupLanguage=ASCIIDOC
|
||||||
|
swagger2markup.swaggerMarkupLanguage=ASCIIDOC
|
||||||
|
swagger2markup.hostnameEnabled=false
|
||||||
|
swagger2markup.basePathPrefixEnabled=false
|
||||||
|
swagger2markup.operationExtensionsEnabled=false
|
||||||
|
swagger2markup.definitionExtensionsEnabled=false
|
||||||
|
swagger2markup.separatedDefinitionsEnabled=false
|
||||||
|
swagger2markup.separatedOperationsEnabled=false
|
||||||
|
swagger2markup.pathsGroupedBy=AS_IS
|
||||||
|
swagger2markup.outputLanguage=EN
|
||||||
|
swagger2markup.inlineSchemaEnabled=true
|
||||||
|
swagger2markup.interDocumentCrossReferencesEnabled=false
|
||||||
|
swagger2markup.flatBodyEnabled=false
|
||||||
|
swagger2markup.pathSecuritySectionEnabled=true
|
||||||
|
swagger2markup.overviewDocument=overview
|
||||||
|
swagger2markup.pathsDocument=paths
|
||||||
|
swagger2markup.definitionsDocument=definitions
|
||||||
|
swagger2markup.securityDocument=security
|
||||||
|
swagger2markup.separatedOperationsFolder=operations
|
||||||
|
swagger2markup.separatedDefinitionsFolder=definitions
|
||||||
|
swagger2markup.tagOrderBy=NATURAL
|
||||||
|
swagger2markup.operationOrderBy=NATURAL
|
||||||
|
swagger2markup.definitionOrderBy=NATURAL
|
||||||
|
swagger2markup.parameterOrderBy=NATURAL
|
||||||
|
swagger2markup.propertyOrderBy=NATURAL
|
||||||
|
swagger2markup.responseOrderBy=NATURAL
|
||||||
|
swagger2markup.listDelimiterEnabled=false
|
||||||
|
swagger2markup.listDelimiter=,
|
||||||
|
swagger2markup.asciidoc.pegdown.timeoutMillis=2000
|
||||||
|
|
||||||
|
swagger2markup.generatedExamplesEnabled=false
|
||||||
|
# basic, curl, invoke-webrequest
|
||||||
|
swagger2markup.requestExamplesFormat=basic
|
||||||
|
# default, bash, powershell, etc.
|
||||||
|
swagger2markup.requestExamplesSourceFormat=default
|
||||||
|
# hide, inherit or hostname
|
||||||
|
swagger2markup.requestExamplesHost=hide
|
||||||
|
# hide, inherit or schema (e.g. https, https, etc.)
|
||||||
|
swagger2markup.requestExamplesSchema=hide
|
||||||
|
swagger2markup.requestExamplesHideBasePath=true
|
||||||
|
swagger2markup.requestExamplesIncludeAllQueryParams=false
|
||||||
|
# single, commaSeparated, multiple, multiple[]
|
||||||
|
swagger2markup.requestExamplesQueryArrayStyle=single
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
label_content=Content
|
||||||
|
label_default=Default
|
||||||
|
label_deprecated=Deprecated
|
||||||
|
label_example=Example
|
||||||
|
label_examples=Examples
|
||||||
|
label_exclusive_maximum=Exclusive Maximum
|
||||||
|
label_exclusive_minimum=Exclusive Minimum
|
||||||
|
label_external_value=External Value
|
||||||
|
label_format=Format
|
||||||
|
label_maximum=Maximum
|
||||||
|
label_max_items=Maximum Items
|
||||||
|
label_max_length=Maximum Length
|
||||||
|
label_max_properties=Maximum Properties
|
||||||
|
label_minimum=Minimum
|
||||||
|
label_min_items=Minimum Items
|
||||||
|
label_min_length=Minimum Length
|
||||||
|
label_min_properties=Minimum Properties
|
||||||
|
label_multiple_of=Multiple Of
|
||||||
|
label_no_links=No Links
|
||||||
|
label_nullable=Nullable
|
||||||
|
label_operation=Operation
|
||||||
|
label_optional=Optional
|
||||||
|
label_parameters=Parameters
|
||||||
|
label_read_only=Read Only
|
||||||
|
label_required=Required
|
||||||
|
label_server=Server
|
||||||
|
label_terms_of_service=Terms Of Service
|
||||||
|
label_title=Title
|
||||||
|
label_type=Type
|
||||||
|
label_unique_items=Unique Items
|
||||||
|
label_write_only=Write Only
|
||||||
|
section_title_components=Components
|
||||||
|
section_title_parameters=Parameters
|
||||||
|
section_title_paths=Paths
|
||||||
|
section_title_schemas=Schemas
|
||||||
|
section_title_security=Security
|
||||||
|
section_title_servers=Servers
|
||||||
|
section_title_overview=Overview
|
||||||
|
section_title_tags=Tags
|
||||||
|
section_title_responses=Responses
|
||||||
|
section_title_headers=Headers
|
||||||
|
section_title_links=Links
|
||||||
|
table_header_default=Default
|
||||||
|
table_header_description=Description
|
||||||
|
table_header_http_code=Code
|
||||||
|
table_header_links=Links
|
||||||
|
table_header_name=Name
|
||||||
|
table_header_possible_values=Possible Values
|
||||||
|
table_header_schema=Schema
|
||||||
|
table_header_scopes=Scopes
|
||||||
|
table_header_type=Type
|
||||||
|
table_header_variable=Variable
|
||||||
|
table_title_headers=Headers
|
||||||
|
table_title_parameters=Parameters
|
||||||
|
table_title_properties=Properties
|
||||||
|
table_title_responses=Responses
|
||||||
|
table_title_security=Security
|
||||||
|
table_title_server_variables=Server Variables
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2017 Robert Winkler
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package io.github.swagger2markup;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.assertions.DiffUtils;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.assertj.core.api.Assertions;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static java.util.Arrays.asList;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
public class AsciidocConverterTest {
|
||||||
|
|
||||||
|
private static final String[] EXPECTED_FILES = new String[]{"definitions.adoc", "overview.adoc", "paths.adoc", "security.adoc"};
|
||||||
|
private List<String> expectedFiles;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
expectedFiles = new ArrayList<>(asList(EXPECTED_FILES));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testToString() throws URISyntaxException {
|
||||||
|
//Given
|
||||||
|
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
|
||||||
|
|
||||||
|
//When
|
||||||
|
String asciiDocAsString = OpenAPI2MarkupConverter.from(file).build()
|
||||||
|
.toString();
|
||||||
|
//Then
|
||||||
|
Assertions.assertThat(asciiDocAsString).isNotEmpty();
|
||||||
|
System.out.println(asciiDocAsString);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testToFolder() throws URISyntaxException {
|
||||||
|
//Given
|
||||||
|
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
|
||||||
|
Path outputDirectory = Paths.get("build/test/asciidoc/to_folder");
|
||||||
|
FileUtils.deleteQuietly(outputDirectory.toFile());
|
||||||
|
|
||||||
|
//When
|
||||||
|
OpenAPI2MarkupConverter.from(file).build()
|
||||||
|
.toFolder(outputDirectory);
|
||||||
|
|
||||||
|
//Then
|
||||||
|
String[] files = outputDirectory.toFile().list();
|
||||||
|
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
||||||
|
|
||||||
|
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/to_folder").toURI());
|
||||||
|
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testToFolder.html");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package io.github.swagger2markup;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
|
import io.swagger.v3.parser.OpenAPIV3Parser;
|
||||||
|
import io.swagger.v3.parser.core.models.ParseOptions;
|
||||||
|
import io.swagger.v3.parser.core.models.SwaggerParseResult;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.Parameterized;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
|
@RunWith(Parameterized.class)
|
||||||
|
public class OpenApi2AsciiDocTest {
|
||||||
|
|
||||||
|
final private String openApiFile;
|
||||||
|
final private String expectedAsciiDoc;
|
||||||
|
|
||||||
|
public OpenApi2AsciiDocTest(String openApiFile, String expectedAsciiDoc) throws IOException {
|
||||||
|
this.openApiFile = "./src/test/resources/open_api/" + openApiFile;
|
||||||
|
this.expectedAsciiDoc = IOUtils.toString(getClass().getResourceAsStream("/asciidoc/" + expectedAsciiDoc), StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Parameterized.Parameters(name = "Run {index}: open api={0}, asciidoc={1}")
|
||||||
|
public static Iterable<Object[]> data() {
|
||||||
|
return Arrays.asList(new Object[][]{
|
||||||
|
{"simple.yaml", "simple.adoc"},
|
||||||
|
{"petstore.yaml", "petstore.adoc"}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void converts_open_api_v3_to_asciidoc() {
|
||||||
|
ParseOptions options = new ParseOptions();
|
||||||
|
options.setResolve(true);
|
||||||
|
SwaggerParseResult result = new OpenAPIV3Parser().readLocation(openApiFile, null, options);
|
||||||
|
OpenAPI swagger = result.getOpenAPI();
|
||||||
|
assertNotNull(swagger);
|
||||||
|
|
||||||
|
OpenAPI2MarkupConverter converter = OpenAPI2MarkupConverter.from(swagger).build();
|
||||||
|
converter.toFolder(Paths.get("build/test/asciidoc"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Copyright 2016 Robert Winkler
|
* Copyright 2017 Robert Winkler
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
1898
openapi2markup/src/test/resources/asciidoc/petstore.adoc
Normal file
1898
openapi2markup/src/test/resources/asciidoc/petstore.adoc
Normal file
File diff suppressed because it is too large
Load Diff
276
openapi2markup/src/test/resources/asciidoc/simple.adoc
Normal file
276
openapi2markup/src/test/resources/asciidoc/simple.adoc
Normal file
@@ -0,0 +1,276 @@
|
|||||||
|
= Simple Inventory API
|
||||||
|
<you@your-company.com>
|
||||||
|
v1.0.0
|
||||||
|
:revnumber: 1.0.0
|
||||||
|
:openapi: 3.0.0
|
||||||
|
:authorcount: 1
|
||||||
|
:email: you@your-company.com
|
||||||
|
|
||||||
|
== Overview
|
||||||
|
This is a simple API
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0]
|
||||||
|
|
||||||
|
== Tags
|
||||||
|
admins::
|
||||||
|
Secured Admin-only calls
|
||||||
|
developers::
|
||||||
|
Operations available to regular developers
|
||||||
|
|
||||||
|
== Servers
|
||||||
|
=== __Server__: /
|
||||||
|
|
||||||
|
== Paths
|
||||||
|
=== __GET__ `/inventory` searches inventory
|
||||||
|
By passing in the appropriate options, you can search for
|
||||||
|
available inventory in the system
|
||||||
|
|
||||||
|
.Parameters
|
||||||
|
[%header,caption=,cols=".^2a,.^3a,.^10a,.^5a"]
|
||||||
|
|===
|
||||||
|
<.<|Type
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Name
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Description
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Schema
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|**query**
|
||||||
|
|
||||||
|
|
||||||
|
<.<|**searchString** +
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|pass an optional search string for looking up inventory
|
||||||
|
|
||||||
|
|
||||||
|
<.<|type: string
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|**query**
|
||||||
|
|
||||||
|
|
||||||
|
<.<|**limit** +
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|maximum number of records to return
|
||||||
|
|
||||||
|
|
||||||
|
<.<|minimum: 0 +
|
||||||
|
type: integer +
|
||||||
|
maximum: 50 +
|
||||||
|
format: int32
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|**query**
|
||||||
|
|
||||||
|
|
||||||
|
<.<|**skip** +
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|number of records to skip for pagination
|
||||||
|
|
||||||
|
|
||||||
|
<.<|minimum: 0 +
|
||||||
|
type: integer +
|
||||||
|
format: int32
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|===
|
||||||
|
.Responses
|
||||||
|
[%header,caption=,cols=".^2a,.^14a,.^4a"]
|
||||||
|
|===
|
||||||
|
<.<|Code
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Description
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Links
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|200
|
||||||
|
|
||||||
|
|
||||||
|
<.<|search results matching criteria
|
||||||
|
|
||||||
|
.Content
|
||||||
|
application/json::
|
||||||
|
+
|
||||||
|
|
||||||
|
type: array
|
||||||
|
|
||||||
|
|
||||||
|
<.<|No Links
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|400
|
||||||
|
|
||||||
|
|
||||||
|
<.<|bad input parameter
|
||||||
|
|
||||||
|
|
||||||
|
<.<|No Links
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|===
|
||||||
|
|
||||||
|
=== __POST__ `/inventory` adds an inventory item
|
||||||
|
Adds an item to the system
|
||||||
|
|
||||||
|
.Responses
|
||||||
|
[%header,caption=,cols=".^2a,.^14a,.^4a"]
|
||||||
|
|===
|
||||||
|
<.<|Code
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Description
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Links
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|201
|
||||||
|
|
||||||
|
|
||||||
|
<.<|item created
|
||||||
|
|
||||||
|
|
||||||
|
<.<|No Links
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|400
|
||||||
|
|
||||||
|
|
||||||
|
<.<|invalid input, object invalid
|
||||||
|
|
||||||
|
|
||||||
|
<.<|No Links
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|409
|
||||||
|
|
||||||
|
|
||||||
|
<.<|an existing item already exists
|
||||||
|
|
||||||
|
|
||||||
|
<.<|No Links
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|===
|
||||||
|
|
||||||
|
[[_components]]
|
||||||
|
== Components
|
||||||
|
[[_components_schemas]]
|
||||||
|
=== Schemas
|
||||||
|
[[_components_schemas_inventoryitem]]
|
||||||
|
==== InventoryItem
|
||||||
|
|
||||||
|
type: object
|
||||||
|
|
||||||
|
.Properties
|
||||||
|
[%header,caption=,cols=".^4a,.^16a"]
|
||||||
|
|===
|
||||||
|
<.<|Name
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Schema
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|id
|
||||||
|
__required__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|type: string +
|
||||||
|
format: uuid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|name
|
||||||
|
__required__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|type: string
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|releaseDate
|
||||||
|
__required__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|type: string +
|
||||||
|
format: date-time
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|manufacturer
|
||||||
|
__required__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|<<_components_schemas_Manufacturer,Manufacturer>>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|===
|
||||||
|
[[_components_schemas_manufacturer]]
|
||||||
|
==== Manufacturer
|
||||||
|
|
||||||
|
type: object
|
||||||
|
|
||||||
|
.Properties
|
||||||
|
[%header,caption=,cols=".^4a,.^16a"]
|
||||||
|
|===
|
||||||
|
<.<|Name
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Schema
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|name
|
||||||
|
__required__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|type: string
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|homePage
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|type: string +
|
||||||
|
format: url
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|phone
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|type: string
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|===
|
||||||
|
|
||||||
@@ -0,0 +1,351 @@
|
|||||||
|
|
||||||
|
[[_components]]
|
||||||
|
== Components
|
||||||
|
[[_components_schemas]]
|
||||||
|
=== Schemas
|
||||||
|
[[_components_schemas_user]]
|
||||||
|
==== User
|
||||||
|
|
||||||
|
.Properties
|
||||||
|
[%header,caption=,cols=".^4a,.^16a,.^4a"]
|
||||||
|
|===
|
||||||
|
<.<|Name
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Description
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Schema
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|id
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|integer (int64)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|username
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|string
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|firstName
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|string
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|lastName
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|string
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|email
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|string
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|password
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|string
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|phone
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|string
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|userStatus
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|User Status
|
||||||
|
|
||||||
|
|
||||||
|
<.<|integer (int32)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|===
|
||||||
|
[[_components_schemas_category]]
|
||||||
|
==== Category
|
||||||
|
|
||||||
|
.Properties
|
||||||
|
[%header,caption=,cols=".^4a,.^16a,.^4a"]
|
||||||
|
|===
|
||||||
|
<.<|Name
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Description
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Schema
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|id
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|integer (int64)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|name
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|The name of the category
|
||||||
|
|
||||||
|
**Maximum Length**: 255 +
|
||||||
|
**Minimum Length**: 0 +
|
||||||
|
**Default**: DefaultCategory
|
||||||
|
|
||||||
|
|
||||||
|
<.<|string
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|===
|
||||||
|
[[_components_schemas_pet]]
|
||||||
|
==== Pet
|
||||||
|
|
||||||
|
.Properties
|
||||||
|
[%header,caption=,cols=".^4a,.^16a,.^4a"]
|
||||||
|
|===
|
||||||
|
<.<|Name
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Description
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Schema
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|id
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|integer (int64)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|category
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|<<_components_schemas_category>>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|name
|
||||||
|
__required__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|string
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|photoUrls
|
||||||
|
__required__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|< string > array
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|tags
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|< <<_components_schemas_tag>>
|
||||||
|
> array
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|status
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|pet status in the store,
|
||||||
|
|
||||||
|
|
||||||
|
<.<|enum (Dead,Alive)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|===
|
||||||
|
[[_components_schemas_tag]]
|
||||||
|
==== Tag
|
||||||
|
|
||||||
|
.Properties
|
||||||
|
[%header,caption=,cols=".^4a,.^16a,.^4a"]
|
||||||
|
|===
|
||||||
|
<.<|Name
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Description
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Schema
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|id
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|integer (int64)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|name
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|string
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|===
|
||||||
|
[[_components_schemas_order]]
|
||||||
|
==== Order
|
||||||
|
|
||||||
|
.Properties
|
||||||
|
[%header,caption=,cols=".^4a,.^16a,.^4a"]
|
||||||
|
|===
|
||||||
|
<.<|Name
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Description
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Schema
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|id
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|integer (int64)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|petId
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|integer (int64)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|quantity
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|**Maximum**: 10000 +
|
||||||
|
**Minimum**: 0 +
|
||||||
|
**Default**: 0
|
||||||
|
|
||||||
|
|
||||||
|
<.<|integer (int32)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|shipDate
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|string (date-time)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|status
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Order Status
|
||||||
|
|
||||||
|
|
||||||
|
<.<|enum (Ordered,Cancelled)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|complete
|
||||||
|
__optional__
|
||||||
|
|
||||||
|
|
||||||
|
<.<|
|
||||||
|
<.<|boolean
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|===
|
||||||
|
|
||||||
|
[[_components_parameters]]
|
||||||
|
=== Responses
|
||||||
|
.Responses
|
||||||
|
[%header,caption=,cols=".^2a,.^14a,.^4a"]
|
||||||
|
|===
|
||||||
|
<.<|Code
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Description
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Links
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<.<|InvalidId
|
||||||
|
|
||||||
|
|
||||||
|
<.<|Invalid ID supplied
|
||||||
|
|
||||||
|
|
||||||
|
<.<|No Links
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|===
|
||||||
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
= Swagger Petstore
|
||||||
|
apiteam@swagger.io
|
||||||
|
v1.0.0
|
||||||
|
:revnumber: 1.0.0
|
||||||
|
:openapi: 3.0.0
|
||||||
|
:author: apiteam@swagger.io
|
||||||
|
:authorcount: 1
|
||||||
|
|
||||||
|
|
||||||
|
== Overview
|
||||||
|
This is a sample server Petstore server.
|
||||||
|
|
||||||
|
[Learn about Swagger](http://swagger.io) or join the IRC channel `#swagger` on irc.freenode.net.
|
||||||
|
|
||||||
|
For this sample, you can use the api key `special-key` to test the authorization filters
|
||||||
|
|
||||||
|
http://helloreverb.com/terms/[Terms Of Service]
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0]
|
||||||
|
|
||||||
|
http://swagger.io[Find out more about Swagger]
|
||||||
|
|
||||||
|
== Tags
|
||||||
|
pet::
|
||||||
|
Pet resource
|
||||||
|
store::
|
||||||
|
Store resource
|
||||||
|
user::
|
||||||
|
User resource
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
14
openapi2markup/src/test/resources/logback.xml
Normal file
14
openapi2markup/src/test/resources/logback.xml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration scan="true">
|
||||||
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<logger name="io.github.swagger2markup" level="DEBUG"/>
|
||||||
|
|
||||||
|
<root level="INFO">
|
||||||
|
<appender-ref ref="CONSOLE" />
|
||||||
|
</root>
|
||||||
|
</configuration>
|
||||||
732
openapi2markup/src/test/resources/open_api/petstore.yaml
Normal file
732
openapi2markup/src/test/resources/open_api/petstore.yaml
Normal file
@@ -0,0 +1,732 @@
|
|||||||
|
openapi: 3.0.0
|
||||||
|
servers:
|
||||||
|
- url: 'http://localhost:8000/v2/api'
|
||||||
|
info:
|
||||||
|
description: >-
|
||||||
|
This is a sample server Petstore server. You can find out more about
|
||||||
|
Swagger at http://swagger.io or on
|
||||||
|
irc.freenode.net, #swagger. For this sample, you can use the api key
|
||||||
|
"special-key" to test the authorization filters
|
||||||
|
version: 1.0.0
|
||||||
|
title: Swagger Petstore
|
||||||
|
termsOfService: 'http://swagger.io/terms/'
|
||||||
|
contact:
|
||||||
|
name: apiteam@swagger.io
|
||||||
|
license:
|
||||||
|
name: Apache 2.0
|
||||||
|
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
|
||||||
|
externalDocs:
|
||||||
|
description: Find more info here
|
||||||
|
url: 'https://swagger.io'
|
||||||
|
tags:
|
||||||
|
- name: pet
|
||||||
|
description: Pet Operations
|
||||||
|
externalDocs:
|
||||||
|
url: 'http://swagger.io'
|
||||||
|
- name: user
|
||||||
|
description: All about the Users
|
||||||
|
paths:
|
||||||
|
/pet/add:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Add a new pet to the store
|
||||||
|
description: ''
|
||||||
|
operationId: createPet
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: This is a sample
|
||||||
|
content:
|
||||||
|
text/plain:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
example: 'whoa!'
|
||||||
|
'405':
|
||||||
|
description: Invalid input
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- 'write:pets'
|
||||||
|
- 'read:pets'
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
description: Pet object that needs to be added to the store
|
||||||
|
/pet:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Add a new pet to the store
|
||||||
|
description: ''
|
||||||
|
operationId: addPet
|
||||||
|
responses:
|
||||||
|
'405':
|
||||||
|
description: Invalid input
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- 'write:pets'
|
||||||
|
- 'read:pets'
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
description: Pet object that needs to be added to the store
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Update an existing pet
|
||||||
|
description: ''
|
||||||
|
operationId: updatePet
|
||||||
|
responses:
|
||||||
|
'400':
|
||||||
|
description: Invalid ID supplied
|
||||||
|
'404':
|
||||||
|
description: Pet not found
|
||||||
|
'405':
|
||||||
|
description: Validation exception
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- 'write:pets'
|
||||||
|
- 'read:pets'
|
||||||
|
requestBody:
|
||||||
|
$ref: '#/components/requestBodies/Pet'
|
||||||
|
/pet/findByStatus:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Finds Pets by status
|
||||||
|
description: Multiple status values can be provided with comma seperated strings
|
||||||
|
operationId: findPetsByStatus
|
||||||
|
parameters:
|
||||||
|
- name: status
|
||||||
|
in: query
|
||||||
|
description: Status values that need to be considered for filter
|
||||||
|
required: false
|
||||||
|
style: pipeDelimited
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
default: available
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/PetArray'
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/PetArray'
|
||||||
|
'400':
|
||||||
|
description: Invalid status value
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- 'write:pets'
|
||||||
|
- 'read:pets'
|
||||||
|
/pet/findByTags:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Finds Pets by tags
|
||||||
|
description: >-
|
||||||
|
Muliple tags can be provided with comma seperated strings. Use tag1,
|
||||||
|
tag2, tag3 for testing.
|
||||||
|
operationId: findPetsByTags
|
||||||
|
parameters:
|
||||||
|
- name: tags
|
||||||
|
in: query
|
||||||
|
description: Tags to filter by
|
||||||
|
required: false
|
||||||
|
explode: true
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
'400':
|
||||||
|
description: Invalid tag value
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- 'write:pets'
|
||||||
|
- 'read:pets'
|
||||||
|
'/pet/{petId}':
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Find pet by ID
|
||||||
|
description: >-
|
||||||
|
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API
|
||||||
|
error conditions
|
||||||
|
operationId: getPetById
|
||||||
|
parameters:
|
||||||
|
- name: petId
|
||||||
|
in: path
|
||||||
|
description: ID of pet that needs to be fetched
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
'400':
|
||||||
|
description: Invalid ID supplied
|
||||||
|
'404':
|
||||||
|
description: Pet not found
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
- petstore_auth:
|
||||||
|
- 'write:pets'
|
||||||
|
- 'read:pets'
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Updates a pet in the store with form data
|
||||||
|
description: ''
|
||||||
|
operationId: updatePetWithForm
|
||||||
|
parameters:
|
||||||
|
- name: petId
|
||||||
|
in: path
|
||||||
|
description: ID of pet that needs to be updated
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'405':
|
||||||
|
description: Invalid input
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- 'write:pets'
|
||||||
|
- 'read:pets'
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/x-www-form-urlencoded:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
description: Updated name of the pet
|
||||||
|
type: string
|
||||||
|
status:
|
||||||
|
description: Updated status of the pet
|
||||||
|
type: string
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Deletes a pet
|
||||||
|
description: ''
|
||||||
|
operationId: deletePet
|
||||||
|
parameters:
|
||||||
|
- name: api_key
|
||||||
|
in: header
|
||||||
|
description: ''
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- name: petId
|
||||||
|
in: path
|
||||||
|
description: Pet id to delete
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
responses:
|
||||||
|
'400':
|
||||||
|
description: Invalid pet value
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- 'write:pets'
|
||||||
|
- 'read:pets'
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
description: Pet extra params that needs to be deleted
|
||||||
|
'/pet/{petId}/uploadImage':
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: uploads an image
|
||||||
|
description: ''
|
||||||
|
operationId: uploadFile
|
||||||
|
parameters:
|
||||||
|
- name: petId
|
||||||
|
in: path
|
||||||
|
description: ID of pet to update
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/ApiResponse"
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- 'write:pets'
|
||||||
|
- 'read:pets'
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
multipart/form-data:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
additionalMetadata:
|
||||||
|
description: Additional data to pass to server
|
||||||
|
type: string
|
||||||
|
file:
|
||||||
|
description: file to upload
|
||||||
|
type: string
|
||||||
|
format: binary
|
||||||
|
/store/inventory:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
summary: Returns pet inventories by status
|
||||||
|
description: Returns a map of status codes to quantities
|
||||||
|
operationId: get inventory+1
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
additionalProperties:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
additionalProperties:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
/store/order:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
summary: Place an order for a pet
|
||||||
|
description: ''
|
||||||
|
operationId: placeOrder
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
'400':
|
||||||
|
description: Invalid Order
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
description: order placed for purchasing the pet
|
||||||
|
'/store/order/{orderId}':
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
summary: Find purchase order by ID
|
||||||
|
description: >-
|
||||||
|
For valid response try integer IDs with value <= 5 or > 10. Other values
|
||||||
|
will generated exceptions
|
||||||
|
operationId: getOrderById
|
||||||
|
parameters:
|
||||||
|
- name: orderId
|
||||||
|
in: path
|
||||||
|
description: ID of pet that needs to be fetched
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
'400':
|
||||||
|
description: Invalid ID supplied
|
||||||
|
'404':
|
||||||
|
description: Order not found
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
summary: Delete purchase order by ID
|
||||||
|
description: >-
|
||||||
|
For valid response try integer IDs with value < 1000. Anything above
|
||||||
|
1000 or nonintegers will generate API errors
|
||||||
|
operationId: deleteOrder
|
||||||
|
parameters:
|
||||||
|
- name: orderId
|
||||||
|
in: path
|
||||||
|
description: ID of the order that needs to be deleted
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'400':
|
||||||
|
description: Invalid ID supplied
|
||||||
|
'404':
|
||||||
|
description: Order not found
|
||||||
|
/user:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Create user
|
||||||
|
description: This can only be done by the logged in user.
|
||||||
|
operationId: createUser
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
content:
|
||||||
|
'application/json':
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
# default is text/plain
|
||||||
|
type: string
|
||||||
|
format: text
|
||||||
|
examples:
|
||||||
|
foo:
|
||||||
|
value: {"foo": "bar"}
|
||||||
|
bar:
|
||||||
|
summary: A bar example
|
||||||
|
value: {"bar": "baz"}
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
description: Created user object
|
||||||
|
/user/createWithArray:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Creates list of users with given input array
|
||||||
|
description: ''
|
||||||
|
operationId: createUsersWithArrayInput
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
requestBody:
|
||||||
|
$ref: '#/components/requestBodies/UserArray'
|
||||||
|
/user/createWithList:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Creates list of users with given input array
|
||||||
|
description: ''
|
||||||
|
operationId: createUsersWithListInput
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
requestBody:
|
||||||
|
$ref: '#/components/requestBodies/UserArray'
|
||||||
|
/user/login:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
security:
|
||||||
|
- https
|
||||||
|
summary: Logs user into the system
|
||||||
|
description: ''
|
||||||
|
operationId: loginUser
|
||||||
|
parameters:
|
||||||
|
- name: username
|
||||||
|
in: query
|
||||||
|
description: The user name for login
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- name: password
|
||||||
|
in: query
|
||||||
|
description: The password for login in clear text
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
'400':
|
||||||
|
description: Invalid username/password supplied
|
||||||
|
/user/logout:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
security:
|
||||||
|
- https
|
||||||
|
summary: Logs out current logged in user session
|
||||||
|
description: ''
|
||||||
|
operationId: logoutUser
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
'/user/{username}':
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Get user by user name
|
||||||
|
description: ''
|
||||||
|
operationId: getUserByName
|
||||||
|
parameters:
|
||||||
|
- name: username
|
||||||
|
in: path
|
||||||
|
description: 'The name that needs to be fetched. Use user1 for testing.'
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
'400':
|
||||||
|
description: Invalid username supplied
|
||||||
|
'404':
|
||||||
|
description: User not found
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Updated user
|
||||||
|
description: This can only be done by the logged in user.
|
||||||
|
operationId: updateUser
|
||||||
|
parameters:
|
||||||
|
- name: username
|
||||||
|
in: path
|
||||||
|
description: name that need to be deleted
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'400':
|
||||||
|
description: Invalid user supplied
|
||||||
|
'404':
|
||||||
|
description: User not found
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
description: Updated user object
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Delete user
|
||||||
|
description: This can only be done by the logged in user.
|
||||||
|
operationId: deleteUser
|
||||||
|
parameters:
|
||||||
|
- name: username
|
||||||
|
in: path
|
||||||
|
description: The name that needs to be deleted
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'400':
|
||||||
|
description: Invalid username supplied
|
||||||
|
'404':
|
||||||
|
description: User not found
|
||||||
|
security:
|
||||||
|
- foo:
|
||||||
|
- bar
|
||||||
|
- baz
|
||||||
|
a:
|
||||||
|
- b
|
||||||
|
- c
|
||||||
|
components:
|
||||||
|
parameters:
|
||||||
|
sharedSkip:
|
||||||
|
name: skip
|
||||||
|
in: query
|
||||||
|
description: Results to skip
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
responses:
|
||||||
|
veryBad:
|
||||||
|
description: failed
|
||||||
|
requestBodies:
|
||||||
|
UserArray:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
description: List of user object
|
||||||
|
Pet:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
description: Pet object that needs to be added to the store
|
||||||
|
securitySchemes:
|
||||||
|
api_key:
|
||||||
|
type: apiKey
|
||||||
|
name: api_key
|
||||||
|
in: header
|
||||||
|
petstore_auth:
|
||||||
|
type: oauth2
|
||||||
|
flows:
|
||||||
|
implicit:
|
||||||
|
authorizationUrl: 'http://petstore.swagger.io/api/oauth/dialog'
|
||||||
|
scopes:
|
||||||
|
'write:pets': modify pets in your account
|
||||||
|
'read:pets': read your pets
|
||||||
|
schemas:
|
||||||
|
User:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
username:
|
||||||
|
type: string
|
||||||
|
firstName:
|
||||||
|
type: string
|
||||||
|
lastName:
|
||||||
|
type: string
|
||||||
|
email:
|
||||||
|
type: string
|
||||||
|
password:
|
||||||
|
type: string
|
||||||
|
phone:
|
||||||
|
type: string
|
||||||
|
userStatus:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
description: User Status
|
||||||
|
xml:
|
||||||
|
name: User
|
||||||
|
Category:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
xml:
|
||||||
|
name: Category
|
||||||
|
Pet:
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
- photoUrls
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
category:
|
||||||
|
$ref: '#/components/schemas/Category'
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
example: doggie
|
||||||
|
photoUrls:
|
||||||
|
type: array
|
||||||
|
xml:
|
||||||
|
name: photoUrl
|
||||||
|
wrapped: true
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
tags:
|
||||||
|
type: array
|
||||||
|
xml:
|
||||||
|
name: tag
|
||||||
|
wrapped: true
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Tag'
|
||||||
|
status:
|
||||||
|
type: string
|
||||||
|
description: pet status in the store
|
||||||
|
xml:
|
||||||
|
name: Pet
|
||||||
|
Tag:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
xml:
|
||||||
|
name: Tag
|
||||||
|
Order:
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
petId:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
quantity:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
shipDate:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
|
status:
|
||||||
|
type: string
|
||||||
|
description: Order Status
|
||||||
|
complete:
|
||||||
|
type: boolean
|
||||||
|
xml:
|
||||||
|
name: Order
|
||||||
|
PetArray:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
115
openapi2markup/src/test/resources/open_api/simple.yaml
Normal file
115
openapi2markup/src/test/resources/open_api/simple.yaml
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
openapi: 3.0.0
|
||||||
|
info:
|
||||||
|
description: This is a simple API
|
||||||
|
version: "1.0.0"
|
||||||
|
title: Simple Inventory API
|
||||||
|
contact:
|
||||||
|
email: you@your-company.com
|
||||||
|
license:
|
||||||
|
name: Apache 2.0
|
||||||
|
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
|
||||||
|
tags:
|
||||||
|
- name: admins
|
||||||
|
description: Secured Admin-only calls
|
||||||
|
- name: developers
|
||||||
|
description: Operations available to regular developers
|
||||||
|
paths:
|
||||||
|
/inventory:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- developers
|
||||||
|
summary: searches inventory
|
||||||
|
operationId: searchInventory
|
||||||
|
description: |
|
||||||
|
By passing in the appropriate options, you can search for
|
||||||
|
available inventory in the system
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: searchString
|
||||||
|
description: pass an optional search string for looking up inventory
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: skip
|
||||||
|
description: number of records to skip for pagination
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
minimum: 0
|
||||||
|
- in: query
|
||||||
|
name: limit
|
||||||
|
description: maximum number of records to return
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
minimum: 0
|
||||||
|
maximum: 50
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: search results matching criteria
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/InventoryItem'
|
||||||
|
'400':
|
||||||
|
description: bad input parameter
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- admins
|
||||||
|
summary: adds an inventory item
|
||||||
|
operationId: addInventory
|
||||||
|
description: Adds an item to the system
|
||||||
|
responses:
|
||||||
|
'201':
|
||||||
|
description: item created
|
||||||
|
'400':
|
||||||
|
description: 'invalid input, object invalid'
|
||||||
|
'409':
|
||||||
|
description: an existing item already exists
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/InventoryItem'
|
||||||
|
description: Inventory item to add
|
||||||
|
components:
|
||||||
|
schemas:
|
||||||
|
InventoryItem:
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- id
|
||||||
|
- name
|
||||||
|
- manufacturer
|
||||||
|
- releaseDate
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
example: d290f1ee-6c54-4b01-90e6-d701748f0851
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
example: Widget Adapter
|
||||||
|
releaseDate:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
|
example: '2016-08-29T09:12:33.001Z'
|
||||||
|
manufacturer:
|
||||||
|
$ref: '#/components/schemas/Manufacturer'
|
||||||
|
Manufacturer:
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
example: ACME Corporation
|
||||||
|
homePage:
|
||||||
|
type: string
|
||||||
|
format: url
|
||||||
|
example: 'https://www.acme-corp.com'
|
||||||
|
phone:
|
||||||
|
type: string
|
||||||
|
example: 408-867-5309
|
||||||
|
type: object
|
||||||
693
openapi2markup/src/test/resources/yaml/swagger_petstore.yaml
Normal file
693
openapi2markup/src/test/resources/yaml/swagger_petstore.yaml
Normal file
@@ -0,0 +1,693 @@
|
|||||||
|
openapi: 3.0.0
|
||||||
|
info:
|
||||||
|
description: >
|
||||||
|
This is a sample server Petstore server.
|
||||||
|
|
||||||
|
|
||||||
|
[Learn about Swagger](http://swagger.io) or join the IRC channel `#swagger` on irc.freenode.net.
|
||||||
|
|
||||||
|
|
||||||
|
For this sample, you can use the api key `special-key` to test the authorization filters
|
||||||
|
version: 1.0.0
|
||||||
|
title: Swagger Petstore
|
||||||
|
termsOfService: http://helloreverb.com/terms/
|
||||||
|
contact:
|
||||||
|
name: apiteam@swagger.io
|
||||||
|
license:
|
||||||
|
name: Apache 2.0
|
||||||
|
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
tags:
|
||||||
|
- name: pet
|
||||||
|
description: Pet resource
|
||||||
|
- name: store
|
||||||
|
description: Store resource
|
||||||
|
- name: user
|
||||||
|
description: User resource
|
||||||
|
paths:
|
||||||
|
/pets:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Add a new pet to the store
|
||||||
|
description: ""
|
||||||
|
operationId: addPet
|
||||||
|
requestBody:
|
||||||
|
$ref: "#/components/requestBodies/Pet"
|
||||||
|
responses:
|
||||||
|
"405":
|
||||||
|
description: Invalid input
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write_pets
|
||||||
|
- read_pets
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Update an existing pet
|
||||||
|
description: ""
|
||||||
|
operationId: updatePet
|
||||||
|
requestBody:
|
||||||
|
$ref: "#/components/requestBodies/Pet"
|
||||||
|
responses:
|
||||||
|
"400":
|
||||||
|
$ref: "#/components/responses/InvalidId"
|
||||||
|
"404":
|
||||||
|
description: Pet not found
|
||||||
|
"405":
|
||||||
|
description: Validation exception
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write_pets
|
||||||
|
- read_pets
|
||||||
|
/pets/findByStatus:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Finds Pets by status
|
||||||
|
description: Multiple status values can be provided with comma seperated strings
|
||||||
|
operationId: findPetsByStatus
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: status
|
||||||
|
description: Status values that need to be considered for filter
|
||||||
|
required: false
|
||||||
|
explode: true
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: successful operation
|
||||||
|
headers:
|
||||||
|
X-Rate-Limit-Limit:
|
||||||
|
description: The number of allowed requests in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
X-Rate-Limit-Remaining:
|
||||||
|
description: The number of remaining requests in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
X-Rate-Limit-Reset:
|
||||||
|
description: The number of seconds left in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/Pet"
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/Pet"
|
||||||
|
"400":
|
||||||
|
description: Invalid status value
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write_pets
|
||||||
|
- read_pets
|
||||||
|
/pets/findByTags:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Finds Pets by tags
|
||||||
|
description: Muliple tags can be provided with comma seperated strings. Use tag1,
|
||||||
|
tag2, tag3 for testing.
|
||||||
|
operationId: findPetsByTags
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: tags
|
||||||
|
description: Tags to filter by
|
||||||
|
required: false
|
||||||
|
example: adorable
|
||||||
|
explode: true
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: successful operation
|
||||||
|
headers:
|
||||||
|
X-Rate-Limit-Limit:
|
||||||
|
description: The number of allowed requests in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
X-Rate-Limit-Remaining:
|
||||||
|
description: The number of remaining requests in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
X-Rate-Limit-Reset:
|
||||||
|
description: The number of seconds left in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/Pet"
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/Pet"
|
||||||
|
"400":
|
||||||
|
description: Invalid tag value
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write_pets
|
||||||
|
- read_pets
|
||||||
|
"/pets/{petId}":
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Find pet by ID
|
||||||
|
description: Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API
|
||||||
|
error conditions
|
||||||
|
operationId: getPetById
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: petId
|
||||||
|
description: ID of pet that needs to be fetched
|
||||||
|
required: true
|
||||||
|
example: 30
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: successful operation
|
||||||
|
headers:
|
||||||
|
X-Rate-Limit-Limit:
|
||||||
|
description: The number of allowed requests in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
X-Rate-Limit-Remaining:
|
||||||
|
description: The number of remaining requests in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
X-Rate-Limit-Reset:
|
||||||
|
description: The number of seconds left in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Pet"
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Pet"
|
||||||
|
"400":
|
||||||
|
$ref: "#/components/responses/InvalidId"
|
||||||
|
"404":
|
||||||
|
description: Pet not found
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
- petstore_auth:
|
||||||
|
- write_pets
|
||||||
|
- read_pets
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Updates a pet in the store with form data
|
||||||
|
description: ""
|
||||||
|
operationId: updatePetWithForm
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: petId
|
||||||
|
description: ID of pet that needs to be updated
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/x-www-form-urlencoded:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
description: Updated name of the pet
|
||||||
|
type: string
|
||||||
|
status:
|
||||||
|
description: Updated status of the pet
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
- status
|
||||||
|
responses:
|
||||||
|
"405":
|
||||||
|
description: Invalid input
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write_pets
|
||||||
|
- read_pets
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Deletes a pet
|
||||||
|
description: ""
|
||||||
|
operationId: deletePet
|
||||||
|
parameters:
|
||||||
|
- in: header
|
||||||
|
name: api_key
|
||||||
|
description: ""
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- in: path
|
||||||
|
name: petId
|
||||||
|
description: Pet id to delete
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
responses:
|
||||||
|
"400":
|
||||||
|
description: Invalid pet value
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- write_pets
|
||||||
|
- read_pets
|
||||||
|
/stores/order:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
summary: Place an order for a pet
|
||||||
|
description: ""
|
||||||
|
operationId: placeOrder
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Order"
|
||||||
|
description: order placed for purchasing the pet
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: successful operation
|
||||||
|
headers:
|
||||||
|
X-Rate-Limit-Limit:
|
||||||
|
description: The number of allowed requests in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
X-Rate-Limit-Remaining:
|
||||||
|
description: The number of remaining requests in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
X-Rate-Limit-Reset:
|
||||||
|
description: The number of seconds left in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Order"
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Order"
|
||||||
|
"400":
|
||||||
|
description: Invalid Order
|
||||||
|
"/stores/order/{orderId}":
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
summary: Find purchase order by ID
|
||||||
|
description: For valid response try integer IDs with value <= 5 or > 10. Other values
|
||||||
|
will generated exceptions
|
||||||
|
operationId: getOrderById
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: orderId
|
||||||
|
description: ID of pet that needs to be fetched
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: successful operation
|
||||||
|
headers:
|
||||||
|
X-Rate-Limit-Limit:
|
||||||
|
description: The number of allowed requests in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
X-Rate-Limit-Remaining:
|
||||||
|
description: The number of remaining requests in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
X-Rate-Limit-Reset:
|
||||||
|
description: The number of seconds left in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Order"
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Order"
|
||||||
|
"400":
|
||||||
|
$ref: "#/components/responses/InvalidId"
|
||||||
|
"404":
|
||||||
|
description: Order not found
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
summary: Delete purchase order by ID
|
||||||
|
description: For valid response try integer IDs with value < 1000. Anything above
|
||||||
|
1000 or nonintegers will generate API errors
|
||||||
|
operationId: deleteOrder
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: orderId
|
||||||
|
description: ID of the order that needs to be deleted
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"400":
|
||||||
|
$ref: "#/components/responses/InvalidId"
|
||||||
|
"404":
|
||||||
|
description: Order not found
|
||||||
|
/users:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Create user
|
||||||
|
description: This can only be done by the logged in user.
|
||||||
|
operationId: createUser
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/User"
|
||||||
|
description: Created user object
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
/users/createWithArray:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Creates list of users with given input array
|
||||||
|
description: ""
|
||||||
|
operationId: createUsersWithArrayInput
|
||||||
|
requestBody:
|
||||||
|
$ref: "#/components/requestBodies/UserArray"
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
/users/createWithList:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Creates list of users with given input array
|
||||||
|
description: ""
|
||||||
|
operationId: createUsersWithListInput
|
||||||
|
requestBody:
|
||||||
|
$ref: "#/components/requestBodies/UserArray"
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
/users/login:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Logs user into the system
|
||||||
|
description: ""
|
||||||
|
operationId: loginUser
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: username
|
||||||
|
description: The user name for login
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- in: query
|
||||||
|
name: password
|
||||||
|
description: The password for login in clear text
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: successful operation
|
||||||
|
headers:
|
||||||
|
X-Rate-Limit-Limit:
|
||||||
|
description: The number of allowed requests in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
X-Rate-Limit-Remaining:
|
||||||
|
description: The number of remaining requests in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
X-Rate-Limit-Reset:
|
||||||
|
description: The number of seconds left in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
"400":
|
||||||
|
description: Invalid username/password supplied
|
||||||
|
/users/logout:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Logs out current logged in user session
|
||||||
|
description: ""
|
||||||
|
operationId: logoutUser
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
"/users/{username}":
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Get user by user name
|
||||||
|
description: ""
|
||||||
|
operationId: getUserByName
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: username
|
||||||
|
description: The name that needs to be fetched. Use user1 for testing.
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: successful operation
|
||||||
|
headers:
|
||||||
|
X-Rate-Limit-Limit:
|
||||||
|
description: The number of allowed requests in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
X-Rate-Limit-Remaining:
|
||||||
|
description: The number of remaining requests in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
X-Rate-Limit-Reset:
|
||||||
|
description: The number of seconds left in the current period
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/User"
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/User"
|
||||||
|
"400":
|
||||||
|
description: Invalid username supplied
|
||||||
|
"404":
|
||||||
|
description: User not found
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Updated user
|
||||||
|
description: This can only be done by the logged in user.
|
||||||
|
operationId: updateUser
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: username
|
||||||
|
description: name that need to be deleted
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/User"
|
||||||
|
description: Updated user object
|
||||||
|
responses:
|
||||||
|
"400":
|
||||||
|
description: Invalid user supplied
|
||||||
|
"404":
|
||||||
|
description: User not found
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Delete user
|
||||||
|
description: This can only be done by the logged in user.
|
||||||
|
operationId: deleteUser
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: username
|
||||||
|
description: The name that needs to be deleted
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
"400":
|
||||||
|
description: Invalid username supplied
|
||||||
|
"404":
|
||||||
|
description: User not found
|
||||||
|
externalDocs:
|
||||||
|
description: Find out more about Swagger
|
||||||
|
url: http://swagger.io
|
||||||
|
servers:
|
||||||
|
- url: http://petstore.swagger.io/v2
|
||||||
|
components:
|
||||||
|
responses:
|
||||||
|
InvalidId:
|
||||||
|
description: Invalid ID supplied
|
||||||
|
requestBodies:
|
||||||
|
UserArray:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/User"
|
||||||
|
description: List of user object
|
||||||
|
Pet:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Pet"
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/Pet"
|
||||||
|
description: Pet object that needs to be added to the store
|
||||||
|
securitySchemes:
|
||||||
|
api_key:
|
||||||
|
type: apiKey
|
||||||
|
name: api_key
|
||||||
|
in: header
|
||||||
|
description: This is another description
|
||||||
|
petstore_auth:
|
||||||
|
type: oauth2
|
||||||
|
description: This is a standard oauth flow
|
||||||
|
flows:
|
||||||
|
implicit:
|
||||||
|
authorizationUrl: http://petstore.swagger.io/api/oauth/dialog
|
||||||
|
scopes:
|
||||||
|
write_pets: modify pets in your account
|
||||||
|
read_pets: read your pets
|
||||||
|
schemas:
|
||||||
|
User:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
username:
|
||||||
|
type: string
|
||||||
|
firstName:
|
||||||
|
type: string
|
||||||
|
lastName:
|
||||||
|
type: string
|
||||||
|
email:
|
||||||
|
type: string
|
||||||
|
password:
|
||||||
|
type: string
|
||||||
|
phone:
|
||||||
|
type: string
|
||||||
|
userStatus:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
description: User Status
|
||||||
|
Category:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
description: The name of the category
|
||||||
|
minLength: 0
|
||||||
|
maxLength: 255
|
||||||
|
pattern: "[A-Za-zäöüÄÖÜß]{0,255}"
|
||||||
|
default: DefaultCategory
|
||||||
|
example: FoobarCategory
|
||||||
|
Pet:
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
- photoUrls
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
category:
|
||||||
|
$ref: "#/components/schemas/Category"
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
example: doggie
|
||||||
|
photoUrls:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
tags:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/Tag"
|
||||||
|
status:
|
||||||
|
type: string
|
||||||
|
description: pet status in the store,
|
||||||
|
enum:
|
||||||
|
- Dead
|
||||||
|
- Alive
|
||||||
|
Tag:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
Order:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
petId:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
quantity:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
minimum: 0
|
||||||
|
maximum: 10000
|
||||||
|
default: 0
|
||||||
|
example: 10
|
||||||
|
shipDate:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
|
status:
|
||||||
|
type: string
|
||||||
|
description: Order Status
|
||||||
|
enum:
|
||||||
|
- Ordered
|
||||||
|
- Cancelled
|
||||||
|
complete:
|
||||||
|
type: boolean
|
||||||
119
publishing.gradle
Normal file
119
publishing.gradle
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
import java.text.SimpleDateFormat
|
||||||
|
|
||||||
|
Date buildTimeAndDate = new Date()
|
||||||
|
ext {
|
||||||
|
buildDate = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate)
|
||||||
|
buildTime = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate)
|
||||||
|
licenseUrl = 'https://github.com/Swagger2Markup/swagger2markup/blob/master/LICENSE.txt'
|
||||||
|
scmUrl = 'https://github.com/Swagger2Markup/swagger2markup.git'
|
||||||
|
}
|
||||||
|
|
||||||
|
def projectArtifactId = 'swagger2markup'
|
||||||
|
def projectUrl = 'https://github.com/Swagger2Markup/swagger2markup'
|
||||||
|
def licenseUrl = 'https://github.com/Swagger2Markup/swagger2markup/blob/master/LICENSE.txt'
|
||||||
|
def scmUrl = 'https://github.com/Swagger2Markup/swagger2markup.git'
|
||||||
|
def issuesUrl = 'https://github.com/Swagger2Markup/swagger2markup/issues'
|
||||||
|
|
||||||
|
jar {
|
||||||
|
manifest {
|
||||||
|
attributes(
|
||||||
|
'Built-By': 'Robert Winkler',
|
||||||
|
'Created-By': System.properties['java.version'] + " (" + System.properties['java.vendor'] + " " + System.properties['java.vm.version'] + ")",
|
||||||
|
'Build-Date': project.buildDate,
|
||||||
|
'Build-Time': project.buildTime,
|
||||||
|
'Specification-Title': projectArtifactId,
|
||||||
|
'Specification-Version': project.version,
|
||||||
|
'Implementation-Title': projectArtifactId,
|
||||||
|
'Implementation-Version': project.version
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task sourcesJar(type: Jar) {
|
||||||
|
from sourceSets.main.allJava
|
||||||
|
archiveClassifier = 'sources'
|
||||||
|
}
|
||||||
|
|
||||||
|
task javadocJar(type: Jar) {
|
||||||
|
from javadoc
|
||||||
|
archiveClassifier = 'javadoc'
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
archives sourcesJar
|
||||||
|
archives javadocJar
|
||||||
|
}
|
||||||
|
|
||||||
|
bintray {
|
||||||
|
user = project.hasProperty('bintrayUsername') ? project.property('bintrayUsername') : ''
|
||||||
|
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : ''
|
||||||
|
dryRun = false //Whether to run this as dry-run, without deploying
|
||||||
|
publish = true //If version should be auto published after an upload
|
||||||
|
publications = ['mavenJava']
|
||||||
|
pkg {
|
||||||
|
repo = 'Maven'
|
||||||
|
name = "${projectArtifactId}"
|
||||||
|
userOrg = "${projectArtifactId}"
|
||||||
|
websiteUrl = "${projectUrl}"
|
||||||
|
issueTrackerUrl = issuesUrl
|
||||||
|
vcsUrl = scmUrl
|
||||||
|
desc = project.description
|
||||||
|
licenses = ['Apache-2.0']
|
||||||
|
version {
|
||||||
|
name = project.version
|
||||||
|
vcsTag = "v${project.version}"
|
||||||
|
gpg {
|
||||||
|
sign = true //Determines whether to GPG sign the files. The default is false
|
||||||
|
//Optional. The passphrase for GPG signing'
|
||||||
|
passphrase = project.hasProperty('gpgPassphrase') ? project.property('gpgPassphrase') : ''
|
||||||
|
}
|
||||||
|
mavenCentralSync {
|
||||||
|
sync = true //Optional (true by default). Determines whether to sync the version to Maven Central.
|
||||||
|
user = project.hasProperty('ossUser') ? project.property('ossUser') : '' //OSS user token
|
||||||
|
password = project.hasProperty('ossPassword') ? project.property('ossPassword') : '' //OSS user password
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
mavenJava(MavenPublication) {
|
||||||
|
from components.java
|
||||||
|
pom.withXml {
|
||||||
|
def devs = ['RobWin': 'Robert Winkler',
|
||||||
|
'austek': 'Ali Ustek']
|
||||||
|
def root = asNode()
|
||||||
|
|
||||||
|
root.dependencies.'*'.findAll() {
|
||||||
|
it.scope.text() == 'runtime' && project.configurations.compile.allDependencies.find { dep ->
|
||||||
|
dep.name == it.artifactId.text()
|
||||||
|
}
|
||||||
|
}.each() {
|
||||||
|
it.scope*.value = 'compile'
|
||||||
|
}
|
||||||
|
|
||||||
|
root.appendNode('name', projectArtifactId)
|
||||||
|
root.appendNode('packaging', 'jar')
|
||||||
|
root.appendNode('url', projectUrl)
|
||||||
|
root.appendNode('description', project.description)
|
||||||
|
|
||||||
|
def license = root.appendNode('licenses').appendNode('license')
|
||||||
|
license.appendNode('name', 'Apache-2.0')
|
||||||
|
license.appendNode('url', licenseUrl)
|
||||||
|
license.appendNode('distribution', 'repo')
|
||||||
|
|
||||||
|
root.appendNode('scm').appendNode('url', scmUrl)
|
||||||
|
|
||||||
|
def developers = root.appendNode('developers')
|
||||||
|
devs.each {
|
||||||
|
def d = developers.appendNode('developer')
|
||||||
|
d.appendNode('id', it.key)
|
||||||
|
d.appendNode('name', it.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
artifact sourcesJar
|
||||||
|
artifact javadocJar
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1 +1,10 @@
|
|||||||
rootProject.name = 'swagger2markup'
|
rootProject.name = 'swagger2markup'
|
||||||
|
|
||||||
|
include 'swagger2markup-asciidoc'
|
||||||
|
include 'swagger2markup-bom'
|
||||||
|
include 'swagger2markup-builder'
|
||||||
|
include 'swagger2markup-documentation'
|
||||||
|
include 'swagger2markup'
|
||||||
|
include 'swagger2markup-core'
|
||||||
|
include 'openapi2markup'
|
||||||
|
|
||||||
|
|||||||
@@ -1,211 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Robert Winkler
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package io.github.swagger2markup;
|
|
||||||
|
|
||||||
import io.github.swagger2markup.markup.builder.LineSeparator;
|
|
||||||
import io.github.swagger2markup.markup.builder.MarkupLanguage;
|
|
||||||
import io.github.swagger2markup.model.PathOperation;
|
|
||||||
import io.swagger.models.parameters.Parameter;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Swagger2Markup configuration interface.
|
|
||||||
*/
|
|
||||||
public interface Swagger2MarkupConfig {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies the markup language which should be used to generate the files.
|
|
||||||
*/
|
|
||||||
MarkupLanguage getMarkupLanguage();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies the markup language used in Swagger descriptions.<br>
|
|
||||||
* By default, {@link io.github.swagger2markup.markup.builder.MarkupLanguage#MARKDOWN} is assumed.
|
|
||||||
*/
|
|
||||||
MarkupLanguage getSwaggerMarkupLanguage();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Include generated examples into the documents.
|
|
||||||
*/
|
|
||||||
boolean isGeneratedExamplesEnabled();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* In addition to the Definitions file, also create separate definition files for each model definition.
|
|
||||||
*/
|
|
||||||
boolean isSeparatedDefinitionsEnabled();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* In addition to the Paths file, also create separate operation files for each operation.
|
|
||||||
*/
|
|
||||||
boolean isSeparatedOperationsEnabled();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies if the operations should be grouped by tags or stay as-is.
|
|
||||||
*/
|
|
||||||
GroupBy getPathsGroupedBy();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies labels language of output files.
|
|
||||||
*/
|
|
||||||
Language getOutputLanguage();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies if inline schemas are detailed
|
|
||||||
*/
|
|
||||||
boolean isInlineSchemaEnabled();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies tag ordering.
|
|
||||||
*/
|
|
||||||
OrderBy getTagOrderBy();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies a custom comparator function to order tags.
|
|
||||||
*/
|
|
||||||
Comparator<String> getTagOrdering();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies operation ordering.
|
|
||||||
*/
|
|
||||||
OrderBy getOperationOrderBy();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies a custom comparator function to order operations.
|
|
||||||
*/
|
|
||||||
Comparator<PathOperation> getOperationOrdering();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies definition ordering.
|
|
||||||
*/
|
|
||||||
OrderBy getDefinitionOrderBy();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies a custom comparator function to order definitions.
|
|
||||||
*/
|
|
||||||
Comparator<String> getDefinitionOrdering();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies parameter ordering.
|
|
||||||
*/
|
|
||||||
OrderBy getParameterOrderBy();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies a custom comparator function to order parameters.
|
|
||||||
*/
|
|
||||||
Comparator<Parameter> getParameterOrdering();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies property ordering.
|
|
||||||
*/
|
|
||||||
OrderBy getPropertyOrderBy();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies a custom comparator function to order properties.
|
|
||||||
*/
|
|
||||||
Comparator<String> getPropertyOrdering();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies response ordering.
|
|
||||||
*/
|
|
||||||
OrderBy getResponseOrderBy();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies a custom comparator function to order responses.
|
|
||||||
*/
|
|
||||||
Comparator<String> getResponseOrdering();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable use of inter-document cross-references when needed.
|
|
||||||
*/
|
|
||||||
boolean isInterDocumentCrossReferencesEnabled();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inter-document cross-references optional prefix.
|
|
||||||
*/
|
|
||||||
String getInterDocumentCrossReferencesPrefix();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optionally isolate the body parameter, if any, from other parameters.
|
|
||||||
*/
|
|
||||||
boolean isFlatBodyEnabled();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optionally disable the security section for path sections
|
|
||||||
*/
|
|
||||||
boolean isPathSecuritySectionEnabled();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optionally prefix all anchors for uniqueness.
|
|
||||||
*/
|
|
||||||
String getAnchorPrefix();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Overview document name (without extension).
|
|
||||||
*
|
|
||||||
* @return the overview document name (without extension)
|
|
||||||
*/
|
|
||||||
String getOverviewDocument();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Paths document name (without extension).
|
|
||||||
*
|
|
||||||
* @return the paths document name (without extension)
|
|
||||||
*/
|
|
||||||
String getPathsDocument();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Definitions document name (without extension).
|
|
||||||
*
|
|
||||||
* @return the definitions document name (without extension)
|
|
||||||
*/
|
|
||||||
String getDefinitionsDocument();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Security document name (without extension).
|
|
||||||
*
|
|
||||||
* @return the security document name (without extension)
|
|
||||||
*/
|
|
||||||
String getSecurityDocument();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Separated operations sub-folder name.
|
|
||||||
*
|
|
||||||
* @return the operations sub-folder name
|
|
||||||
*/
|
|
||||||
String getSeparatedOperationsFolder();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Separated definitions sub-folder name.
|
|
||||||
*
|
|
||||||
* @return the definitions sub-folder name
|
|
||||||
*/
|
|
||||||
String getSeparatedDefinitionsFolder();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies the line separator which should be used.
|
|
||||||
*
|
|
||||||
* @return the line separator
|
|
||||||
*/
|
|
||||||
LineSeparator getLineSeparator();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns properties for extensions.
|
|
||||||
*
|
|
||||||
* @return the extension properties
|
|
||||||
*/
|
|
||||||
Swagger2MarkupProperties getExtensionsProperties();
|
|
||||||
}
|
|
||||||
@@ -1,707 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Robert Winkler
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package io.github.swagger2markup.builder;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.collect.Ordering;
|
|
||||||
import io.github.swagger2markup.*;
|
|
||||||
import io.github.swagger2markup.markup.builder.LineSeparator;
|
|
||||||
import io.github.swagger2markup.markup.builder.MarkupLanguage;
|
|
||||||
import io.github.swagger2markup.model.PathOperation;
|
|
||||||
import io.swagger.models.HttpMethod;
|
|
||||||
import io.swagger.models.parameters.Parameter;
|
|
||||||
import org.apache.commons.configuration2.*;
|
|
||||||
import org.apache.commons.configuration2.builder.fluent.Configurations;
|
|
||||||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.commons.lang3.Validate;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import static io.github.swagger2markup.Swagger2MarkupProperties.*;
|
|
||||||
|
|
||||||
public class Swagger2MarkupConfigBuilder {
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(Swagger2MarkupConfigBuilder.class);
|
|
||||||
|
|
||||||
private static final String PROPERTIES_DEFAULT = "io/github/swagger2markup/config/default.properties";
|
|
||||||
|
|
||||||
static final Ordering<PathOperation> OPERATION_METHOD_NATURAL_ORDERING = Ordering
|
|
||||||
.explicit(HttpMethod.POST, HttpMethod.GET, HttpMethod.PUT, HttpMethod.DELETE, HttpMethod.PATCH, HttpMethod.HEAD, HttpMethod.OPTIONS)
|
|
||||||
.onResultOf(new Function<PathOperation, HttpMethod>() {
|
|
||||||
public HttpMethod apply(PathOperation operation) {
|
|
||||||
return operation.getMethod();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
static final Ordering<PathOperation> OPERATION_PATH_NATURAL_ORDERING = Ordering
|
|
||||||
.natural()
|
|
||||||
.onResultOf(new Function<PathOperation, String>() {
|
|
||||||
public String apply(PathOperation operation) {
|
|
||||||
return operation.getPath();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
static final Ordering<Parameter> PARAMETER_IN_NATURAL_ORDERING = Ordering
|
|
||||||
.explicit("header", "path", "query", "formData", "body")
|
|
||||||
.onResultOf(new Function<Parameter, String>() {
|
|
||||||
public String apply(Parameter parameter) {
|
|
||||||
return parameter.getIn();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
static final Ordering<Parameter> PARAMETER_NAME_NATURAL_ORDERING = Ordering
|
|
||||||
.natural()
|
|
||||||
.onResultOf(new Function<Parameter, String>() {
|
|
||||||
public String apply(Parameter parameter) {
|
|
||||||
return parameter.getName();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
DefaultSwagger2MarkupConfig config = new DefaultSwagger2MarkupConfig();
|
|
||||||
|
|
||||||
public Swagger2MarkupConfigBuilder() {
|
|
||||||
this(new PropertiesConfiguration());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Swagger2MarkupConfigBuilder(Properties properties) {
|
|
||||||
this(ConfigurationConverter.getConfiguration(properties));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Swagger2MarkupConfigBuilder(Map<String, String> map) {
|
|
||||||
this(new MapConfiguration(map));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Swagger2MarkupConfigBuilder(Configuration configuration) {
|
|
||||||
CompositeConfiguration compositeConfiguration = new CompositeConfiguration();
|
|
||||||
compositeConfiguration.addConfiguration(new SystemConfiguration());
|
|
||||||
compositeConfiguration.addConfiguration(configuration);
|
|
||||||
compositeConfiguration.addConfiguration(getDefaultConfiguration());
|
|
||||||
|
|
||||||
Swagger2MarkupProperties swagger2MarkupProperties = new Swagger2MarkupProperties(compositeConfiguration);
|
|
||||||
|
|
||||||
config.markupLanguage = swagger2MarkupProperties.getRequiredMarkupLanguage(MARKUP_LANGUAGE);
|
|
||||||
config.swaggerMarkupLanguage = swagger2MarkupProperties.getRequiredMarkupLanguage(SWAGGER_MARKUP_LANGUAGE);
|
|
||||||
config.generatedExamplesEnabled = swagger2MarkupProperties.getRequiredBoolean(GENERATED_EXAMPLES_ENABLED);
|
|
||||||
config.separatedDefinitionsEnabled = swagger2MarkupProperties.getRequiredBoolean(SEPARATED_DEFINITIONS_ENABLED);
|
|
||||||
config.separatedOperationsEnabled = swagger2MarkupProperties.getRequiredBoolean(SEPARATED_OPERATIONS_ENABLED);
|
|
||||||
config.pathsGroupedBy = swagger2MarkupProperties.getGroupBy(PATHS_GROUPED_BY);
|
|
||||||
config.outputLanguage = swagger2MarkupProperties.getLanguage(OUTPUT_LANGUAGE);
|
|
||||||
config.inlineSchemaEnabled = swagger2MarkupProperties.getRequiredBoolean(INLINE_SCHEMA_ENABLED);
|
|
||||||
config.interDocumentCrossReferencesEnabled = swagger2MarkupProperties.getRequiredBoolean(INTER_DOCUMENT_CROSS_REFERENCES_ENABLED);
|
|
||||||
config.interDocumentCrossReferencesPrefix = swagger2MarkupProperties.getString(INTER_DOCUMENT_CROSS_REFERENCES_PREFIX, null);
|
|
||||||
config.flatBodyEnabled = swagger2MarkupProperties.getRequiredBoolean(FLAT_BODY_ENABLED);
|
|
||||||
config.pathSecuritySectionEnabled = swagger2MarkupProperties.getRequiredBoolean(PATH_SECURITY_SECTION_ENABLED);
|
|
||||||
config.anchorPrefix = swagger2MarkupProperties.getString(ANCHOR_PREFIX, null);
|
|
||||||
config.overviewDocument = swagger2MarkupProperties.getRequiredString(OVERVIEW_DOCUMENT);
|
|
||||||
config.pathsDocument = swagger2MarkupProperties.getRequiredString(PATHS_DOCUMENT);
|
|
||||||
config.definitionsDocument = swagger2MarkupProperties.getRequiredString(DEFINITIONS_DOCUMENT);
|
|
||||||
config.securityDocument = swagger2MarkupProperties.getRequiredString(SECURITY_DOCUMENT);
|
|
||||||
config.separatedOperationsFolder = swagger2MarkupProperties.getRequiredString(SEPARATED_OPERATIONS_FOLDER);
|
|
||||||
config.separatedDefinitionsFolder = swagger2MarkupProperties.getRequiredString(SEPARATED_DEFINITIONS_FOLDER);
|
|
||||||
config.tagOrderBy = swagger2MarkupProperties.getOrderBy(TAG_ORDER_BY);
|
|
||||||
config.operationOrderBy = swagger2MarkupProperties.getOrderBy(OPERATION_ORDER_BY);
|
|
||||||
config.definitionOrderBy = swagger2MarkupProperties.getOrderBy(DEFINITION_ORDER_BY);
|
|
||||||
config.parameterOrderBy = swagger2MarkupProperties.getOrderBy(PARAMETER_ORDER_BY);
|
|
||||||
config.propertyOrderBy = swagger2MarkupProperties.getOrderBy(PROPERTY_ORDER_BY);
|
|
||||||
config.responseOrderBy = swagger2MarkupProperties.getOrderBy(RESPONSE_ORDER_BY);
|
|
||||||
Optional<String> lineSeparator = swagger2MarkupProperties.getString(LINE_SEPARATOR);
|
|
||||||
if(lineSeparator.isPresent() && StringUtils.isNoneBlank(lineSeparator.get())){
|
|
||||||
config.lineSeparator = LineSeparator.valueOf(lineSeparator.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
Configuration swagger2markupConfiguration = compositeConfiguration.subset(PROPERTIES_PREFIX);
|
|
||||||
Configuration extensionsConfiguration = swagger2markupConfiguration.subset(EXTENSION_PREFIX);
|
|
||||||
config.extensionsProperties = new Swagger2MarkupProperties(extensionsConfiguration);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the default properties from the classpath.
|
|
||||||
*
|
|
||||||
* @return the default properties
|
|
||||||
*/
|
|
||||||
private Configuration getDefaultConfiguration() {
|
|
||||||
Configurations configs = new Configurations();
|
|
||||||
try {
|
|
||||||
return configs.properties(PROPERTIES_DEFAULT);
|
|
||||||
} catch (ConfigurationException e) {
|
|
||||||
throw new RuntimeException(String.format("Can't load default properties '%s'", PROPERTIES_DEFAULT), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the Swagger2MarkupConfig.
|
|
||||||
*
|
|
||||||
* @return the Swagger2MarkupConfig
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfig build() {
|
|
||||||
buildNaturalOrdering();
|
|
||||||
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildNaturalOrdering() {
|
|
||||||
if (config.tagOrderBy == OrderBy.NATURAL)
|
|
||||||
config.tagOrdering = Ordering.natural();
|
|
||||||
if (config.operationOrderBy == OrderBy.NATURAL)
|
|
||||||
config.operationOrdering = OPERATION_PATH_NATURAL_ORDERING.compound(OPERATION_METHOD_NATURAL_ORDERING);
|
|
||||||
if (config.definitionOrderBy == OrderBy.NATURAL)
|
|
||||||
config.definitionOrdering = Ordering.natural();
|
|
||||||
if (config.parameterOrderBy == OrderBy.NATURAL)
|
|
||||||
config.parameterOrdering = PARAMETER_IN_NATURAL_ORDERING.compound(PARAMETER_NAME_NATURAL_ORDERING);
|
|
||||||
if (config.propertyOrderBy == OrderBy.NATURAL)
|
|
||||||
config.propertyOrdering = Ordering.natural();
|
|
||||||
if (config.responseOrderBy == OrderBy.NATURAL)
|
|
||||||
config.responseOrdering = Ordering.natural();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies the markup language which should be used to generate the files.
|
|
||||||
*
|
|
||||||
* @param markupLanguage the markup language which is used to generate the files
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withMarkupLanguage(MarkupLanguage markupLanguage) {
|
|
||||||
Validate.notNull(markupLanguage, "%s must not be null", "markupLanguage");
|
|
||||||
config.markupLanguage = markupLanguage;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies the markup language used in Swagger descriptions.
|
|
||||||
*
|
|
||||||
* @param swaggerMarkupLanguage the markup language used in Swagger descriptions
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withSwaggerMarkupLanguage(MarkupLanguage swaggerMarkupLanguage) {
|
|
||||||
Validate.notNull(swaggerMarkupLanguage, "%s must not be null", "swaggerMarkupLanguage");
|
|
||||||
config.swaggerMarkupLanguage = swaggerMarkupLanguage;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Include generated examples into the documents.
|
|
||||||
*
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withGeneratedExamples() {
|
|
||||||
config.generatedExamplesEnabled = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* In addition to the Definitions file, also create separate definition files for each model definition.
|
|
||||||
*
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withSeparatedDefinitions() {
|
|
||||||
config.separatedDefinitionsEnabled = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* In addition to the Paths file, also create separate operation files for each operation.
|
|
||||||
*
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withSeparatedOperations() {
|
|
||||||
config.separatedOperationsEnabled = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies if the paths should be grouped by tags or stay as-is.
|
|
||||||
*
|
|
||||||
* @param pathsGroupedBy the GroupBy enum
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withPathsGroupedBy(GroupBy pathsGroupedBy) {
|
|
||||||
Validate.notNull(pathsGroupedBy, "%s must not be null", "pathsGroupedBy");
|
|
||||||
config.pathsGroupedBy = pathsGroupedBy;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies labels language of output files.
|
|
||||||
*
|
|
||||||
* @param language the enum
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withOutputLanguage(Language language) {
|
|
||||||
Validate.notNull(language, "%s must not be null", "language");
|
|
||||||
config.outputLanguage = language;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable inline schema support.
|
|
||||||
*
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withoutInlineSchema() {
|
|
||||||
config.inlineSchemaEnabled = false;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies tag ordering.<br>
|
|
||||||
* By default tag ordering == {@link io.github.swagger2markup.OrderBy#NATURAL}.<br>
|
|
||||||
* Use {@link #withTagOrdering(Comparator)} to set a custom ordering.
|
|
||||||
*
|
|
||||||
* @param orderBy tag ordering
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withTagOrdering(OrderBy orderBy) {
|
|
||||||
Validate.notNull(orderBy, "%s must not be null", "orderBy");
|
|
||||||
Validate.isTrue(orderBy != OrderBy.CUSTOM, "You must provide a custom comparator if orderBy == OrderBy.CUSTOM");
|
|
||||||
config.tagOrderBy = orderBy;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies a custom comparator function to order tags.
|
|
||||||
*
|
|
||||||
* @param tagOrdering tag ordering
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withTagOrdering(Comparator<String> tagOrdering) {
|
|
||||||
Validate.notNull(tagOrdering, "%s must not be null", "tagOrdering");
|
|
||||||
config.tagOrderBy = OrderBy.CUSTOM;
|
|
||||||
config.tagOrdering = tagOrdering;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies operation ordering.<br>
|
|
||||||
* By default operation ordering == {@link io.github.swagger2markup.OrderBy#AS_IS}.<br>
|
|
||||||
* Use {@link #withOperationOrdering(Comparator)} to set a custom ordering.
|
|
||||||
*
|
|
||||||
* @param orderBy operation ordering
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withOperationOrdering(OrderBy orderBy) {
|
|
||||||
Validate.notNull(orderBy, "%s must not be null", "orderBy");
|
|
||||||
Validate.isTrue(orderBy != OrderBy.CUSTOM, "You must provide a custom comparator if orderBy == OrderBy.CUSTOM");
|
|
||||||
config.operationOrderBy = orderBy;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies a custom comparator function to order operations.
|
|
||||||
*
|
|
||||||
* @param operationOrdering operation ordering
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withOperationOrdering(Comparator<PathOperation> operationOrdering) {
|
|
||||||
Validate.notNull(operationOrdering, "%s must not be null", "operationOrdering");
|
|
||||||
config.operationOrderBy = OrderBy.CUSTOM;
|
|
||||||
config.operationOrdering = operationOrdering;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies definition ordering.<br>
|
|
||||||
* By default definition ordering == {@link io.github.swagger2markup.OrderBy#NATURAL}.<br>
|
|
||||||
* Use {@link #withDefinitionOrdering(Comparator)} to set a custom ordering.
|
|
||||||
*
|
|
||||||
* @param orderBy definition ordering
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withDefinitionOrdering(OrderBy orderBy) {
|
|
||||||
Validate.notNull(orderBy, "%s must not be null", "orderBy");
|
|
||||||
Validate.isTrue(orderBy != OrderBy.CUSTOM, "You must provide a custom comparator if orderBy == OrderBy.CUSTOM");
|
|
||||||
config.definitionOrderBy = orderBy;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies a custom comparator function to order definitions.
|
|
||||||
*
|
|
||||||
* @param definitionOrdering definition ordering
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withDefinitionOrdering(Comparator<String> definitionOrdering) {
|
|
||||||
Validate.notNull(definitionOrdering, "%s must not be null", "definitionOrdering");
|
|
||||||
config.definitionOrderBy = OrderBy.CUSTOM;
|
|
||||||
config.definitionOrdering = definitionOrdering;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies parameter ordering.<br>
|
|
||||||
* By default parameter ordering == {@link OrderBy#NATURAL}.<br>
|
|
||||||
* Use {@link #withParameterOrdering(Comparator)} to set a custom ordering.
|
|
||||||
*
|
|
||||||
* @param orderBy parameter ordering
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withParameterOrdering(OrderBy orderBy) {
|
|
||||||
Validate.notNull(orderBy, "%s must not be null", "orderBy");
|
|
||||||
Validate.isTrue(orderBy != OrderBy.CUSTOM, "You must provide a custom comparator if orderBy == OrderBy.CUSTOM");
|
|
||||||
config.parameterOrderBy = orderBy;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies a custom comparator function to order parameters.
|
|
||||||
*
|
|
||||||
* @param parameterOrdering parameter ordering
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withParameterOrdering(Comparator<Parameter> parameterOrdering) {
|
|
||||||
Validate.notNull(parameterOrdering, "%s must not be null", "parameterOrdering");
|
|
||||||
|
|
||||||
config.parameterOrderBy = OrderBy.CUSTOM;
|
|
||||||
config.parameterOrdering = parameterOrdering;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies property ordering.<br>
|
|
||||||
* By default property ordering == {@link io.github.swagger2markup.OrderBy#NATURAL}.<br>
|
|
||||||
* Use {@link #withPropertyOrdering(Comparator)} to set a custom ordering.
|
|
||||||
*
|
|
||||||
* @param orderBy property ordering
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withPropertyOrdering(OrderBy orderBy) {
|
|
||||||
Validate.notNull(orderBy, "%s must not be null", "orderBy");
|
|
||||||
Validate.isTrue(orderBy != OrderBy.CUSTOM, "You must provide a custom comparator if orderBy == OrderBy.CUSTOM");
|
|
||||||
config.propertyOrderBy = orderBy;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies a custom comparator function to order properties.
|
|
||||||
*
|
|
||||||
* @param propertyOrdering property ordering
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withPropertyOrdering(Comparator<String> propertyOrdering) {
|
|
||||||
Validate.notNull(propertyOrdering, "%s must not be null", "propertyOrdering");
|
|
||||||
|
|
||||||
config.propertyOrderBy = OrderBy.CUSTOM;
|
|
||||||
config.propertyOrdering = propertyOrdering;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies response ordering.<br>
|
|
||||||
* By default response ordering == {@link io.github.swagger2markup.OrderBy#NATURAL}.<br>
|
|
||||||
* Use {@link #withResponseOrdering(Comparator)} to set a custom ordering.
|
|
||||||
*
|
|
||||||
* @param orderBy response ordering
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withResponseOrdering(OrderBy orderBy) {
|
|
||||||
Validate.notNull(orderBy, "%s must not be null", "orderBy");
|
|
||||||
Validate.isTrue(orderBy != OrderBy.CUSTOM, "You must provide a custom comparator if orderBy == OrderBy.CUSTOM");
|
|
||||||
config.responseOrderBy = orderBy;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies a custom comparator function to order responses.
|
|
||||||
*
|
|
||||||
* @param responseOrdering response ordering
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withResponseOrdering(Comparator<String> responseOrdering) {
|
|
||||||
Validate.notNull(responseOrdering, "%s must not be null", "responseOrdering");
|
|
||||||
|
|
||||||
config.responseOrderBy = OrderBy.CUSTOM;
|
|
||||||
config.responseOrdering = responseOrdering;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable use of inter-document cross-references when needed.
|
|
||||||
*
|
|
||||||
* @param prefix Prefix to document in all inter-document cross-references.
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withInterDocumentCrossReferences(String prefix) {
|
|
||||||
Validate.notNull(prefix, "%s must not be null", "prefix");
|
|
||||||
config.interDocumentCrossReferencesEnabled = true;
|
|
||||||
config.interDocumentCrossReferencesPrefix = prefix;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable use of inter-document cross-references when needed.
|
|
||||||
*
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withInterDocumentCrossReferences() {
|
|
||||||
config.interDocumentCrossReferencesEnabled = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optionally isolate the body parameter, if any, from other parameters.
|
|
||||||
*
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withFlatBody() {
|
|
||||||
config.flatBodyEnabled = true;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optionally disable the security section for path sections
|
|
||||||
*
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withoutPathSecuritySection() {
|
|
||||||
config.pathSecuritySectionEnabled = false;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optionally prefix all anchors for uniqueness.
|
|
||||||
*
|
|
||||||
* @param anchorPrefix anchor prefix.
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withAnchorPrefix(String anchorPrefix) {
|
|
||||||
Validate.notNull(anchorPrefix, "%s must no be null", "anchorPrefix");
|
|
||||||
config.anchorPrefix = anchorPrefix;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies the line separator which should be used.
|
|
||||||
*
|
|
||||||
* @param lineSeparator the lineSeparator
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public Swagger2MarkupConfigBuilder withLineSeparator(LineSeparator lineSeparator) {
|
|
||||||
Validate.notNull(lineSeparator, "%s must no be null", "lineSeparator");
|
|
||||||
config.lineSeparator = lineSeparator;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
static class DefaultSwagger2MarkupConfig implements Swagger2MarkupConfig{
|
|
||||||
|
|
||||||
private MarkupLanguage markupLanguage;
|
|
||||||
private MarkupLanguage swaggerMarkupLanguage;
|
|
||||||
private boolean generatedExamplesEnabled;
|
|
||||||
private boolean separatedDefinitionsEnabled;
|
|
||||||
private boolean separatedOperationsEnabled;
|
|
||||||
private GroupBy pathsGroupedBy;
|
|
||||||
private Language outputLanguage;
|
|
||||||
private boolean inlineSchemaEnabled;
|
|
||||||
private OrderBy tagOrderBy;
|
|
||||||
private Comparator<String> tagOrdering;
|
|
||||||
private OrderBy operationOrderBy;
|
|
||||||
private Comparator<PathOperation> operationOrdering;
|
|
||||||
private OrderBy definitionOrderBy;
|
|
||||||
private Comparator<String> definitionOrdering;
|
|
||||||
private OrderBy parameterOrderBy;
|
|
||||||
private Comparator<Parameter> parameterOrdering;
|
|
||||||
private OrderBy propertyOrderBy;
|
|
||||||
private Comparator<String> propertyOrdering;
|
|
||||||
private OrderBy responseOrderBy;
|
|
||||||
private Comparator<String> responseOrdering;
|
|
||||||
private boolean interDocumentCrossReferencesEnabled;
|
|
||||||
private String interDocumentCrossReferencesPrefix;
|
|
||||||
private boolean flatBodyEnabled;
|
|
||||||
private boolean pathSecuritySectionEnabled;
|
|
||||||
private String anchorPrefix;
|
|
||||||
private LineSeparator lineSeparator;
|
|
||||||
|
|
||||||
private String overviewDocument;
|
|
||||||
private String pathsDocument;
|
|
||||||
private String definitionsDocument;
|
|
||||||
private String securityDocument;
|
|
||||||
private String separatedOperationsFolder;
|
|
||||||
private String separatedDefinitionsFolder;
|
|
||||||
|
|
||||||
private Swagger2MarkupProperties extensionsProperties;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MarkupLanguage getMarkupLanguage() {
|
|
||||||
return markupLanguage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MarkupLanguage getSwaggerMarkupLanguage() {
|
|
||||||
return swaggerMarkupLanguage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isGeneratedExamplesEnabled() {
|
|
||||||
return generatedExamplesEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSeparatedDefinitionsEnabled() {
|
|
||||||
return separatedDefinitionsEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSeparatedOperationsEnabled() {
|
|
||||||
return separatedOperationsEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GroupBy getPathsGroupedBy() {
|
|
||||||
return pathsGroupedBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Language getOutputLanguage() {
|
|
||||||
return outputLanguage;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInlineSchemaEnabled() {
|
|
||||||
return inlineSchemaEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OrderBy getTagOrderBy() {
|
|
||||||
return tagOrderBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Comparator<String> getTagOrdering() {
|
|
||||||
return tagOrdering;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OrderBy getOperationOrderBy() {
|
|
||||||
return operationOrderBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Comparator<PathOperation> getOperationOrdering() {
|
|
||||||
return operationOrdering;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OrderBy getDefinitionOrderBy() {
|
|
||||||
return definitionOrderBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Comparator<String> getDefinitionOrdering() {
|
|
||||||
return definitionOrdering;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OrderBy getParameterOrderBy() {
|
|
||||||
return parameterOrderBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Comparator<Parameter> getParameterOrdering() {
|
|
||||||
return parameterOrdering;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OrderBy getPropertyOrderBy() {
|
|
||||||
return propertyOrderBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Comparator<String> getPropertyOrdering() {
|
|
||||||
return propertyOrdering;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public OrderBy getResponseOrderBy() {
|
|
||||||
return responseOrderBy;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Comparator<String> getResponseOrdering() {
|
|
||||||
return responseOrdering;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInterDocumentCrossReferencesEnabled() {
|
|
||||||
return interDocumentCrossReferencesEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInterDocumentCrossReferencesPrefix() {
|
|
||||||
return interDocumentCrossReferencesPrefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isFlatBodyEnabled() {
|
|
||||||
return flatBodyEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPathSecuritySectionEnabled() {
|
|
||||||
return pathSecuritySectionEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getAnchorPrefix() {
|
|
||||||
return anchorPrefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getOverviewDocument() {
|
|
||||||
return overviewDocument;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPathsDocument() {
|
|
||||||
return pathsDocument;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDefinitionsDocument() {
|
|
||||||
return definitionsDocument;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSecurityDocument() {
|
|
||||||
return securityDocument;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSeparatedOperationsFolder() {
|
|
||||||
return separatedOperationsFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSeparatedDefinitionsFolder() {
|
|
||||||
return separatedDefinitionsFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LineSeparator getLineSeparator() {
|
|
||||||
return lineSeparator;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Swagger2MarkupProperties getExtensionsProperties() {
|
|
||||||
return extensionsProperties;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Robert Winkler
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package io.github.swagger2markup.internal.document;
|
|
||||||
|
|
||||||
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
|
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.nio.file.OpenOption;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
|
|
||||||
public class MarkupDocument {
|
|
||||||
|
|
||||||
private MarkupDocBuilder markupDocBuilder;
|
|
||||||
|
|
||||||
public MarkupDocument(MarkupDocBuilder markupDocBuilder) {
|
|
||||||
this.markupDocBuilder = markupDocBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a string representation of the document.
|
|
||||||
*/
|
|
||||||
public String toString() {
|
|
||||||
return markupDocBuilder.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes the content of the builder to a file.<br>
|
|
||||||
* An extension identifying the markup language will be automatically added to file name.
|
|
||||||
*
|
|
||||||
* @param file the generated file
|
|
||||||
* @param charset the the charset to use for encoding
|
|
||||||
* @param options the file open options
|
|
||||||
*/
|
|
||||||
public void writeToFile(Path file, Charset charset, OpenOption... options) {
|
|
||||||
markupDocBuilder.writeToFile(file, charset, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes the content of the builder to a file.
|
|
||||||
*
|
|
||||||
* @param file the generated file
|
|
||||||
* @param charset the the charset to use for encoding
|
|
||||||
* @param options the file open options
|
|
||||||
*/
|
|
||||||
public void writeToFileWithoutExtension(Path file, Charset charset, OpenOption... options) {
|
|
||||||
markupDocBuilder.writeToFileWithoutExtension(file, charset, options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,336 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Robert Winkler
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package io.github.swagger2markup.internal.document.builder;
|
|
||||||
|
|
||||||
import io.github.swagger2markup.Swagger2MarkupConverter;
|
|
||||||
import io.github.swagger2markup.Swagger2MarkupExtensionRegistry;
|
|
||||||
import io.github.swagger2markup.internal.document.MarkupDocument;
|
|
||||||
import io.github.swagger2markup.internal.type.ObjectType;
|
|
||||||
import io.github.swagger2markup.internal.type.ObjectTypePolymorphism;
|
|
||||||
import io.github.swagger2markup.internal.type.Type;
|
|
||||||
import io.github.swagger2markup.internal.utils.ModelUtils;
|
|
||||||
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
|
|
||||||
import io.github.swagger2markup.spi.DefinitionsDocumentExtension;
|
|
||||||
import io.swagger.models.Model;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.apache.commons.collections4.MapUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.commons.lang3.Validate;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static io.github.swagger2markup.internal.utils.MapUtils.toKeySet;
|
|
||||||
import static io.github.swagger2markup.spi.DefinitionsDocumentExtension.Context;
|
|
||||||
import static io.github.swagger2markup.spi.DefinitionsDocumentExtension.Position;
|
|
||||||
import static io.github.swagger2markup.utils.IOUtils.normalizeName;
|
|
||||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robert Winkler
|
|
||||||
*/
|
|
||||||
public class DefinitionsDocumentBuilder extends MarkupDocumentBuilder {
|
|
||||||
|
|
||||||
/* Discriminator is only displayed for inheriting definitions */
|
|
||||||
private static final boolean ALWAYS_DISPLAY_DISCRIMINATOR = false;
|
|
||||||
|
|
||||||
private static final String DEFINITIONS_ANCHOR = "definitions";
|
|
||||||
private final String DEFINITIONS;
|
|
||||||
private final String DISCRIMINATOR_COLUMN;
|
|
||||||
private final String POLYMORPHISM_COLUMN;
|
|
||||||
private final Map<ObjectTypePolymorphism.Nature, String> POLYMORPHISM_NATURE;
|
|
||||||
private final String TYPE_COLUMN;
|
|
||||||
private static final List<String> IGNORED_DEFINITIONS = Collections.singletonList("Void");
|
|
||||||
|
|
||||||
public DefinitionsDocumentBuilder(Swagger2MarkupConverter.Context context, Swagger2MarkupExtensionRegistry extensionRegistry, Path outputPath) {
|
|
||||||
super(context, extensionRegistry, outputPath);
|
|
||||||
|
|
||||||
final ResourceBundle labels = ResourceBundle.getBundle("io/github/swagger2markup/lang/labels", config.getOutputLanguage().toLocale());
|
|
||||||
DEFINITIONS = labels.getString("definitions");
|
|
||||||
POLYMORPHISM_COLUMN = labels.getString("polymorphism.column");
|
|
||||||
DISCRIMINATOR_COLUMN = labels.getString("polymorphism.discriminator");
|
|
||||||
POLYMORPHISM_NATURE = new HashMap<ObjectTypePolymorphism.Nature, String>() {{
|
|
||||||
put(ObjectTypePolymorphism.Nature.COMPOSITION, labels.getString("polymorphism.nature.COMPOSITION"));
|
|
||||||
put(ObjectTypePolymorphism.Nature.INHERITANCE, labels.getString("polymorphism.nature.INHERITANCE"));
|
|
||||||
}};
|
|
||||||
TYPE_COLUMN = labels.getString("type_column");
|
|
||||||
|
|
||||||
if (config.isSeparatedDefinitionsEnabled()) {
|
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug("Create separated definition files is enabled.");
|
|
||||||
}
|
|
||||||
Validate.notNull(outputPath, "Output directory is required for separated definition files!");
|
|
||||||
} else {
|
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug("Create separated definition files is disabled.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the definitions MarkupDocument.
|
|
||||||
*
|
|
||||||
* @return the definitions MarkupDocument
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public MarkupDocument build() {
|
|
||||||
if (MapUtils.isNotEmpty(globalContext.getSwagger().getDefinitions())) {
|
|
||||||
applyDefinitionsDocumentExtension(new Context(Position.DOCUMENT_BEFORE, this.markupDocBuilder));
|
|
||||||
buildDefinitionsTitle(DEFINITIONS);
|
|
||||||
applyDefinitionsDocumentExtension(new Context(Position.DOCUMENT_BEGIN, this.markupDocBuilder));
|
|
||||||
buildDefinitionsSection();
|
|
||||||
applyDefinitionsDocumentExtension(new Context(Position.DOCUMENT_END, this.markupDocBuilder));
|
|
||||||
applyDefinitionsDocumentExtension(new Context(Position.DOCUMENT_AFTER, this.markupDocBuilder));
|
|
||||||
}
|
|
||||||
return new MarkupDocument(markupDocBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildDefinitionsSection() {
|
|
||||||
Set<String> definitionNames = toKeySet(globalContext.getSwagger().getDefinitions(), config.getDefinitionOrdering());
|
|
||||||
for (String definitionName : definitionNames) {
|
|
||||||
Model model = globalContext.getSwagger().getDefinitions().get(definitionName);
|
|
||||||
if (isNotBlank(definitionName)) {
|
|
||||||
if (checkThatDefinitionIsNotInIgnoreList(definitionName)) {
|
|
||||||
buildDefinition(definitionName, model);
|
|
||||||
if (logger.isInfoEnabled()) {
|
|
||||||
logger.info("Definition processed : '{}'", definitionName);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug("Definition was ignored : '{}'", definitionName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildDefinitionsTitle(String title) {
|
|
||||||
this.markupDocBuilder.sectionTitleWithAnchorLevel1(title, DEFINITIONS_ANCHOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Apply extension context to all DefinitionsContentExtension
|
|
||||||
*
|
|
||||||
* @param context context
|
|
||||||
*/
|
|
||||||
private void applyDefinitionsDocumentExtension(Context context) {
|
|
||||||
for (DefinitionsDocumentExtension extension : extensionRegistry.getDefinitionsDocumentExtensions()) {
|
|
||||||
extension.apply(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the definition filename depending on the generation mode
|
|
||||||
*
|
|
||||||
* @param definitionName definition name
|
|
||||||
* @return definition filename
|
|
||||||
*/
|
|
||||||
private String resolveDefinitionDocument(String definitionName) {
|
|
||||||
if (config.isSeparatedDefinitionsEnabled())
|
|
||||||
return new File(config.getSeparatedDefinitionsFolder(), markupDocBuilder.addFileExtension(normalizeName(definitionName))).getPath();
|
|
||||||
else
|
|
||||||
return markupDocBuilder.addFileExtension(config.getDefinitionsDocument());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate definition files depending on the generation mode
|
|
||||||
*
|
|
||||||
* @param definitionName definition name to process
|
|
||||||
* @param model definition model to process
|
|
||||||
*/
|
|
||||||
private void buildDefinition(String definitionName, Model model) {
|
|
||||||
|
|
||||||
if (config.isSeparatedDefinitionsEnabled()) {
|
|
||||||
MarkupDocBuilder defDocBuilder = copyMarkupDocBuilder();
|
|
||||||
buildDefinition(definitionName, model, defDocBuilder);
|
|
||||||
Path definitionFile = outputPath.resolve(resolveDefinitionDocument(definitionName));
|
|
||||||
defDocBuilder.writeToFileWithoutExtension(definitionFile, StandardCharsets.UTF_8);
|
|
||||||
if (logger.isInfoEnabled()) {
|
|
||||||
logger.info("Separate definition file produced : '{}'", definitionFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
definitionRef(definitionName, this.markupDocBuilder);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
buildDefinition(definitionName, model, this.markupDocBuilder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks that the definition is not in the list of ignored definitions.
|
|
||||||
*
|
|
||||||
* @param definitionName the name of the definition
|
|
||||||
* @return true if the definition can be processed
|
|
||||||
*/
|
|
||||||
private boolean checkThatDefinitionIsNotInIgnoreList(String definitionName) {
|
|
||||||
return !IGNORED_DEFINITIONS.contains(definitionName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds a concrete definition
|
|
||||||
*
|
|
||||||
* @param definitionName the name of the definition
|
|
||||||
* @param model the Swagger Model of the definition
|
|
||||||
* @param docBuilder the docbuilder do use for output
|
|
||||||
*/
|
|
||||||
private void buildDefinition(String definitionName, Model model, MarkupDocBuilder docBuilder) {
|
|
||||||
applyDefinitionsDocumentExtension(new Context(Position.DEFINITION_BEFORE, docBuilder, definitionName, model));
|
|
||||||
buildDefinitionTitle(definitionName, definitionName, docBuilder);
|
|
||||||
applyDefinitionsDocumentExtension(new Context(Position.DEFINITION_BEGIN, docBuilder, definitionName, model));
|
|
||||||
buildDescriptionParagraph(model, docBuilder);
|
|
||||||
inlineDefinitions(typeSection(definitionName, model, docBuilder), definitionName, docBuilder);
|
|
||||||
applyDefinitionsDocumentExtension(new Context(Position.DEFINITION_END, docBuilder, definitionName, model));
|
|
||||||
applyDefinitionsDocumentExtension(new Context(Position.DEFINITION_AFTER, docBuilder, definitionName, model));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds a cross-reference to a separated definition file.
|
|
||||||
*
|
|
||||||
* @param definitionName definition name to target
|
|
||||||
* @param docBuilder the docbuilder do use for output
|
|
||||||
*/
|
|
||||||
private void definitionRef(String definitionName, MarkupDocBuilder docBuilder) {
|
|
||||||
buildDefinitionTitle(copyMarkupDocBuilder().crossReference(new DefinitionDocumentResolverDefault().apply(definitionName), definitionName, definitionName).toString(), "ref-" + definitionName, docBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds definition title
|
|
||||||
*
|
|
||||||
* @param title definition title
|
|
||||||
* @param anchor optional anchor (null => auto-generate from title)
|
|
||||||
* @param docBuilder the docbuilder do use for output
|
|
||||||
*/
|
|
||||||
private void buildDefinitionTitle(String title, String anchor, MarkupDocBuilder docBuilder) {
|
|
||||||
docBuilder.sectionTitleWithAnchorLevel2(title, anchor);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the type informations of a definition
|
|
||||||
*
|
|
||||||
* @param definitionName name of the definition to display
|
|
||||||
* @param model model of the definition to display
|
|
||||||
* @param docBuilder the docbuilder do use for output
|
|
||||||
* @return a list of inlined types.
|
|
||||||
*/
|
|
||||||
private List<ObjectType> typeSection(String definitionName, Model model, MarkupDocBuilder docBuilder) {
|
|
||||||
List<ObjectType> inlineDefinitions = new ArrayList<>();
|
|
||||||
Type modelType = ModelUtils.resolveRefType(ModelUtils.getType(model, globalContext.getSwagger().getDefinitions(), new DefinitionDocumentResolverFromDefinition()));
|
|
||||||
|
|
||||||
if (!(modelType instanceof ObjectType)) {
|
|
||||||
modelType = createInlineType(modelType, definitionName, definitionName + " " + "inline", inlineDefinitions);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modelType instanceof ObjectType) {
|
|
||||||
ObjectType objectType = (ObjectType) modelType;
|
|
||||||
MarkupDocBuilder typeInfos = copyMarkupDocBuilder();
|
|
||||||
switch (objectType.getPolymorphism().getNature()) {
|
|
||||||
case COMPOSITION:
|
|
||||||
typeInfos.italicText(POLYMORPHISM_COLUMN).textLine(COLON + POLYMORPHISM_NATURE.get(objectType.getPolymorphism().getNature()));
|
|
||||||
break;
|
|
||||||
case INHERITANCE:
|
|
||||||
typeInfos.italicText(POLYMORPHISM_COLUMN).textLine(COLON + POLYMORPHISM_NATURE.get(objectType.getPolymorphism().getNature()));
|
|
||||||
typeInfos.italicText(DISCRIMINATOR_COLUMN).textLine(COLON + objectType.getPolymorphism().getDiscriminator());
|
|
||||||
break;
|
|
||||||
case NONE:
|
|
||||||
if (ALWAYS_DISPLAY_DISCRIMINATOR) {
|
|
||||||
if (StringUtils.isNotBlank(objectType.getPolymorphism().getDiscriminator()))
|
|
||||||
typeInfos.italicText(DISCRIMINATOR_COLUMN).textLine(COLON + objectType.getPolymorphism().getDiscriminator());
|
|
||||||
}
|
|
||||||
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
|
|
||||||
String typeInfosString = typeInfos.toString();
|
|
||||||
if (StringUtils.isNotBlank(typeInfosString))
|
|
||||||
docBuilder.paragraph(typeInfosString, true);
|
|
||||||
|
|
||||||
inlineDefinitions.addAll(buildPropertiesTable(((ObjectType) modelType).getProperties(), definitionName, new DefinitionDocumentResolverFromDefinition(), docBuilder));
|
|
||||||
} else if (modelType != null) {
|
|
||||||
MarkupDocBuilder typeInfos = copyMarkupDocBuilder();
|
|
||||||
typeInfos.italicText(TYPE_COLUMN).textLine(COLON + modelType.displaySchema(docBuilder));
|
|
||||||
|
|
||||||
docBuilder.paragraph(typeInfos.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return inlineDefinitions;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildDescriptionParagraph(Model model, MarkupDocBuilder docBuilder) {
|
|
||||||
modelDescription(model, docBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void modelDescription(Model model, MarkupDocBuilder docBuilder) {
|
|
||||||
String description = model.getDescription();
|
|
||||||
if (isNotBlank(description)) {
|
|
||||||
buildDescriptionParagraph(description, docBuilder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the title of an inline schema.
|
|
||||||
* Inline definitions should never been referenced in TOC because they have no real existence, so they are just text.
|
|
||||||
*
|
|
||||||
* @param title inline schema title
|
|
||||||
* @param anchor inline schema anchor
|
|
||||||
* @param docBuilder the docbuilder do use for output
|
|
||||||
*/
|
|
||||||
private void addInlineDefinitionTitle(String title, String anchor, MarkupDocBuilder docBuilder) {
|
|
||||||
docBuilder.anchor(anchor, null);
|
|
||||||
docBuilder.newLine();
|
|
||||||
docBuilder.boldTextLine(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds inline schema definitions
|
|
||||||
*
|
|
||||||
* @param definitions all inline definitions to display
|
|
||||||
* @param uniquePrefix unique prefix to prepend to inline object names to enforce unicity
|
|
||||||
* @param docBuilder the docbuilder do use for output
|
|
||||||
*/
|
|
||||||
private void inlineDefinitions(List<ObjectType> definitions, String uniquePrefix, MarkupDocBuilder docBuilder) {
|
|
||||||
if (CollectionUtils.isNotEmpty(definitions)) {
|
|
||||||
for (ObjectType definition : definitions) {
|
|
||||||
addInlineDefinitionTitle(definition.getName(), definition.getUniqueName(), docBuilder);
|
|
||||||
List<ObjectType> localDefinitions = buildPropertiesTable(definition.getProperties(), uniquePrefix, new DefinitionDocumentResolverFromDefinition(), docBuilder);
|
|
||||||
for (ObjectType localDefinition : localDefinitions)
|
|
||||||
inlineDefinitions(Collections.singletonList(localDefinition), localDefinition.getUniqueName(), docBuilder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Overrides definition document resolver functor for inter-document cross-references from definitions files.
|
|
||||||
* This implementation simplify the path between two definitions because all definitions are in the same path.
|
|
||||||
*/
|
|
||||||
class DefinitionDocumentResolverFromDefinition extends DefinitionDocumentResolverDefault {
|
|
||||||
|
|
||||||
public DefinitionDocumentResolverFromDefinition() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public String apply(String definitionName) {
|
|
||||||
String defaultResolver = super.apply(definitionName);
|
|
||||||
|
|
||||||
if (defaultResolver != null && config.isSeparatedDefinitionsEnabled())
|
|
||||||
return defaultString(config.getInterDocumentCrossReferencesPrefix()) + markupDocBuilder.addFileExtension(normalizeName(definitionName));
|
|
||||||
else
|
|
||||||
return defaultResolver;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,357 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Robert Winkler
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package io.github.swagger2markup.internal.document.builder;
|
|
||||||
|
|
||||||
import io.github.swagger2markup.Swagger2MarkupConfig;
|
|
||||||
import io.github.swagger2markup.Swagger2MarkupConverter;
|
|
||||||
import io.github.swagger2markup.Swagger2MarkupExtensionRegistry;
|
|
||||||
import io.github.swagger2markup.internal.document.MarkupDocument;
|
|
||||||
import io.github.swagger2markup.internal.type.*;
|
|
||||||
import io.github.swagger2markup.internal.utils.PropertyUtils;
|
|
||||||
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
|
|
||||||
import io.github.swagger2markup.markup.builder.MarkupDocBuilders;
|
|
||||||
import io.github.swagger2markup.markup.builder.MarkupLanguage;
|
|
||||||
import io.github.swagger2markup.markup.builder.MarkupTableColumn;
|
|
||||||
import io.github.swagger2markup.utils.IOUtils;
|
|
||||||
import io.swagger.models.properties.Property;
|
|
||||||
import io.swagger.util.Json;
|
|
||||||
import org.apache.commons.collections4.MapUtils;
|
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringReader;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static io.github.swagger2markup.internal.utils.MapUtils.toKeySet;
|
|
||||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robert Winkler
|
|
||||||
*/
|
|
||||||
public abstract class MarkupDocumentBuilder {
|
|
||||||
|
|
||||||
protected static final String COLON = " : ";
|
|
||||||
|
|
||||||
protected final String DEFAULT_COLUMN;
|
|
||||||
|
|
||||||
protected final String MAXLENGTH_COLUMN;
|
|
||||||
protected final String MINLENGTH_COLUMN;
|
|
||||||
protected final String LENGTH_COLUMN;
|
|
||||||
|
|
||||||
protected final String PATTERN_COLUMN;
|
|
||||||
protected final String MINVALUE_COLUMN;
|
|
||||||
protected final String MAXVALUE_COLUMN;
|
|
||||||
|
|
||||||
|
|
||||||
protected final String EXAMPLE_COLUMN;
|
|
||||||
protected final String SCHEMA_COLUMN;
|
|
||||||
protected final String NAME_COLUMN;
|
|
||||||
protected final String DESCRIPTION_COLUMN;
|
|
||||||
protected final String SCOPES_COLUMN;
|
|
||||||
protected final String DESCRIPTION;
|
|
||||||
protected final String PRODUCES;
|
|
||||||
protected final String CONSUMES;
|
|
||||||
protected final String TAGS;
|
|
||||||
protected final String NO_CONTENT;
|
|
||||||
protected final String FLAGS_COLUMN;
|
|
||||||
protected final String FLAGS_REQUIRED;
|
|
||||||
protected final String FLAGS_OPTIONAL;
|
|
||||||
protected final String FLAGS_READ_ONLY;
|
|
||||||
|
|
||||||
|
|
||||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
|
||||||
|
|
||||||
protected Swagger2MarkupConverter.Context globalContext;
|
|
||||||
protected Swagger2MarkupExtensionRegistry extensionRegistry;
|
|
||||||
protected Swagger2MarkupConfig config;
|
|
||||||
protected MarkupDocBuilder markupDocBuilder;
|
|
||||||
protected Path outputPath;
|
|
||||||
|
|
||||||
MarkupDocumentBuilder(Swagger2MarkupConverter.Context globalContext, Swagger2MarkupExtensionRegistry extensionRegistry, Path outputPath) {
|
|
||||||
this.globalContext = globalContext;
|
|
||||||
this.extensionRegistry = extensionRegistry;
|
|
||||||
this.config = globalContext.getConfig();
|
|
||||||
this.outputPath = outputPath;
|
|
||||||
|
|
||||||
this.markupDocBuilder = MarkupDocBuilders.documentBuilder(config.getMarkupLanguage(), config.getLineSeparator()).withAnchorPrefix(config.getAnchorPrefix());
|
|
||||||
|
|
||||||
ResourceBundle labels = ResourceBundle.getBundle("io/github/swagger2markup/lang/labels", config.getOutputLanguage().toLocale());
|
|
||||||
DEFAULT_COLUMN = labels.getString("default_column");
|
|
||||||
|
|
||||||
MINLENGTH_COLUMN = labels.getString("minlength_column");
|
|
||||||
MAXLENGTH_COLUMN = labels.getString("maxlength_column");
|
|
||||||
LENGTH_COLUMN = labels.getString("length_column");
|
|
||||||
|
|
||||||
PATTERN_COLUMN = labels.getString("pattern_column");
|
|
||||||
MINVALUE_COLUMN = labels.getString("minvalue_column");
|
|
||||||
MAXVALUE_COLUMN = labels.getString("maxvalue_column");
|
|
||||||
|
|
||||||
EXAMPLE_COLUMN = labels.getString("example_column");
|
|
||||||
FLAGS_COLUMN = labels.getString("flags.column");
|
|
||||||
FLAGS_REQUIRED = labels.getString("flags.required");
|
|
||||||
FLAGS_OPTIONAL = labels.getString("flags.optional");
|
|
||||||
FLAGS_READ_ONLY = labels.getString("flags.read_only");
|
|
||||||
SCHEMA_COLUMN = labels.getString("schema_column");
|
|
||||||
NAME_COLUMN = labels.getString("name_column");
|
|
||||||
DESCRIPTION_COLUMN = labels.getString("description_column");
|
|
||||||
SCOPES_COLUMN = labels.getString("scopes_column");
|
|
||||||
DESCRIPTION = DESCRIPTION_COLUMN;
|
|
||||||
PRODUCES = labels.getString("produces");
|
|
||||||
CONSUMES = labels.getString("consumes");
|
|
||||||
TAGS = labels.getString("tags");
|
|
||||||
NO_CONTENT = labels.getString("no_content");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the MarkupDocument.
|
|
||||||
*
|
|
||||||
* @return the built MarkupDocument
|
|
||||||
* @throws IOException if the files to include are not readable
|
|
||||||
*/
|
|
||||||
public abstract MarkupDocument build() throws IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a RefType to a new inlined type named with {@code name} and {@code uniqueName}.<br>
|
|
||||||
* The returned RefType point to the new inlined type which is added to the {@code inlineDefinitions} collection.<br>
|
|
||||||
* The function is recursive and support collections (ArrayType and MapType).<br>
|
|
||||||
* The function is transparent : {@code type} is returned as-is if type is not inlinable or if !config.isInlineSchemaEnabled().<br>
|
|
||||||
*
|
|
||||||
* @param type type to inline
|
|
||||||
* @param name name of the created inline ObjectType
|
|
||||||
* @param uniqueName unique name of the created inline ObjectType
|
|
||||||
* @param inlineDefinitions a non null collection of inline ObjectType
|
|
||||||
* @return the type referencing the newly created inline ObjectType. Can be a RefType, an ArrayType or a MapType
|
|
||||||
*/
|
|
||||||
protected Type createInlineType(Type type, String name, String uniqueName, List<ObjectType> inlineDefinitions) {
|
|
||||||
if (!config.isInlineSchemaEnabled())
|
|
||||||
return type;
|
|
||||||
|
|
||||||
if (type instanceof ObjectType) {
|
|
||||||
return createInlineObjectType(type, name, uniqueName, inlineDefinitions);
|
|
||||||
} else if (type instanceof ArrayType) {
|
|
||||||
ArrayType arrayType = (ArrayType)type;
|
|
||||||
arrayType.setOfType(createInlineType(arrayType.getOfType(), name, uniqueName, inlineDefinitions));
|
|
||||||
|
|
||||||
return arrayType;
|
|
||||||
} else if (type instanceof MapType) {
|
|
||||||
MapType mapType = (MapType)type;
|
|
||||||
if (mapType.getValueType() instanceof ObjectType)
|
|
||||||
mapType.setValueType(createInlineType(mapType.getValueType(), name, uniqueName, inlineDefinitions));
|
|
||||||
|
|
||||||
return mapType;
|
|
||||||
} else {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Type createInlineObjectType(Type type, String name, String uniqueName, List<ObjectType> inlineDefinitions) {
|
|
||||||
if (type instanceof ObjectType) {
|
|
||||||
ObjectType objectType = (ObjectType)type;
|
|
||||||
if (MapUtils.isNotEmpty(objectType.getProperties())) {
|
|
||||||
if (objectType.getName() == null) {
|
|
||||||
objectType.setName(name);
|
|
||||||
objectType.setUniqueName(uniqueName);
|
|
||||||
}
|
|
||||||
inlineDefinitions.add(objectType);
|
|
||||||
return new RefType(objectType);
|
|
||||||
} else
|
|
||||||
return type;
|
|
||||||
} else
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Build a generic property table
|
|
||||||
*
|
|
||||||
* @param properties properties to display
|
|
||||||
* @param uniquePrefix unique prefix to prepend to inline object names to enforce unicity
|
|
||||||
* @param definitionDocumentResolver definition document resolver to apply to property type cross-reference
|
|
||||||
* @param docBuilder the docbuilder do use for output
|
|
||||||
* @return a list of inline schemas referenced by some properties, for later display
|
|
||||||
*/
|
|
||||||
protected List<ObjectType> buildPropertiesTable(Map<String, Property> properties, String uniquePrefix, DefinitionDocumentResolver definitionDocumentResolver, MarkupDocBuilder docBuilder) {
|
|
||||||
List<ObjectType> inlineDefinitions = new ArrayList<>();
|
|
||||||
List<List<String>> cells = new ArrayList<>();
|
|
||||||
List<MarkupTableColumn> cols = Arrays.asList(
|
|
||||||
new MarkupTableColumn(NAME_COLUMN).withWidthRatio(3).withHeaderColumn(false).withMarkupSpecifiers(MarkupLanguage.ASCIIDOC, ".^3"),
|
|
||||||
new MarkupTableColumn(DESCRIPTION_COLUMN).withWidthRatio(11).withMarkupSpecifiers(MarkupLanguage.ASCIIDOC, ".^11"),
|
|
||||||
new MarkupTableColumn(SCHEMA_COLUMN).withWidthRatio(4).withMarkupSpecifiers(MarkupLanguage.ASCIIDOC, ".^4"));
|
|
||||||
if (MapUtils.isNotEmpty(properties)) {
|
|
||||||
Set<String> propertyNames = toKeySet(properties, config.getPropertyOrdering());
|
|
||||||
for (String propertyName : propertyNames) {
|
|
||||||
Property property = properties.get(propertyName);
|
|
||||||
Type propertyType = PropertyUtils.getType(property, definitionDocumentResolver);
|
|
||||||
|
|
||||||
propertyType = createInlineType(propertyType, propertyName, uniquePrefix + " " + propertyName, inlineDefinitions);
|
|
||||||
|
|
||||||
Object example = PropertyUtils.getExample(config.isGeneratedExamplesEnabled(), property, markupDocBuilder);
|
|
||||||
|
|
||||||
Object defaultValue = PropertyUtils.getDefaultValue(property);
|
|
||||||
|
|
||||||
Integer maxlength = PropertyUtils.getMaxlength(property);
|
|
||||||
Integer minlength = PropertyUtils.getMinlength(property);
|
|
||||||
String pattern = PropertyUtils.getPattern(property);
|
|
||||||
Double minValue = PropertyUtils.getMin(property);
|
|
||||||
Double maxValue = PropertyUtils.getMax(property);
|
|
||||||
|
|
||||||
MarkupDocBuilder propertyNameContent = copyMarkupDocBuilder();
|
|
||||||
propertyNameContent.boldTextLine(propertyName, true);
|
|
||||||
if (BooleanUtils.isTrue(property.getRequired()))
|
|
||||||
propertyNameContent.italicText(FLAGS_REQUIRED.toLowerCase());
|
|
||||||
else
|
|
||||||
propertyNameContent.italicText(FLAGS_OPTIONAL.toLowerCase());
|
|
||||||
if (BooleanUtils.isTrue(property.getReadOnly())) {
|
|
||||||
propertyNameContent.newLine(true);
|
|
||||||
propertyNameContent.italicText(FLAGS_READ_ONLY.toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
MarkupDocBuilder descriptionContent = copyMarkupDocBuilder();
|
|
||||||
String description = defaultString(swaggerMarkupDescription(property.getDescription()));
|
|
||||||
if (isNotBlank(description.toString()))
|
|
||||||
descriptionContent.text(description);
|
|
||||||
|
|
||||||
if(defaultValue != null){
|
|
||||||
if (isNotBlank(descriptionContent.toString()))
|
|
||||||
descriptionContent.newLine(true);
|
|
||||||
descriptionContent.boldText(DEFAULT_COLUMN).text(COLON).literalText(Json.pretty(defaultValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minlength != null && maxlength != null) {
|
|
||||||
// combination of minlength/maxlength
|
|
||||||
|
|
||||||
if (isNotBlank(descriptionContent.toString()))
|
|
||||||
descriptionContent.newLine(true);
|
|
||||||
|
|
||||||
String lengthRange = minlength + " - " + maxlength;
|
|
||||||
if (minlength.equals(maxlength)) {
|
|
||||||
lengthRange = minlength.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
descriptionContent.boldText(LENGTH_COLUMN).text(COLON).literalText(lengthRange);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if(minlength != null){
|
|
||||||
if (isNotBlank(descriptionContent.toString()))
|
|
||||||
descriptionContent.newLine(true);
|
|
||||||
descriptionContent.boldText(MINLENGTH_COLUMN).text(COLON).literalText(minlength.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(maxlength != null){
|
|
||||||
if (isNotBlank(descriptionContent.toString()))
|
|
||||||
descriptionContent.newLine(true);
|
|
||||||
descriptionContent.boldText(MAXLENGTH_COLUMN).text(COLON).literalText(maxlength.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(pattern != null){
|
|
||||||
if (isNotBlank(descriptionContent.toString()))
|
|
||||||
descriptionContent.newLine(true);
|
|
||||||
|
|
||||||
descriptionContent.boldText(PATTERN_COLUMN).text(COLON).literalText(Json.pretty(pattern));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(minValue != null){
|
|
||||||
if (isNotBlank(descriptionContent.toString()))
|
|
||||||
descriptionContent.newLine(true);
|
|
||||||
descriptionContent.boldText(MINVALUE_COLUMN).text(COLON).literalText(minValue.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(maxValue != null){
|
|
||||||
if (isNotBlank(descriptionContent.toString()))
|
|
||||||
descriptionContent.newLine(true);
|
|
||||||
descriptionContent.boldText(MAXVALUE_COLUMN).text(COLON).literalText(maxValue.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (example != null) {
|
|
||||||
if (isNotBlank(description) || defaultValue != null)
|
|
||||||
descriptionContent.newLine(true);
|
|
||||||
descriptionContent.boldText(EXAMPLE_COLUMN).text(COLON).literalText(Json.pretty(example));
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> content = Arrays.asList(
|
|
||||||
propertyNameContent.toString(),
|
|
||||||
descriptionContent.toString(),
|
|
||||||
propertyType.displaySchema(docBuilder)
|
|
||||||
);
|
|
||||||
cells.add(content);
|
|
||||||
}
|
|
||||||
docBuilder.tableWithColumnSpecs(cols, cells);
|
|
||||||
} else {
|
|
||||||
docBuilder.textLine(NO_CONTENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
return inlineDefinitions;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected MarkupDocBuilder copyMarkupDocBuilder() {
|
|
||||||
return markupDocBuilder.copy(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String boldText(String text) {
|
|
||||||
return copyMarkupDocBuilder().boldText(text).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String italicText(String text) {
|
|
||||||
return copyMarkupDocBuilder().italicText(text).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String literalText(String text) {
|
|
||||||
return copyMarkupDocBuilder().literalText(text).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns converted markup text from Swagger.
|
|
||||||
*
|
|
||||||
* @param markupText text to convert, or null
|
|
||||||
* @return converted markup text, or null if {@code markupText} == null
|
|
||||||
*/
|
|
||||||
protected String swaggerMarkupDescription(String markupText) {
|
|
||||||
if (markupText == null)
|
|
||||||
return null;
|
|
||||||
return copyMarkupDocBuilder().importMarkup(new StringReader(markupText), globalContext.getConfig().getSwaggerMarkupLanguage()).toString().trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void buildDescriptionParagraph(String description, MarkupDocBuilder docBuilder) {
|
|
||||||
if (isNotBlank(description)) {
|
|
||||||
docBuilder.paragraph(swaggerMarkupDescription(description));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default {@code DefinitionDocumentResolver} functor
|
|
||||||
*/
|
|
||||||
class DefinitionDocumentResolverDefault implements DefinitionDocumentResolver {
|
|
||||||
|
|
||||||
public DefinitionDocumentResolverDefault() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public String apply(String definitionName) {
|
|
||||||
if (!config.isInterDocumentCrossReferencesEnabled() || outputPath == null)
|
|
||||||
return null;
|
|
||||||
else if (config.isSeparatedDefinitionsEnabled())
|
|
||||||
return defaultString(config.getInterDocumentCrossReferencesPrefix()) + new File(config.getSeparatedDefinitionsFolder(), markupDocBuilder.addFileExtension(IOUtils.normalizeName(definitionName))).getPath();
|
|
||||||
else
|
|
||||||
return defaultString(config.getInterDocumentCrossReferencesPrefix()) + markupDocBuilder.addFileExtension(config.getDefinitionsDocument());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,224 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Robert Winkler
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package io.github.swagger2markup.internal.document.builder;
|
|
||||||
|
|
||||||
import io.github.swagger2markup.Swagger2MarkupConverter;
|
|
||||||
import io.github.swagger2markup.Swagger2MarkupExtensionRegistry;
|
|
||||||
import io.github.swagger2markup.internal.document.MarkupDocument;
|
|
||||||
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
|
|
||||||
import io.github.swagger2markup.spi.OverviewDocumentExtension;
|
|
||||||
import io.swagger.models.*;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
import static io.github.swagger2markup.spi.OverviewDocumentExtension.Context;
|
|
||||||
import static io.github.swagger2markup.spi.OverviewDocumentExtension.Position;
|
|
||||||
import static org.apache.commons.collections4.CollectionUtils.isNotEmpty;
|
|
||||||
import static org.apache.commons.lang3.StringUtils.*;
|
|
||||||
|
|
||||||
public class OverviewDocumentBuilder extends MarkupDocumentBuilder {
|
|
||||||
|
|
||||||
private static final String OVERVIEW_ANCHOR = "overview";
|
|
||||||
private final String OVERVIEW;
|
|
||||||
private final String CURRENT_VERSION;
|
|
||||||
private final String VERSION;
|
|
||||||
private final String CONTACT_INFORMATION;
|
|
||||||
private final String CONTACT_NAME;
|
|
||||||
private final String CONTACT_EMAIL;
|
|
||||||
private final String LICENSE_INFORMATION;
|
|
||||||
private final String LICENSE;
|
|
||||||
private final String LICENSE_URL;
|
|
||||||
private final String TERMS_OF_SERVICE;
|
|
||||||
private final String URI_SCHEME;
|
|
||||||
private final String HOST;
|
|
||||||
private final String BASE_PATH;
|
|
||||||
private final String SCHEMES;
|
|
||||||
|
|
||||||
public OverviewDocumentBuilder(Swagger2MarkupConverter.Context context, Swagger2MarkupExtensionRegistry extensionRegistry, Path outputPath){
|
|
||||||
super(context, extensionRegistry, outputPath);
|
|
||||||
|
|
||||||
ResourceBundle labels = ResourceBundle.getBundle("io/github/swagger2markup/lang/labels", config.getOutputLanguage().toLocale());
|
|
||||||
OVERVIEW = labels.getString("overview");
|
|
||||||
CURRENT_VERSION = labels.getString("current_version");
|
|
||||||
VERSION = labels.getString("version");
|
|
||||||
CONTACT_INFORMATION = labels.getString("contact_information");
|
|
||||||
CONTACT_NAME = labels.getString("contact_name");
|
|
||||||
CONTACT_EMAIL = labels.getString("contact_email");
|
|
||||||
LICENSE_INFORMATION = labels.getString("license_information");
|
|
||||||
LICENSE = labels.getString("license");
|
|
||||||
LICENSE_URL = labels.getString("license_url");
|
|
||||||
TERMS_OF_SERVICE = labels.getString("terms_of_service");
|
|
||||||
URI_SCHEME = labels.getString("uri_scheme");
|
|
||||||
HOST = labels.getString("host");
|
|
||||||
BASE_PATH = labels.getString("base_path");
|
|
||||||
SCHEMES = labels.getString("schemes");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the overview MarkupDocument.
|
|
||||||
*
|
|
||||||
* @return the overview MarkupDocument
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public MarkupDocument build(){
|
|
||||||
Swagger swagger = globalContext.getSwagger();
|
|
||||||
Info info = swagger.getInfo();
|
|
||||||
buildDocumentTitle(info.getTitle());
|
|
||||||
applyOverviewDocumentExtension(new Context(Position.DOCUMENT_BEFORE, this.markupDocBuilder));
|
|
||||||
buildOverviewTitle(OVERVIEW);
|
|
||||||
applyOverviewDocumentExtension(new Context(Position.DOCUMENT_BEGIN, this.markupDocBuilder));
|
|
||||||
buildDescriptionParagraph(info.getDescription(), this.markupDocBuilder);
|
|
||||||
buildVersionInfoSection(info.getVersion());
|
|
||||||
buildContactInfoSection(info.getContact());
|
|
||||||
buildLicenseInfoSection(info.getLicense(), info.getTermsOfService());
|
|
||||||
buildUriSchemeSection(swagger);
|
|
||||||
buildTagsSection(swagger.getTags());
|
|
||||||
buildConsumesSection(swagger.getConsumes());
|
|
||||||
buildProducesSection(swagger.getProduces());
|
|
||||||
applyOverviewDocumentExtension(new Context(Position.DOCUMENT_END, this.markupDocBuilder));
|
|
||||||
applyOverviewDocumentExtension(new Context(Position.DOCUMENT_AFTER, this.markupDocBuilder));
|
|
||||||
return new MarkupDocument(markupDocBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildDocumentTitle(String title) {
|
|
||||||
this.markupDocBuilder.documentTitle(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildOverviewTitle(String title) {
|
|
||||||
this.markupDocBuilder.sectionTitleWithAnchorLevel1(title, OVERVIEW_ANCHOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildVersionInfoSection(String version) {
|
|
||||||
if(isNotBlank(version)){
|
|
||||||
this.markupDocBuilder.sectionTitleLevel2(CURRENT_VERSION);
|
|
||||||
|
|
||||||
MarkupDocBuilder paragraph = copyMarkupDocBuilder();
|
|
||||||
paragraph.italicText(VERSION).textLine(COLON + version);
|
|
||||||
this.markupDocBuilder.paragraph(paragraph.toString(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildContactInfoSection(Contact contact) {
|
|
||||||
if(contact != null){
|
|
||||||
this.markupDocBuilder.sectionTitleLevel2(CONTACT_INFORMATION);
|
|
||||||
MarkupDocBuilder paragraph = copyMarkupDocBuilder();
|
|
||||||
if(isNotBlank(contact.getName())){
|
|
||||||
paragraph.italicText(CONTACT_NAME).textLine(COLON + contact.getName());
|
|
||||||
}
|
|
||||||
if(isNotBlank(contact.getEmail())){
|
|
||||||
paragraph.italicText(CONTACT_EMAIL).textLine(COLON + contact.getEmail());
|
|
||||||
}
|
|
||||||
this.markupDocBuilder.paragraph(paragraph.toString(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildLicenseInfoSection(License license, String termOfService) {
|
|
||||||
if (
|
|
||||||
(license != null && (isNotBlank(license.getName()) || isNotBlank(license.getUrl()))) ||
|
|
||||||
(isNotBlank(termOfService))
|
|
||||||
) {
|
|
||||||
this.markupDocBuilder.sectionTitleLevel2(LICENSE_INFORMATION);
|
|
||||||
MarkupDocBuilder paragraph = copyMarkupDocBuilder();
|
|
||||||
if (license != null && isNotBlank(license.getName())) {
|
|
||||||
paragraph.italicText(LICENSE).textLine(COLON + license.getName());
|
|
||||||
}
|
|
||||||
if (license != null && isNotBlank(license.getUrl())) {
|
|
||||||
paragraph.italicText(LICENSE_URL).textLine(COLON + license.getUrl());
|
|
||||||
}
|
|
||||||
if(isNotBlank(termOfService)){
|
|
||||||
paragraph.italicText(TERMS_OF_SERVICE).textLine(COLON + termOfService);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.markupDocBuilder.paragraph(paragraph.toString(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildUriSchemeSection(Swagger swagger) {
|
|
||||||
if(isNotBlank(swagger.getHost()) || isNotBlank(swagger.getBasePath()) || isNotEmpty(swagger.getSchemes())) {
|
|
||||||
this.markupDocBuilder.sectionTitleLevel2(URI_SCHEME);
|
|
||||||
MarkupDocBuilder paragraph = copyMarkupDocBuilder();
|
|
||||||
if (isNotBlank(swagger.getHost())) {
|
|
||||||
paragraph.italicText(HOST).textLine(COLON + swagger.getHost());
|
|
||||||
}
|
|
||||||
if (isNotBlank(swagger.getBasePath())) {
|
|
||||||
paragraph.italicText(BASE_PATH).textLine(COLON + swagger.getBasePath());
|
|
||||||
}
|
|
||||||
if (isNotEmpty(swagger.getSchemes())) {
|
|
||||||
List<String> schemes = new ArrayList<>();
|
|
||||||
for (Scheme scheme : swagger.getSchemes()) {
|
|
||||||
schemes.add(scheme.toString());
|
|
||||||
}
|
|
||||||
paragraph.italicText(SCHEMES).textLine(COLON + join(schemes, ", "));
|
|
||||||
}
|
|
||||||
this.markupDocBuilder.paragraph(paragraph.toString(), true);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildTagsSection(List<Tag> tags) {
|
|
||||||
if(isNotEmpty(tags)){
|
|
||||||
this.markupDocBuilder.sectionTitleLevel2(TAGS);
|
|
||||||
List<String> tagsList = new ArrayList<>();
|
|
||||||
for(Tag tag : tags){
|
|
||||||
String name = tag.getName();
|
|
||||||
String description = tag.getDescription();
|
|
||||||
if(isNoneBlank(description)){
|
|
||||||
tagsList.add(name + COLON + description);
|
|
||||||
}else{
|
|
||||||
tagsList.add(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.markupDocBuilder.unorderedList(tagsList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildConsumesSection(List<String> consumes) {
|
|
||||||
if (isNotEmpty(consumes)) {
|
|
||||||
this.markupDocBuilder.sectionTitleLevel2(CONSUMES);
|
|
||||||
this.markupDocBuilder.newLine();
|
|
||||||
for (String consume : consumes) {
|
|
||||||
this.markupDocBuilder.unorderedListItem(literalText(consume));
|
|
||||||
}
|
|
||||||
this.markupDocBuilder.newLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildProducesSection(List<String> produces) {
|
|
||||||
if (isNotEmpty(produces)) {
|
|
||||||
this.markupDocBuilder.sectionTitleLevel2(PRODUCES);
|
|
||||||
this.markupDocBuilder.newLine();
|
|
||||||
for (String produce : produces) {
|
|
||||||
this.markupDocBuilder.unorderedListItem(literalText(produce));
|
|
||||||
}
|
|
||||||
this.markupDocBuilder.newLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Apply extension context to all OverviewContentExtension
|
|
||||||
*
|
|
||||||
* @param context context
|
|
||||||
*/
|
|
||||||
private void applyOverviewDocumentExtension(Context context) {
|
|
||||||
for (OverviewDocumentExtension extension : extensionRegistry.getOverviewDocumentExtensions()) {
|
|
||||||
extension.apply(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,771 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Robert Winkler
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package io.github.swagger2markup.internal.document.builder;
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import com.google.common.collect.Multimap;
|
|
||||||
import io.github.swagger2markup.GroupBy;
|
|
||||||
import io.github.swagger2markup.Swagger2MarkupConverter;
|
|
||||||
import io.github.swagger2markup.Swagger2MarkupExtensionRegistry;
|
|
||||||
import io.github.swagger2markup.internal.document.MarkupDocument;
|
|
||||||
import io.github.swagger2markup.internal.type.ObjectType;
|
|
||||||
import io.github.swagger2markup.internal.type.Type;
|
|
||||||
import io.github.swagger2markup.internal.utils.ExamplesUtil;
|
|
||||||
import io.github.swagger2markup.internal.utils.ParameterUtils;
|
|
||||||
import io.github.swagger2markup.internal.utils.PropertyUtils;
|
|
||||||
import io.github.swagger2markup.internal.utils.TagUtils;
|
|
||||||
import io.github.swagger2markup.markup.builder.*;
|
|
||||||
import io.github.swagger2markup.model.PathOperation;
|
|
||||||
import io.github.swagger2markup.spi.PathsDocumentExtension;
|
|
||||||
import io.swagger.models.*;
|
|
||||||
import io.swagger.models.auth.SecuritySchemeDefinition;
|
|
||||||
import io.swagger.models.parameters.Parameter;
|
|
||||||
import io.swagger.models.properties.Property;
|
|
||||||
import io.swagger.util.Json;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.apache.commons.collections4.MapUtils;
|
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.commons.lang3.Validate;
|
|
||||||
import org.apache.commons.lang3.text.WordUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static io.github.swagger2markup.internal.utils.ListUtils.toSet;
|
|
||||||
import static io.github.swagger2markup.internal.utils.MapUtils.toKeySet;
|
|
||||||
import static io.github.swagger2markup.internal.utils.TagUtils.convertTagsListToMap;
|
|
||||||
import static io.github.swagger2markup.internal.utils.TagUtils.getTagDescription;
|
|
||||||
import static io.github.swagger2markup.spi.PathsDocumentExtension.Context;
|
|
||||||
import static io.github.swagger2markup.spi.PathsDocumentExtension.Position;
|
|
||||||
import static io.github.swagger2markup.utils.IOUtils.normalizeName;
|
|
||||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robert Winkler
|
|
||||||
*/
|
|
||||||
public class PathsDocumentBuilder extends MarkupDocumentBuilder {
|
|
||||||
|
|
||||||
private final String RESPONSE;
|
|
||||||
private final String REQUEST;
|
|
||||||
private final String PATHS;
|
|
||||||
private final String RESOURCES;
|
|
||||||
private final String PARAMETERS;
|
|
||||||
private final String BODY_PARAMETER;
|
|
||||||
private final String RESPONSES;
|
|
||||||
private final String HEADERS_COLUMN;
|
|
||||||
private final String EXAMPLE_REQUEST;
|
|
||||||
private final String EXAMPLE_RESPONSE;
|
|
||||||
|
|
||||||
private final String SECURITY;
|
|
||||||
private final String TYPE_COLUMN;
|
|
||||||
private final String HTTP_CODE_COLUMN;
|
|
||||||
|
|
||||||
private final String DEPRECATED_OPERATION;
|
|
||||||
private final String UNKNOWN;
|
|
||||||
|
|
||||||
private static final String PATHS_ANCHOR = "paths";
|
|
||||||
|
|
||||||
public PathsDocumentBuilder(Swagger2MarkupConverter.Context globalContext, Swagger2MarkupExtensionRegistry extensionRegistry, java.nio.file.Path outputPath) {
|
|
||||||
super(globalContext, extensionRegistry, outputPath);
|
|
||||||
|
|
||||||
ResourceBundle labels = ResourceBundle.getBundle("io/github/swagger2markup/lang/labels", config.getOutputLanguage().toLocale());
|
|
||||||
RESPONSE = labels.getString("response");
|
|
||||||
REQUEST = labels.getString("request");
|
|
||||||
PATHS = labels.getString("paths");
|
|
||||||
RESOURCES = labels.getString("resources");
|
|
||||||
PARAMETERS = labels.getString("parameters");
|
|
||||||
BODY_PARAMETER = labels.getString("body_parameter");
|
|
||||||
RESPONSES = labels.getString("responses");
|
|
||||||
HEADERS_COLUMN = labels.getString("headers_column");
|
|
||||||
EXAMPLE_REQUEST = labels.getString("example_request");
|
|
||||||
EXAMPLE_RESPONSE = labels.getString("example_response");
|
|
||||||
SECURITY = labels.getString("security");
|
|
||||||
TYPE_COLUMN = labels.getString("type_column");
|
|
||||||
HTTP_CODE_COLUMN = labels.getString("http_code_column");
|
|
||||||
DEPRECATED_OPERATION = labels.getString("operation.deprecated");
|
|
||||||
UNKNOWN = labels.getString("unknown");
|
|
||||||
|
|
||||||
if (config.isGeneratedExamplesEnabled()) {
|
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug("Include examples is enabled.");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug("Include examples is disabled.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.isSeparatedOperationsEnabled()) {
|
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug("Create separated operation files is enabled.");
|
|
||||||
}
|
|
||||||
Validate.notNull(outputPath, "Output directory is required for separated operation files!");
|
|
||||||
} else {
|
|
||||||
if (logger.isDebugEnabled()) {
|
|
||||||
logger.debug("Create separated operation files is disabled.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the paths MarkupDocument.
|
|
||||||
*
|
|
||||||
* @return the paths MarkupDocument
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public MarkupDocument build() {
|
|
||||||
Map<String, Path> paths = globalContext.getSwagger().getPaths();
|
|
||||||
if (MapUtils.isNotEmpty(paths)) {
|
|
||||||
applyPathsDocumentExtension(new Context(Position.DOCUMENT_BEFORE, this.markupDocBuilder));
|
|
||||||
buildPathsTitle();
|
|
||||||
applyPathsDocumentExtension(new Context(Position.DOCUMENT_BEGIN, this.markupDocBuilder));
|
|
||||||
buildsPathsSection(paths);
|
|
||||||
applyPathsDocumentExtension(new Context(Position.DOCUMENT_END, this.markupDocBuilder));
|
|
||||||
applyPathsDocumentExtension(new Context(Position.DOCUMENT_AFTER, this.markupDocBuilder));
|
|
||||||
}
|
|
||||||
return new MarkupDocument(markupDocBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildsPathsSection(Map<String, Path> paths) {
|
|
||||||
Set<PathOperation> pathOperations = toPathOperationsSet(paths);
|
|
||||||
if (CollectionUtils.isNotEmpty(pathOperations)) {
|
|
||||||
if (config.getPathsGroupedBy() == GroupBy.AS_IS) {
|
|
||||||
for (PathOperation operation : pathOperations) {
|
|
||||||
buildOperation(operation);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Multimap<String, PathOperation> operationsGroupedByTag = TagUtils.groupOperationsByTag(pathOperations, config.getTagOrdering(), config.getOperationOrdering());
|
|
||||||
Map<String, Tag> tagsMap = convertTagsListToMap(globalContext.getSwagger().getTags());
|
|
||||||
for (String tagName : operationsGroupedByTag.keySet()) {
|
|
||||||
this.markupDocBuilder.sectionTitleWithAnchorLevel2(WordUtils.capitalize(tagName), tagName + "_resource");
|
|
||||||
|
|
||||||
Optional<String> tagDescription = getTagDescription(tagsMap, tagName);
|
|
||||||
if (tagDescription.isPresent()) {
|
|
||||||
this.markupDocBuilder.paragraph(tagDescription.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (PathOperation operation : operationsGroupedByTag.get(tagName)) {
|
|
||||||
buildOperation(operation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the path title depending on the operationsGroupedBy configuration setting.
|
|
||||||
*/
|
|
||||||
private void buildPathsTitle() {
|
|
||||||
if (config.getPathsGroupedBy() == GroupBy.AS_IS) {
|
|
||||||
buildPathsTitle(PATHS);
|
|
||||||
} else {
|
|
||||||
buildPathsTitle(RESOURCES);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts the Swagger paths into a list PathOperations.
|
|
||||||
*
|
|
||||||
* @param paths the Swagger paths
|
|
||||||
* @return the path operations
|
|
||||||
*/
|
|
||||||
private Set<PathOperation> toPathOperationsSet(Map<String, Path> paths) {
|
|
||||||
Set<PathOperation> pathOperations;
|
|
||||||
if (config.getOperationOrdering() != null) {
|
|
||||||
pathOperations = new TreeSet<>(config.getOperationOrdering());
|
|
||||||
} else {
|
|
||||||
pathOperations = new LinkedHashSet<>();
|
|
||||||
}
|
|
||||||
for (Map.Entry<String, Path> path : paths.entrySet()) {
|
|
||||||
Map<HttpMethod, Operation> operations = path.getValue().getOperationMap(); // TODO AS_IS does not work because of https://github.com/swagger-api/swagger-core/issues/1696
|
|
||||||
if (MapUtils.isNotEmpty(operations)) {
|
|
||||||
for (Map.Entry<HttpMethod, Operation> operation : operations.entrySet()) {
|
|
||||||
pathOperations.add(new PathOperation(operation.getKey(), path.getKey(), operation.getValue()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return pathOperations;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildPathsTitle(String title) {
|
|
||||||
this.markupDocBuilder.sectionTitleWithAnchorLevel1(title, PATHS_ANCHOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Apply extension context to all OperationsContentExtension.
|
|
||||||
*
|
|
||||||
* @param context context
|
|
||||||
*/
|
|
||||||
private void applyPathsDocumentExtension(Context context) {
|
|
||||||
for (PathsDocumentExtension extension : extensionRegistry.getPathsDocumentExtensions()) {
|
|
||||||
extension.apply(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the operation filename depending on the generation mode
|
|
||||||
*
|
|
||||||
* @param operation operation
|
|
||||||
* @return operation filename
|
|
||||||
*/
|
|
||||||
private String resolveOperationDocument(PathOperation operation) {
|
|
||||||
if (config.isSeparatedOperationsEnabled())
|
|
||||||
return new File(config.getSeparatedOperationsFolder(), this.markupDocBuilder.addFileExtension(normalizeName(operation.getId()))).getPath();
|
|
||||||
else
|
|
||||||
return this.markupDocBuilder.addFileExtension(config.getPathsDocument());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds a path operation depending on generation mode.
|
|
||||||
*
|
|
||||||
* @param operation operation
|
|
||||||
*/
|
|
||||||
private void buildOperation(PathOperation operation) {
|
|
||||||
if (config.isSeparatedOperationsEnabled()) {
|
|
||||||
MarkupDocBuilder pathDocBuilder = copyMarkupDocBuilder();
|
|
||||||
buildOperation(operation, pathDocBuilder);
|
|
||||||
java.nio.file.Path operationFile = outputPath.resolve(resolveOperationDocument(operation));
|
|
||||||
pathDocBuilder.writeToFileWithoutExtension(operationFile, StandardCharsets.UTF_8);
|
|
||||||
if (logger.isInfoEnabled()) {
|
|
||||||
logger.info("Separate operation file produced : '{}'", operationFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
buildOperationRef(operation, this.markupDocBuilder);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
buildOperation(operation, this.markupDocBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (logger.isInfoEnabled()) {
|
|
||||||
logger.info("Operation processed : '{}' (normalized id = '{}')", operation, normalizeName(operation.getId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds a path operation.
|
|
||||||
*
|
|
||||||
* @param operation the Swagger Operation
|
|
||||||
* @param docBuilder the docbuilder do use for output
|
|
||||||
*/
|
|
||||||
private void buildOperation(PathOperation operation, MarkupDocBuilder docBuilder) {
|
|
||||||
if (operation != null) {
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_BEFORE, docBuilder, operation));
|
|
||||||
buildDeprecatedSection(operation, docBuilder);
|
|
||||||
buildOperationTitle(operation, docBuilder);
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_BEGIN, docBuilder, operation));
|
|
||||||
buildDescriptionSection(operation, docBuilder);
|
|
||||||
inlineDefinitions(buildParametersSection(operation, docBuilder), operation.getPath() + " " + operation.getMethod(), docBuilder);
|
|
||||||
inlineDefinitions(buildBodyParameterSection(operation, docBuilder), operation.getPath() + " " + operation.getMethod(), docBuilder);
|
|
||||||
inlineDefinitions(buildResponsesSection(operation, docBuilder), operation.getPath() + " " + operation.getMethod(), docBuilder);
|
|
||||||
buildConsumesSection(operation, docBuilder);
|
|
||||||
buildProducesSection(operation, docBuilder);
|
|
||||||
buildTagsSection(operation, docBuilder);
|
|
||||||
if (config.isPathSecuritySectionEnabled()) {
|
|
||||||
buildSecuritySchemeSection(operation, docBuilder);
|
|
||||||
}
|
|
||||||
buildExamplesSection(operation, docBuilder);
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_END, docBuilder, operation));
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_AFTER, docBuilder, operation));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds a cross-reference to a separated operation file
|
|
||||||
*
|
|
||||||
* @param operation the Swagger Operation
|
|
||||||
* @param docBuilder the docbuilder do use for output
|
|
||||||
*/
|
|
||||||
private void buildOperationRef(PathOperation operation, MarkupDocBuilder docBuilder) {
|
|
||||||
String document;
|
|
||||||
if (!config.isInterDocumentCrossReferencesEnabled() || outputPath == null)
|
|
||||||
document = null;
|
|
||||||
else if (config.isSeparatedOperationsEnabled())
|
|
||||||
document = defaultString(config.getInterDocumentCrossReferencesPrefix()) + resolveOperationDocument(operation);
|
|
||||||
else
|
|
||||||
document = defaultString(config.getInterDocumentCrossReferencesPrefix()) + resolveOperationDocument(operation);
|
|
||||||
|
|
||||||
buildOperationTitle(copyMarkupDocBuilder().crossReference(document, operation.getId(), operation.getTitle()).toString(), "ref-" + operation.getId(), docBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds a warning if method is deprecated.
|
|
||||||
*
|
|
||||||
* @param operation the Swagger Operation
|
|
||||||
* @param docBuilder the docbuilder do use for output
|
|
||||||
*/
|
|
||||||
private void buildDeprecatedSection(PathOperation operation, MarkupDocBuilder docBuilder) {
|
|
||||||
Boolean deprecated = operation.getOperation().isDeprecated();
|
|
||||||
if (deprecated != null && deprecated) {
|
|
||||||
docBuilder.block(DEPRECATED_OPERATION, MarkupBlockStyle.EXAMPLE, null, MarkupAdmonition.CAUTION);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the operation title to the document. If the operation has a summary, the title is the summary.
|
|
||||||
* Otherwise the title is the method of the operation and the URL of the operation.
|
|
||||||
*
|
|
||||||
* @param operation the Swagger Operation
|
|
||||||
* @param docBuilder the docbuilder do use for output
|
|
||||||
*/
|
|
||||||
private void buildOperationTitle(PathOperation operation, MarkupDocBuilder docBuilder) {
|
|
||||||
buildOperationTitle(operation.getTitle(), operation.getId(), docBuilder);
|
|
||||||
if (operation.getTitle().equals(operation.getOperation().getSummary())) {
|
|
||||||
docBuilder.block(operation.getMethod() + " " + operation.getPath(), MarkupBlockStyle.LITERAL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a operation title to the document.
|
|
||||||
*
|
|
||||||
* @param title the operation title
|
|
||||||
* @param anchor optional anchor (null => auto-generate from title)
|
|
||||||
* @param docBuilder the MarkupDocBuilder to use
|
|
||||||
*/
|
|
||||||
private void buildOperationTitle(String title, String anchor, MarkupDocBuilder docBuilder) {
|
|
||||||
if (config.getPathsGroupedBy() == GroupBy.AS_IS) {
|
|
||||||
docBuilder.sectionTitleWithAnchorLevel2(title, anchor);
|
|
||||||
} else {
|
|
||||||
docBuilder.sectionTitleWithAnchorLevel3(title, anchor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a operation section title to the document.
|
|
||||||
*
|
|
||||||
* @param title the section title
|
|
||||||
* @param docBuilder the MarkupDocBuilder to use
|
|
||||||
*/
|
|
||||||
private void buildSectionTitle(String title, MarkupDocBuilder docBuilder) {
|
|
||||||
if (config.getPathsGroupedBy() == GroupBy.AS_IS) {
|
|
||||||
docBuilder.sectionTitleLevel3(title);
|
|
||||||
} else {
|
|
||||||
docBuilder.sectionTitleLevel4(title);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a example title to the document.
|
|
||||||
*
|
|
||||||
* @param title the section title
|
|
||||||
* @param docBuilder the MarkupDocBuilder to use
|
|
||||||
*/
|
|
||||||
private void buildExampleTitle(String title, MarkupDocBuilder docBuilder) {
|
|
||||||
if (config.getPathsGroupedBy() == GroupBy.AS_IS) {
|
|
||||||
docBuilder.sectionTitleLevel4(title);
|
|
||||||
} else {
|
|
||||||
docBuilder.sectionTitleLevel5(title);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a operation description to the document.
|
|
||||||
*
|
|
||||||
* @param operation the Swagger Operation
|
|
||||||
* @param docBuilder the docbuilder do use for output
|
|
||||||
*/
|
|
||||||
private void buildDescriptionSection(PathOperation operation, MarkupDocBuilder docBuilder) {
|
|
||||||
MarkupDocBuilder descriptionBuilder = copyMarkupDocBuilder();
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_DESCRIPTION_BEGIN, descriptionBuilder, operation));
|
|
||||||
buildDescriptionParagraph(operation.getOperation().getDescription(), descriptionBuilder);
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_DESCRIPTION_END, descriptionBuilder, operation));
|
|
||||||
String descriptionContent = descriptionBuilder.toString();
|
|
||||||
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_DESCRIPTION_BEFORE, docBuilder, operation));
|
|
||||||
if (isNotBlank(descriptionContent)) {
|
|
||||||
buildSectionTitle(DESCRIPTION, docBuilder);
|
|
||||||
docBuilder.text(descriptionContent);
|
|
||||||
}
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_DESCRIPTION_AFTER, docBuilder, operation));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Filter parameters to display in parameters section
|
|
||||||
*
|
|
||||||
* @param parameter parameter to filter
|
|
||||||
* @return true if parameter can be displayed
|
|
||||||
*/
|
|
||||||
private boolean filterParameter(Parameter parameter) {
|
|
||||||
return (!config.isFlatBodyEnabled() || !StringUtils.equals(parameter.getIn(), "body"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<ObjectType> buildParametersSection(PathOperation operation, MarkupDocBuilder docBuilder) {
|
|
||||||
List<Parameter> parameters = operation.getOperation().getParameters();
|
|
||||||
if (config.getParameterOrdering() != null)
|
|
||||||
Collections.sort(parameters, config.getParameterOrdering());
|
|
||||||
List<ObjectType> inlineDefinitions = new ArrayList<>();
|
|
||||||
|
|
||||||
boolean hasParameters = false;
|
|
||||||
if (CollectionUtils.isNotEmpty(parameters)) {
|
|
||||||
for (Parameter p : parameters) {
|
|
||||||
if (filterParameter(p)) {
|
|
||||||
hasParameters = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MarkupDocBuilder parametersBuilder = copyMarkupDocBuilder();
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_DESCRIPTION_BEGIN, parametersBuilder, operation));
|
|
||||||
if (hasParameters) {
|
|
||||||
List<List<String>> cells = new ArrayList<>();
|
|
||||||
List<MarkupTableColumn> cols = Arrays.asList(
|
|
||||||
new MarkupTableColumn(TYPE_COLUMN).withWidthRatio(2).withHeaderColumn(false).withMarkupSpecifiers(MarkupLanguage.ASCIIDOC, ".^2"),
|
|
||||||
new MarkupTableColumn(NAME_COLUMN).withWidthRatio(3).withHeaderColumn(false).withMarkupSpecifiers(MarkupLanguage.ASCIIDOC, ".^3"),
|
|
||||||
new MarkupTableColumn(DESCRIPTION_COLUMN).withWidthRatio(9).withMarkupSpecifiers(MarkupLanguage.ASCIIDOC, ".^9"),
|
|
||||||
new MarkupTableColumn(SCHEMA_COLUMN).withWidthRatio(4).withMarkupSpecifiers(MarkupLanguage.ASCIIDOC, ".^4"),
|
|
||||||
new MarkupTableColumn(DEFAULT_COLUMN).withWidthRatio(2).withMarkupSpecifiers(MarkupLanguage.ASCIIDOC, ".^2"));
|
|
||||||
for (Parameter parameter : parameters) {
|
|
||||||
if (filterParameter(parameter)) {
|
|
||||||
Type type = ParameterUtils.getType(parameter, globalContext.getSwagger().getDefinitions(), new DefinitionDocumentResolverFromOperation());
|
|
||||||
|
|
||||||
type = createInlineType(type, parameter.getName(), operation.getId() + " " + parameter.getName(), inlineDefinitions);
|
|
||||||
|
|
||||||
String parameterType = WordUtils.capitalize(parameter.getIn());
|
|
||||||
|
|
||||||
MarkupDocBuilder parameterNameContent = copyMarkupDocBuilder();
|
|
||||||
parameterNameContent.boldTextLine(parameter.getName(), true);
|
|
||||||
if (parameter.getRequired())
|
|
||||||
parameterNameContent.italicText(FLAGS_REQUIRED.toLowerCase());
|
|
||||||
else
|
|
||||||
parameterNameContent.italicText(FLAGS_OPTIONAL.toLowerCase());
|
|
||||||
|
|
||||||
Object defaultValue = ParameterUtils.getDefaultValue(parameter);
|
|
||||||
|
|
||||||
List<String> content = Arrays.asList(
|
|
||||||
boldText(parameterType),
|
|
||||||
parameterNameContent.toString(),
|
|
||||||
defaultString(swaggerMarkupDescription(parameter.getDescription())),
|
|
||||||
type.displaySchema(markupDocBuilder),
|
|
||||||
defaultValue != null ? literalText(Json.pretty(defaultValue)) : "");
|
|
||||||
cells.add(content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
parametersBuilder.tableWithColumnSpecs(cols, cells);
|
|
||||||
}
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_DESCRIPTION_END, parametersBuilder, operation));
|
|
||||||
String parametersContent = parametersBuilder.toString();
|
|
||||||
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_PARAMETERS_BEFORE, docBuilder, operation));
|
|
||||||
if (isNotBlank(parametersContent)) {
|
|
||||||
buildSectionTitle(PARAMETERS, docBuilder);
|
|
||||||
docBuilder.text(parametersContent);
|
|
||||||
}
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_PARAMETERS_AFTER, docBuilder, operation));
|
|
||||||
|
|
||||||
return inlineDefinitions;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the body parameter section, if {@code Swagger2MarkupConfig.isIsolatedBody()} is true
|
|
||||||
*
|
|
||||||
* @param operation the Swagger Operation
|
|
||||||
* @param docBuilder the docbuilder do use for output
|
|
||||||
* @return a list of inlined types.
|
|
||||||
*/
|
|
||||||
private List<ObjectType> buildBodyParameterSection(PathOperation operation, MarkupDocBuilder docBuilder) {
|
|
||||||
List<ObjectType> inlineDefinitions = new ArrayList<>();
|
|
||||||
|
|
||||||
if (config.isFlatBodyEnabled()) {
|
|
||||||
List<Parameter> parameters = operation.getOperation().getParameters();
|
|
||||||
if (CollectionUtils.isNotEmpty(parameters)) {
|
|
||||||
for (Parameter parameter : parameters) {
|
|
||||||
if (StringUtils.equals(parameter.getIn(), "body")) {
|
|
||||||
Type type = ParameterUtils.getType(parameter, globalContext.getSwagger().getDefinitions(), new DefinitionDocumentResolverFromOperation());
|
|
||||||
|
|
||||||
if (!(type instanceof ObjectType)) {
|
|
||||||
type = createInlineType(type, parameter.getName(), operation.getId() + " " + parameter.getName(), inlineDefinitions);
|
|
||||||
}
|
|
||||||
|
|
||||||
buildSectionTitle(BODY_PARAMETER, docBuilder);
|
|
||||||
if (isNotBlank(parameter.getDescription())) {
|
|
||||||
buildDescriptionParagraph(parameter.getDescription(), docBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
MarkupDocBuilder typeInfos = copyMarkupDocBuilder();
|
|
||||||
typeInfos.italicText(NAME_COLUMN).textLine(COLON + parameter.getName());
|
|
||||||
typeInfos.italicText(FLAGS_COLUMN).textLine(COLON + (BooleanUtils.isTrue(parameter.getRequired()) ? FLAGS_REQUIRED.toLowerCase() : FLAGS_OPTIONAL.toLowerCase()));
|
|
||||||
|
|
||||||
if (!(type instanceof ObjectType)) {
|
|
||||||
typeInfos.italicText(TYPE_COLUMN).textLine(COLON + type.displaySchema(docBuilder));
|
|
||||||
}
|
|
||||||
|
|
||||||
docBuilder.paragraph(typeInfos.toString(), true);
|
|
||||||
|
|
||||||
if (type instanceof ObjectType) {
|
|
||||||
inlineDefinitions.addAll(buildPropertiesTable(((ObjectType) type).getProperties(), operation.getId(), new DefinitionDocumentResolverFromOperation(), docBuilder));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return inlineDefinitions;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildConsumesSection(PathOperation operation, MarkupDocBuilder docBuilder) {
|
|
||||||
List<String> consumes = operation.getOperation().getConsumes();
|
|
||||||
if (CollectionUtils.isNotEmpty(consumes)) {
|
|
||||||
buildSectionTitle(CONSUMES, docBuilder);
|
|
||||||
docBuilder.newLine();
|
|
||||||
for (String consume : consumes) {
|
|
||||||
docBuilder.unorderedListItem(literalText(consume));
|
|
||||||
}
|
|
||||||
docBuilder.newLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildProducesSection(PathOperation operation, MarkupDocBuilder docBuilder) {
|
|
||||||
List<String> produces = operation.getOperation().getProduces();
|
|
||||||
if (CollectionUtils.isNotEmpty(produces)) {
|
|
||||||
buildSectionTitle(PRODUCES, docBuilder);
|
|
||||||
docBuilder.newLine();
|
|
||||||
for (String produce : produces) {
|
|
||||||
docBuilder.unorderedListItem(literalText(produce));
|
|
||||||
}
|
|
||||||
docBuilder.newLine();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildTagsSection(PathOperation operation, MarkupDocBuilder docBuilder) {
|
|
||||||
if (config.getPathsGroupedBy() == GroupBy.AS_IS) {
|
|
||||||
List<String> tags = operation.getOperation().getTags();
|
|
||||||
if (CollectionUtils.isNotEmpty(tags)) {
|
|
||||||
buildSectionTitle(TAGS, docBuilder);
|
|
||||||
Set<String> tagsSet = toSet(tags, config.getTagOrdering());
|
|
||||||
docBuilder.unorderedList(new ArrayList<>(tagsSet));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the example section of a Swagger Operation.
|
|
||||||
*
|
|
||||||
* @param operation the Swagger Operation
|
|
||||||
* @param docBuilder the docbuilder do use for output
|
|
||||||
*/
|
|
||||||
private void buildExamplesSection(PathOperation operation, MarkupDocBuilder docBuilder) {
|
|
||||||
|
|
||||||
Map<String, Object> generatedRequestExampleMap = ExamplesUtil.generateRequestExampleMap(config.isGeneratedExamplesEnabled(), operation, globalContext.getSwagger().getDefinitions(), markupDocBuilder);
|
|
||||||
Map<String, Object> generatedResponseExampleMap = ExamplesUtil.generateResponseExampleMap(config.isGeneratedExamplesEnabled(), operation.getOperation(), globalContext.getSwagger().getDefinitions(), markupDocBuilder);
|
|
||||||
|
|
||||||
exampleMap(generatedRequestExampleMap, EXAMPLE_REQUEST, REQUEST, docBuilder);
|
|
||||||
exampleMap(generatedResponseExampleMap, EXAMPLE_RESPONSE, RESPONSE, docBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void exampleMap(Map<String, Object> exampleMap, String operationSectionTitle, String sectionTitle, MarkupDocBuilder docBuilder) {
|
|
||||||
if (exampleMap.size() > 0) {
|
|
||||||
buildSectionTitle(operationSectionTitle, docBuilder);
|
|
||||||
for (Map.Entry<String, Object> entry : exampleMap.entrySet()) {
|
|
||||||
buildExampleTitle(sectionTitle + " " + entry.getKey(), docBuilder);
|
|
||||||
docBuilder.listingBlock(Json.pretty(entry.getValue()), "json");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the security section of a Swagger Operation.
|
|
||||||
*
|
|
||||||
* @param operation the Swagger Operation
|
|
||||||
* @param docBuilder the MarkupDocBuilder document builder
|
|
||||||
*/
|
|
||||||
private void buildSecuritySchemeSection(PathOperation operation, MarkupDocBuilder docBuilder) {
|
|
||||||
List<Map<String, List<String>>> securitySchemes = operation.getOperation().getSecurity();
|
|
||||||
|
|
||||||
MarkupDocBuilder securityBuilder = copyMarkupDocBuilder();
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_SECURITY_BEGIN, securityBuilder, operation));
|
|
||||||
if (CollectionUtils.isNotEmpty(securitySchemes)) {
|
|
||||||
|
|
||||||
Map<String, SecuritySchemeDefinition> securityDefinitions = globalContext.getSwagger().getSecurityDefinitions();
|
|
||||||
List<List<String>> cells = new ArrayList<>();
|
|
||||||
List<MarkupTableColumn> cols = Arrays.asList(
|
|
||||||
new MarkupTableColumn(TYPE_COLUMN).withWidthRatio(3).withHeaderColumn(false).withMarkupSpecifiers(MarkupLanguage.ASCIIDOC, ".^3"),
|
|
||||||
new MarkupTableColumn(NAME_COLUMN).withWidthRatio(4).withHeaderColumn(false).withMarkupSpecifiers(MarkupLanguage.ASCIIDOC, ".^4"),
|
|
||||||
new MarkupTableColumn(SCOPES_COLUMN).withWidthRatio(13).withMarkupSpecifiers(MarkupLanguage.ASCIIDOC, ".^13"));
|
|
||||||
for (Map<String, List<String>> securityScheme : securitySchemes) {
|
|
||||||
for (Map.Entry<String, List<String>> securityEntry : securityScheme.entrySet()) {
|
|
||||||
String securityKey = securityEntry.getKey();
|
|
||||||
String type = UNKNOWN;
|
|
||||||
if (securityDefinitions != null && securityDefinitions.containsKey(securityKey)) {
|
|
||||||
type = securityDefinitions.get(securityKey).getType();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> content = Arrays.asList(boldText(type), boldText(copyMarkupDocBuilder().crossReference(securityDocumentResolver(), securityKey, securityKey).toString()),
|
|
||||||
Joiner.on(",").join(securityEntry.getValue()));
|
|
||||||
cells.add(content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
securityBuilder.tableWithColumnSpecs(cols, cells);
|
|
||||||
}
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_SECURITY_END, securityBuilder, operation));
|
|
||||||
String securityContent = securityBuilder.toString();
|
|
||||||
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_SECURITY_BEFORE, docBuilder, operation));
|
|
||||||
if (isNotBlank(securityContent)) {
|
|
||||||
buildSectionTitle(SECURITY, docBuilder);
|
|
||||||
docBuilder.text(securityContent);
|
|
||||||
}
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_SECURITY_AFTER, docBuilder, operation));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resolve Security document for use in cross-references.
|
|
||||||
*
|
|
||||||
* @return document or null if cross-reference is not inter-document
|
|
||||||
*/
|
|
||||||
private String securityDocumentResolver() {
|
|
||||||
if (!config.isInterDocumentCrossReferencesEnabled() || outputPath == null)
|
|
||||||
return null;
|
|
||||||
else
|
|
||||||
return defaultString(config.getInterDocumentCrossReferencesPrefix()) + markupDocBuilder.addFileExtension(config.getSecurityDocument());
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<ObjectType> buildResponsesSection(PathOperation operation, MarkupDocBuilder docBuilder) {
|
|
||||||
Map<String, Response> responses = operation.getOperation().getResponses();
|
|
||||||
List<ObjectType> inlineDefinitions = new ArrayList<>();
|
|
||||||
|
|
||||||
MarkupDocBuilder responsesBuilder = copyMarkupDocBuilder();
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_RESPONSES_BEGIN, responsesBuilder, operation));
|
|
||||||
if (MapUtils.isNotEmpty(responses)) {
|
|
||||||
List<MarkupTableColumn> responseCols = Arrays.asList(
|
|
||||||
new MarkupTableColumn(HTTP_CODE_COLUMN).withWidthRatio(2).withHeaderColumn(false).withMarkupSpecifiers(MarkupLanguage.ASCIIDOC, ".^2"),
|
|
||||||
new MarkupTableColumn(DESCRIPTION_COLUMN).withWidthRatio(14).withMarkupSpecifiers(MarkupLanguage.ASCIIDOC, ".^14"),
|
|
||||||
new MarkupTableColumn(SCHEMA_COLUMN).withWidthRatio(4).withMarkupSpecifiers(MarkupLanguage.ASCIIDOC, ".^4"));
|
|
||||||
|
|
||||||
List<List<String>> cells = new ArrayList<>();
|
|
||||||
|
|
||||||
Set<String> responseNames = toKeySet(responses, config.getResponseOrdering());
|
|
||||||
for (String responseName : responseNames) {
|
|
||||||
Response response = responses.get(responseName);
|
|
||||||
|
|
||||||
String schemaContent = NO_CONTENT;
|
|
||||||
if (response.getSchema() != null) {
|
|
||||||
Property property = response.getSchema();
|
|
||||||
Type type = PropertyUtils.getType(property, new DefinitionDocumentResolverFromOperation());
|
|
||||||
|
|
||||||
type = createInlineType(type, RESPONSE + " " + responseName, operation.getId() + " " + RESPONSE + " " + responseName, inlineDefinitions);
|
|
||||||
|
|
||||||
schemaContent = type.displaySchema(markupDocBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
MarkupDocBuilder descriptionBuilder = copyMarkupDocBuilder();
|
|
||||||
|
|
||||||
descriptionBuilder.text(defaultString(swaggerMarkupDescription(response.getDescription())));
|
|
||||||
|
|
||||||
Map<String, Property> headers = response.getHeaders();
|
|
||||||
if (MapUtils.isNotEmpty(headers)) {
|
|
||||||
descriptionBuilder.newLine(true).boldText(HEADERS_COLUMN).text(COLON);
|
|
||||||
for (Map.Entry<String, Property> header : headers.entrySet()) {
|
|
||||||
descriptionBuilder.newLine(true);
|
|
||||||
Property headerProperty = header.getValue();
|
|
||||||
Type propertyType = PropertyUtils.getType(headerProperty, null);
|
|
||||||
String headerDescription = defaultString(swaggerMarkupDescription(headerProperty.getDescription()));
|
|
||||||
Object defaultValue = PropertyUtils.getDefaultValue(headerProperty);
|
|
||||||
|
|
||||||
descriptionBuilder
|
|
||||||
.literalText(header.getKey())
|
|
||||||
.text(String.format(" (%s)", propertyType.displaySchema(markupDocBuilder)));
|
|
||||||
|
|
||||||
if (isNotBlank(headerDescription) || defaultValue != null) {
|
|
||||||
descriptionBuilder.text(COLON);
|
|
||||||
|
|
||||||
if (isNotBlank(headerDescription) && !headerDescription.endsWith("."))
|
|
||||||
headerDescription += ".";
|
|
||||||
|
|
||||||
descriptionBuilder.text(headerDescription);
|
|
||||||
|
|
||||||
if (defaultValue != null) {
|
|
||||||
descriptionBuilder.text(" ").boldText(DEFAULT_COLUMN).text(COLON).literalText(Json.pretty(defaultValue));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cells.add(Arrays.asList(boldText(responseName), descriptionBuilder.toString(), schemaContent));
|
|
||||||
}
|
|
||||||
|
|
||||||
responsesBuilder.tableWithColumnSpecs(responseCols, cells);
|
|
||||||
}
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_RESPONSES_END, responsesBuilder, operation));
|
|
||||||
String responsesContent = responsesBuilder.toString();
|
|
||||||
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_RESPONSES_BEFORE, docBuilder, operation));
|
|
||||||
if (isNotBlank(responsesContent)) {
|
|
||||||
buildSectionTitle(RESPONSES, docBuilder);
|
|
||||||
docBuilder.text(responsesContent);
|
|
||||||
}
|
|
||||||
applyPathsDocumentExtension(new Context(Position.OPERATION_RESPONSES_AFTER, docBuilder, operation));
|
|
||||||
|
|
||||||
return inlineDefinitions;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the title of an inline schema.
|
|
||||||
* Inline definitions should never been referenced in TOC because they have no real existence, so they are just text.
|
|
||||||
*
|
|
||||||
* @param title inline schema title
|
|
||||||
* @param anchor inline schema anchor
|
|
||||||
* @param docBuilder the docbuilder do use for output
|
|
||||||
*/
|
|
||||||
private void addInlineDefinitionTitle(String title, String anchor, MarkupDocBuilder docBuilder) {
|
|
||||||
docBuilder.anchor(anchor);
|
|
||||||
docBuilder.newLine();
|
|
||||||
docBuilder.boldTextLine(title);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds inline schema definitions
|
|
||||||
*
|
|
||||||
* @param definitions all inline definitions to display
|
|
||||||
* @param uniquePrefix unique prefix to prepend to inline object names to enforce unicity
|
|
||||||
* @param docBuilder the docbuilder do use for output
|
|
||||||
*/
|
|
||||||
private void inlineDefinitions(List<ObjectType> definitions, String uniquePrefix, MarkupDocBuilder docBuilder) {
|
|
||||||
if (CollectionUtils.isNotEmpty(definitions)) {
|
|
||||||
for (ObjectType definition : definitions) {
|
|
||||||
addInlineDefinitionTitle(definition.getName(), definition.getUniqueName(), docBuilder);
|
|
||||||
|
|
||||||
List<ObjectType> localDefinitions = buildPropertiesTable(definition.getProperties(), uniquePrefix, new DefinitionDocumentResolverFromOperation(), docBuilder);
|
|
||||||
for (ObjectType localDefinition : localDefinitions)
|
|
||||||
inlineDefinitions(Collections.singletonList(localDefinition), localDefinition.getUniqueName(), docBuilder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Overrides definition document resolver functor for inter-document cross-references from operations files.
|
|
||||||
* This implementation adapt the relative paths to definitions files
|
|
||||||
*/
|
|
||||||
class DefinitionDocumentResolverFromOperation extends DefinitionDocumentResolverDefault {
|
|
||||||
|
|
||||||
public DefinitionDocumentResolverFromOperation() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public String apply(String definitionName) {
|
|
||||||
String defaultResolver = super.apply(definitionName);
|
|
||||||
|
|
||||||
if (defaultResolver != null && config.isSeparatedOperationsEnabled())
|
|
||||||
return defaultString(config.getInterDocumentCrossReferencesPrefix()) + new File("..", defaultResolver).getPath();
|
|
||||||
else
|
|
||||||
return defaultResolver;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Robert Winkler
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package io.github.swagger2markup.internal.document.builder;
|
|
||||||
|
|
||||||
import com.google.common.collect.Ordering;
|
|
||||||
import io.github.swagger2markup.Swagger2MarkupConverter;
|
|
||||||
import io.github.swagger2markup.Swagger2MarkupExtensionRegistry;
|
|
||||||
import io.github.swagger2markup.internal.document.MarkupDocument;
|
|
||||||
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
|
|
||||||
import io.github.swagger2markup.markup.builder.MarkupLanguage;
|
|
||||||
import io.github.swagger2markup.markup.builder.MarkupTableColumn;
|
|
||||||
import io.github.swagger2markup.spi.SecurityDocumentExtension;
|
|
||||||
import io.swagger.models.auth.ApiKeyAuthDefinition;
|
|
||||||
import io.swagger.models.auth.OAuth2Definition;
|
|
||||||
import io.swagger.models.auth.SecuritySchemeDefinition;
|
|
||||||
import org.apache.commons.collections4.MapUtils;
|
|
||||||
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import static io.github.swagger2markup.internal.utils.MapUtils.toKeySet;
|
|
||||||
import static io.github.swagger2markup.spi.SecurityDocumentExtension.Context;
|
|
||||||
import static io.github.swagger2markup.spi.SecurityDocumentExtension.Position;
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Robert Winkler
|
|
||||||
*/
|
|
||||||
public class SecurityDocumentBuilder extends MarkupDocumentBuilder {
|
|
||||||
|
|
||||||
private static final String SECURITY_ANCHOR = "securityScheme";
|
|
||||||
private final String SECURITY;
|
|
||||||
private final String TYPE;
|
|
||||||
private final String NAME;
|
|
||||||
private final String IN;
|
|
||||||
private final String FLOW;
|
|
||||||
private final String AUTHORIZATION_URL;
|
|
||||||
private final String TOKEN_URL;
|
|
||||||
|
|
||||||
public SecurityDocumentBuilder(Swagger2MarkupConverter.Context context, Swagger2MarkupExtensionRegistry extensionRegistry, Path outputPath) {
|
|
||||||
super(context, extensionRegistry, outputPath);
|
|
||||||
|
|
||||||
ResourceBundle labels = ResourceBundle.getBundle("io/github/swagger2markup/lang/labels", config.getOutputLanguage().toLocale());
|
|
||||||
SECURITY = labels.getString("security");
|
|
||||||
TYPE = labels.getString("security_type");
|
|
||||||
NAME = labels.getString("security_name");
|
|
||||||
IN = labels.getString("security_in");
|
|
||||||
FLOW = labels.getString("security_flow");
|
|
||||||
AUTHORIZATION_URL = labels.getString("security_authorizationUrl");
|
|
||||||
TOKEN_URL = labels.getString("security_tokenUrl");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the security MarkupDocument.
|
|
||||||
*
|
|
||||||
* @return the security MarkupDocument
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public MarkupDocument build(){
|
|
||||||
Map<String, SecuritySchemeDefinition> definitions = globalContext.getSwagger().getSecurityDefinitions();
|
|
||||||
if (MapUtils.isNotEmpty(definitions)) {
|
|
||||||
applySecurityDocumentExtension(new Context(Position.DOCUMENT_BEFORE, this.markupDocBuilder));
|
|
||||||
buildSecurityTitle(SECURITY);
|
|
||||||
applySecurityDocumentExtension(new Context(Position.DOCUMENT_BEGIN, this.markupDocBuilder));
|
|
||||||
buildSecuritySchemeDefinitionsSection(definitions);
|
|
||||||
applySecurityDocumentExtension(new Context(Position.DOCUMENT_END, this.markupDocBuilder));
|
|
||||||
applySecurityDocumentExtension(new Context(Position.DOCUMENT_AFTER, this.markupDocBuilder));
|
|
||||||
}
|
|
||||||
return new MarkupDocument(markupDocBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildSecurityTitle(String title) {
|
|
||||||
this.markupDocBuilder.sectionTitleWithAnchorLevel1(title, SECURITY_ANCHOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildSecuritySchemeDefinitionsSection(Map<String, SecuritySchemeDefinition> securitySchemes) {
|
|
||||||
Set<String> securitySchemeNames = toKeySet(securitySchemes, null); // TODO : provide a dedicated ordering configuration for security schemes
|
|
||||||
for (String securitySchemeName : securitySchemeNames) {
|
|
||||||
SecuritySchemeDefinition securityScheme = securitySchemes.get(securitySchemeName);
|
|
||||||
applySecurityDocumentExtension(new Context(Position.SECURITY_SCHEME_BEFORE, markupDocBuilder, securitySchemeName, securityScheme));
|
|
||||||
buildSecuritySchemeDefinitionTitle(securitySchemeName);
|
|
||||||
applySecurityDocumentExtension(new Context(Position.SECURITY_SCHEME_BEGIN, markupDocBuilder, securitySchemeName, securityScheme));
|
|
||||||
buildDescriptionParagraph(securityScheme.getDescription(), this.markupDocBuilder);
|
|
||||||
buildSecurityScheme(securityScheme);
|
|
||||||
applySecurityDocumentExtension(new Context(Position.SECURITY_SCHEME_END, markupDocBuilder, securitySchemeName, securityScheme));
|
|
||||||
applySecurityDocumentExtension(new Context(Position.SECURITY_SCHEME_AFTER, markupDocBuilder, securitySchemeName, securityScheme));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private MarkupDocBuilder buildSecuritySchemeDefinitionTitle(String securitySchemeName) {
|
|
||||||
return markupDocBuilder.sectionTitleWithAnchorLevel2(securitySchemeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildSecurityScheme(SecuritySchemeDefinition securityScheme) {
|
|
||||||
String type = securityScheme.getType();
|
|
||||||
MarkupDocBuilder paragraph = copyMarkupDocBuilder();
|
|
||||||
|
|
||||||
paragraph.italicText(TYPE).textLine(COLON + type);
|
|
||||||
|
|
||||||
if (securityScheme instanceof ApiKeyAuthDefinition) {
|
|
||||||
paragraph.italicText(NAME).textLine(COLON + ((ApiKeyAuthDefinition) securityScheme).getName());
|
|
||||||
paragraph.italicText(IN).textLine(COLON + ((ApiKeyAuthDefinition) securityScheme).getIn());
|
|
||||||
|
|
||||||
markupDocBuilder.paragraph(paragraph.toString(), true);
|
|
||||||
} else if (securityScheme instanceof OAuth2Definition) {
|
|
||||||
OAuth2Definition oauth2Scheme = (OAuth2Definition) securityScheme;
|
|
||||||
String flow = oauth2Scheme.getFlow();
|
|
||||||
paragraph.italicText(FLOW).textLine(COLON + flow);
|
|
||||||
if (isNotBlank(oauth2Scheme.getAuthorizationUrl())) {
|
|
||||||
paragraph.italicText(AUTHORIZATION_URL).textLine(COLON + oauth2Scheme.getAuthorizationUrl());
|
|
||||||
}
|
|
||||||
if (isNotBlank(oauth2Scheme.getTokenUrl())) {
|
|
||||||
paragraph.italicText(TOKEN_URL).textLine(COLON + oauth2Scheme.getTokenUrl());
|
|
||||||
}
|
|
||||||
|
|
||||||
List<List<String>> cells = new ArrayList<>();
|
|
||||||
List<MarkupTableColumn> cols = Arrays.asList(
|
|
||||||
new MarkupTableColumn(NAME_COLUMN).withWidthRatio(3).withMarkupSpecifiers(MarkupLanguage.ASCIIDOC, ".^3"),
|
|
||||||
new MarkupTableColumn(DESCRIPTION_COLUMN).withWidthRatio(17).withMarkupSpecifiers(MarkupLanguage.ASCIIDOC, ".^17"));
|
|
||||||
for (Map.Entry<String, String> scope : oauth2Scheme.getScopes().entrySet()) {
|
|
||||||
List<String> content = Arrays.asList(scope.getKey(), scope.getValue());
|
|
||||||
cells.add(content);
|
|
||||||
}
|
|
||||||
|
|
||||||
markupDocBuilder.paragraph(paragraph.toString(), true);
|
|
||||||
markupDocBuilder.tableWithColumnSpecs(cols, cells);
|
|
||||||
} else {
|
|
||||||
markupDocBuilder.paragraph(paragraph.toString(), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Apply extension context to all SecurityContentExtension
|
|
||||||
*
|
|
||||||
* @param context context
|
|
||||||
*/
|
|
||||||
private void applySecurityDocumentExtension(Context context) {
|
|
||||||
for (SecurityDocumentExtension extension : extensionRegistry.getSecurityDocumentExtensions()) {
|
|
||||||
extension.apply(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,300 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Robert Winkler
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.github.swagger2markup.internal.utils;
|
|
||||||
|
|
||||||
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
|
|
||||||
import io.github.swagger2markup.model.PathOperation;
|
|
||||||
import io.swagger.models.*;
|
|
||||||
import io.swagger.models.parameters.*;
|
|
||||||
import io.swagger.models.properties.ArrayProperty;
|
|
||||||
import io.swagger.models.properties.MapProperty;
|
|
||||||
import io.swagger.models.properties.Property;
|
|
||||||
import io.swagger.models.properties.RefProperty;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ExamplesUtil {
|
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(ExamplesUtil.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a Map of response examples
|
|
||||||
*
|
|
||||||
* @param generateMissingExamples specifies the missing examples should be generated
|
|
||||||
* @param operation the Swagger Operation
|
|
||||||
* @param definitions the map of definitions
|
|
||||||
* @param markupDocBuilder the markup builder
|
|
||||||
* @return map containing response examples.
|
|
||||||
*/
|
|
||||||
public static Map<String, Object> generateResponseExampleMap(boolean generateMissingExamples, Operation operation, Map<String, Model> definitions, MarkupDocBuilder markupDocBuilder) {
|
|
||||||
Map<String, Object> examples = new LinkedHashMap<>();
|
|
||||||
Map<String, Response> responses = operation.getResponses();
|
|
||||||
if (responses != null)
|
|
||||||
for (Map.Entry<String, Response> responseEntry : responses.entrySet()) {
|
|
||||||
Response response = responseEntry.getValue();
|
|
||||||
Object example = response.getExamples();
|
|
||||||
if (example == null) {
|
|
||||||
Property schema = response.getSchema();
|
|
||||||
if (schema != null) {
|
|
||||||
example = schema.getExample();
|
|
||||||
|
|
||||||
if (example == null && schema instanceof RefProperty) {
|
|
||||||
String simpleRef = ((RefProperty) schema).getSimpleRef();
|
|
||||||
example = generateExampleForRefModel(generateMissingExamples, simpleRef, definitions, markupDocBuilder);
|
|
||||||
}
|
|
||||||
if (example == null && generateMissingExamples) {
|
|
||||||
example = PropertyUtils.generateExample(schema, markupDocBuilder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (example != null)
|
|
||||||
examples.put(responseEntry.getKey(), example);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return examples;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates examples for request
|
|
||||||
*
|
|
||||||
* @param generateMissingExamples specifies the missing examples should be generated
|
|
||||||
* @param pathOperation the Swagger Operation
|
|
||||||
* @param definitions the map of definitions
|
|
||||||
* @param markupDocBuilder the markup builder
|
|
||||||
* @return an Optional with the example content
|
|
||||||
*/
|
|
||||||
public static Map<String, Object> generateRequestExampleMap(boolean generateMissingExamples, PathOperation pathOperation, Map<String, Model> definitions, MarkupDocBuilder markupDocBuilder) {
|
|
||||||
Operation operation = pathOperation.getOperation();
|
|
||||||
List<Parameter> parameters = operation.getParameters();
|
|
||||||
Map<String, Object> examples = new LinkedHashMap<>();
|
|
||||||
|
|
||||||
// Path example should always be included (if generateMissingExamples):
|
|
||||||
if (generateMissingExamples)
|
|
||||||
examples.put("path", pathOperation.getPath());
|
|
||||||
for (Parameter parameter : parameters) {
|
|
||||||
Object example = null;
|
|
||||||
if (parameter instanceof BodyParameter) {
|
|
||||||
example = ((BodyParameter) parameter).getExamples();
|
|
||||||
if (example == null) {
|
|
||||||
Model schema = ((BodyParameter) parameter).getSchema();
|
|
||||||
if (schema instanceof RefModel) {
|
|
||||||
String simpleRef = ((RefModel) schema).getSimpleRef();
|
|
||||||
example = generateExampleForRefModel(generateMissingExamples, simpleRef, definitions, markupDocBuilder);
|
|
||||||
} else if (generateMissingExamples) {
|
|
||||||
if (schema instanceof ComposedModel) {
|
|
||||||
example = exampleMapForProperties(getPropertiesForComposedModel(
|
|
||||||
(ComposedModel) schema, definitions), definitions, markupDocBuilder);
|
|
||||||
} else if (schema instanceof ArrayModel) {
|
|
||||||
example = generateExampleForArrayModel((ArrayModel) schema, definitions, markupDocBuilder);
|
|
||||||
} else {
|
|
||||||
example = schema.getExample();
|
|
||||||
if (example == null) {
|
|
||||||
example = exampleMapForProperties(schema.getProperties(), definitions, markupDocBuilder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (parameter instanceof AbstractSerializableParameter) {
|
|
||||||
if (generateMissingExamples) {
|
|
||||||
Object abstractSerializableParameterExample;
|
|
||||||
abstractSerializableParameterExample = ((AbstractSerializableParameter) parameter).getExample();
|
|
||||||
if (abstractSerializableParameterExample == null) {
|
|
||||||
Property item = ((AbstractSerializableParameter) parameter).getItems();
|
|
||||||
if (item != null) {
|
|
||||||
abstractSerializableParameterExample = item.getExample();
|
|
||||||
if (abstractSerializableParameterExample == null) {
|
|
||||||
abstractSerializableParameterExample = PropertyUtils.generateExample(item, markupDocBuilder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (abstractSerializableParameterExample == null) {
|
|
||||||
abstractSerializableParameterExample = ParameterUtils.generateExample((AbstractSerializableParameter)parameter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (parameter instanceof PathParameter) {
|
|
||||||
String pathExample = (String) examples.get("path");
|
|
||||||
pathExample = pathExample.replace('{' + parameter.getName() + '}', String.valueOf(abstractSerializableParameterExample));
|
|
||||||
example = pathExample;
|
|
||||||
} else {
|
|
||||||
example = abstractSerializableParameterExample;
|
|
||||||
}
|
|
||||||
if (parameter instanceof QueryParameter) {
|
|
||||||
//noinspection unchecked
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Map<String, Object> queryExampleMap = (Map<String, Object>) examples.get("query");
|
|
||||||
if (queryExampleMap == null) {
|
|
||||||
queryExampleMap = new LinkedHashMap<>();
|
|
||||||
}
|
|
||||||
queryExampleMap.put(parameter.getName(), abstractSerializableParameterExample);
|
|
||||||
example = queryExampleMap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (parameter instanceof RefParameter) {
|
|
||||||
String simpleRef = ((RefParameter) parameter).getSimpleRef();
|
|
||||||
example = generateExampleForRefModel(generateMissingExamples, simpleRef, definitions, markupDocBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (example != null)
|
|
||||||
examples.put(parameter.getIn(), example);
|
|
||||||
}
|
|
||||||
|
|
||||||
return examples;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates an example object from a simple reference
|
|
||||||
*
|
|
||||||
* @param generateMissingExamples specifies the missing examples should be generated
|
|
||||||
* @param simpleRef the simple reference string
|
|
||||||
* @param definitions the map of definitions
|
|
||||||
* @param markupDocBuilder the markup builder
|
|
||||||
* @return returns an Object or Map of examples
|
|
||||||
*/
|
|
||||||
public static Object generateExampleForRefModel(boolean generateMissingExamples, String simpleRef, Map<String, Model> definitions, MarkupDocBuilder markupDocBuilder) {
|
|
||||||
Model model = definitions.get(simpleRef);
|
|
||||||
Object example = null;
|
|
||||||
if (model != null) {
|
|
||||||
example = model.getExample();
|
|
||||||
if (example == null && generateMissingExamples) {
|
|
||||||
if (model instanceof ComposedModel) {
|
|
||||||
example = exampleMapForProperties(getPropertiesForComposedModel((ComposedModel) model, definitions), definitions, markupDocBuilder);
|
|
||||||
} else {
|
|
||||||
example = exampleMapForProperties(model.getProperties(), definitions, markupDocBuilder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return example;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Map<String, Property> getPropertiesForComposedModel(ComposedModel model, Map<String, Model> definitions) {
|
|
||||||
Map<String, Property> combinedProperties;
|
|
||||||
if (model.getParent() instanceof RefModel) {
|
|
||||||
Map<String, Property> parentProperties = definitions.get(((RefModel) model.getParent()).getSimpleRef()).getProperties();
|
|
||||||
if (parentProperties == null) {
|
|
||||||
return null;
|
|
||||||
} else {
|
|
||||||
combinedProperties = new LinkedHashMap<>(parentProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
combinedProperties = new LinkedHashMap<>(model.getParent().getProperties());
|
|
||||||
}
|
|
||||||
Map<String, Property> childProperties;
|
|
||||||
if (model.getChild() instanceof RefModel) {
|
|
||||||
childProperties = definitions.get(((RefModel) model.getChild()).getSimpleRef()).getProperties();
|
|
||||||
} else {
|
|
||||||
childProperties = model.getChild().getProperties();
|
|
||||||
}
|
|
||||||
if (childProperties != null) {
|
|
||||||
combinedProperties.putAll(childProperties);
|
|
||||||
}
|
|
||||||
return combinedProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a map of examples from a map of properties. If defined examples are found, those are used. Otherwise,
|
|
||||||
* examples are generated from the type.
|
|
||||||
*
|
|
||||||
* @param properties the map of properties
|
|
||||||
* @param definitions the map of definitions
|
|
||||||
* @param markupDocBuilder the markup builder
|
|
||||||
*
|
|
||||||
* @return a Map of examples
|
|
||||||
*/
|
|
||||||
public static Map<String, Object> exampleMapForProperties(Map<String, Property> properties, Map<String, Model> definitions, MarkupDocBuilder markupDocBuilder) {
|
|
||||||
Map<String, Object> exampleMap = new LinkedHashMap<>();
|
|
||||||
if (properties != null) {
|
|
||||||
for (Map.Entry<String, Property> property : properties.entrySet()) {
|
|
||||||
Object exampleObject = property.getValue().getExample();
|
|
||||||
if (exampleObject == null) {
|
|
||||||
if (property.getValue() instanceof RefProperty) {
|
|
||||||
exampleObject = generateExampleForRefModel(true, ((RefProperty) property.getValue()).getSimpleRef(), definitions, markupDocBuilder);
|
|
||||||
} else if (property.getValue() instanceof ArrayProperty) {
|
|
||||||
exampleObject = generateExampleForArrayProperty((ArrayProperty) property.getValue(), definitions, markupDocBuilder);
|
|
||||||
} else if (property.getValue() instanceof MapProperty) {
|
|
||||||
exampleObject = generateExampleForMapProperty((MapProperty) property.getValue(), markupDocBuilder);
|
|
||||||
}
|
|
||||||
if (exampleObject == null) {
|
|
||||||
Property valueProperty = property.getValue();
|
|
||||||
exampleObject = PropertyUtils.generateExample(valueProperty, markupDocBuilder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exampleMap.put(property.getKey(), exampleObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return exampleMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object generateExampleForMapProperty(MapProperty property, MarkupDocBuilder markupDocBuilder) {
|
|
||||||
if (property.getExample() != null) {
|
|
||||||
return property.getExample();
|
|
||||||
}
|
|
||||||
Map<String, Object> exampleMap = new LinkedHashMap<>();
|
|
||||||
Property valueProperty = property.getAdditionalProperties();
|
|
||||||
if (valueProperty.getExample() != null) {
|
|
||||||
return valueProperty.getExample();
|
|
||||||
}
|
|
||||||
exampleMap.put("string", PropertyUtils.generateExample(valueProperty, markupDocBuilder));
|
|
||||||
return exampleMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Object generateExampleForArrayModel(ArrayModel model, Map<String, Model> definitions, MarkupDocBuilder markupDocBuilder) {
|
|
||||||
if (model.getExample() != null) {
|
|
||||||
return model.getExample();
|
|
||||||
} else if (model.getProperties() != null) {
|
|
||||||
return new Object[]{exampleMapForProperties(model.getProperties(), definitions, markupDocBuilder)};
|
|
||||||
} else {
|
|
||||||
Property itemProperty = model.getItems();
|
|
||||||
if (itemProperty.getExample() != null) {
|
|
||||||
return new Object[]{itemProperty.getExample()};
|
|
||||||
} else if (itemProperty instanceof ArrayProperty) {
|
|
||||||
return new Object[]{generateExampleForArrayProperty((ArrayProperty) itemProperty, definitions, markupDocBuilder)};
|
|
||||||
} else if (itemProperty instanceof RefProperty) {
|
|
||||||
return new Object[]{generateExampleForRefModel(true, ((RefProperty) itemProperty).getSimpleRef(), definitions, markupDocBuilder)};
|
|
||||||
} else {
|
|
||||||
return new Object[]{PropertyUtils.generateExample(itemProperty, markupDocBuilder)};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates examples from an ArrayProperty
|
|
||||||
*
|
|
||||||
* @param value ArrayProperty
|
|
||||||
* @param definitions map of definitions
|
|
||||||
* @param markupDocBuilder the markup builder
|
|
||||||
* @return array of Object
|
|
||||||
*/
|
|
||||||
public static Object[] generateExampleForArrayProperty(ArrayProperty value, Map<String, Model> definitions, MarkupDocBuilder markupDocBuilder) {
|
|
||||||
Property property = value.getItems();
|
|
||||||
if (property.getExample() != null) {
|
|
||||||
return new Object[]{property.getExample()};
|
|
||||||
} else if (property instanceof ArrayProperty) {
|
|
||||||
return new Object[]{generateExampleForArrayProperty((ArrayProperty) property, definitions, markupDocBuilder)};
|
|
||||||
} else if (property instanceof RefProperty) {
|
|
||||||
return new Object[]{generateExampleForRefModel(true, ((RefProperty) property).getSimpleRef(), definitions, markupDocBuilder)};
|
|
||||||
} else {
|
|
||||||
return new Object[]{PropertyUtils.generateExample(property, markupDocBuilder)};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Robert Winkler
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package io.github.swagger2markup.internal.utils;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import io.github.swagger2markup.internal.type.*;
|
|
||||||
import io.swagger.models.Model;
|
|
||||||
import io.swagger.models.parameters.AbstractSerializableParameter;
|
|
||||||
import io.swagger.models.parameters.BodyParameter;
|
|
||||||
import io.swagger.models.parameters.Parameter;
|
|
||||||
import io.swagger.models.parameters.RefParameter;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.apache.commons.lang3.Validate;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
public final class ParameterUtils {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the type of a parameter, or otherwise null
|
|
||||||
*
|
|
||||||
* @param parameter the parameter
|
|
||||||
* @param definitionDocumentResolver the defintion document resolver
|
|
||||||
* @return the type of the parameter, or otherwise null
|
|
||||||
*/
|
|
||||||
public static Type getType(Parameter parameter, Map<String, Model> definitions, Function<String, String> definitionDocumentResolver){
|
|
||||||
Validate.notNull(parameter, "parameter must not be null!");
|
|
||||||
Type type = null;
|
|
||||||
|
|
||||||
if(parameter instanceof BodyParameter){
|
|
||||||
BodyParameter bodyParameter = (BodyParameter)parameter;
|
|
||||||
Model model = bodyParameter.getSchema();
|
|
||||||
|
|
||||||
if(model != null){
|
|
||||||
type = ModelUtils.getType(model, definitions, definitionDocumentResolver);
|
|
||||||
}else{
|
|
||||||
type = new BasicType("string", null);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else if(parameter instanceof AbstractSerializableParameter){
|
|
||||||
AbstractSerializableParameter serializableParameter = (AbstractSerializableParameter)parameter;
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
List<String> enums = serializableParameter.getEnum();
|
|
||||||
|
|
||||||
if(CollectionUtils.isNotEmpty(enums)){
|
|
||||||
type = new EnumType(null, enums);
|
|
||||||
}else{
|
|
||||||
type = new BasicType(serializableParameter.getType(), null, serializableParameter.getFormat());
|
|
||||||
}
|
|
||||||
if(serializableParameter.getType().equals("array")){
|
|
||||||
String collectionFormat = serializableParameter.getCollectionFormat();
|
|
||||||
|
|
||||||
type = new ArrayType(null, PropertyUtils.getType(serializableParameter.getItems(), definitionDocumentResolver), collectionFormat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(parameter instanceof RefParameter){
|
|
||||||
String refName = ((RefParameter)parameter).getSimpleRef();
|
|
||||||
|
|
||||||
type = new RefType(definitionDocumentResolver.apply(refName), new ObjectType(refName, null /* FIXME, not used for now */));
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the default value of a parameter, or otherwise returns null
|
|
||||||
*
|
|
||||||
* @param parameter the parameter
|
|
||||||
* @return the default value of the parameter, or otherwise null
|
|
||||||
*/
|
|
||||||
public static Object getDefaultValue(Parameter parameter){
|
|
||||||
Validate.notNull(parameter, "parameter must not be null!");
|
|
||||||
Object defaultValue = null;
|
|
||||||
|
|
||||||
if(parameter instanceof AbstractSerializableParameter){
|
|
||||||
AbstractSerializableParameter serializableParameter = (AbstractSerializableParameter)parameter;
|
|
||||||
defaultValue = serializableParameter.getDefaultValue();
|
|
||||||
}
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a default example value for parameter.
|
|
||||||
*
|
|
||||||
* @param parameter parameter
|
|
||||||
* @return a generated example for the parameter
|
|
||||||
*/
|
|
||||||
public static Object generateExample(AbstractSerializableParameter parameter) {
|
|
||||||
switch (parameter.getType()) {
|
|
||||||
case "integer":
|
|
||||||
return 0;
|
|
||||||
case "number":
|
|
||||||
return 0.0;
|
|
||||||
case "boolean":
|
|
||||||
return true;
|
|
||||||
case "string":
|
|
||||||
return "string";
|
|
||||||
default:
|
|
||||||
return parameter.getType();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,325 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Robert Winkler
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package io.github.swagger2markup.internal.utils;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import io.github.swagger2markup.internal.type.*;
|
|
||||||
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
|
|
||||||
import io.swagger.models.properties.*;
|
|
||||||
import io.swagger.models.refs.RefFormat;
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.apache.commons.lang3.Validate;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
|
||||||
|
|
||||||
public final class PropertyUtils {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the type and format of a property.
|
|
||||||
*
|
|
||||||
* @param property the property
|
|
||||||
* @param definitionDocumentResolver the definition document resolver
|
|
||||||
* @return the type of the property
|
|
||||||
*/
|
|
||||||
public static Type getType(Property property, Function<String, String> definitionDocumentResolver) {
|
|
||||||
Validate.notNull(property, "property must not be null");
|
|
||||||
Type type;
|
|
||||||
if (property instanceof RefProperty) {
|
|
||||||
RefProperty refProperty = (RefProperty) property;
|
|
||||||
if (refProperty.getRefFormat() == RefFormat.RELATIVE)
|
|
||||||
type = new ObjectType(refProperty.getTitle(), null); // FIXME : Workaround for https://github.com/swagger-api/swagger-parser/issues/177
|
|
||||||
else
|
|
||||||
type = new RefType(definitionDocumentResolver.apply(refProperty.getSimpleRef()), new ObjectType(refProperty.getSimpleRef(), null /* FIXME, not used for now */));
|
|
||||||
} else if (property instanceof ArrayProperty) {
|
|
||||||
ArrayProperty arrayProperty = (ArrayProperty) property;
|
|
||||||
Property items = arrayProperty.getItems();
|
|
||||||
if (items == null)
|
|
||||||
type = new ArrayType(arrayProperty.getTitle(), new ObjectType(null, null)); // FIXME : Workaround for Swagger parser issue with composed models (https://github.com/Swagger2Markup/swagger2markup/issues/150)
|
|
||||||
else
|
|
||||||
type = new ArrayType(arrayProperty.getTitle(), getType(items, definitionDocumentResolver));
|
|
||||||
} else if (property instanceof MapProperty) {
|
|
||||||
MapProperty mapProperty = (MapProperty) property;
|
|
||||||
Property additionalProperties = mapProperty.getAdditionalProperties();
|
|
||||||
if (additionalProperties == null)
|
|
||||||
type = new MapType(mapProperty.getTitle(), new ObjectType(null, null)); // FIXME : Workaround for Swagger parser issue with composed models (https://github.com/Swagger2Markup/swagger2markup/issues/150)
|
|
||||||
else
|
|
||||||
type = new MapType(mapProperty.getTitle(), getType(additionalProperties, definitionDocumentResolver));
|
|
||||||
} else if (property instanceof StringProperty) {
|
|
||||||
StringProperty stringProperty = (StringProperty) property;
|
|
||||||
List<String> enums = stringProperty.getEnum();
|
|
||||||
if (CollectionUtils.isNotEmpty(enums)) {
|
|
||||||
type = new EnumType(stringProperty.getTitle(), enums);
|
|
||||||
} else {
|
|
||||||
type = new BasicType(stringProperty.getType(), stringProperty.getTitle());
|
|
||||||
}
|
|
||||||
} else if (property instanceof ObjectProperty) {
|
|
||||||
type = new ObjectType(property.getTitle(), ((ObjectProperty) property).getProperties());
|
|
||||||
} else {
|
|
||||||
if (isNotBlank(property.getFormat())) {
|
|
||||||
type = new BasicType(property.getType(), property.getTitle(), property.getFormat());
|
|
||||||
} else {
|
|
||||||
type = new BasicType(property.getType(), property.getTitle());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the default value of a property, or otherwise returns null.
|
|
||||||
*
|
|
||||||
* @param property the property
|
|
||||||
* @return the default value of the property, or otherwise null
|
|
||||||
*/
|
|
||||||
public static Object getDefaultValue(Property property) {
|
|
||||||
Validate.notNull(property, "property must not be null");
|
|
||||||
Object defaultValue = null;
|
|
||||||
|
|
||||||
if (property instanceof BooleanProperty) {
|
|
||||||
BooleanProperty booleanProperty = (BooleanProperty) property;
|
|
||||||
defaultValue = booleanProperty.getDefault();
|
|
||||||
} else if (property instanceof StringProperty) {
|
|
||||||
StringProperty stringProperty = (StringProperty) property;
|
|
||||||
defaultValue = stringProperty.getDefault();
|
|
||||||
} else if (property instanceof DoubleProperty) {
|
|
||||||
DoubleProperty doubleProperty = (DoubleProperty) property;
|
|
||||||
defaultValue = doubleProperty.getDefault();
|
|
||||||
} else if (property instanceof FloatProperty) {
|
|
||||||
FloatProperty floatProperty = (FloatProperty) property;
|
|
||||||
defaultValue = floatProperty.getDefault();
|
|
||||||
} else if (property instanceof IntegerProperty) {
|
|
||||||
IntegerProperty integerProperty = (IntegerProperty) property;
|
|
||||||
defaultValue = integerProperty.getDefault();
|
|
||||||
} else if (property instanceof LongProperty) {
|
|
||||||
LongProperty longProperty = (LongProperty) property;
|
|
||||||
defaultValue = longProperty.getDefault();
|
|
||||||
} else if (property instanceof UUIDProperty) {
|
|
||||||
UUIDProperty uuidProperty = (UUIDProperty) property;
|
|
||||||
defaultValue = uuidProperty.getDefault();
|
|
||||||
}
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the minLength of a property, or otherwise returns null.
|
|
||||||
*
|
|
||||||
* @param property the property
|
|
||||||
* @return the minLength of the property, or otherwise null
|
|
||||||
*/
|
|
||||||
public static Integer getMinlength(Property property) {
|
|
||||||
Validate.notNull(property, "property must not be null");
|
|
||||||
Integer minLength = null;
|
|
||||||
|
|
||||||
if (property instanceof StringProperty) {
|
|
||||||
StringProperty stringProperty = (StringProperty) property;
|
|
||||||
minLength = stringProperty.getMinLength();
|
|
||||||
} else if (property instanceof UUIDProperty) {
|
|
||||||
UUIDProperty uuidProperty = (UUIDProperty) property;
|
|
||||||
minLength = uuidProperty.getMinLength();
|
|
||||||
}
|
|
||||||
return minLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the maxLength of a property, or otherwise returns null.
|
|
||||||
*
|
|
||||||
* @param property the property
|
|
||||||
* @return the maxLength of the property, or otherwise null
|
|
||||||
*/
|
|
||||||
public static Integer getMaxlength(Property property) {
|
|
||||||
Validate.notNull(property, "property must not be null");
|
|
||||||
Integer maxLength = null;
|
|
||||||
|
|
||||||
if (property instanceof StringProperty) {
|
|
||||||
StringProperty stringProperty = (StringProperty) property;
|
|
||||||
maxLength = stringProperty.getMaxLength();
|
|
||||||
} else if (property instanceof UUIDProperty) {
|
|
||||||
UUIDProperty uuidProperty = (UUIDProperty) property;
|
|
||||||
maxLength = uuidProperty.getMaxLength();
|
|
||||||
}
|
|
||||||
return maxLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the pattern of a property, or otherwise returns null.
|
|
||||||
*
|
|
||||||
* @param property the property
|
|
||||||
* @return the pattern of the property, or otherwise null
|
|
||||||
*/
|
|
||||||
public static String getPattern(Property property) {
|
|
||||||
Validate.notNull(property, "property must not be null");
|
|
||||||
String pattern = null;
|
|
||||||
|
|
||||||
if (property instanceof StringProperty) {
|
|
||||||
StringProperty stringProperty = (StringProperty) property;
|
|
||||||
pattern = stringProperty.getPattern();
|
|
||||||
} else if (property instanceof UUIDProperty) {
|
|
||||||
UUIDProperty uuidProperty = (UUIDProperty) property;
|
|
||||||
pattern = uuidProperty.getPattern();
|
|
||||||
}
|
|
||||||
return pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the minimum value of a property, or otherwise returns null.
|
|
||||||
*
|
|
||||||
* @param property the property
|
|
||||||
* @return the minimum value of the property, or otherwise null
|
|
||||||
*/
|
|
||||||
public static Double getMin(Property property) {
|
|
||||||
Validate.notNull(property, "property must not be null");
|
|
||||||
Double min = null;
|
|
||||||
|
|
||||||
if (property instanceof DoubleProperty) {
|
|
||||||
DoubleProperty doubleProperty = (DoubleProperty) property;
|
|
||||||
min = doubleProperty.getMinimum();
|
|
||||||
} else if (property instanceof FloatProperty) {
|
|
||||||
FloatProperty floatProperty = (FloatProperty) property;
|
|
||||||
min = floatProperty.getMinimum();
|
|
||||||
} else if (property instanceof IntegerProperty) {
|
|
||||||
IntegerProperty integerProperty = (IntegerProperty) property;
|
|
||||||
min = integerProperty.getMinimum();
|
|
||||||
} else if (property instanceof LongProperty) {
|
|
||||||
LongProperty longProperty = (LongProperty) property;
|
|
||||||
min = longProperty.getMinimum();
|
|
||||||
}
|
|
||||||
return min;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the minimum value of a property, or otherwise returns null.
|
|
||||||
*
|
|
||||||
* @param property the property
|
|
||||||
* @return the minimum value of the property, or otherwise null
|
|
||||||
*/
|
|
||||||
public static Double getMax(Property property) {
|
|
||||||
Validate.notNull(property, "property must not be null");
|
|
||||||
Double max = null;
|
|
||||||
|
|
||||||
if (property instanceof DoubleProperty) {
|
|
||||||
DoubleProperty doubleProperty = (DoubleProperty) property;
|
|
||||||
max = doubleProperty.getMaximum();
|
|
||||||
} else if (property instanceof FloatProperty) {
|
|
||||||
FloatProperty floatProperty = (FloatProperty) property;
|
|
||||||
max = floatProperty.getMaximum();
|
|
||||||
} else if (property instanceof IntegerProperty) {
|
|
||||||
IntegerProperty integerProperty = (IntegerProperty) property;
|
|
||||||
max = integerProperty.getMaximum();
|
|
||||||
} else if (property instanceof LongProperty) {
|
|
||||||
LongProperty longProperty = (LongProperty) property;
|
|
||||||
max = longProperty.getMaximum();
|
|
||||||
}
|
|
||||||
return max;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return example display string for the given {@code property}.
|
|
||||||
*
|
|
||||||
* @param generateMissingExamples specifies if missing examples should be generated
|
|
||||||
* @param property property
|
|
||||||
* @param markupDocBuilder doc builder
|
|
||||||
* @return property example display string
|
|
||||||
*/
|
|
||||||
public static Object getExample(boolean generateMissingExamples, Property property, MarkupDocBuilder markupDocBuilder) {
|
|
||||||
Validate.notNull(property, "property must not be null");
|
|
||||||
Object examplesValue = null;
|
|
||||||
if (property.getExample() != null) {
|
|
||||||
examplesValue = property.getExample();
|
|
||||||
} else if (property instanceof MapProperty) {
|
|
||||||
Property additionalProperty = ((MapProperty) property).getAdditionalProperties();
|
|
||||||
if (additionalProperty.getExample() != null) {
|
|
||||||
examplesValue = additionalProperty.getExample();
|
|
||||||
} else if (generateMissingExamples) {
|
|
||||||
Map<String, Object> exampleMap = new HashMap<>();
|
|
||||||
exampleMap.put("string", generateExample(additionalProperty, markupDocBuilder));
|
|
||||||
examplesValue = exampleMap;
|
|
||||||
}
|
|
||||||
} else if (property instanceof ArrayProperty) {
|
|
||||||
if (generateMissingExamples) {
|
|
||||||
Property itemProperty = ((ArrayProperty) property).getItems();
|
|
||||||
List<Object> exampleArray = new ArrayList<>();
|
|
||||||
exampleArray.add(generateExample(itemProperty, markupDocBuilder));
|
|
||||||
examplesValue = exampleArray;
|
|
||||||
}
|
|
||||||
} else if (generateMissingExamples) {
|
|
||||||
examplesValue = generateExample(property, markupDocBuilder);
|
|
||||||
}
|
|
||||||
|
|
||||||
return examplesValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a default example value for property.
|
|
||||||
*
|
|
||||||
* @param property property
|
|
||||||
* @param markupDocBuilder doc builder
|
|
||||||
* @return a generated example for the property
|
|
||||||
*/
|
|
||||||
public static Object generateExample(Property property, MarkupDocBuilder markupDocBuilder) {
|
|
||||||
switch (property.getType()) {
|
|
||||||
case "integer":
|
|
||||||
return 0;
|
|
||||||
case "number":
|
|
||||||
return 0.0;
|
|
||||||
case "boolean":
|
|
||||||
return true;
|
|
||||||
case "string":
|
|
||||||
return "string";
|
|
||||||
case "ref":
|
|
||||||
if (property instanceof RefProperty) {
|
|
||||||
return markupDocBuilder.copy(false).crossReference(((RefProperty) property).getSimpleRef()).toString();
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return property.getType();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a string {@code value} to specified {@code type}.
|
|
||||||
*
|
|
||||||
* @param value value to convert
|
|
||||||
* @param type target conversion type
|
|
||||||
* @return converted value as object
|
|
||||||
*/
|
|
||||||
public static Object convertExample(String value, String type) {
|
|
||||||
if (value == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
switch (type) {
|
|
||||||
case "integer":
|
|
||||||
return Integer.valueOf(value);
|
|
||||||
case "number":
|
|
||||||
return Float.valueOf(value);
|
|
||||||
case "boolean":
|
|
||||||
return Boolean.valueOf(value);
|
|
||||||
case "string":
|
|
||||||
return value;
|
|
||||||
default:
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
throw new RuntimeException(String.format("Value '%s' cannot be converted to '%s'", value, type), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Robert Winkler
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package io.github.swagger2markup.internal.utils;
|
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import com.google.common.collect.Multimap;
|
|
||||||
import com.google.common.collect.MultimapBuilder;
|
|
||||||
import com.google.common.collect.Ordering;
|
|
||||||
import io.github.swagger2markup.model.PathOperation;
|
|
||||||
import io.swagger.models.Tag;
|
|
||||||
import org.apache.commons.lang3.Validate;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class TagUtils {
|
|
||||||
|
|
||||||
private static Logger LOG = LoggerFactory.getLogger(TagUtils.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts the global Tag list into a Map where the tag name is the key and the Tag the value.
|
|
||||||
*
|
|
||||||
* @param tags the List of tags
|
|
||||||
* @return the Map of tags
|
|
||||||
*/
|
|
||||||
public static Map<String, Tag> convertTagsListToMap(List<Tag> tags) {
|
|
||||||
if (tags == null) {
|
|
||||||
tags = new ArrayList<>();
|
|
||||||
}
|
|
||||||
Map<String, Tag> tagsMap = new HashMap<>();
|
|
||||||
for (Tag tag : tags) tagsMap.put(tag.getName(), tag);
|
|
||||||
return tagsMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the optional description of a tag.
|
|
||||||
*
|
|
||||||
* @param tagsMap the Map of tags
|
|
||||||
* @param tagName the name of the tag
|
|
||||||
* @return the optional description of the tag
|
|
||||||
*/
|
|
||||||
public static Optional<String> getTagDescription(Map<String, Tag> tagsMap, String tagName) {
|
|
||||||
Tag tag = tagsMap.get(tagName);
|
|
||||||
if(tag != null){
|
|
||||||
return Optional.fromNullable(tag.getDescription());
|
|
||||||
}
|
|
||||||
return Optional.absent();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Groups the operations by tag. The key of the Multimap is the tag name.
|
|
||||||
* The value of the Multimap is a PathOperation
|
|
||||||
*
|
|
||||||
* @param allOperations all operations
|
|
||||||
* @param tagOrdering comparator for tags
|
|
||||||
* @param operationOrdering comparator for operations, for a given tag
|
|
||||||
* @return Operations grouped by Tag
|
|
||||||
*/
|
|
||||||
public static Multimap<String, PathOperation> groupOperationsByTag(Set<PathOperation> allOperations, Comparator<String> tagOrdering, Comparator<PathOperation> operationOrdering) {
|
|
||||||
MultimapBuilder.MultimapBuilderWithKeys<String> multimapBuilderWithKeys;
|
|
||||||
|
|
||||||
if (tagOrdering == null)
|
|
||||||
multimapBuilderWithKeys = MultimapBuilder.SortedSetMultimapBuilder.treeKeys(Ordering.<String>natural()); // FIXME as-is sorting not supported because of limitations in MultiMap::hashkeys(). Replaced with Ordering.natural()
|
|
||||||
else
|
|
||||||
multimapBuilderWithKeys = MultimapBuilder.SortedSetMultimapBuilder.treeKeys(tagOrdering);
|
|
||||||
|
|
||||||
Multimap<String, PathOperation> operationsGroupedByTag;
|
|
||||||
if (operationOrdering == null)
|
|
||||||
operationsGroupedByTag = multimapBuilderWithKeys.hashSetValues().build();
|
|
||||||
else
|
|
||||||
operationsGroupedByTag = multimapBuilderWithKeys.treeSetValues(operationOrdering).build();
|
|
||||||
|
|
||||||
for (PathOperation operation : allOperations) {
|
|
||||||
List<String> tags = operation.getOperation().getTags();
|
|
||||||
Validate.notEmpty(tags, "Can't GroupBy.TAGS > Operation '%s' has not tags", operation);
|
|
||||||
for (String tag : tags) {
|
|
||||||
if (LOG.isInfoEnabled()) {
|
|
||||||
LOG.info("Added path operation '{}' to tag '{}'", operation, tag);
|
|
||||||
}
|
|
||||||
operationsGroupedByTag.put(tag, operation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return operationsGroupedByTag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Robert Winkler
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.github.swagger2markup.model;
|
|
||||||
|
|
||||||
import io.swagger.models.HttpMethod;
|
|
||||||
import io.swagger.models.Operation;
|
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
|
||||||
|
|
||||||
public class PathOperation {
|
|
||||||
|
|
||||||
protected HttpMethod method;
|
|
||||||
protected String path;
|
|
||||||
protected Operation operation;
|
|
||||||
|
|
||||||
public PathOperation(HttpMethod method, String path, Operation operation) {
|
|
||||||
this.method = method;
|
|
||||||
this.path = path;
|
|
||||||
this.operation = operation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HttpMethod getMethod() {
|
|
||||||
return method;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPath() {
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the display title for an operation
|
|
||||||
* @return the operation title
|
|
||||||
*/
|
|
||||||
public String getTitle() {
|
|
||||||
String operationName = operation.getSummary();
|
|
||||||
if (isBlank(operationName)) {
|
|
||||||
operationName = getMethod().toString() + " " + getPath();
|
|
||||||
}
|
|
||||||
return operationName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an unique id for the operation.<br>
|
|
||||||
* Use {@code <operation id>}, then {@code <operation path> lowercase(<operation method>)} if operation id is not set.
|
|
||||||
*
|
|
||||||
* @return operation unique id
|
|
||||||
*/
|
|
||||||
public String getId() {
|
|
||||||
String id = operation.getOperationId();
|
|
||||||
|
|
||||||
if (id == null)
|
|
||||||
id = getPath() + " " + getMethod().toString().toLowerCase();
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Operation getOperation() {
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return getId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,552 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2016 Robert Winkler
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package io.github.swagger2markup;
|
|
||||||
|
|
||||||
import io.github.swagger2markup.assertions.DiffUtils;
|
|
||||||
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
|
||||||
import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown;
|
|
||||||
import static org.assertj.core.api.BDDAssertions.assertThat;
|
|
||||||
|
|
||||||
public class AsciidocConverterTest {
|
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(AsciidocConverterTest.class);
|
|
||||||
private static final String[] EXPECTED_FILES = new String[]{"definitions.adoc", "overview.adoc", "paths.adoc", "security.adoc"};
|
|
||||||
private List<String> expectedFiles;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp(){
|
|
||||||
expectedFiles = new ArrayList<>(asList(EXPECTED_FILES));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionAsString() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
|
|
||||||
|
|
||||||
//When
|
|
||||||
String asciiDocAsString = Swagger2MarkupConverter.from(file).build()
|
|
||||||
.toString();
|
|
||||||
//Then
|
|
||||||
assertThat(asciiDocAsString).isNotEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversion() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/default");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConverter.from(file).build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
|
||||||
|
|
||||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/default").toURI());
|
|
||||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocConversion.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionInstagram() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_instagram.yaml").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/instagram");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConverter.from(file).build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
|
||||||
|
|
||||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/instagram").toURI());
|
|
||||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocConversionInstagram.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionWithInterDocumentCrossReferences() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/idxref");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
|
||||||
.withInterDocumentCrossReferences()
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Swagger2MarkupConverter.from(file).withConfig(config).build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
|
||||||
|
|
||||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/idxref").toURI());
|
|
||||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocConversionWithInterDocumentCrossReferences.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionFromString() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
String swaggerJsonString = IOUtils.toString(getClass().getResourceAsStream("/yaml/swagger_petstore.yaml"));
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/default");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConverter.from(swaggerJsonString).build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
|
||||||
|
|
||||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/default").toURI());
|
|
||||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocConversion.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionWithExamples() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
String swaggerJsonString = IOUtils.toString(getClass().getResourceAsStream("/json/swagger_examples.json"));
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/examples");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
|
||||||
.withoutInlineSchema()
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Swagger2MarkupConverter.from(swaggerJsonString)
|
|
||||||
.withConfig(config)
|
|
||||||
.build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
|
||||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/examples").toURI());
|
|
||||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocConversionWithExamples.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionWithGeneratedExamples() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
String swaggerJsonString = IOUtils.toString(getClass().getResourceAsStream("/json/swagger_examples.json"));
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/generated_examples");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
|
||||||
.withoutInlineSchema()
|
|
||||||
.withGeneratedExamples()
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Swagger2MarkupConverter.from(swaggerJsonString)
|
|
||||||
.withConfig(config)
|
|
||||||
.build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
|
||||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/generated_examples").toURI());
|
|
||||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocConversionWithGeneratedExamples.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocWithInlineSchema() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_inlineSchema.yaml").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/inline_schema");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
|
||||||
.build();
|
|
||||||
Swagger2MarkupConverter.from(file)
|
|
||||||
.withConfig(config)
|
|
||||||
.build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
|
||||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/inline_schema").toURI());
|
|
||||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocWithInlineSchema.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocWithInlineSchemaAndFlatBody() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_inlineSchema.yaml").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/inline_schema_flat_body");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
|
||||||
.withFlatBody()
|
|
||||||
.build();
|
|
||||||
Swagger2MarkupConverter.from(file)
|
|
||||||
.withConfig(config)
|
|
||||||
.build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
|
||||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/inline_schema_flat_body").toURI());
|
|
||||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocWithInlineSchemaAndFlatBody.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocGroupedByTags() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/group_by_tags");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
|
||||||
.withPathsGroupedBy(GroupBy.TAGS)
|
|
||||||
.build();
|
|
||||||
Swagger2MarkupConverter.from(file)
|
|
||||||
.withConfig(config)
|
|
||||||
.build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
|
||||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/group_by_tags").toURI());
|
|
||||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocGroupedByTags.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocGroupedByTagsWithMissingTag() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/json/swagger_missing_tag.json").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/generated");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
//When
|
|
||||||
try {
|
|
||||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
|
||||||
.withPathsGroupedBy(GroupBy.TAGS)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Swagger2MarkupConverter.from(file)
|
|
||||||
.withConfig(config)
|
|
||||||
.build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
// If NullPointerException was not thrown, test would fail the specified message
|
|
||||||
failBecauseExceptionWasNotThrown(NullPointerException.class);
|
|
||||||
} catch (Exception e) {
|
|
||||||
assertThat(e).hasMessage("Can't GroupBy.TAGS > Operation 'updatePet' has not tags");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionDoesNotContainUriScheme() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_should_not_contain_uri_scheme.yaml").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/generated");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConverter.from(file).build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
|
||||||
|
|
||||||
assertThat(new String(Files.readAllBytes(outputDirectory.resolve("overview.adoc"))))
|
|
||||||
.doesNotContain("=== URI scheme");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionContainsUriScheme() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_should_contain_uri_scheme.yaml").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/generated");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConverter.from(file).build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
|
||||||
|
|
||||||
assertThat(new String(Files.readAllBytes(outputDirectory.resolve("overview.adoc"))))
|
|
||||||
.contains("=== URI scheme");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionWithSeparatedDefinitions() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/generated");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
|
||||||
.withSeparatedDefinitions()
|
|
||||||
.build();
|
|
||||||
Swagger2MarkupConverter.from(file).withConfig(config).build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
expectedFiles.add("definitions");
|
|
||||||
assertThat(files).hasSize(5).containsAll(expectedFiles);
|
|
||||||
|
|
||||||
Path definitionsDirectory = outputDirectory.resolve("definitions");
|
|
||||||
String[] definitions = definitionsDirectory.toFile().list();
|
|
||||||
assertThat(definitions).hasSize(5).containsAll(
|
|
||||||
asList("Category.adoc", "Order.adoc", "Pet.adoc", "Tag.adoc", "User.adoc"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionWithSeparatedOperations() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/generated");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
|
||||||
.withSeparatedOperations()
|
|
||||||
.build();
|
|
||||||
Swagger2MarkupConverter.from(file).withConfig(config).build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
expectedFiles.add("operations");
|
|
||||||
assertThat(files).hasSize(5).containsAll(expectedFiles);
|
|
||||||
|
|
||||||
Path pathsDirectory = outputDirectory.resolve("operations");
|
|
||||||
String[] paths = pathsDirectory.toFile().list();
|
|
||||||
assertThat(paths).hasSize(18);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionWithRussianOutputLanguage() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/generated");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
|
||||||
.withOutputLanguage(Language.RU)
|
|
||||||
.build();
|
|
||||||
Swagger2MarkupConverter.from(file)
|
|
||||||
.withConfig(config)
|
|
||||||
.build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
assertThat(new String(Files.readAllBytes(outputDirectory.resolve("definitions.adoc")), Charset.forName("UTF-8")))
|
|
||||||
.contains("== Определения");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionWithFrenchOutputLanguage() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/generated");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
|
||||||
.withOutputLanguage(Language.FR)
|
|
||||||
.build();
|
|
||||||
Swagger2MarkupConverter.from(file)
|
|
||||||
.withConfig(config)
|
|
||||||
.build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
assertThat(new String(Files.readAllBytes(outputDirectory.resolve("overview.adoc")), Charset.forName("UTF-8")))
|
|
||||||
.contains("== Sch\u00E9ma d'URI");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionWithMaps() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/json/swagger_maps.json").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/maps");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
|
||||||
.build();
|
|
||||||
Swagger2MarkupConverter.from(file)
|
|
||||||
.withConfig(config)
|
|
||||||
.build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
|
||||||
|
|
||||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/maps").toURI());
|
|
||||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocConversionWithMaps.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionWithEnums() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/json/swagger_enums.json").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/enums");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
|
||||||
.build();
|
|
||||||
Swagger2MarkupConverter.from(file)
|
|
||||||
.withConfig(config)
|
|
||||||
.build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
|
||||||
|
|
||||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/enums").toURI());
|
|
||||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocConversionWithEnums.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionWithValidators() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/json/swagger_validators.json").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/validators");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
|
||||||
.build();
|
|
||||||
Swagger2MarkupConverter.from(file)
|
|
||||||
.withConfig(config)
|
|
||||||
.build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
|
||||||
|
|
||||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/validators").toURI());
|
|
||||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocConversionWithValidators.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionWithPolymorphism() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/json/swagger_polymorphism.json").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/polymorphism");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
|
||||||
.build();
|
|
||||||
Swagger2MarkupConverter.from(file)
|
|
||||||
.withConfig(config)
|
|
||||||
.build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
|
||||||
|
|
||||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/polymorphism").toURI());
|
|
||||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocConversionWithPolymorphism.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionWithPolymorphismAsIsOrdering() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/json/swagger_polymorphism.json").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/polymorphismAsIsOrdering");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
|
||||||
.withPropertyOrdering(OrderBy.AS_IS)
|
|
||||||
.build();
|
|
||||||
Swagger2MarkupConverter.from(file)
|
|
||||||
.withConfig(config)
|
|
||||||
.build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
|
||||||
|
|
||||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/polymorphismAsIsOrdering").toURI());
|
|
||||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocConversionWithPolymorphismAsIsOrdering.html");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSwagger2AsciiDocConversionWithResponseHeaders() throws IOException, URISyntaxException {
|
|
||||||
//Given
|
|
||||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_response_headers.yaml").toURI());
|
|
||||||
Path outputDirectory = Paths.get("build/test/asciidoc/response_headers");
|
|
||||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
|
||||||
|
|
||||||
//When
|
|
||||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
|
||||||
.build();
|
|
||||||
Swagger2MarkupConverter.from(file)
|
|
||||||
.withConfig(config)
|
|
||||||
.build()
|
|
||||||
.toFolder(outputDirectory);
|
|
||||||
|
|
||||||
//Then
|
|
||||||
String[] files = outputDirectory.toFile().list();
|
|
||||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
|
||||||
|
|
||||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/response_headers").toURI());
|
|
||||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocConversionWithResponseHeaders.html");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
|
|
||||||
[[_definitions]]
|
|
||||||
== Definitions
|
|
||||||
|
|
||||||
[[_category]]
|
|
||||||
=== Category
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_|The name of the category +
|
|
||||||
*Default* : `"DefaultCategory"` +
|
|
||||||
*Length* : `0 - 255` +
|
|
||||||
*Pattern* : `"[A-Za-zäöüÄÖÜß]{0,255}"` +
|
|
||||||
*Example* : `"FoobarCategory"`|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_order]]
|
|
||||||
=== Order
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*complete* +
|
|
||||||
_optional_||boolean
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*petId* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*quantity* +
|
|
||||||
_optional_|*Default* : `0` +
|
|
||||||
*Minimum value* : `0.0` +
|
|
||||||
*Maximum value* : `10000.0` +
|
|
||||||
*Example* : `10`|integer(int32)
|
|
||||||
|*shipDate* +
|
|
||||||
_optional_||string(date-time)
|
|
||||||
|*status* +
|
|
||||||
_optional_|Order Status|enum (Ordered, Cancelled)
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_pet]]
|
|
||||||
=== Pet
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*category* +
|
|
||||||
_optional_||<<_category,Category>>
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_required_|*Example* : `"doggie"`|string
|
|
||||||
|*photoUrls* +
|
|
||||||
_required_||< string > array
|
|
||||||
|*status* +
|
|
||||||
_optional_|pet status in the store,|enum (Dead, Alive)
|
|
||||||
|*tags* +
|
|
||||||
_optional_||< <<_tag,Tag>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_tag]]
|
|
||||||
=== Tag
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_user]]
|
|
||||||
=== User
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*email* +
|
|
||||||
_optional_||string
|
|
||||||
|*firstName* +
|
|
||||||
_optional_||string
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*lastName* +
|
|
||||||
_optional_||string
|
|
||||||
|*password* +
|
|
||||||
_optional_||string
|
|
||||||
|*phone* +
|
|
||||||
_optional_||string
|
|
||||||
|*userStatus* +
|
|
||||||
_optional_|User Status|integer(int32)
|
|
||||||
|*username* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
|
|
||||||
[[_definitions]]
|
|
||||||
== Definitions
|
|
||||||
|
|
||||||
[[_enumstring]]
|
|
||||||
=== EnumString
|
|
||||||
Enum string
|
|
||||||
|
|
||||||
_Type_ : enum (ADDED, REMOVED, CHANGED)
|
|
||||||
|
|
||||||
|
|
||||||
[[_simplestring]]
|
|
||||||
=== SimpleString
|
|
||||||
Simple string
|
|
||||||
|
|
||||||
_Type_ : string
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
|
|
||||||
[[_paths]]
|
|
||||||
== Paths
|
|
||||||
|
|
||||||
[[_createstate]]
|
|
||||||
=== Create state
|
|
||||||
....
|
|
||||||
POST /state
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Description
|
|
||||||
Return state
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Path*|*oldState* +
|
|
||||||
_required_|Old State as raw string|enum (ADDED, REMOVED, CHANGED)|
|
|
||||||
|*Body*|*StateModel* +
|
|
||||||
_optional_|State as enum in object|<<_createstate_statemodel,StateModel>>|
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_createstate_statemodel]]
|
|
||||||
*StateModel*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*value* +
|
|
||||||
_optional_|State value|enum (ADDED, REMOVED, CHANGED)
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*200*|OK|enum (ADDED, REMOVED, CHANGED)
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Consumes
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `*/*`
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
|
|
||||||
[[_definitions]]
|
|
||||||
== Definitions
|
|
||||||
|
|
||||||
[[_category]]
|
|
||||||
=== Category
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_|*Example* : `123`|integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_|*Example* : `"Canines"`|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_complexobject]]
|
|
||||||
=== ComplexObject
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*subObject* +
|
|
||||||
_optional_||object
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_identified]]
|
|
||||||
=== Identified
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_order]]
|
|
||||||
=== Order
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*complete* +
|
|
||||||
_optional_||boolean
|
|
||||||
|*id* +
|
|
||||||
_optional_|*Example* : `77`|integer(int64)
|
|
||||||
|*petId* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*quantity* +
|
|
||||||
_optional_||integer(int32)
|
|
||||||
|*shipDate* +
|
|
||||||
_optional_||string(date-time)
|
|
||||||
|*status* +
|
|
||||||
_optional_|Order Status +
|
|
||||||
*Example* : `"DONE"`|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_pet]]
|
|
||||||
=== Pet
|
|
||||||
Test description
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*category* +
|
|
||||||
_optional_||<<_category,Category>>
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_required_|*Example* : `"doggie"`|string
|
|
||||||
|*nicknames* +
|
|
||||||
_optional_||< string, string > map
|
|
||||||
|*photoUrls* +
|
|
||||||
_required_||< string > array
|
|
||||||
|*status* +
|
|
||||||
_optional_|pet status in the store|string
|
|
||||||
|*tags* +
|
|
||||||
_optional_||< <<_tag,Tag>> > array
|
|
||||||
|*weight* +
|
|
||||||
_optional_|the weight of the pet|number
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_tag]]
|
|
||||||
=== Tag
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_user]]
|
|
||||||
=== User
|
|
||||||
[%hardbreaks]
|
|
||||||
_Polymorphism_ : Composition
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*email* +
|
|
||||||
_optional_||string
|
|
||||||
|*firstName* +
|
|
||||||
_optional_||string
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*lastName* +
|
|
||||||
_optional_||string
|
|
||||||
|*password* +
|
|
||||||
_optional_||string
|
|
||||||
|*phone* +
|
|
||||||
_optional_||string
|
|
||||||
|*pictures* +
|
|
||||||
_optional_||< string(byte) > array
|
|
||||||
|*userStatus* +
|
|
||||||
_optional_|User Status|integer(int32)
|
|
||||||
|*username* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
|
|
||||||
[[_definitions]]
|
|
||||||
== Definitions
|
|
||||||
|
|
||||||
[[_ref-category]]
|
|
||||||
=== <<_category,Category>>
|
|
||||||
|
|
||||||
[[_ref-order]]
|
|
||||||
=== <<_order,Order>>
|
|
||||||
|
|
||||||
[[_ref-pet]]
|
|
||||||
=== <<_pet,Pet>>
|
|
||||||
|
|
||||||
[[_ref-tag]]
|
|
||||||
=== <<_tag,Tag>>
|
|
||||||
|
|
||||||
[[_ref-user]]
|
|
||||||
=== <<_user,User>>
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
|
|
||||||
[[_tag]]
|
|
||||||
=== Tag
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,827 +0,0 @@
|
|||||||
|
|
||||||
[[_paths]]
|
|
||||||
== Paths
|
|
||||||
|
|
||||||
[[_addpet]]
|
|
||||||
=== Add a new pet to the store
|
|
||||||
....
|
|
||||||
POST /pets
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Body*|*body* +
|
|
||||||
_optional_|Pet object that needs to be added to the store|<<_pet,Pet>>|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*405*|Invalid input|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Consumes
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* pet
|
|
||||||
|
|
||||||
|
|
||||||
==== Security
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^4,.^13"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Scopes
|
|
||||||
|*oauth2*|*<<_petstore_auth,petstore_auth>>*|write_pets,read_pets
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_updatepet]]
|
|
||||||
=== Update an existing pet
|
|
||||||
....
|
|
||||||
PUT /pets
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Body*|*body* +
|
|
||||||
_optional_|Pet object that needs to be added to the store|<<_pet,Pet>>|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*400*|Invalid ID supplied|No Content
|
|
||||||
|*404*|Pet not found|No Content
|
|
||||||
|*405*|Validation exception|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Consumes
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* pet
|
|
||||||
|
|
||||||
|
|
||||||
==== Security
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^4,.^13"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Scopes
|
|
||||||
|*oauth2*|*<<_petstore_auth,petstore_auth>>*|write_pets,read_pets
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_findpetsbystatus]]
|
|
||||||
=== Finds Pets by status
|
|
||||||
....
|
|
||||||
GET /pets/findByStatus
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Description
|
|
||||||
Multiple status values can be provided with comma seperated strings
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Query*|*status* +
|
|
||||||
_optional_|Status values that need to be considered for filter|< string > array(multi)|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*200*|successful operation +
|
|
||||||
*Headers* : +
|
|
||||||
`X-Rate-Limit-Limit` (integer) : The number of allowed requests in the current period. +
|
|
||||||
`X-Rate-Limit-Remaining` (integer) : The number of remaining requests in the current period. +
|
|
||||||
`X-Rate-Limit-Reset` (integer) : The number of seconds left in the current period.|< <<_pet,Pet>> > array
|
|
||||||
|*400*|Invalid status value|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* pet
|
|
||||||
|
|
||||||
|
|
||||||
==== Security
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^4,.^13"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Scopes
|
|
||||||
|*oauth2*|*<<_petstore_auth,petstore_auth>>*|write_pets,read_pets
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_findpetsbytags]]
|
|
||||||
=== Finds Pets by tags
|
|
||||||
....
|
|
||||||
GET /pets/findByTags
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Description
|
|
||||||
Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Query*|*tags* +
|
|
||||||
_optional_|Tags to filter by|< string > array(multi)|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*200*|successful operation +
|
|
||||||
*Headers* : +
|
|
||||||
`X-Rate-Limit-Limit` (integer) : The number of allowed requests in the current period. +
|
|
||||||
`X-Rate-Limit-Remaining` (integer) : The number of remaining requests in the current period. +
|
|
||||||
`X-Rate-Limit-Reset` (integer) : The number of seconds left in the current period.|< <<_pet,Pet>> > array
|
|
||||||
|*400*|Invalid tag value|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* pet
|
|
||||||
|
|
||||||
|
|
||||||
==== Security
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^4,.^13"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Scopes
|
|
||||||
|*oauth2*|*<<_petstore_auth,petstore_auth>>*|write_pets,read_pets
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_updatepetwithform]]
|
|
||||||
=== Updates a pet in the store with form data
|
|
||||||
....
|
|
||||||
POST /pets/{petId}
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Path*|*petId* +
|
|
||||||
_required_|ID of pet that needs to be updated|string|
|
|
||||||
|*FormData*|*name* +
|
|
||||||
_required_|Updated name of the pet|string|
|
|
||||||
|*FormData*|*status* +
|
|
||||||
_required_|Updated status of the pet|string|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*405*|Invalid input|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Consumes
|
|
||||||
|
|
||||||
* `application/x-www-form-urlencoded`
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* pet
|
|
||||||
|
|
||||||
|
|
||||||
==== Security
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^4,.^13"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Scopes
|
|
||||||
|*oauth2*|*<<_petstore_auth,petstore_auth>>*|write_pets,read_pets
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_getpetbyid]]
|
|
||||||
=== Find pet by ID
|
|
||||||
....
|
|
||||||
GET /pets/{petId}
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Description
|
|
||||||
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Path*|*petId* +
|
|
||||||
_required_|ID of pet that needs to be fetched|integer(int64)|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*200*|successful operation +
|
|
||||||
*Headers* : +
|
|
||||||
`X-Rate-Limit-Limit` (integer) : The number of allowed requests in the current period. +
|
|
||||||
`X-Rate-Limit-Remaining` (integer) : The number of remaining requests in the current period. +
|
|
||||||
`X-Rate-Limit-Reset` (integer) : The number of seconds left in the current period.|<<_pet,Pet>>
|
|
||||||
|*400*|Invalid ID supplied|No Content
|
|
||||||
|*404*|Pet not found|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* pet
|
|
||||||
|
|
||||||
|
|
||||||
==== Security
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^4,.^13"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Scopes
|
|
||||||
|*apiKey*|*<<_api_key,api_key>>*|
|
|
||||||
|*oauth2*|*<<_petstore_auth,petstore_auth>>*|write_pets,read_pets
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_deletepet]]
|
|
||||||
=== Deletes a pet
|
|
||||||
....
|
|
||||||
DELETE /pets/{petId}
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Header*|*api_key* +
|
|
||||||
_required_||string|
|
|
||||||
|*Path*|*petId* +
|
|
||||||
_required_|Pet id to delete|integer(int64)|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*400*|Invalid pet value|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* pet
|
|
||||||
|
|
||||||
|
|
||||||
==== Security
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^4,.^13"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Scopes
|
|
||||||
|*oauth2*|*<<_petstore_auth,petstore_auth>>*|write_pets,read_pets
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_placeorder]]
|
|
||||||
=== Place an order for a pet
|
|
||||||
....
|
|
||||||
POST /stores/order
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Body*|*body* +
|
|
||||||
_optional_|order placed for purchasing the pet|<<_order,Order>>|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*200*|successful operation +
|
|
||||||
*Headers* : +
|
|
||||||
`X-Rate-Limit-Limit` (integer) : The number of allowed requests in the current period. +
|
|
||||||
`X-Rate-Limit-Remaining` (integer) : The number of remaining requests in the current period. +
|
|
||||||
`X-Rate-Limit-Reset` (integer) : The number of seconds left in the current period.|<<_order,Order>>
|
|
||||||
|*400*|Invalid Order|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* store
|
|
||||||
|
|
||||||
|
|
||||||
[[_getorderbyid]]
|
|
||||||
=== Find purchase order by ID
|
|
||||||
....
|
|
||||||
GET /stores/order/{orderId}
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Description
|
|
||||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Path*|*orderId* +
|
|
||||||
_required_|ID of pet that needs to be fetched|string|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*200*|successful operation +
|
|
||||||
*Headers* : +
|
|
||||||
`X-Rate-Limit-Limit` (integer) : The number of allowed requests in the current period. +
|
|
||||||
`X-Rate-Limit-Remaining` (integer) : The number of remaining requests in the current period. +
|
|
||||||
`X-Rate-Limit-Reset` (integer) : The number of seconds left in the current period.|<<_order,Order>>
|
|
||||||
|*400*|Invalid ID supplied|No Content
|
|
||||||
|*404*|Order not found|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* store
|
|
||||||
|
|
||||||
|
|
||||||
[[_deleteorder]]
|
|
||||||
=== Delete purchase order by ID
|
|
||||||
....
|
|
||||||
DELETE /stores/order/{orderId}
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Description
|
|
||||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Path*|*orderId* +
|
|
||||||
_required_|ID of the order that needs to be deleted|string|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*400*|Invalid ID supplied|No Content
|
|
||||||
|*404*|Order not found|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* store
|
|
||||||
|
|
||||||
|
|
||||||
[[_createuser]]
|
|
||||||
=== Create user
|
|
||||||
....
|
|
||||||
POST /users
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Description
|
|
||||||
This can only be done by the logged in user.
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Body*|*body* +
|
|
||||||
_optional_|Created user object|<<_user,User>>|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*default*|successful operation|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* user
|
|
||||||
|
|
||||||
|
|
||||||
[[_createuserswitharrayinput]]
|
|
||||||
=== Creates list of users with given input array
|
|
||||||
....
|
|
||||||
POST /users/createWithArray
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Body*|*body* +
|
|
||||||
_optional_|List of user object|< <<_user,User>> > array|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*default*|successful operation|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* user
|
|
||||||
|
|
||||||
|
|
||||||
[[_createuserswithlistinput]]
|
|
||||||
=== Creates list of users with given input array
|
|
||||||
....
|
|
||||||
POST /users/createWithList
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Body*|*body* +
|
|
||||||
_optional_|List of user object|< <<_user,User>> > array|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*default*|successful operation|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* user
|
|
||||||
|
|
||||||
|
|
||||||
[[_loginuser]]
|
|
||||||
=== Logs user into the system
|
|
||||||
....
|
|
||||||
GET /users/login
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Query*|*password* +
|
|
||||||
_optional_|The password for login in clear text|string|
|
|
||||||
|*Query*|*username* +
|
|
||||||
_optional_|The user name for login|string|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*200*|successful operation +
|
|
||||||
*Headers* : +
|
|
||||||
`X-Rate-Limit-Limit` (integer) : The number of allowed requests in the current period. +
|
|
||||||
`X-Rate-Limit-Remaining` (integer) : The number of remaining requests in the current period. +
|
|
||||||
`X-Rate-Limit-Reset` (integer) : The number of seconds left in the current period.|string
|
|
||||||
|*400*|Invalid username/password supplied|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* user
|
|
||||||
|
|
||||||
|
|
||||||
[[_logoutuser]]
|
|
||||||
=== Logs out current logged in user session
|
|
||||||
....
|
|
||||||
GET /users/logout
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*default*|successful operation|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* user
|
|
||||||
|
|
||||||
|
|
||||||
[[_getuserbyname]]
|
|
||||||
=== Get user by user name
|
|
||||||
....
|
|
||||||
GET /users/{username}
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Path*|*username* +
|
|
||||||
_required_|The name that needs to be fetched. Use user1 for testing.|string|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*200*|successful operation +
|
|
||||||
*Headers* : +
|
|
||||||
`X-Rate-Limit-Limit` (integer) : The number of allowed requests in the current period. +
|
|
||||||
`X-Rate-Limit-Remaining` (integer) : The number of remaining requests in the current period. +
|
|
||||||
`X-Rate-Limit-Reset` (integer) : The number of seconds left in the current period.|<<_user,User>>
|
|
||||||
|*400*|Invalid username supplied|No Content
|
|
||||||
|*404*|User not found|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* user
|
|
||||||
|
|
||||||
|
|
||||||
[[_updateuser]]
|
|
||||||
=== Updated user
|
|
||||||
....
|
|
||||||
PUT /users/{username}
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Description
|
|
||||||
This can only be done by the logged in user.
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Path*|*username* +
|
|
||||||
_required_|name that need to be deleted|string|
|
|
||||||
|*Body*|*body* +
|
|
||||||
_optional_|Updated user object|<<_user,User>>|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*400*|Invalid user supplied|No Content
|
|
||||||
|*404*|User not found|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* user
|
|
||||||
|
|
||||||
|
|
||||||
[[_deleteuser]]
|
|
||||||
=== Delete user
|
|
||||||
....
|
|
||||||
DELETE /users/{username}
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Description
|
|
||||||
This can only be done by the logged in user.
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Path*|*username* +
|
|
||||||
_required_|The name that needs to be deleted|string|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*400*|Invalid username supplied|No Content
|
|
||||||
|*404*|User not found|No Content
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Produces
|
|
||||||
|
|
||||||
* `application/json`
|
|
||||||
* `application/xml`
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* user
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
|
|
||||||
[[_definitions]]
|
|
||||||
== Definitions
|
|
||||||
|
|
||||||
[[_category]]
|
|
||||||
=== Category
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_|*Example* : `123`|integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_|*Example* : `"Canines"`|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_complexobject]]
|
|
||||||
=== ComplexObject
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*subObject* +
|
|
||||||
_optional_|*Example* : `"object"`|object
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_identified]]
|
|
||||||
=== Identified
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_|*Example* : `0`|integer(int64)
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_order]]
|
|
||||||
=== Order
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*complete* +
|
|
||||||
_optional_|*Example* : `true`|boolean
|
|
||||||
|*id* +
|
|
||||||
_optional_|*Example* : `77`|integer(int64)
|
|
||||||
|*petId* +
|
|
||||||
_optional_|*Example* : `0`|integer(int64)
|
|
||||||
|*quantity* +
|
|
||||||
_optional_|*Example* : `0`|integer(int32)
|
|
||||||
|*shipDate* +
|
|
||||||
_optional_|*Example* : `"string"`|string(date-time)
|
|
||||||
|*status* +
|
|
||||||
_optional_|Order Status +
|
|
||||||
*Example* : `"DONE"`|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_pet]]
|
|
||||||
=== Pet
|
|
||||||
Test description
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*category* +
|
|
||||||
_optional_|*Example* : `"<<_category>>"`|<<_category,Category>>
|
|
||||||
|*id* +
|
|
||||||
_optional_|*Example* : `0`|integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_required_|*Example* : `"doggie"`|string
|
|
||||||
|*nicknames* +
|
|
||||||
_optional_|*Example* : `{
|
|
||||||
"string" : "string"
|
|
||||||
}`|< string, string > map
|
|
||||||
|*photoUrls* +
|
|
||||||
_required_|*Example* : `[ "string" ]`|< string > array
|
|
||||||
|*status* +
|
|
||||||
_optional_|pet status in the store +
|
|
||||||
*Example* : `"string"`|string
|
|
||||||
|*tags* +
|
|
||||||
_optional_|*Example* : `[ "<<_tag>>" ]`|< <<_tag,Tag>> > array
|
|
||||||
|*weight* +
|
|
||||||
_optional_|the weight of the pet +
|
|
||||||
*Example* : `0.0`|number
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_tag]]
|
|
||||||
=== Tag
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_|*Example* : `0`|integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_|*Example* : `"string"`|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_user]]
|
|
||||||
=== User
|
|
||||||
[%hardbreaks]
|
|
||||||
_Polymorphism_ : Composition
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*email* +
|
|
||||||
_optional_|*Example* : `"string"`|string
|
|
||||||
|*firstName* +
|
|
||||||
_optional_|*Example* : `"string"`|string
|
|
||||||
|*id* +
|
|
||||||
_optional_|*Example* : `0`|integer(int64)
|
|
||||||
|*lastName* +
|
|
||||||
_optional_|*Example* : `"string"`|string
|
|
||||||
|*password* +
|
|
||||||
_optional_|*Example* : `"string"`|string
|
|
||||||
|*phone* +
|
|
||||||
_optional_|*Example* : `"string"`|string
|
|
||||||
|*pictures* +
|
|
||||||
_optional_|*Example* : `[ "string" ]`|< string(byte) > array
|
|
||||||
|*userStatus* +
|
|
||||||
_optional_|User Status +
|
|
||||||
*Example* : `0`|integer(int32)
|
|
||||||
|*username* +
|
|
||||||
_optional_|*Example* : `"string"`|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
|
|
||||||
[[_definitions]]
|
|
||||||
== Definitions
|
|
||||||
|
|
||||||
[[_category]]
|
|
||||||
=== Category
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_|The name of the category +
|
|
||||||
*Default* : `"DefaultCategory"` +
|
|
||||||
*Length* : `0 - 255` +
|
|
||||||
*Pattern* : `"[A-Za-zäöüÄÖÜß]{0,255}"` +
|
|
||||||
*Example* : `"FoobarCategory"`|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_order]]
|
|
||||||
=== Order
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*complete* +
|
|
||||||
_optional_||boolean
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*petId* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*quantity* +
|
|
||||||
_optional_|*Default* : `0` +
|
|
||||||
*Minimum value* : `0.0` +
|
|
||||||
*Maximum value* : `10000.0` +
|
|
||||||
*Example* : `10`|integer(int32)
|
|
||||||
|*shipDate* +
|
|
||||||
_optional_||string(date-time)
|
|
||||||
|*status* +
|
|
||||||
_optional_|Order Status|enum (Ordered, Cancelled)
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_pet]]
|
|
||||||
=== Pet
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*category* +
|
|
||||||
_optional_||<<_category,Category>>
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_required_|*Example* : `"doggie"`|string
|
|
||||||
|*photoUrls* +
|
|
||||||
_required_||< string > array
|
|
||||||
|*status* +
|
|
||||||
_optional_|pet status in the store,|enum (Dead, Alive)
|
|
||||||
|*tags* +
|
|
||||||
_optional_||< <<_tag,Tag>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_tag]]
|
|
||||||
=== Tag
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_user]]
|
|
||||||
=== User
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*email* +
|
|
||||||
_optional_||string
|
|
||||||
|*firstName* +
|
|
||||||
_optional_||string
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*lastName* +
|
|
||||||
_optional_||string
|
|
||||||
|*password* +
|
|
||||||
_optional_||string
|
|
||||||
|*phone* +
|
|
||||||
_optional_||string
|
|
||||||
|*userStatus* +
|
|
||||||
_optional_|User Status|integer(int32)
|
|
||||||
|*username* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
[[_securityscheme]]
|
|
||||||
== Security
|
|
||||||
|
|
||||||
[[_petstore_auth]]
|
|
||||||
=== petstore_auth
|
|
||||||
[%hardbreaks]
|
|
||||||
_Type_ : oauth2
|
|
||||||
_Flow_ : implicit
|
|
||||||
_Token URL_ : http://petstore.swagger.io/api/oauth/dialog
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^17"]
|
|
||||||
|===
|
|
||||||
|Name|Description
|
|
||||||
|write_pets|modify pets in your account
|
|
||||||
|read_pets|read your pets
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_api_key]]
|
|
||||||
=== api_key
|
|
||||||
[%hardbreaks]
|
|
||||||
_Type_ : apiKey
|
|
||||||
_Name_ : api_key
|
|
||||||
_In_ : HEADER
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
|
|
||||||
[[_definitions]]
|
|
||||||
== Definitions
|
|
||||||
|
|
||||||
[[_category]]
|
|
||||||
=== Category
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_|The name of the category +
|
|
||||||
*Default* : `"DefaultCategory"` +
|
|
||||||
*Length* : `0 - 255` +
|
|
||||||
*Pattern* : `"[A-Za-zäöüÄÖÜß]{0,255}"` +
|
|
||||||
*Example* : `"FoobarCategory"`|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_order]]
|
|
||||||
=== Order
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*complete* +
|
|
||||||
_optional_||boolean
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*petId* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*quantity* +
|
|
||||||
_optional_|*Default* : `0` +
|
|
||||||
*Minimum value* : `0.0` +
|
|
||||||
*Maximum value* : `10000.0` +
|
|
||||||
*Example* : `10`|integer(int32)
|
|
||||||
|*shipDate* +
|
|
||||||
_optional_||string(date-time)
|
|
||||||
|*status* +
|
|
||||||
_optional_|Order Status|enum (Ordered, Cancelled)
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_pet]]
|
|
||||||
=== Pet
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*category* +
|
|
||||||
_optional_||<<definitions.adoc#_category,Category>>
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_required_|*Example* : `"doggie"`|string
|
|
||||||
|*photoUrls* +
|
|
||||||
_required_||< string > array
|
|
||||||
|*status* +
|
|
||||||
_optional_|pet status in the store,|enum (Dead, Alive)
|
|
||||||
|*tags* +
|
|
||||||
_optional_||< <<definitions.adoc#_tag,Tag>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_tag]]
|
|
||||||
=== Tag
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_user]]
|
|
||||||
=== User
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*email* +
|
|
||||||
_optional_||string
|
|
||||||
|*firstName* +
|
|
||||||
_optional_||string
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*lastName* +
|
|
||||||
_optional_||string
|
|
||||||
|*password* +
|
|
||||||
_optional_||string
|
|
||||||
|*phone* +
|
|
||||||
_optional_||string
|
|
||||||
|*userStatus* +
|
|
||||||
_optional_|User Status|integer(int32)
|
|
||||||
|*username* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
[[_securityscheme]]
|
|
||||||
== Security
|
|
||||||
|
|
||||||
[[_petstore_auth]]
|
|
||||||
=== petstore_auth
|
|
||||||
[%hardbreaks]
|
|
||||||
_Type_ : oauth2
|
|
||||||
_Flow_ : implicit
|
|
||||||
_Token URL_ : http://petstore.swagger.io/api/oauth/dialog
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^17"]
|
|
||||||
|===
|
|
||||||
|Name|Description
|
|
||||||
|write_pets|modify pets in your account
|
|
||||||
|read_pets|read your pets
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_api_key]]
|
|
||||||
=== api_key
|
|
||||||
[%hardbreaks]
|
|
||||||
_Type_ : apiKey
|
|
||||||
_Name_ : api_key
|
|
||||||
_In_ : HEADER
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,280 +0,0 @@
|
|||||||
|
|
||||||
[[_definitions]]
|
|
||||||
== Definitions
|
|
||||||
|
|
||||||
[[_error]]
|
|
||||||
=== Error
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*error-code* +
|
|
||||||
_optional_|Error code|integer
|
|
||||||
|*message* +
|
|
||||||
_optional_|Error message|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_externallocation]]
|
|
||||||
=== ExternalLocation
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*Place* +
|
|
||||||
_optional_|Place|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_inlinedepthschema]]
|
|
||||||
=== InlineDepthSchema
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*Loop* +
|
|
||||||
_optional_||<<_inlinedepthschema_loop,Loop>>
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_inlinedepthschema_loop]]
|
|
||||||
*Loop*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*p1* +
|
|
||||||
_optional_|Description p1|string
|
|
||||||
|*p2* +
|
|
||||||
_optional_|Description p2|<<_inlinedepthschema_p2,p2>>
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_inlinedepthschema_p2]]
|
|
||||||
*p2*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*p2-1* +
|
|
||||||
_optional_|Description p2-1|string
|
|
||||||
|*p2-2* +
|
|
||||||
_optional_|Description p2-2|<<_inlinedepthschema_p2_p2-2,p2-2>>
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_inlinedepthschema_p2_p2-2]]
|
|
||||||
*p2-2*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*p2-2-1* +
|
|
||||||
_optional_|Description p2-2-1|<<_inlinedepthschema_p2_p2-2_p2-2-1,p2-2-1>>
|
|
||||||
|*p2-2-2* +
|
|
||||||
_optional_|Description p2-2-2|<<_inlinedepthschema_p2_p2-2_p2-2-2,p2-2-2>>
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_inlinedepthschema_p2_p2-2_p2-2-1]]
|
|
||||||
*p2-2-1*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*p2-2-1-1* +
|
|
||||||
_optional_|Description p2-2-1-1|string
|
|
||||||
|*p2-2-1-2* +
|
|
||||||
_optional_|Description p2-2-1-2|boolean
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_inlinedepthschema_p2_p2-2_p2-2-2]]
|
|
||||||
*p2-2-2*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*p2-2-2-1* +
|
|
||||||
_optional_|Description p2-2-2-1|string
|
|
||||||
|*p2-2-2-2* +
|
|
||||||
_optional_|Description p2-2-2-2|boolean
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_inlinepet]]
|
|
||||||
=== InlinePet
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*category* +
|
|
||||||
_optional_||<<_inlinepet_category,category>>
|
|
||||||
|*id* +
|
|
||||||
_required_||integer(int64)
|
|
||||||
|*tags* +
|
|
||||||
_optional_||< <<_inlinepet_tags,tags>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_inlinepet_category]]
|
|
||||||
*category*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_inlinepet_tags]]
|
|
||||||
*tags*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_inlinetitlepet]]
|
|
||||||
=== InlineTitlePet
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*category* +
|
|
||||||
_optional_||<<_categorymodel,CategoryModel>>
|
|
||||||
|*id* +
|
|
||||||
_required_||integer(int64)
|
|
||||||
|*tags* +
|
|
||||||
_optional_||< <<_tagmodel,TagModel>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_categorymodel]]
|
|
||||||
*CategoryModel*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_tagmodel]]
|
|
||||||
*TagModel*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_location]]
|
|
||||||
=== Location
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*Place* +
|
|
||||||
_optional_|Place|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_mixedschema]]
|
|
||||||
=== MixedSchema
|
|
||||||
mixed collections and objects
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myTable* +
|
|
||||||
_optional_||< <<_mixedschema_mytable,myTable>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_mixedschema_mytable]]
|
|
||||||
*myTable*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myDict* +
|
|
||||||
_optional_||< string, <<_mixedschema_mydict,myDict>> > map
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_mixedschema_mydict]]
|
|
||||||
*myDict*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*k* +
|
|
||||||
_optional_||string
|
|
||||||
|*v* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_recursivecollectionschema]]
|
|
||||||
=== RecursiveCollectionSchema
|
|
||||||
Options k/v pairs list
|
|
||||||
|
|
||||||
_Type_ : < < string, <<_recursivecollectionschema_inline,RecursiveCollectionSchema>> > map > array
|
|
||||||
|
|
||||||
[[_recursivecollectionschema_inline]]
|
|
||||||
*RecursiveCollectionSchema*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*key* +
|
|
||||||
_optional_|option key|string
|
|
||||||
|*value* +
|
|
||||||
_optional_|option value|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_titledschema]]
|
|
||||||
=== TitledSchema
|
|
||||||
mixed collections and objects
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myTable* +
|
|
||||||
_optional_||< <<_tablecontent,TableContent>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_tablecontent]]
|
|
||||||
*TableContent*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*emptyObject* +
|
|
||||||
_optional_||object
|
|
||||||
|*myDict* +
|
|
||||||
_optional_||< string, <<_kvpair,KVPair>> > map
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_kvpair]]
|
|
||||||
*KVPair*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*k* +
|
|
||||||
_optional_||string
|
|
||||||
|*v* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,370 +0,0 @@
|
|||||||
|
|
||||||
[[_paths]]
|
|
||||||
== Paths
|
|
||||||
|
|
||||||
[[_collectionparameters_post]]
|
|
||||||
=== Recursive collection parameter
|
|
||||||
....
|
|
||||||
POST /CollectionParameters
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Description
|
|
||||||
Dummy description
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Body*|*Version* +
|
|
||||||
_optional_|The API version|< < string, <<_collectionparameters_post_version,Version>> > map > array|
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_collectionparameters_post_version]]
|
|
||||||
*Version*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*key* +
|
|
||||||
_optional_|option key|string
|
|
||||||
|*value* +
|
|
||||||
_optional_|option value|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*200*|Result|< < string, <<_collectionparameters_post_response_200,Response 200>> > map > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_collectionparameters_post_response_200]]
|
|
||||||
*Response 200*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*key* +
|
|
||||||
_optional_|option key|string
|
|
||||||
|*value* +
|
|
||||||
_optional_|option value|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* All
|
|
||||||
|
|
||||||
|
|
||||||
[[_launchcommand_post]]
|
|
||||||
=== LaunchCommand
|
|
||||||
....
|
|
||||||
POST /LaunchCommand
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Description
|
|
||||||
Dummy description
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Query*|*Option* +
|
|
||||||
_optional_|An optional option|string|
|
|
||||||
|*Query*|*Version* +
|
|
||||||
_optional_|The API version|string|
|
|
||||||
|*Body*|*LaunchCommandRequest* +
|
|
||||||
_optional_|Launch something new|<<_launchcommand_post_launchcommandrequest,LaunchCommandRequest>>|
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_launchcommand_post_launchcommandrequest]]
|
|
||||||
*LaunchCommandRequest*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*Command* +
|
|
||||||
_required_|Dummy description|<<_launchcommand_post_command,Command>>
|
|
||||||
|*Location* +
|
|
||||||
_optional_|Dummy description|<<_location,Location>>
|
|
||||||
|*Options* +
|
|
||||||
_optional_|Options k/v pairs|< <<_launchcommand_post_options,Options>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_launchcommand_post_command]]
|
|
||||||
*Command*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*args* +
|
|
||||||
_optional_|Command arguments|string
|
|
||||||
|*path* +
|
|
||||||
_optional_|Command path|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_launchcommand_post_options]]
|
|
||||||
*Options*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*key* +
|
|
||||||
_optional_|option key|string
|
|
||||||
|*value* +
|
|
||||||
_optional_|option value|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*200*|Result +
|
|
||||||
*Headers* : +
|
|
||||||
`X-Rate-Limit-Limit` (integer) : The number of allowed requests in the current period. +
|
|
||||||
`X-Rate-Limit-Remaining` (integer) : The number of remaining requests in the current period. +
|
|
||||||
`X-Rate-Limit-Reset` (integer) : The number of seconds left in the current period.|<<_launchcommand_post_response_200,Response 200>>
|
|
||||||
|*400*|Error|<<_error,Error>>
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_launchcommand_post_response_200]]
|
|
||||||
*Response 200*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*Location* +
|
|
||||||
_optional_|<description>|<<_location,Location>>
|
|
||||||
|*Options* +
|
|
||||||
_optional_|Options k/v pairs|< <<_launchcommand_post_options,Options>> > array
|
|
||||||
|*ReservationId* +
|
|
||||||
_optional_|<description>|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_launchcommand_post_options]]
|
|
||||||
*Options*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*key* +
|
|
||||||
_optional_|option key|string
|
|
||||||
|*value* +
|
|
||||||
_optional_|option value|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* All
|
|
||||||
|
|
||||||
|
|
||||||
[[_mixedparameters_post]]
|
|
||||||
=== Mixed multi-level objects and collection parameter
|
|
||||||
....
|
|
||||||
POST /MixedParameters
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Description
|
|
||||||
Dummy description
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Body*|*Version* +
|
|
||||||
_optional_|The API version|<<_mixedparameters_post_version,Version>>|
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_mixedparameters_post_version]]
|
|
||||||
*Version*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myTable* +
|
|
||||||
_optional_||< <<_mixedparameters_post_mytable,myTable>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_mixedparameters_post_mytable]]
|
|
||||||
*myTable*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myDict* +
|
|
||||||
_optional_||< string, <<_mixedparameters_post_mytable_mydict,myDict>> > map
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_mixedparameters_post_mytable_mydict]]
|
|
||||||
*myDict*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*k* +
|
|
||||||
_optional_||string
|
|
||||||
|*v* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*200*|Result|<<_mixedparameters_post_response_200,Response 200>>
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_mixedparameters_post_response_200]]
|
|
||||||
*Response 200*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myTable* +
|
|
||||||
_optional_||< <<_mixedparameters_post_mytable,myTable>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_mixedparameters_post_mytable]]
|
|
||||||
*myTable*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myDict* +
|
|
||||||
_optional_||< string, <<_mixedparameters_post_mytable_mydict,myDict>> > map
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_mixedparameters_post_mytable_mydict]]
|
|
||||||
*myDict*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*k* +
|
|
||||||
_optional_||string
|
|
||||||
|*v* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* All
|
|
||||||
|
|
||||||
|
|
||||||
[[_titledparameters_post]]
|
|
||||||
=== Titled, mixed multi-level objects and collection parameter
|
|
||||||
....
|
|
||||||
POST /TitledParameters
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Description
|
|
||||||
Dummy description
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Body*|*Version* +
|
|
||||||
_optional_|The API version|<<_request,Request>>|
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_request]]
|
|
||||||
*Request*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myTable* +
|
|
||||||
_optional_||< <<_tablecontent,TableContent>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_tablecontent]]
|
|
||||||
*TableContent*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myDict* +
|
|
||||||
_optional_||< string, <<_kvpair,KVPair>> > map
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_kvpair]]
|
|
||||||
*KVPair*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*k* +
|
|
||||||
_optional_||string
|
|
||||||
|*v* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*200*|Result|<<_result,Result>>
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_result]]
|
|
||||||
*Result*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myTable* +
|
|
||||||
_optional_||< <<_tablecontent,TableContent>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_tablecontent]]
|
|
||||||
*TableContent*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myDict* +
|
|
||||||
_optional_||< string, <<_kvpair,KVPair>> > map
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_kvpair]]
|
|
||||||
*KVPair*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*k* +
|
|
||||||
_optional_||string
|
|
||||||
|*v* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* All
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,280 +0,0 @@
|
|||||||
|
|
||||||
[[_definitions]]
|
|
||||||
== Definitions
|
|
||||||
|
|
||||||
[[_error]]
|
|
||||||
=== Error
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*error-code* +
|
|
||||||
_optional_|Error code|integer
|
|
||||||
|*message* +
|
|
||||||
_optional_|Error message|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_externallocation]]
|
|
||||||
=== ExternalLocation
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*Place* +
|
|
||||||
_optional_|Place|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_inlinedepthschema]]
|
|
||||||
=== InlineDepthSchema
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*Loop* +
|
|
||||||
_optional_||<<_inlinedepthschema_loop,Loop>>
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_inlinedepthschema_loop]]
|
|
||||||
*Loop*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*p1* +
|
|
||||||
_optional_|Description p1|string
|
|
||||||
|*p2* +
|
|
||||||
_optional_|Description p2|<<_inlinedepthschema_p2,p2>>
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_inlinedepthschema_p2]]
|
|
||||||
*p2*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*p2-1* +
|
|
||||||
_optional_|Description p2-1|string
|
|
||||||
|*p2-2* +
|
|
||||||
_optional_|Description p2-2|<<_inlinedepthschema_p2_p2-2,p2-2>>
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_inlinedepthschema_p2_p2-2]]
|
|
||||||
*p2-2*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*p2-2-1* +
|
|
||||||
_optional_|Description p2-2-1|<<_inlinedepthschema_p2_p2-2_p2-2-1,p2-2-1>>
|
|
||||||
|*p2-2-2* +
|
|
||||||
_optional_|Description p2-2-2|<<_inlinedepthschema_p2_p2-2_p2-2-2,p2-2-2>>
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_inlinedepthschema_p2_p2-2_p2-2-1]]
|
|
||||||
*p2-2-1*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*p2-2-1-1* +
|
|
||||||
_optional_|Description p2-2-1-1|string
|
|
||||||
|*p2-2-1-2* +
|
|
||||||
_optional_|Description p2-2-1-2|boolean
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_inlinedepthschema_p2_p2-2_p2-2-2]]
|
|
||||||
*p2-2-2*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*p2-2-2-1* +
|
|
||||||
_optional_|Description p2-2-2-1|string
|
|
||||||
|*p2-2-2-2* +
|
|
||||||
_optional_|Description p2-2-2-2|boolean
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_inlinepet]]
|
|
||||||
=== InlinePet
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*category* +
|
|
||||||
_optional_||<<_inlinepet_category,category>>
|
|
||||||
|*id* +
|
|
||||||
_required_||integer(int64)
|
|
||||||
|*tags* +
|
|
||||||
_optional_||< <<_inlinepet_tags,tags>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_inlinepet_category]]
|
|
||||||
*category*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_inlinepet_tags]]
|
|
||||||
*tags*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_inlinetitlepet]]
|
|
||||||
=== InlineTitlePet
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*category* +
|
|
||||||
_optional_||<<_categorymodel,CategoryModel>>
|
|
||||||
|*id* +
|
|
||||||
_required_||integer(int64)
|
|
||||||
|*tags* +
|
|
||||||
_optional_||< <<_tagmodel,TagModel>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_categorymodel]]
|
|
||||||
*CategoryModel*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_tagmodel]]
|
|
||||||
*TagModel*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer(int64)
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_location]]
|
|
||||||
=== Location
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*Place* +
|
|
||||||
_optional_|Place|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_mixedschema]]
|
|
||||||
=== MixedSchema
|
|
||||||
mixed collections and objects
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myTable* +
|
|
||||||
_optional_||< <<_mixedschema_mytable,myTable>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_mixedschema_mytable]]
|
|
||||||
*myTable*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myDict* +
|
|
||||||
_optional_||< string, <<_mixedschema_mydict,myDict>> > map
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_mixedschema_mydict]]
|
|
||||||
*myDict*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*k* +
|
|
||||||
_optional_||string
|
|
||||||
|*v* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_recursivecollectionschema]]
|
|
||||||
=== RecursiveCollectionSchema
|
|
||||||
Options k/v pairs list
|
|
||||||
|
|
||||||
_Type_ : < < string, <<_recursivecollectionschema_inline,RecursiveCollectionSchema>> > map > array
|
|
||||||
|
|
||||||
[[_recursivecollectionschema_inline]]
|
|
||||||
*RecursiveCollectionSchema*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*key* +
|
|
||||||
_optional_|option key|string
|
|
||||||
|*value* +
|
|
||||||
_optional_|option value|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_titledschema]]
|
|
||||||
=== TitledSchema
|
|
||||||
mixed collections and objects
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myTable* +
|
|
||||||
_optional_||< <<_tablecontent,TableContent>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_tablecontent]]
|
|
||||||
*TableContent*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*emptyObject* +
|
|
||||||
_optional_||object
|
|
||||||
|*myDict* +
|
|
||||||
_optional_||< string, <<_kvpair,KVPair>> > map
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_kvpair]]
|
|
||||||
*KVPair*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*k* +
|
|
||||||
_optional_||string
|
|
||||||
|*v* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,365 +0,0 @@
|
|||||||
|
|
||||||
[[_paths]]
|
|
||||||
== Paths
|
|
||||||
|
|
||||||
[[_collectionparameters_post]]
|
|
||||||
=== Recursive collection parameter
|
|
||||||
....
|
|
||||||
POST /CollectionParameters
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Description
|
|
||||||
Dummy description
|
|
||||||
|
|
||||||
|
|
||||||
==== Body parameter
|
|
||||||
The API version
|
|
||||||
|
|
||||||
[%hardbreaks]
|
|
||||||
_Name_ : Version
|
|
||||||
_Flags_ : optional
|
|
||||||
_Type_ : < < string, <<_collectionparameters_post_version,Version>> > map > array
|
|
||||||
|
|
||||||
[[_collectionparameters_post_version]]
|
|
||||||
*Version*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*key* +
|
|
||||||
_optional_|option key|string
|
|
||||||
|*value* +
|
|
||||||
_optional_|option value|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*200*|Result|< < string, <<_collectionparameters_post_response_200,Response 200>> > map > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_collectionparameters_post_response_200]]
|
|
||||||
*Response 200*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*key* +
|
|
||||||
_optional_|option key|string
|
|
||||||
|*value* +
|
|
||||||
_optional_|option value|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* All
|
|
||||||
|
|
||||||
|
|
||||||
[[_launchcommand_post]]
|
|
||||||
=== LaunchCommand
|
|
||||||
....
|
|
||||||
POST /LaunchCommand
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Description
|
|
||||||
Dummy description
|
|
||||||
|
|
||||||
|
|
||||||
==== Parameters
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^3,.^9,.^4,.^2"]
|
|
||||||
|===
|
|
||||||
|Type|Name|Description|Schema|Default
|
|
||||||
|*Query*|*Option* +
|
|
||||||
_optional_|An optional option|string|
|
|
||||||
|*Query*|*Version* +
|
|
||||||
_optional_|The API version|string|
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Body parameter
|
|
||||||
Launch something new
|
|
||||||
|
|
||||||
[%hardbreaks]
|
|
||||||
_Name_ : LaunchCommandRequest
|
|
||||||
_Flags_ : optional
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*Command* +
|
|
||||||
_required_|Dummy description|<<_launchcommand_post_command,Command>>
|
|
||||||
|*Location* +
|
|
||||||
_optional_|Dummy description|<<_location,Location>>
|
|
||||||
|*Options* +
|
|
||||||
_optional_|Options k/v pairs|< <<_launchcommand_post_options,Options>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_launchcommand_post_command]]
|
|
||||||
*Command*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*args* +
|
|
||||||
_optional_|Command arguments|string
|
|
||||||
|*path* +
|
|
||||||
_optional_|Command path|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_launchcommand_post_options]]
|
|
||||||
*Options*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*key* +
|
|
||||||
_optional_|option key|string
|
|
||||||
|*value* +
|
|
||||||
_optional_|option value|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*200*|Result +
|
|
||||||
*Headers* : +
|
|
||||||
`X-Rate-Limit-Limit` (integer) : The number of allowed requests in the current period. +
|
|
||||||
`X-Rate-Limit-Remaining` (integer) : The number of remaining requests in the current period. +
|
|
||||||
`X-Rate-Limit-Reset` (integer) : The number of seconds left in the current period.|<<_launchcommand_post_response_200,Response 200>>
|
|
||||||
|*400*|Error|<<_error,Error>>
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_launchcommand_post_response_200]]
|
|
||||||
*Response 200*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*Location* +
|
|
||||||
_optional_|<description>|<<_location,Location>>
|
|
||||||
|*Options* +
|
|
||||||
_optional_|Options k/v pairs|< <<_launchcommand_post_options,Options>> > array
|
|
||||||
|*ReservationId* +
|
|
||||||
_optional_|<description>|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_launchcommand_post_options]]
|
|
||||||
*Options*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*key* +
|
|
||||||
_optional_|option key|string
|
|
||||||
|*value* +
|
|
||||||
_optional_|option value|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* All
|
|
||||||
|
|
||||||
|
|
||||||
[[_mixedparameters_post]]
|
|
||||||
=== Mixed multi-level objects and collection parameter
|
|
||||||
....
|
|
||||||
POST /MixedParameters
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Description
|
|
||||||
Dummy description
|
|
||||||
|
|
||||||
|
|
||||||
==== Body parameter
|
|
||||||
The API version
|
|
||||||
|
|
||||||
[%hardbreaks]
|
|
||||||
_Name_ : Version
|
|
||||||
_Flags_ : optional
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myTable* +
|
|
||||||
_optional_||< <<_mixedparameters_post_mytable,myTable>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_mixedparameters_post_mytable]]
|
|
||||||
*myTable*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myDict* +
|
|
||||||
_optional_||< string, <<_mixedparameters_post_mydict,myDict>> > map
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_mixedparameters_post_mydict]]
|
|
||||||
*myDict*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*k* +
|
|
||||||
_optional_||string
|
|
||||||
|*v* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*200*|Result|<<_mixedparameters_post_response_200,Response 200>>
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_mixedparameters_post_response_200]]
|
|
||||||
*Response 200*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myTable* +
|
|
||||||
_optional_||< <<_mixedparameters_post_mytable,myTable>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_mixedparameters_post_mytable]]
|
|
||||||
*myTable*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myDict* +
|
|
||||||
_optional_||< string, <<_mixedparameters_post_mytable_mydict,myDict>> > map
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_mixedparameters_post_mytable_mydict]]
|
|
||||||
*myDict*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*k* +
|
|
||||||
_optional_||string
|
|
||||||
|*v* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* All
|
|
||||||
|
|
||||||
|
|
||||||
[[_titledparameters_post]]
|
|
||||||
=== Titled, mixed multi-level objects and collection parameter
|
|
||||||
....
|
|
||||||
POST /TitledParameters
|
|
||||||
....
|
|
||||||
|
|
||||||
|
|
||||||
==== Description
|
|
||||||
Dummy description
|
|
||||||
|
|
||||||
|
|
||||||
==== Body parameter
|
|
||||||
The API version
|
|
||||||
|
|
||||||
[%hardbreaks]
|
|
||||||
_Name_ : Version
|
|
||||||
_Flags_ : optional
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myTable* +
|
|
||||||
_optional_||< <<_tablecontent,TableContent>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_tablecontent]]
|
|
||||||
*TableContent*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myDict* +
|
|
||||||
_optional_||< string, <<_kvpair,KVPair>> > map
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_kvpair]]
|
|
||||||
*KVPair*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*k* +
|
|
||||||
_optional_||string
|
|
||||||
|*v* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Responses
|
|
||||||
|
|
||||||
[options="header", cols=".^2,.^14,.^4"]
|
|
||||||
|===
|
|
||||||
|HTTP Code|Description|Schema
|
|
||||||
|*200*|Result|<<_result,Result>>
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_result]]
|
|
||||||
*Result*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myTable* +
|
|
||||||
_optional_||< <<_tablecontent,TableContent>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_tablecontent]]
|
|
||||||
*TableContent*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*myDict* +
|
|
||||||
_optional_||< string, <<_kvpair,KVPair>> > map
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_kvpair]]
|
|
||||||
*KVPair*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*k* +
|
|
||||||
_optional_||string
|
|
||||||
|*v* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
==== Tags
|
|
||||||
|
|
||||||
* All
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,225 +0,0 @@
|
|||||||
|
|
||||||
[[_definitions]]
|
|
||||||
== Definitions
|
|
||||||
|
|
||||||
[[_comment]]
|
|
||||||
=== Comment
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*created_time* +
|
|
||||||
_optional_||string
|
|
||||||
|*from* +
|
|
||||||
_optional_||<<_miniprofile,MiniProfile>>
|
|
||||||
|*id* +
|
|
||||||
_optional_||string
|
|
||||||
|*text* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_image]]
|
|
||||||
=== Image
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*height* +
|
|
||||||
_optional_||integer
|
|
||||||
|*url* +
|
|
||||||
_optional_||string
|
|
||||||
|*width* +
|
|
||||||
_optional_||integer
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_like]]
|
|
||||||
=== Like
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*first_name* +
|
|
||||||
_optional_||string
|
|
||||||
|*id* +
|
|
||||||
_optional_||string
|
|
||||||
|*last_name* +
|
|
||||||
_optional_||string
|
|
||||||
|*type* +
|
|
||||||
_optional_||string
|
|
||||||
|*user_name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_location]]
|
|
||||||
=== Location
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*id* +
|
|
||||||
_optional_||string
|
|
||||||
|*latitude* +
|
|
||||||
_optional_||number
|
|
||||||
|*longitude* +
|
|
||||||
_optional_||number
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_media]]
|
|
||||||
=== Media
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*comments:* +
|
|
||||||
_optional_||<<_media_comments,comments:>>
|
|
||||||
|*created_time* +
|
|
||||||
_optional_|Epoc time (ms)|integer
|
|
||||||
|*filter* +
|
|
||||||
_optional_||string
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer
|
|
||||||
|*images* +
|
|
||||||
_optional_||<<_media_images,images>>
|
|
||||||
|*likes* +
|
|
||||||
_optional_||<<_media_likes,likes>>
|
|
||||||
|*location* +
|
|
||||||
_optional_||<<_location,Location>>
|
|
||||||
|*tags* +
|
|
||||||
_optional_||< <<_tag,Tag>> > array
|
|
||||||
|*type* +
|
|
||||||
_optional_||string
|
|
||||||
|*user* +
|
|
||||||
_optional_||<<_miniprofile,MiniProfile>>
|
|
||||||
|*users_in_photo* +
|
|
||||||
_optional_||< <<_miniprofile,MiniProfile>> > array
|
|
||||||
|*videos* +
|
|
||||||
_optional_||<<_media_videos,videos>>
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_media_comments]]
|
|
||||||
*comments:*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*count* +
|
|
||||||
_optional_||integer
|
|
||||||
|*data* +
|
|
||||||
_optional_||< <<_comment,Comment>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_media_images]]
|
|
||||||
*images*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*low_resolution* +
|
|
||||||
_optional_||<<_image,Image>>
|
|
||||||
|*standard_resolution* +
|
|
||||||
_optional_||<<_image,Image>>
|
|
||||||
|*thumbnail* +
|
|
||||||
_optional_||<<_image,Image>>
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_media_likes]]
|
|
||||||
*likes*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*count* +
|
|
||||||
_optional_||integer
|
|
||||||
|*data* +
|
|
||||||
_optional_||< <<_miniprofile,MiniProfile>> > array
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_media_videos]]
|
|
||||||
*videos*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*low_resolution* +
|
|
||||||
_optional_||<<_image,Image>>
|
|
||||||
|*standard_resolution* +
|
|
||||||
_optional_||<<_image,Image>>
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_miniprofile]]
|
|
||||||
=== MiniProfile
|
|
||||||
A shorter version of User for likes array
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*full_name* +
|
|
||||||
_optional_||string
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer
|
|
||||||
|*profile_picture* +
|
|
||||||
_optional_||string
|
|
||||||
|*user_name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_tag]]
|
|
||||||
=== Tag
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*media_count* +
|
|
||||||
_optional_||integer
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_user]]
|
|
||||||
=== User
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*bio* +
|
|
||||||
_optional_||string
|
|
||||||
|*counts* +
|
|
||||||
_optional_||<<_user_counts,counts>>
|
|
||||||
|*full_name* +
|
|
||||||
_optional_||string
|
|
||||||
|*id* +
|
|
||||||
_optional_||integer
|
|
||||||
|*profile_picture* +
|
|
||||||
_optional_||string
|
|
||||||
|*username* +
|
|
||||||
_optional_||string
|
|
||||||
|*website* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
[[_user_counts]]
|
|
||||||
*counts*
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*follows* +
|
|
||||||
_optional_||integer
|
|
||||||
|*follwed_by* +
|
|
||||||
_optional_||integer
|
|
||||||
|*media* +
|
|
||||||
_optional_||integer
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,24 +0,0 @@
|
|||||||
|
|
||||||
[[_definitions]]
|
|
||||||
== Definitions
|
|
||||||
|
|
||||||
[[_mappinginfo]]
|
|
||||||
=== MappingInfo
|
|
||||||
Information about a given HTTP mapping.
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*bean* +
|
|
||||||
_optional_|Unique name of the bean which handles the given mapping.|string
|
|
||||||
|*method* +
|
|
||||||
_optional_|The signature of the method which processes requests to the given mapping.|string
|
|
||||||
|*tags* +
|
|
||||||
_optional_||< string, string > map
|
|
||||||
|*type* +
|
|
||||||
_optional_|The class which processes requests to the given mapping.|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
|
|
||||||
[[_definitions]]
|
|
||||||
== Definitions
|
|
||||||
|
|
||||||
[[_array]]
|
|
||||||
=== Array
|
|
||||||
An array
|
|
||||||
|
|
||||||
[%hardbreaks]
|
|
||||||
_Polymorphism_ : Inheritance
|
|
||||||
_Discriminator_ : collType
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*collType* +
|
|
||||||
_required_|collection type discriminator|string
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_cat]]
|
|
||||||
=== Cat
|
|
||||||
A representation of a cat
|
|
||||||
|
|
||||||
[%hardbreaks]
|
|
||||||
_Polymorphism_ : Inheritance
|
|
||||||
_Discriminator_ : petType
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*huntingSkill* +
|
|
||||||
_required_|The measured skill for hunting +
|
|
||||||
*Default* : `"lazy"`|enum (clueless, lazy, adventurous, aggressive)
|
|
||||||
|*name* +
|
|
||||||
_optional_|conflicting property with inheriting model (issue #44)|string
|
|
||||||
|*petType* +
|
|
||||||
_required_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_collection]]
|
|
||||||
=== Collection
|
|
||||||
Collection parent type without discriminator
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_dog]]
|
|
||||||
=== Dog
|
|
||||||
A representation of a dog with an alternative discriminator
|
|
||||||
|
|
||||||
[%hardbreaks]
|
|
||||||
_Polymorphism_ : Inheritance
|
|
||||||
_Discriminator_ : dogType
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*dogType* +
|
|
||||||
_required_||string
|
|
||||||
|*name* +
|
|
||||||
_required_||string
|
|
||||||
|*packSize* +
|
|
||||||
_required_|the size of the pack the dog is from +
|
|
||||||
*Default* : `0` +
|
|
||||||
*Minimum value* : `0.0`|integer(int32)
|
|
||||||
|*petType* +
|
|
||||||
_required_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_map]]
|
|
||||||
=== Map
|
|
||||||
A map without discriminator
|
|
||||||
|
|
||||||
[%hardbreaks]
|
|
||||||
_Polymorphism_ : Composition
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*collType* +
|
|
||||||
_required_|collection type discriminator|string
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_pet]]
|
|
||||||
=== Pet
|
|
||||||
Pet parent type with discriminator
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*name* +
|
|
||||||
_required_||string
|
|
||||||
|*petType* +
|
|
||||||
_required_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
|
|
||||||
[[_definitions]]
|
|
||||||
== Definitions
|
|
||||||
|
|
||||||
[[_array]]
|
|
||||||
=== Array
|
|
||||||
An array
|
|
||||||
|
|
||||||
[%hardbreaks]
|
|
||||||
_Polymorphism_ : Inheritance
|
|
||||||
_Discriminator_ : collType
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|*collType* +
|
|
||||||
_required_|collection type discriminator|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_cat]]
|
|
||||||
=== Cat
|
|
||||||
A representation of a cat
|
|
||||||
|
|
||||||
[%hardbreaks]
|
|
||||||
_Polymorphism_ : Inheritance
|
|
||||||
_Discriminator_ : petType
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*name* +
|
|
||||||
_optional_|conflicting property with inheriting model (issue #44)|string
|
|
||||||
|*petType* +
|
|
||||||
_required_||string
|
|
||||||
|*huntingSkill* +
|
|
||||||
_required_|The measured skill for hunting +
|
|
||||||
*Default* : `"lazy"`|enum (clueless, lazy, adventurous, aggressive)
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_collection]]
|
|
||||||
=== Collection
|
|
||||||
Collection parent type without discriminator
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_dog]]
|
|
||||||
=== Dog
|
|
||||||
A representation of a dog with an alternative discriminator
|
|
||||||
|
|
||||||
[%hardbreaks]
|
|
||||||
_Polymorphism_ : Inheritance
|
|
||||||
_Discriminator_ : dogType
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*name* +
|
|
||||||
_required_||string
|
|
||||||
|*petType* +
|
|
||||||
_required_||string
|
|
||||||
|*dogType* +
|
|
||||||
_required_||string
|
|
||||||
|*packSize* +
|
|
||||||
_required_|the size of the pack the dog is from +
|
|
||||||
*Default* : `0` +
|
|
||||||
*Minimum value* : `0.0`|integer(int32)
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_map]]
|
|
||||||
=== Map
|
|
||||||
A map without discriminator
|
|
||||||
|
|
||||||
[%hardbreaks]
|
|
||||||
_Polymorphism_ : Composition
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*name* +
|
|
||||||
_optional_||string
|
|
||||||
|*collType* +
|
|
||||||
_required_|collection type discriminator|string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
[[_pet]]
|
|
||||||
=== Pet
|
|
||||||
Pet parent type with discriminator
|
|
||||||
|
|
||||||
|
|
||||||
[options="header", cols=".^3,.^11,.^4"]
|
|
||||||
|===
|
|
||||||
|Name|Description|Schema
|
|
||||||
|*name* +
|
|
||||||
_required_||string
|
|
||||||
|*petType* +
|
|
||||||
_required_||string
|
|
||||||
|===
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user