Compare commits
6 Commits
githubActi
...
issue/264
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
052b417fdb | ||
|
|
8f16457e49 | ||
|
|
2d8f46f5f6 | ||
|
|
2886d30dec | ||
|
|
282e74becb | ||
|
|
164b1ad2a8 |
82
.github/workflows/gradle-build.yml
vendored
@@ -1,82 +0,0 @@
|
|||||||
# 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
.gitignore
vendored
@@ -6,3 +6,4 @@ build
|
|||||||
/.classpath
|
/.classpath
|
||||||
/.project
|
/.project
|
||||||
/.settings/
|
/.settings/
|
||||||
|
/out/
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
language: java
|
language: java
|
||||||
jdk:
|
jdk:
|
||||||
- openjdk8
|
- oraclejdk8
|
||||||
before_install:
|
before_install:
|
||||||
- chmod +x gradlew
|
- chmod +x gradlew
|
||||||
after_success:
|
after_success:
|
||||||
|
|||||||
17
README.adoc
@@ -7,17 +7,6 @@ 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].
|
||||||
|
|
||||||
@@ -33,12 +22,12 @@ The project requires at least JDK 8.
|
|||||||
|
|
||||||
== Example
|
== Example
|
||||||
|
|
||||||
image::swagger2markup-documentation/src/docs/asciidoc/images/Swagger2Markup.PNG[]
|
image::src/docs/asciidoc/images/Swagger2Markup.PNG[]
|
||||||
|
|
||||||
image::swagger2markup-documentation/src/docs/asciidoc/images/Swagger2Markup_definitions.PNG[]
|
image::src/docs/asciidoc/images/Swagger2Markup_definitions.PNG[]
|
||||||
|
|
||||||
== Reference documentation
|
== Reference documentation
|
||||||
- http://swagger2markup.github.io/swagger2markup/1.3.3/[Reference Documentation]
|
- http://swagger2markup.github.io/swagger2markup/1.3.1/[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]
|
||||||
|
|
||||||
|
|||||||
@@ -3,21 +3,6 @@
|
|||||||
== 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.
|
||||||
|
|
||||||
@@ -117,7 +102,6 @@
|
|||||||
* PR #190: Add support for Spanish language
|
* PR #190: Add support for Spanish language
|
||||||
* PR #192: Updated min/max value to format correctly based on the data type
|
* PR #192: Updated min/max value to format correctly based on the data type
|
||||||
* PR #193: Added support for exclusiveMin and exclusiveMax
|
* 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
|
=== Version 1.1.1
|
||||||
* Issue #194: Added a config parameter which allows to prepend the basePath to all paths.
|
* Issue #194: Added a config parameter which allows to prepend the basePath to all paths.
|
||||||
@@ -131,10 +115,6 @@
|
|||||||
* Issue #198: Chinese chinese language encoding
|
* Issue #198: Chinese chinese language encoding
|
||||||
* Issue #207: Properties that start with an underscore are displayed correctly now
|
* 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.
|
* 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
|
== Version 1.2.0
|
||||||
* Issue #214: Add page break locations
|
* Issue #214: Add page break locations
|
||||||
@@ -152,18 +132,3 @@
|
|||||||
|
|
||||||
=== Version 1.3.1
|
=== Version 1.3.1
|
||||||
* PR #247: Fix request path and query params example support.
|
* 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
|
|
||||||
|
|
||||||
|
|||||||
178
build.gradle
@@ -1,142 +1,70 @@
|
|||||||
plugins {
|
buildscript {
|
||||||
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 {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven {
|
}
|
||||||
name "OSS Snapshots"
|
dependencies {
|
||||||
url "https://oss.jfrog.org/artifactory/oss-snapshot-local"
|
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.3'
|
||||||
}
|
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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
artifactoryPublish.skip = true // apply to all projects except the root
|
description = 'swagger2markup Build'
|
||||||
|
version = '1.3.2-SNAPSHOT'
|
||||||
|
ext.releaseVersion = '1.3.1'
|
||||||
|
group = 'io.github.swagger2markup'
|
||||||
|
|
||||||
ext {
|
apply plugin: 'java'
|
||||||
coreProjects = subprojects.findAll {
|
apply plugin: 'eclipse'
|
||||||
p -> !p.name.contains("documentation") && !p.name.endsWith("-bom")
|
apply from: 'gradle/publishing.gradle'
|
||||||
}
|
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"
|
||||||
}
|
}
|
||||||
|
|
||||||
configure(project.coreProjects) {
|
repositories {
|
||||||
apply plugin: 'java'
|
maven {
|
||||||
apply plugin: 'maven'
|
url "https://oss.jfrog.org/artifactory/oss-snapshot-local"
|
||||||
apply plugin: 'maven-publish'
|
|
||||||
apply plugin: 'com.jfrog.bintray'
|
|
||||||
apply from: "${rootDir}/publishing.gradle"
|
|
||||||
apply plugin: 'jacoco'
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
|
||||||
sourceCompatibility = "1.8"
|
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
jcenter()
|
||||||
|
mavenCentral()
|
||||||
|
//mavenLocal()
|
||||||
}
|
}
|
||||||
|
|
||||||
sonarqube {
|
dependencies {
|
||||||
properties {
|
compile 'io.github.swagger2markup:markup-document-builder:1.1.1'
|
||||||
property "sonar.projectName", "swagger2markup"
|
compile 'io.swagger:swagger-compat-spec-parser:1.0.25'
|
||||||
property "sonar.projectKey", "swagger2markup_swagger2markup"
|
compile 'org.apache.commons:commons-configuration2:2.1'
|
||||||
property "sonar.links.homepage", "https://github.com/Swagger2Markup/swagger2markup"
|
compile 'commons-beanutils:commons-beanutils:1.9.2'
|
||||||
property "sonar.links.ci", "https://travis-ci.org/Swagger2Markup/swagger2markup"
|
compile 'org.apache.commons:commons-collections4:4.1'
|
||||||
property "sonar.links.scm", "https://github.com/Swagger2Markup/swagger2markup"
|
compile 'io.javaslang:javaslang:2.0.5'
|
||||||
property "sonar.links.issue", "https://github.com/Swagger2Markup/swagger2markup/issues"
|
compile 'ch.netzwerg:paleo-core:0.10.2'
|
||||||
property "sonar.language", "java"
|
testCompile 'junit:junit:4.11'
|
||||||
}
|
testCompile 'org.asciidoctor:asciidoctorj:1.5.4'
|
||||||
|
testCompile 'ch.qos.logback:logback-classic:1.1.2'
|
||||||
|
testCompile 'org.assertj:assertj-core:3.5.2'
|
||||||
|
testCompile 'io.github.robwin:assertj-diff:0.1.1'
|
||||||
}
|
}
|
||||||
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 {
|
||||||
dependsOn(subprojects.test) // required by cobertura to aggregate report
|
if (System.properties['http.proxyHost']) {
|
||||||
|
systemProperty 'http.proxyHost', System.properties['http.proxyHost']
|
||||||
|
systemProperty 'http.proxyPort', System.properties['http.proxyPort']
|
||||||
|
systemProperty 'http.nonProxyHosts', System.properties['http.nonProxyHosts']
|
||||||
|
}
|
||||||
|
systemProperty 'file.encoding', 'UTF-8'
|
||||||
}
|
}
|
||||||
|
|
||||||
artifactory {
|
|
||||||
contextUrl = 'https://oss.jfrog.org'
|
task wrapper(type: Wrapper) {
|
||||||
resolve {
|
gradleVersion = '3.3'
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
13
gradle/coverage.gradle
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
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,11 +1,6 @@
|
|||||||
apply plugin: 'org.asciidoctor.convert'
|
apply plugin: 'org.asciidoctor.convert'
|
||||||
apply plugin: 'org.ajoberstar.github-pages'
|
apply plugin: 'org.ajoberstar.github-pages'
|
||||||
|
|
||||||
artifactoryPublish.skip=true
|
|
||||||
sonarqube.skipProject=true
|
|
||||||
|
|
||||||
asciidoctor.dependsOn test
|
|
||||||
|
|
||||||
asciidoctor {
|
asciidoctor {
|
||||||
sources {
|
sources {
|
||||||
include 'index.adoc'
|
include 'index.adoc'
|
||||||
@@ -19,27 +14,21 @@ asciidoctor {
|
|||||||
sectlinks: '',
|
sectlinks: '',
|
||||||
sectanchors: '',
|
sectanchors: '',
|
||||||
hardbreaks: '',
|
hardbreaks: '',
|
||||||
'release-version': project.releaseVersion,
|
'release-version': project.releaseVersion
|
||||||
'coreProjectDir': project(':swagger2markup').projectDir
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
publishGhPages.dependsOn asciidoctor
|
publishGhPages.dependsOn asciidoctor
|
||||||
|
|
||||||
githubPages {
|
githubPages {
|
||||||
repoUri = 'https://github.com/Swagger2Markup/swagger2markup.git'
|
repoUri = 'https://github.com/Swagger2Markup/swagger2markup.git'
|
||||||
|
|
||||||
// use ENV GRGIT_USER
|
|
||||||
// use ENV GRGIT_PASS
|
|
||||||
// or org.ajoberstar.grgit.auth.username system property
|
|
||||||
// org.ajoberstar.grgit.auth.password system property
|
|
||||||
// see http://ajoberstar.org/grgit/grgit-authentication.html for details
|
|
||||||
credentials {
|
credentials {
|
||||||
username = project.hasProperty('githubUser') ? project.githubUser : System.getenv('GITHUB_USER')
|
username = project.hasProperty('githubUser') ? project.githubUser : System.getenv('GITHUB_USER')
|
||||||
password = project.hasProperty('githubPassword') ? project.githubPassword : System.getenv('GITHUB_PASSWORD')
|
password = project.hasProperty('githubPassword') ? project.githubPassword : System.getenv('GITHUB_PASSWORD')
|
||||||
}
|
}
|
||||||
|
|
||||||
pages {
|
pages {
|
||||||
from file(asciidoctor.outputDir.path + '/html5')
|
from file(asciidoctor.outputDir.path + '/html5')
|
||||||
into project.releaseVersion
|
into project.releaseVersion
|
||||||
}
|
}
|
||||||
151
gradle/publishing.gradle
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
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
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Mon Oct 21 16:35:38 BST 2019
|
#Thu Jan 05 14:27:30 CET 2017
|
||||||
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-5.6.3-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip
|
||||||
|
|||||||
23
gradlew
vendored
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
##
|
||||||
@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
|
|||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD="maximum"
|
||||||
|
|
||||||
warn () {
|
warn ( ) {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
}
|
}
|
||||||
|
|
||||||
die () {
|
die ( ) {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
@@ -154,19 +154,16 @@ if $cygwin ; then
|
|||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Escape application args
|
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
|
||||||
save () {
|
function splitJvmOpts() {
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
JVM_OPTS=("$@")
|
||||||
echo " "
|
|
||||||
}
|
}
|
||||||
APP_ARGS=$(save "$@")
|
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
|
||||||
|
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
|
||||||
# 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
|
# 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
|
if [[ "$(uname)" == "Darwin" ]] && [[ "$HOME" == "$PWD" ]]; then
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
// 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,
|
|
||||||
]
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
@@ -1,378 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
package io.github.swagger2markup;
|
|
||||||
|
|
||||||
import io.github.swagger2markup.config.builder.Schema2MarkupConfigBuilder;
|
|
||||||
|
|
||||||
public class OpenSchema2MarkupConfig extends Schema2MarkupConfigBuilder.DefaultSchema2MarkupConfig {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
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()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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();
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,127 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
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 "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
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,276 +0,0 @@
|
|||||||
= 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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|===
|
|
||||||
|
|
||||||
@@ -1,351 +0,0 @@
|
|||||||
|
|
||||||
[[_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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|===
|
|
||||||
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
= 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
|
|
||||||
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<?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>
|
|
||||||
@@ -1,732 +0,0 @@
|
|||||||
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'
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -1,693 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
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,10 +1 @@
|
|||||||
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'
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ To create a custom extension, you have to create a class (e.g. `io.myname.MyExte
|
|||||||
|
|
||||||
[source,java,indent=0]
|
[source,java,indent=0]
|
||||||
----
|
----
|
||||||
include::{coreProjectDir}/src/test/java/io/github/swagger2markup/builder/MyExtension.java[tags=MyExtension]
|
include::../../test/java/io/github/swagger2markup/builder/MyExtension.java[tags=MyExtension]
|
||||||
----
|
----
|
||||||
1. You can retrieve extension properties from the config to configure the extension.
|
1. You can retrieve extension properties from the config to configure the extension.
|
||||||
2. You can retrieve a `MarkupDocBuilder` from the `Context`.
|
2. You can retrieve a `MarkupDocBuilder` from the `Context`.
|
||||||
@@ -47,7 +47,7 @@ To register your extension manually, you have to use the `Swagger2MarkupExtensio
|
|||||||
|
|
||||||
[source,java,indent=0]
|
[source,java,indent=0]
|
||||||
----
|
----
|
||||||
include::{coreProjectDir}/src/test/java/io/github/swagger2markup/DocumentationTest.java[tags=swagger2MarkupExtensionRegistryBuilder]
|
include::../../test/java/io/github/swagger2markup/DocumentationTest.java[tags=swagger2MarkupExtensionRegistryBuilder]
|
||||||
----
|
----
|
||||||
1. Create a ``Swagger2MarkupExtensionRegistryBuilder`` using the default constructor
|
1. Create a ``Swagger2MarkupExtensionRegistryBuilder`` using the default constructor
|
||||||
2. Register your custom extension
|
2. Register your custom extension
|
||||||
@@ -142,7 +142,7 @@ Example:
|
|||||||
|
|
||||||
[source,java,indent=0]
|
[source,java,indent=0]
|
||||||
----
|
----
|
||||||
include::{coreProjectDir}/src/test/java/io/github/swagger2markup/builder/MySwaggerModelExtension.java[tags=MySwaggerModelExtension]
|
include::../../test/java/io/github/swagger2markup/builder/MySwaggerModelExtension.java[tags=MySwaggerModelExtension]
|
||||||
----
|
----
|
||||||
1. You can change any Swagger model property
|
1. You can change any Swagger model property
|
||||||
2. You could even remove elements from the Swagger model
|
2. You could even remove elements from the Swagger model
|
||||||
|
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 130 KiB |
|
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 116 KiB |
|
Before Width: | Height: | Size: 133 KiB After Width: | Height: | Size: 133 KiB |
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
@@ -6,7 +6,7 @@ NOTE: The Swagger Specification has been donated to to the https://openapis.org/
|
|||||||
|
|
||||||
Swagger2Markup converts a Swagger JSON or YAML specification into either **AsciiDoc**, **GitHub Flavored Markdown** or *Atlassian Confluence Wiki* documents which can be combined with hand-written Markup documentation. The Swagger source file can be located locally or remotely via HTTP. Internally Swagger2Markup uses the __official__ https://github.com/swagger-api/swagger-parser[swagger-parser] and https://github.com/Swagger2Markup/markup-document-builder[markup-document-builder].
|
Swagger2Markup converts a Swagger JSON or YAML specification into either **AsciiDoc**, **GitHub Flavored Markdown** or *Atlassian Confluence Wiki* documents which can be combined with hand-written Markup documentation. The Swagger source file can be located locally or remotely via HTTP. Internally Swagger2Markup uses the __official__ https://github.com/swagger-api/swagger-parser[swagger-parser] and https://github.com/Swagger2Markup/markup-document-builder[markup-document-builder].
|
||||||
|
|
||||||
You can use Swagger2Markup to convert your contract-first Swagger YAML file into Markup. As an alternative, you can choose the code-first approach and use Swagger2Markup together with https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-JAX-RS-Project-Setup-1.5.X[Swagger JAX-RS], https://github.com/springfox/springfox[Springfox] or https://github.com/spring-projects/spring-restdocs[spring-restdocs]. If you are a Gradle or Maven user, you can also use the https://github.com/Swagger2Markup/swagger2markup-gradle-plugin[Swagger2Markup Gradle Plugin] or https://github.com/redowl/swagger2markup-maven-plugin[Swagger2markup Maven Plugin].
|
You can use Swagger2Markup to convert your contract-first Swagger YAML file into Markup. As an alternative, you can choose the code-first approach and use Swagger2Markup together with https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-JAX-RS-Project-Setup-1.5.X[Swagger JAX-RS], https://github.com/springfox/springfox[Springfox] or https://github.com/spring-projects/spring-restdocs[spring-restdocs]. If you are are Gradle or Maven user, you can also use the https://github.com/Swagger2Markup/swagger2markup-gradle-plugin[Swagger2Markup Gradle Plugin] or https://github.com/redowl/swagger2markup-maven-plugin[Swagger2markup Maven Plugin].
|
||||||
|
|
||||||
NOTE: The project requires at least JDK 8.
|
NOTE: The project requires at least JDK 8.
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ The entry point of the Swagger2Markup API is the ``Swagger2MarkupConverter`` cla
|
|||||||
|
|
||||||
[source,java,indent=0]
|
[source,java,indent=0]
|
||||||
----
|
----
|
||||||
include::{coreProjectDir}/src/test/java/io/github/swagger2markup/DocumentationTest.java[tags=localSwaggerSpec]
|
include::../../test/java/io/github/swagger2markup/DocumentationTest.java[tags=localSwaggerSpec]
|
||||||
----
|
----
|
||||||
|
|
||||||
1. Create a ``Swagger2MarkupConverter.Builder`` by specifying the Path to the local file
|
1. Create a ``Swagger2MarkupConverter.Builder`` by specifying the Path to the local file
|
||||||
@@ -26,7 +26,7 @@ You can convert a remote Swagger specification which must be accessible via HTTP
|
|||||||
|
|
||||||
[source,java,indent=0]
|
[source,java,indent=0]
|
||||||
----
|
----
|
||||||
include::{coreProjectDir}/src/test/java/io/github/swagger2markup/DocumentationTest.java[tags=remoteSwaggerSpec]
|
include::../../test/java/io/github/swagger2markup/DocumentationTest.java[tags=remoteSwaggerSpec]
|
||||||
----
|
----
|
||||||
|
|
||||||
1. Create a ``Swagger2MarkupConverter.Builder`` by specifying the URL to the remote file
|
1. Create a ``Swagger2MarkupConverter.Builder`` by specifying the URL to the remote file
|
||||||
@@ -40,7 +40,7 @@ You can convert the Swagger specification into a file.
|
|||||||
|
|
||||||
[source,java,indent=0]
|
[source,java,indent=0]
|
||||||
----
|
----
|
||||||
include::{coreProjectDir}/src/test/java/io/github/swagger2markup/DocumentationTest.java[tags=convertIntoOneFile]
|
include::../../test/java/io/github/swagger2markup/DocumentationTest.java[tags=convertIntoOneFile]
|
||||||
----
|
----
|
||||||
|
|
||||||
==== Conversion to a String
|
==== Conversion to a String
|
||||||
@@ -50,7 +50,7 @@ You can convert the Swagger specification to a String.
|
|||||||
|
|
||||||
[source,java,indent=0]
|
[source,java,indent=0]
|
||||||
----
|
----
|
||||||
include::{coreProjectDir}/src/test/java/io/github/swagger2markup/DocumentationTest.java[tags=convertIntoString]
|
include::../../test/java/io/github/swagger2markup/DocumentationTest.java[tags=convertIntoString]
|
||||||
----
|
----
|
||||||
|
|
||||||
=== Configuration
|
=== Configuration
|
||||||
@@ -69,7 +69,7 @@ You can configure the Swagger2MarkupConverter by using the `Swagger2MarkupConfig
|
|||||||
|
|
||||||
[source,java,indent=0]
|
[source,java,indent=0]
|
||||||
----
|
----
|
||||||
include::{coreProjectDir}/src/test/java/io/github/swagger2markup/DocumentationTest.java[tags=swagger2MarkupConfigBuilder]
|
include::../../test/java/io/github/swagger2markup/DocumentationTest.java[tags=swagger2MarkupConfigBuilder]
|
||||||
----
|
----
|
||||||
|
|
||||||
1. Create a `Swagger2MarkupConfigBuilder` using the default constructor.
|
1. Create a `Swagger2MarkupConfigBuilder` using the default constructor.
|
||||||
@@ -85,7 +85,7 @@ You can also create a `Swagger2MarkupConfig` from a Properties file, a `Map` or
|
|||||||
|
|
||||||
[source,java,indent=0]
|
[source,java,indent=0]
|
||||||
----
|
----
|
||||||
include::{coreProjectDir}/src/test/java/io/github/swagger2markup/DocumentationTest.java[tags=swagger2MarkupConfigFromProperties]
|
include::../../test/java/io/github/swagger2markup/DocumentationTest.java[tags=swagger2MarkupConfigFromProperties]
|
||||||
----
|
----
|
||||||
1. Load a `Properties` file from the classpath or local filesystem.
|
1. Load a `Properties` file from the classpath or local filesystem.
|
||||||
2. Create a `Swagger2MarkupConfigBuilder` using the proper constructor.
|
2. Create a `Swagger2MarkupConfigBuilder` using the proper constructor.
|
||||||
@@ -94,7 +94,7 @@ include::{coreProjectDir}/src/test/java/io/github/swagger2markup/DocumentationTe
|
|||||||
|
|
||||||
[source,java,indent=0]
|
[source,java,indent=0]
|
||||||
----
|
----
|
||||||
include::{coreProjectDir}/src/test/java/io/github/swagger2markup/DocumentationTest.java[tags=swagger2MarkupConfigFromMap]
|
include::../../test/java/io/github/swagger2markup/DocumentationTest.java[tags=swagger2MarkupConfigFromMap]
|
||||||
----
|
----
|
||||||
|
|
||||||
1. Create a `Map` and configure the `Swagger2MarkupProperties`.
|
1. Create a `Map` and configure the `Swagger2MarkupProperties`.
|
||||||
@@ -113,7 +113,7 @@ Configuration parameters may be loaded from the following sources using Apache C
|
|||||||
|
|
||||||
[source,java,indent=0]
|
[source,java,indent=0]
|
||||||
----
|
----
|
||||||
include::{coreProjectDir}/src/test/java/io/github/swagger2markup/DocumentationTest.java[tags=swagger2MarkupConfigFromCommonsConfiguration]
|
include::../../test/java/io/github/swagger2markup/DocumentationTest.java[tags=swagger2MarkupConfigFromCommonsConfiguration]
|
||||||
----
|
----
|
||||||
|
|
||||||
1. Create an Apache Commons `Configuration` object using the proper ConfigurationBuilder.
|
1. Create an Apache Commons `Configuration` object using the proper ConfigurationBuilder.
|
||||||
@@ -139,6 +139,7 @@ The following tables list all available properties of Swagger2Markup:
|
|||||||
|swagger2markup.pathsGroupedBy| Specifies how the paths should be grouped | AS_IS, TAGS, REGEX | AS_IS
|
|swagger2markup.pathsGroupedBy| Specifies how the paths should be grouped | AS_IS, TAGS, REGEX | AS_IS
|
||||||
|swagger2markup.outputLanguage| Specifies the language of the labels | EN, DE, FR, RU | EN
|
|swagger2markup.outputLanguage| Specifies the language of the labels | EN, DE, FR, RU | EN
|
||||||
|swagger2markup.lineSeparator| Specifies the line separator which should be used | UNIX, WINDOWS, MAC | <System-dependent>
|
|swagger2markup.lineSeparator| Specifies the line separator which should be used | UNIX, WINDOWS, MAC | <System-dependent>
|
||||||
|
|swagger2markup.generatedExamplesEnabled| Specifies if HTTP request and response examples should be generated | true, false | false
|
||||||
|swagger2markup.flatBodyEnabled| Optionally isolate the body parameter, if any, from other parameters | true, false | false
|
|swagger2markup.flatBodyEnabled| Optionally isolate the body parameter, if any, from other parameters | true, false | false
|
||||||
|swagger2markup.pathSecuritySectionEnabled| Optionally disable the security section for path sections | true, false | true
|
|swagger2markup.pathSecuritySectionEnabled| Optionally disable the security section for path sections | true, false | true
|
||||||
|swagger2markup.anchorPrefix| Optionally prefix all anchors for uniqueness if you want to include generated documents into a global documentation | Any String |
|
|swagger2markup.anchorPrefix| Optionally prefix all anchors for uniqueness if you want to include generated documents into a global documentation | Any String |
|
||||||
@@ -200,59 +201,6 @@ The following tables list all available properties of Swagger2Markup:
|
|||||||
|swagger2markup.pageBreakLocations | Specifies where page breaks should be inserted. | BEFORE_OPERATION, BEFORE_OPERATION_DESCRIPTION, BEFORE_OPERATION_PARAMETERS, BEFORE_OPERATION_RESPONSES, BEFORE_OPERATION_CONSUMES, BEFORE_OPERATION_PRODUCES, BEFORE_OPERATION_EXAMPLE_REQUEST, BEFORE_OPERATION_EXAMPLE_RESPONSE, BEFORE_DEFINITION, AFTER_OPERATION, AFTER_OPERATION_DESCRIPTION, AFTER_OPERATION_PARAMETERS, AFTER_OPERATION_RESPONSES, AFTER_OPERATION_CONSUMES, AFTER_OPERATION_PRODUCES, AFTER_OPERATION_EXAMPLE_REQUEST, AFTER_OPERATION_EXAMPLE_RESPONSE, AFTER_DEFINITION | empty
|
|swagger2markup.pageBreakLocations | Specifies where page breaks should be inserted. | BEFORE_OPERATION, BEFORE_OPERATION_DESCRIPTION, BEFORE_OPERATION_PARAMETERS, BEFORE_OPERATION_RESPONSES, BEFORE_OPERATION_CONSUMES, BEFORE_OPERATION_PRODUCES, BEFORE_OPERATION_EXAMPLE_REQUEST, BEFORE_OPERATION_EXAMPLE_RESPONSE, BEFORE_DEFINITION, AFTER_OPERATION, AFTER_OPERATION_DESCRIPTION, AFTER_OPERATION_PARAMETERS, AFTER_OPERATION_RESPONSES, AFTER_OPERATION_CONSUMES, AFTER_OPERATION_PRODUCES, AFTER_OPERATION_EXAMPLE_REQUEST, AFTER_OPERATION_EXAMPLE_RESPONSE, AFTER_DEFINITION | empty
|
||||||
|===
|
|===
|
||||||
|
|
||||||
|
|
||||||
[options="header"]
|
|
||||||
.Properties which configure examples generation
|
|
||||||
|===
|
|
||||||
|Name |Description |Possible Values |Default
|
|
||||||
|
|
||||||
|swagger2markup.generatedExamplesEnabled
|
|
||||||
| Specifies if HTTP request and response examples should be generated
|
|
||||||
| true, false
|
|
||||||
| false
|
|
||||||
|
|
||||||
|swagger2markup.requestExamplesFormat
|
|
||||||
| Specifies if `Request path` contents in `Example HTTP request` section should contain popular example utility
|
|
||||||
invocation, e.g. `curl`
|
|
||||||
a|
|
|
||||||
* `basic` — example will have only endpoint and query params
|
|
||||||
* `curl` — example with `curl` utility
|
|
||||||
* `invoke-webrequest` — example with `Invoke-WebRequest` command of `powershell`
|
|
||||||
| basic
|
|
||||||
|
|
||||||
|swagger2markup.requestExamplesSourceFormat
|
|
||||||
|`Request path` source block code style format
|
|
||||||
| `default` or any suppordet by asciidoc
|
|
||||||
| none for `basic`, `bash` for `curl` and `powershell` for `WebRequest`
|
|
||||||
|
|
||||||
|swagger2markup.requestExamplesIncludeAllQueryParams
|
|
||||||
|Specifies if `Request path` should contain required and optional params (if true) or only required (if false)
|
|
||||||
|true, false
|
|
||||||
|false
|
|
||||||
|
|
||||||
|swagger2markup.requestExamplesHost
|
|
||||||
|Should we hide, inherit or override hostname (e.g. with google.com) from yml file
|
|
||||||
|`hide`, `inherit` or string with hostname to be used in request example
|
|
||||||
| hide
|
|
||||||
|
|
||||||
|swagger2markup.requestExamplesSchema
|
|
||||||
|Should we hide, inherit or override schema (http, https name it) from yml file
|
|
||||||
|`hide`, `inherit` or string with schema name to be used in request example
|
|
||||||
| hide
|
|
||||||
|
|
||||||
|swagger2markup.requestExamplesHideBasePath
|
|
||||||
|Should we hide or show base path in example request endpoint address
|
|
||||||
|true, false
|
|
||||||
|true
|
|
||||||
|
|
||||||
|swagger2markup.requestExamplesQueryArrayStyle
|
|
||||||
|How we should output array query params
|
|
||||||
|`single` — single time (similar to basic types), `commaSeparated` — single time with multiple comma separated values, `multiple` times with same param name and different values, `multiple[]` times with array brackets as param name suffix.
|
|
||||||
|single
|
|
||||||
|
|
||||||
|
|
||||||
|===
|
|
||||||
|
|
||||||
=== Logging
|
=== Logging
|
||||||
|
|
||||||
Swagger2Markup uses http://www.slf4j.org/[SLF4J] for all internal logging, but leaves the underlying log implementation open. To change the log level, you have the set the log level of the `io.github.swagger2markup` package.
|
Swagger2Markup uses http://www.slf4j.org/[SLF4J] for all internal logging, but leaves the underlying log implementation open. To change the log level, you have the set the log level of the `io.github.swagger2markup` package.
|
||||||
14
src/main/java/io/github/swagger2markup/ExampleType.java
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package io.github.swagger2markup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* swagger2markup (c) Duco Hosting
|
||||||
|
* Created by cas on 02-Oct-17.
|
||||||
|
*/
|
||||||
|
public enum ExampleType {
|
||||||
|
QUERY,
|
||||||
|
POST,
|
||||||
|
HEADER,
|
||||||
|
PATH,
|
||||||
|
BODY,
|
||||||
|
OTHER
|
||||||
|
}
|
||||||
@@ -15,9 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.swagger2markup;
|
package io.github.swagger2markup;
|
||||||
|
|
||||||
/**
|
|
||||||
* GroupBy enum for ordering
|
|
||||||
*/
|
|
||||||
public enum GroupBy {
|
public enum GroupBy {
|
||||||
AS_IS,
|
AS_IS,
|
||||||
TAGS,
|
TAGS,
|
||||||
@@ -15,10 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.swagger2markup;
|
package io.github.swagger2markup;
|
||||||
|
|
||||||
|
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class SwaggerLabels extends Labels {
|
public class Labels {
|
||||||
|
|
||||||
public static final String DEFAULT_COLUMN = "default_column";
|
public static final String DEFAULT_COLUMN = "default_column";
|
||||||
public static final String MAXLENGTH_COLUMN = "maxlength_column";
|
public static final String MAXLENGTH_COLUMN = "maxlength_column";
|
||||||
@@ -90,15 +89,25 @@ public class SwaggerLabels extends Labels {
|
|||||||
public static final String BODY_PARAMETER = "body_parameter";
|
public static final String BODY_PARAMETER = "body_parameter";
|
||||||
public static final String RESPONSES = "responses";
|
public static final String RESPONSES = "responses";
|
||||||
public static final String HEADERS_COLUMN = "headers_column";
|
public static final String HEADERS_COLUMN = "headers_column";
|
||||||
public static final String MIN_ITEMS = "min_items";
|
|
||||||
public static final String MAX_ITEMS = "max_items";
|
|
||||||
public static final String EXAMPLE_REQUEST = "example_request";
|
public static final String EXAMPLE_REQUEST = "example_request";
|
||||||
public static final String EXAMPLE_RESPONSE = "example_response";
|
public static final String EXAMPLE_RESPONSE = "example_response";
|
||||||
public static final String HTTP_CODE_COLUMN = "http_code_column";
|
public static final String HTTP_CODE_COLUMN = "http_code_column";
|
||||||
public static final String DEPRECATED_OPERATION = "operation.deprecated";
|
public static final String DEPRECATED_OPERATION = "operation.deprecated";
|
||||||
public static final String UNKNOWN = "unknown";
|
public static final String UNKNOWN = "unknown";
|
||||||
|
|
||||||
public SwaggerLabels(Swagger2MarkupConfig config) {
|
private ResourceBundle resourceBundle;
|
||||||
super(ResourceBundle.getBundle("io/github/swagger2markup/lang/labels", config.getLanguage().toLocale()));
|
|
||||||
|
public Labels(Swagger2MarkupConfig config) {
|
||||||
|
this.resourceBundle = ResourceBundle.getBundle("io/github/swagger2markup/lang/labels", config.getOutputLanguage().toLocale());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a label for the given key from this resource bundle.
|
||||||
|
*
|
||||||
|
* @param key the key for the desired label
|
||||||
|
* @return the label for the given key
|
||||||
|
*/
|
||||||
|
public String getLabel(String key) {
|
||||||
|
return resourceBundle.getString(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,8 +30,7 @@ public enum Language {
|
|||||||
ZH(Locale.CHINESE),
|
ZH(Locale.CHINESE),
|
||||||
ES(new Locale("es")),
|
ES(new Locale("es")),
|
||||||
BR(new Locale("pt", "BR")),
|
BR(new Locale("pt", "BR")),
|
||||||
JA(Locale.JAPANESE),
|
JA(Locale.JAPANESE);
|
||||||
PL(new Locale("pl"));
|
|
||||||
|
|
||||||
private final Locale lang;
|
private final Locale lang;
|
||||||
|
|
||||||
@@ -15,9 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.swagger2markup;
|
package io.github.swagger2markup;
|
||||||
|
|
||||||
/**
|
|
||||||
* Marker interface for PageBreak enums
|
|
||||||
*/
|
|
||||||
public enum PageBreakLocations {
|
public enum PageBreakLocations {
|
||||||
BEFORE_OPERATION,
|
BEFORE_OPERATION,
|
||||||
BEFORE_OPERATION_DESCRIPTION,
|
BEFORE_OPERATION_DESCRIPTION,
|
||||||
@@ -13,11 +13,12 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package io.github.swagger2markup.config;
|
package io.github.swagger2markup;
|
||||||
|
|
||||||
import io.github.swagger2markup.*;
|
import io.github.swagger2markup.markup.builder.LineSeparator;
|
||||||
import io.github.swagger2markup.model.Parameter;
|
import io.github.swagger2markup.markup.builder.MarkupLanguage;
|
||||||
import io.github.swagger2markup.model.PathOperation;
|
import io.github.swagger2markup.model.PathOperation;
|
||||||
|
import io.swagger.models.parameters.Parameter;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -26,202 +27,141 @@ import java.util.regex.Pattern;
|
|||||||
/**
|
/**
|
||||||
* Swagger2Markup configuration interface.
|
* Swagger2Markup configuration interface.
|
||||||
*/
|
*/
|
||||||
public interface Schema2MarkupConfig {
|
public interface Swagger2MarkupConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the markup language which should be used to generate the files.
|
* Specifies the markup language which should be used to generate the files.
|
||||||
*
|
|
||||||
* @return Specifies the markup language which should be used to generate the files.
|
|
||||||
*/
|
*/
|
||||||
MarkupLanguage getMarkupLanguage();
|
MarkupLanguage getMarkupLanguage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the markup language used in Swagger descriptions.<br>
|
* Specifies the markup language used in Swagger descriptions.<br>
|
||||||
* By default, {@link MarkupLanguage#MARKDOWN} is assumed.
|
* By default, {@link io.github.swagger2markup.markup.builder.MarkupLanguage#MARKDOWN} is assumed.
|
||||||
*
|
|
||||||
* @return Specifies the markup language used in Swagger descriptions.
|
|
||||||
*/
|
*/
|
||||||
MarkupLanguage getSchemaMarkupLanguage();
|
MarkupLanguage getSwaggerMarkupLanguage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Include generated examples into the documents.
|
* Include generated examples into the documents.
|
||||||
*
|
|
||||||
* @return Include generated examples into the documents.
|
|
||||||
*/
|
*/
|
||||||
boolean isGeneratedExamplesEnabled();
|
boolean isGeneratedExamplesEnabled();
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepend the hostname to all paths.
|
|
||||||
*
|
|
||||||
* @return Prepend the hostname to all paths.
|
|
||||||
*/
|
|
||||||
boolean isHostnameEnabled();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepend the base path to all paths.
|
* Prepend the base path to all paths.
|
||||||
*
|
|
||||||
* @return Prepend the base path to all paths.
|
|
||||||
*/
|
*/
|
||||||
boolean isBasePathPrefixEnabled();
|
boolean isBasePathPrefixEnabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In addition to the Definitions file, also create separate definition files for each model definition.
|
* In addition to the Definitions file, also create separate definition files for each model definition.
|
||||||
*
|
|
||||||
* @return In addition to the Definitions file, also create separate definition files for each model definition.
|
|
||||||
*/
|
*/
|
||||||
boolean isSeparatedDefinitionsEnabled();
|
boolean isSeparatedDefinitionsEnabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In addition to the Paths file, also create separate operation files for each operation.
|
* In addition to the Paths file, also create separate operation files for each operation.
|
||||||
*
|
|
||||||
* @return In addition to the Paths file, also create separate operation files for each operation.
|
|
||||||
*/
|
*/
|
||||||
boolean isSeparatedOperationsEnabled();
|
boolean isSeparatedOperationsEnabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies if the operations should be grouped by tags or stay as-is.
|
* Specifies if the operations should be grouped by tags or stay as-is.
|
||||||
*
|
|
||||||
* @return Specifies if the operations should be grouped by tags or stay as-is.
|
|
||||||
*/
|
*/
|
||||||
GroupBy getPathsGroupedBy();
|
GroupBy getPathsGroupedBy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies labels language of output files.
|
* Specifies labels language of output files.
|
||||||
*
|
|
||||||
* @return Specifies labels language of output files.
|
|
||||||
*/
|
*/
|
||||||
Language getLanguage();
|
Language getOutputLanguage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies if inline schemas are detailed
|
* Specifies if inline schemas are detailed
|
||||||
*
|
|
||||||
* @return Specifies if inline schemas are detailed
|
|
||||||
*/
|
*/
|
||||||
boolean isInlineSchemaEnabled();
|
boolean isInlineSchemaEnabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies tag ordering.
|
* Specifies tag ordering.
|
||||||
*
|
|
||||||
* @return Specifies tag ordering.
|
|
||||||
*/
|
*/
|
||||||
OrderBy getTagOrderBy();
|
OrderBy getTagOrderBy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the regex pattern used for header matching
|
* Specifies the regex pattern used for header matching
|
||||||
*
|
|
||||||
* @return Specifies the regex pattern used for header matching
|
|
||||||
*/
|
*/
|
||||||
Pattern getHeaderPattern();
|
Pattern getHeaderPattern();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies a custom comparator function to order tags.
|
* Specifies a custom comparator function to order tags.
|
||||||
*
|
|
||||||
* @return Specifies a custom comparator function to order tags.
|
|
||||||
*/
|
*/
|
||||||
Comparator<String> getTagOrdering();
|
Comparator<String> getTagOrdering();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies operation ordering.
|
* Specifies operation ordering.
|
||||||
*
|
|
||||||
* @return Specifies operation ordering.
|
|
||||||
*/
|
*/
|
||||||
OrderBy getOperationOrderBy();
|
OrderBy getOperationOrderBy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies a custom comparator function to order operations.
|
* Specifies a custom comparator function to order operations.
|
||||||
*
|
|
||||||
* @return Specifies a custom comparator function to order operations.
|
|
||||||
*/
|
*/
|
||||||
Comparator<PathOperation> getOperationOrdering();
|
Comparator<PathOperation> getOperationOrdering();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies definition ordering.
|
* Specifies definition ordering.
|
||||||
*
|
|
||||||
* @return Specifies definition ordering.
|
|
||||||
*/
|
*/
|
||||||
OrderBy getDefinitionOrderBy();
|
OrderBy getDefinitionOrderBy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies a custom comparator function to order definitions.
|
* Specifies a custom comparator function to order definitions.
|
||||||
*
|
|
||||||
* @return Specifies a custom comparator function to order definitions.
|
|
||||||
*/
|
*/
|
||||||
Comparator<String> getDefinitionOrdering();
|
Comparator<String> getDefinitionOrdering();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies parameter ordering.
|
* Specifies parameter ordering.
|
||||||
*
|
|
||||||
* @return Specifies parameter ordering.
|
|
||||||
*/
|
*/
|
||||||
OrderBy getParameterOrderBy();
|
OrderBy getParameterOrderBy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies a custom comparator function to order parameters.
|
* Specifies a custom comparator function to order parameters.
|
||||||
*
|
|
||||||
* @return Specifies a custom comparator function to order parameters.
|
|
||||||
*/
|
*/
|
||||||
Comparator<Parameter> getParameterOrdering();
|
Comparator<Parameter> getParameterOrdering();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies property ordering.
|
* Specifies property ordering.
|
||||||
*
|
|
||||||
* @return Specifies property ordering.
|
|
||||||
*/
|
*/
|
||||||
OrderBy getPropertyOrderBy();
|
OrderBy getPropertyOrderBy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies a custom comparator function to order properties.
|
* Specifies a custom comparator function to order properties.
|
||||||
*
|
|
||||||
* @return Specifies a custom comparator function to order properties.
|
|
||||||
*/
|
*/
|
||||||
Comparator<String> getPropertyOrdering();
|
Comparator<String> getPropertyOrdering();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies response ordering.
|
* Specifies response ordering.
|
||||||
*
|
|
||||||
* @return Specifies response ordering.
|
|
||||||
*/
|
*/
|
||||||
OrderBy getResponseOrderBy();
|
OrderBy getResponseOrderBy();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies a custom comparator function to order responses.
|
* Specifies a custom comparator function to order responses.
|
||||||
*
|
|
||||||
* @return Specifies a custom comparator function to order responses.
|
|
||||||
*/
|
*/
|
||||||
Comparator<String> getResponseOrdering();
|
Comparator<String> getResponseOrdering();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable use of inter-document cross-references when needed.
|
* Enable use of inter-document cross-references when needed.
|
||||||
*
|
|
||||||
* @return Enable use of inter-document cross-references when needed.
|
|
||||||
*/
|
*/
|
||||||
boolean isInterDocumentCrossReferencesEnabled();
|
boolean isInterDocumentCrossReferencesEnabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inter-document cross-references optional prefix.
|
* Inter-document cross-references optional prefix.
|
||||||
*
|
|
||||||
* @return Inter-document cross-references optional prefix.
|
|
||||||
*/
|
*/
|
||||||
String getInterDocumentCrossReferencesPrefix();
|
String getInterDocumentCrossReferencesPrefix();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optionally isolate the body parameter, if any, from other parameters.
|
* Optionally isolate the body parameter, if any, from other parameters.
|
||||||
*
|
|
||||||
* @return Optionally isolate the body parameter, if any, from other parameters.
|
|
||||||
*/
|
*/
|
||||||
boolean isFlatBodyEnabled();
|
boolean isFlatBodyEnabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optionally disable the security section for path sections
|
* Optionally disable the security section for path sections
|
||||||
*
|
|
||||||
* @return Optionally disable the security section for path sections
|
|
||||||
*/
|
*/
|
||||||
boolean isPathSecuritySectionEnabled();
|
boolean isPathSecuritySectionEnabled();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optionally prefix all anchors for uniqueness.
|
* Optionally prefix all anchors for uniqueness.
|
||||||
*
|
|
||||||
* @return Optionally prefix all anchors for uniqueness.
|
|
||||||
*/
|
*/
|
||||||
String getAnchorPrefix();
|
String getAnchorPrefix();
|
||||||
|
|
||||||
@@ -276,7 +216,6 @@ public interface Schema2MarkupConfig {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the array element delimiter to use for multi-valued properties.
|
* Specifies the array element delimiter to use for multi-valued properties.
|
||||||
*
|
|
||||||
* @return the element delimiter if any
|
* @return the element delimiter if any
|
||||||
*/
|
*/
|
||||||
Character getListDelimiter();
|
Character getListDelimiter();
|
||||||
@@ -284,7 +223,6 @@ public interface Schema2MarkupConfig {
|
|||||||
/**
|
/**
|
||||||
* Optionally allow lists in property values. Uses the {{@link #getListDelimiter()} to
|
* Optionally allow lists in property values. Uses the {{@link #getListDelimiter()} to
|
||||||
* delimit list values.
|
* delimit list values.
|
||||||
*
|
|
||||||
* @return whether lists are converted to arrays
|
* @return whether lists are converted to arrays
|
||||||
*/
|
*/
|
||||||
boolean isListDelimiterEnabled();
|
boolean isListDelimiterEnabled();
|
||||||
@@ -294,7 +232,7 @@ public interface Schema2MarkupConfig {
|
|||||||
*
|
*
|
||||||
* @return the extension properties
|
* @return the extension properties
|
||||||
*/
|
*/
|
||||||
Schema2MarkupProperties getExtensionsProperties();
|
Swagger2MarkupProperties getExtensionsProperties();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of page break locations
|
* Returns the list of page break locations
|
||||||
@@ -302,62 +240,4 @@ public interface Schema2MarkupConfig {
|
|||||||
* @return List of PageBreakLocations
|
* @return List of PageBreakLocations
|
||||||
*/
|
*/
|
||||||
List<PageBreakLocations> getPageBreakLocations();
|
List<PageBreakLocations> getPageBreakLocations();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns custom timeout value.
|
|
||||||
*
|
|
||||||
* @return custom timeout value
|
|
||||||
*/
|
|
||||||
int getAsciidocPegdownTimeoutMillis();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns format name which should be used to format request example string.
|
|
||||||
*
|
|
||||||
* @return `basic`, `curl` or `invoke-webrequest`
|
|
||||||
*/
|
|
||||||
String getRequestExamplesFormat();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns format name which should be used to highlight source block with request example string
|
|
||||||
*
|
|
||||||
* @return any string or `default`
|
|
||||||
*/
|
|
||||||
String getRequestExamplesSourceFormat();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Should we output optional query params in source block with request example string
|
|
||||||
*
|
|
||||||
* @return false if example request should contain only required params
|
|
||||||
*/
|
|
||||||
boolean getRequestExamplesIncludeAllQueryParams();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* How we should output array query params:
|
|
||||||
*
|
|
||||||
* @return `single` — single time (similar to basic types), `commaSeparated` — single time with multiple comma
|
|
||||||
* separated values, `multiple` times with same param name and different values, `multiple[]` times with array
|
|
||||||
* brackets as param name suffix.
|
|
||||||
*/
|
|
||||||
String getRequestExamplesQueryArrayStyle();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Should we hide, inherit or override hostname (e.g. with google.com) from yml file
|
|
||||||
*
|
|
||||||
* @return `hide`, `inherit` or string with hostname to be used in request example
|
|
||||||
*/
|
|
||||||
String getRequestExamplesHost();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Should we hide, inherit or override schema (http, https name it) from yml file
|
|
||||||
*
|
|
||||||
* @return `hide`, `inherit` or string with schema name to be used in request example
|
|
||||||
*/
|
|
||||||
String getRequestExamplesSchema();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Should we hide or show base path in example request endpoint address
|
|
||||||
*
|
|
||||||
* @return true or false
|
|
||||||
*/
|
|
||||||
boolean getRequestExamplesHideBasePath();
|
|
||||||
}
|
}
|
||||||
@@ -21,11 +21,8 @@ import io.github.swagger2markup.internal.document.DefinitionsDocument;
|
|||||||
import io.github.swagger2markup.internal.document.OverviewDocument;
|
import io.github.swagger2markup.internal.document.OverviewDocument;
|
||||||
import io.github.swagger2markup.internal.document.PathsDocument;
|
import io.github.swagger2markup.internal.document.PathsDocument;
|
||||||
import io.github.swagger2markup.internal.document.SecurityDocument;
|
import io.github.swagger2markup.internal.document.SecurityDocument;
|
||||||
import io.github.swagger2markup.markup.builder.LineSeparator;
|
|
||||||
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
|
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
|
||||||
import io.github.swagger2markup.markup.builder.MarkupDocBuilders;
|
import io.github.swagger2markup.markup.builder.MarkupDocBuilders;
|
||||||
import io.github.swagger2markup.markup.builder.MarkupLanguage;
|
|
||||||
import io.github.swagger2markup.spi.Swagger2MarkupExtensionRegistry;
|
|
||||||
import io.github.swagger2markup.utils.URIUtils;
|
import io.github.swagger2markup.utils.URIUtils;
|
||||||
import io.swagger.models.Swagger;
|
import io.swagger.models.Swagger;
|
||||||
import io.swagger.parser.SwaggerParser;
|
import io.swagger.parser.SwaggerParser;
|
||||||
@@ -49,20 +46,20 @@ import java.nio.file.StandardOpenOption;
|
|||||||
/**
|
/**
|
||||||
* @author Robert Winkler
|
* @author Robert Winkler
|
||||||
*/
|
*/
|
||||||
public class Swagger2MarkupConverter extends AbstractSchema2MarkupConverter<Swagger> {
|
public class Swagger2MarkupConverter {
|
||||||
|
|
||||||
|
private final Context context;
|
||||||
private final OverviewDocument overviewDocument;
|
private final OverviewDocument overviewDocument;
|
||||||
private final PathsDocument pathsDocument;
|
private final PathsDocument pathsDocument;
|
||||||
private final DefinitionsDocument definitionsDocument;
|
private final DefinitionsDocument definitionsDocument;
|
||||||
private final SecurityDocument securityDocument;
|
private final SecurityDocument securityDocument;
|
||||||
private final SwaggerContext swaggerContext;
|
|
||||||
|
|
||||||
public Swagger2MarkupConverter(SwaggerContext swaggerContext) {
|
public Swagger2MarkupConverter(Context context) {
|
||||||
super(swaggerContext);
|
this.context = context;
|
||||||
this.swaggerContext = swaggerContext;
|
this.overviewDocument = new OverviewDocument(context);
|
||||||
this.overviewDocument = new OverviewDocument(swaggerContext);
|
this.pathsDocument = new PathsDocument(context);
|
||||||
this.pathsDocument = new PathsDocument(swaggerContext);
|
this.definitionsDocument = new DefinitionsDocument(context);
|
||||||
this.definitionsDocument = new DefinitionsDocument(swaggerContext);
|
this.securityDocument = new SecurityDocument(context);
|
||||||
this.securityDocument = new SecurityDocument(swaggerContext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -166,8 +163,8 @@ public class Swagger2MarkupConverter extends AbstractSchema2MarkupConverter<Swag
|
|||||||
*
|
*
|
||||||
* @return the global Context
|
* @return the global Context
|
||||||
*/
|
*/
|
||||||
public SwaggerContext getContext() {
|
public Context getContext() {
|
||||||
return swaggerContext;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -178,40 +175,40 @@ public class Swagger2MarkupConverter extends AbstractSchema2MarkupConverter<Swag
|
|||||||
public void toFolder(Path outputDirectory) {
|
public void toFolder(Path outputDirectory) {
|
||||||
Validate.notNull(outputDirectory, "outputDirectory must not be null");
|
Validate.notNull(outputDirectory, "outputDirectory must not be null");
|
||||||
|
|
||||||
swaggerContext.setOutputPath(outputDirectory);
|
context.setOutputPath(outputDirectory);
|
||||||
|
|
||||||
applyOverviewDocument()
|
applyOverviewDocument()
|
||||||
.writeToFile(outputDirectory.resolve(swaggerContext.config.getOverviewDocument()), StandardCharsets.UTF_8);
|
.writeToFile(outputDirectory.resolve(context.config.getOverviewDocument()), StandardCharsets.UTF_8);
|
||||||
applyPathsDocument()
|
applyPathsDocument()
|
||||||
.writeToFile(outputDirectory.resolve(swaggerContext.config.getPathsDocument()), StandardCharsets.UTF_8);
|
.writeToFile(outputDirectory.resolve(context.config.getPathsDocument()), StandardCharsets.UTF_8);
|
||||||
applyDefinitionsDocument()
|
applyDefinitionsDocument()
|
||||||
.writeToFile(outputDirectory.resolve(swaggerContext.config.getDefinitionsDocument()), StandardCharsets.UTF_8);
|
.writeToFile(outputDirectory.resolve(context.config.getDefinitionsDocument()), StandardCharsets.UTF_8);
|
||||||
applySecurityDocument()
|
applySecurityDocument()
|
||||||
.writeToFile(outputDirectory.resolve(swaggerContext.config.getSecurityDocument()), StandardCharsets.UTF_8);
|
.writeToFile(outputDirectory.resolve(context.config.getSecurityDocument()), StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MarkupDocBuilder applyOverviewDocument() {
|
private MarkupDocBuilder applyOverviewDocument() {
|
||||||
return overviewDocument.apply(
|
return overviewDocument.apply(
|
||||||
swaggerContext.createMarkupDocBuilder(),
|
context.createMarkupDocBuilder(),
|
||||||
OverviewDocument.parameters(swaggerContext.getSchema()));
|
OverviewDocument.parameters(context.getSwagger()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private MarkupDocBuilder applyPathsDocument() {
|
private MarkupDocBuilder applyPathsDocument() {
|
||||||
return pathsDocument.apply(
|
return pathsDocument.apply(
|
||||||
swaggerContext.createMarkupDocBuilder(),
|
context.createMarkupDocBuilder(),
|
||||||
PathsDocument.parameters(swaggerContext.getSchema().getPaths()));
|
PathsDocument.parameters(context.getSwagger().getPaths()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private MarkupDocBuilder applyDefinitionsDocument() {
|
private MarkupDocBuilder applyDefinitionsDocument() {
|
||||||
return definitionsDocument.apply(
|
return definitionsDocument.apply(
|
||||||
swaggerContext.createMarkupDocBuilder(),
|
context.createMarkupDocBuilder(),
|
||||||
DefinitionsDocument.parameters(swaggerContext.getSchema().getDefinitions()));
|
DefinitionsDocument.parameters(context.getSwagger().getDefinitions()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private MarkupDocBuilder applySecurityDocument() {
|
private MarkupDocBuilder applySecurityDocument() {
|
||||||
return securityDocument.apply(
|
return securityDocument.apply(
|
||||||
swaggerContext.createMarkupDocBuilder(),
|
context.createMarkupDocBuilder(),
|
||||||
SecurityDocument.parameters(swaggerContext.getSchema().getSecurityDefinitions()));
|
SecurityDocument.parameters(context.getSwagger().getSecurityDefinitions()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -346,8 +343,8 @@ public class Swagger2MarkupConverter extends AbstractSchema2MarkupConverter<Swag
|
|||||||
|
|
||||||
if (extensionRegistry == null)
|
if (extensionRegistry == null)
|
||||||
extensionRegistry = new Swagger2MarkupExtensionRegistryBuilder().build();
|
extensionRegistry = new Swagger2MarkupExtensionRegistryBuilder().build();
|
||||||
SwaggerLabels swaggerLabels = new SwaggerLabels(config);
|
|
||||||
SwaggerContext context = new SwaggerContext(config, extensionRegistry, swagger, swaggerLocation, swaggerLabels);
|
Context context = new Context(config, extensionRegistry, swagger, swaggerLocation);
|
||||||
|
|
||||||
initExtensions(context);
|
initExtensions(context);
|
||||||
|
|
||||||
@@ -356,7 +353,7 @@ public class Swagger2MarkupConverter extends AbstractSchema2MarkupConverter<Swag
|
|||||||
return new Swagger2MarkupConverter(context);
|
return new Swagger2MarkupConverter(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initExtensions(SwaggerContext context) {
|
private void initExtensions(Context context) {
|
||||||
extensionRegistry.getSwaggerModelExtensions().forEach(extension -> extension.setGlobalContext(context));
|
extensionRegistry.getSwaggerModelExtensions().forEach(extension -> extension.setGlobalContext(context));
|
||||||
extensionRegistry.getOverviewDocumentExtensions().forEach(extension -> extension.setGlobalContext(context));
|
extensionRegistry.getOverviewDocumentExtensions().forEach(extension -> extension.setGlobalContext(context));
|
||||||
extensionRegistry.getDefinitionsDocumentExtensions().forEach(extension -> extension.setGlobalContext(context));
|
extensionRegistry.getDefinitionsDocumentExtensions().forEach(extension -> extension.setGlobalContext(context));
|
||||||
@@ -364,44 +361,61 @@ public class Swagger2MarkupConverter extends AbstractSchema2MarkupConverter<Swag
|
|||||||
extensionRegistry.getSecurityDocumentExtensions().forEach(extension -> extension.setGlobalContext(context));
|
extensionRegistry.getSecurityDocumentExtensions().forEach(extension -> extension.setGlobalContext(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applySwaggerExtensions(SwaggerContext context) {
|
private void applySwaggerExtensions(Context context) {
|
||||||
extensionRegistry.getSwaggerModelExtensions().forEach(extension -> extension.apply(context.getSchema()));
|
extensionRegistry.getSwaggerModelExtensions().forEach(extension -> extension.apply(context.getSwagger()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SwaggerContext extends Context<Swagger> {
|
public static class Context {
|
||||||
private Swagger2MarkupConfig config;
|
private final Swagger2MarkupConfig config;
|
||||||
private Swagger2MarkupExtensionRegistry extensionRegistry;
|
private final Swagger swagger;
|
||||||
|
private final URI swaggerLocation;
|
||||||
|
private final Swagger2MarkupExtensionRegistry extensionRegistry;
|
||||||
|
private final Labels labels;
|
||||||
|
private Path outputPath;
|
||||||
|
|
||||||
public SwaggerContext(Swagger2MarkupConfig config,
|
public Context(Swagger2MarkupConfig config,
|
||||||
Swagger2MarkupExtensionRegistry extensionRegistry,
|
Swagger2MarkupExtensionRegistry extensionRegistry,
|
||||||
Swagger schema, URI swaggerLocation, Labels labels) {
|
Swagger swagger,
|
||||||
super(config, extensionRegistry, schema, swaggerLocation, labels);
|
URI swaggerLocation) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.extensionRegistry = extensionRegistry;
|
this.extensionRegistry = extensionRegistry;
|
||||||
|
this.swagger = swagger;
|
||||||
|
this.swaggerLocation = swaggerLocation;
|
||||||
|
this.labels = new Labels(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Swagger2MarkupConfig getConfig() {
|
public Swagger2MarkupConfig getConfig() {
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Swagger getSwagger() {
|
||||||
|
return swagger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public URI getSwaggerLocation() {
|
||||||
|
return swaggerLocation;
|
||||||
|
}
|
||||||
|
|
||||||
public Swagger2MarkupExtensionRegistry getExtensionRegistry() {
|
public Swagger2MarkupExtensionRegistry getExtensionRegistry() {
|
||||||
return extensionRegistry;
|
return extensionRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Labels getLabels() {
|
||||||
|
return labels;
|
||||||
|
}
|
||||||
|
|
||||||
public MarkupDocBuilder createMarkupDocBuilder() {
|
public MarkupDocBuilder createMarkupDocBuilder() {
|
||||||
MarkupLanguage markupLanguage = null;
|
return MarkupDocBuilders.documentBuilder(config.getMarkupLanguage(),
|
||||||
if (config.getMarkupLanguage() != null) {
|
config.getLineSeparator()).withAnchorPrefix(config.getAnchorPrefix());
|
||||||
markupLanguage = MarkupLanguage.valueOf(config.getMarkupLanguage().name());
|
}
|
||||||
}
|
|
||||||
LineSeparator lineSeparator = null;
|
public Path getOutputPath() {
|
||||||
if (config.getLineSeparator() != null) {
|
return outputPath;
|
||||||
lineSeparator = LineSeparator.valueOf(config.getLineSeparator().name());
|
}
|
||||||
}
|
|
||||||
return MarkupDocBuilders.documentBuilder(markupLanguage, lineSeparator,
|
public void setOutputPath(Path outputPath) {
|
||||||
config.getAsciidocPegdownTimeoutMillis()).withAnchorPrefix(config.getAnchorPrefix());
|
this.outputPath = outputPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13,16 +13,16 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package io.github.swagger2markup.spi;
|
package io.github.swagger2markup;
|
||||||
|
|
||||||
import io.github.swagger2markup.extension.Schema2MarkupExtensionRegistry;
|
import io.github.swagger2markup.spi.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extension points registry interface.
|
* Extension points registry interface.
|
||||||
*/
|
*/
|
||||||
public interface Swagger2MarkupExtensionRegistry extends Schema2MarkupExtensionRegistry {
|
public interface Swagger2MarkupExtensionRegistry {
|
||||||
/**
|
/**
|
||||||
* SwaggerModelExtension extension point can be used to preprocess the Swagger model.
|
* SwaggerModelExtension extension point can be used to preprocess the Swagger model.
|
||||||
*
|
*
|
||||||
@@ -15,7 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.swagger2markup;
|
package io.github.swagger2markup;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.markup.builder.MarkupLanguage;
|
||||||
import io.github.swagger2markup.utils.URIUtils;
|
import io.github.swagger2markup.utils.URIUtils;
|
||||||
|
|
||||||
import org.apache.commons.collections4.IteratorUtils;
|
import org.apache.commons.collections4.IteratorUtils;
|
||||||
import org.apache.commons.configuration2.Configuration;
|
import org.apache.commons.configuration2.Configuration;
|
||||||
import org.apache.commons.configuration2.ConfigurationConverter;
|
import org.apache.commons.configuration2.ConfigurationConverter;
|
||||||
@@ -28,24 +30,16 @@ import java.nio.file.Paths;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class Schema2MarkupProperties {
|
public class Swagger2MarkupProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefix for Swagger2Markup properties
|
* Prefix for Swagger2Markup properties
|
||||||
*/
|
*/
|
||||||
public static final String PROPERTIES_PREFIX = "swagger2markup";
|
public static final String PROPERTIES_PREFIX = "swagger2markup";
|
||||||
|
|
||||||
public static final String REQUEST_EXAMPLES_FORMAT = PROPERTIES_PREFIX + ".requestExamplesFormat";
|
|
||||||
public static final String REQUEST_EXAMPLES_SOURCE_FORMAT = PROPERTIES_PREFIX + ".requestExamplesSourceFormat";
|
|
||||||
public static final String REQUEST_EXAMPLES_HOST = PROPERTIES_PREFIX + ".requestExamplesHost";
|
|
||||||
public static final String REQUEST_EXAMPLES_SCHEMA = PROPERTIES_PREFIX + ".requestExamplesSchema";
|
|
||||||
public static final String REQUEST_EXAMPLES_HIDE_BASE_PATH = PROPERTIES_PREFIX + ".requestExamplesHideBasePath";
|
|
||||||
public static final String REQUEST_EXAMPLES_QUERY_ARRAY_STYLE = PROPERTIES_PREFIX +".requestExamplesQueryArrayStyle";
|
|
||||||
public static final String REQUEST_EXAMPLES_INCLUDE_ALL_QUERY_PARAMS = PROPERTIES_PREFIX + ".requestExamplesIncludeAllQueryParams";
|
|
||||||
public static final String MARKUP_LANGUAGE = PROPERTIES_PREFIX + ".markupLanguage";
|
public static final String MARKUP_LANGUAGE = PROPERTIES_PREFIX + ".markupLanguage";
|
||||||
public static final String SWAGGER_MARKUP_LANGUAGE = PROPERTIES_PREFIX + ".swaggerMarkupLanguage";
|
public static final String SWAGGER_MARKUP_LANGUAGE = PROPERTIES_PREFIX + ".swaggerMarkupLanguage";
|
||||||
public static final String GENERATED_EXAMPLES_ENABLED = PROPERTIES_PREFIX + ".generatedExamplesEnabled";
|
public static final String GENERATED_EXAMPLES_ENABLED = PROPERTIES_PREFIX + ".generatedExamplesEnabled";
|
||||||
public static final String HOSTNAME_ENABLED = PROPERTIES_PREFIX + ".hostnameEnabled";
|
|
||||||
public static final String BASE_PATH_PREFIX_ENABLED = PROPERTIES_PREFIX + ".basePathPrefixEnabled";
|
public static final String BASE_PATH_PREFIX_ENABLED = PROPERTIES_PREFIX + ".basePathPrefixEnabled";
|
||||||
public static final String SEPARATED_DEFINITIONS_ENABLED = PROPERTIES_PREFIX + ".separatedDefinitionsEnabled";
|
public static final String SEPARATED_DEFINITIONS_ENABLED = PROPERTIES_PREFIX + ".separatedDefinitionsEnabled";
|
||||||
public static final String SEPARATED_OPERATIONS_ENABLED = PROPERTIES_PREFIX + ".separatedOperationsEnabled";
|
public static final String SEPARATED_OPERATIONS_ENABLED = PROPERTIES_PREFIX + ".separatedOperationsEnabled";
|
||||||
@@ -74,7 +68,6 @@ public class Schema2MarkupProperties {
|
|||||||
public static final String RESPONSE_ORDER_BY = PROPERTIES_PREFIX + ".responseOrderBy";
|
public static final String RESPONSE_ORDER_BY = PROPERTIES_PREFIX + ".responseOrderBy";
|
||||||
public static final String LINE_SEPARATOR = PROPERTIES_PREFIX + ".lineSeparator";
|
public static final String LINE_SEPARATOR = PROPERTIES_PREFIX + ".lineSeparator";
|
||||||
public static final String PAGE_BREAK_LOCATIONS = PROPERTIES_PREFIX + ".pageBreakLocations";
|
public static final String PAGE_BREAK_LOCATIONS = PROPERTIES_PREFIX + ".pageBreakLocations";
|
||||||
public static final String ASCIIDOC_PEGDOWN_TIMEOUT = PROPERTIES_PREFIX + ".asciidoc.pegdown.timeoutMillis";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefix for Swagger2Markup extension properties
|
* Prefix for Swagger2Markup extension properties
|
||||||
@@ -83,22 +76,18 @@ public class Schema2MarkupProperties {
|
|||||||
|
|
||||||
private final Configuration configuration;
|
private final Configuration configuration;
|
||||||
|
|
||||||
public Schema2MarkupProperties(Properties properties) {
|
public Swagger2MarkupProperties(Properties properties) {
|
||||||
this(ConfigurationConverter.getConfiguration(properties));
|
this(ConfigurationConverter.getConfiguration(properties));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Schema2MarkupProperties(Map<String, String> map) {
|
public Swagger2MarkupProperties(Map<String, String> map) {
|
||||||
this(new MapConfiguration(map));
|
this(new MapConfiguration(map));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Schema2MarkupProperties(Configuration configuration) {
|
public Swagger2MarkupProperties(Configuration configuration) {
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Configuration getConfiguration() {
|
|
||||||
return configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an optional String property value associated with the given key.
|
* Returns an optional String property value associated with the given key.
|
||||||
*
|
*
|
||||||
@@ -146,7 +135,6 @@ public class Schema2MarkupProperties {
|
|||||||
/**
|
/**
|
||||||
* Return the int property value associated with the given key (never {@code null}).
|
* Return the int property value associated with the given key (never {@code null}).
|
||||||
*
|
*
|
||||||
* @param key the property name to resolve
|
|
||||||
* @return The int property
|
* @return The int property
|
||||||
* @throws IllegalStateException if the key cannot be
|
* @throws IllegalStateException if the key cannot be
|
||||||
*/
|
*/
|
||||||
@@ -161,7 +149,6 @@ public class Schema2MarkupProperties {
|
|||||||
/**
|
/**
|
||||||
* Return the boolean property value associated with the given key (never {@code null}).
|
* Return the boolean property value associated with the given key (never {@code null}).
|
||||||
*
|
*
|
||||||
* @param key the property name to resolve
|
|
||||||
* @return The boolean property
|
* @return The boolean property
|
||||||
* @throws IllegalStateException if the key cannot be resolved
|
* @throws IllegalStateException if the key cannot be resolved
|
||||||
*/
|
*/
|
||||||
@@ -196,13 +183,16 @@ public class Schema2MarkupProperties {
|
|||||||
*/
|
*/
|
||||||
public Optional<URI> getURI(String key) {
|
public Optional<URI> getURI(String key) {
|
||||||
Optional<String> property = getString(key);
|
Optional<String> property = getString(key);
|
||||||
return property.map(URIUtils::create);
|
if (property.isPresent()) {
|
||||||
|
return Optional.of(URIUtils.create(property.get()));
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the URI property value associated with the given key (never {@code null}).
|
* Return the URI property value associated with the given key (never {@code null}).
|
||||||
*
|
*
|
||||||
* @param key the property name to resolve
|
|
||||||
* @return The URI property
|
* @return The URI property
|
||||||
* @throws IllegalStateException if the key cannot be resolved
|
* @throws IllegalStateException if the key cannot be resolved
|
||||||
*/
|
*/
|
||||||
@@ -225,7 +215,11 @@ public class Schema2MarkupProperties {
|
|||||||
*/
|
*/
|
||||||
public Optional<Path> getPath(String key) {
|
public Optional<Path> getPath(String key) {
|
||||||
Optional<String> property = getString(key);
|
Optional<String> property = getString(key);
|
||||||
return property.map(s -> Paths.get(s));
|
if (property.isPresent()) {
|
||||||
|
return Optional.of(Paths.get(property.get()));
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -255,7 +249,6 @@ public class Schema2MarkupProperties {
|
|||||||
/**
|
/**
|
||||||
* Return the Path property value associated with the given key (never {@code null}).
|
* Return the Path property value associated with the given key (never {@code null}).
|
||||||
*
|
*
|
||||||
* @param key the property name to resolve
|
|
||||||
* @return The Path property
|
* @return The Path property
|
||||||
* @throws IllegalStateException if the key cannot be resolved
|
* @throws IllegalStateException if the key cannot be resolved
|
||||||
*/
|
*/
|
||||||
@@ -269,22 +262,25 @@ public class Schema2MarkupProperties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the OutputLanguage property value associated with the given key, or
|
* Return the MarkupLanguage property value associated with the given key, or
|
||||||
* {@code defaultValue} if the key cannot be resolved.
|
* {@code defaultValue} if the key cannot be resolved.
|
||||||
*
|
*
|
||||||
* @param key the property name to resolve
|
* @param key the property name to resolve
|
||||||
* @return The OutputLanguage property
|
* @return The MarkupLanguage property
|
||||||
*/
|
*/
|
||||||
public Optional<MarkupLanguage> getMarkupLanguage(String key) {
|
public Optional<MarkupLanguage> getMarkupLanguage(String key) {
|
||||||
Optional<String> property = getString(key);
|
Optional<String> property = getString(key);
|
||||||
return property.map(MarkupLanguage::valueOf);
|
if (property.isPresent()) {
|
||||||
|
return Optional.of(MarkupLanguage.valueOf(property.get()));
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the OutputLanguage property value associated with the given key (never {@code null}).
|
* Return the MarkupLanguage property value associated with the given key (never {@code null}).
|
||||||
*
|
*
|
||||||
* @param key the property name to resolve
|
* @return The MarkupLanguage property
|
||||||
* @return The OutputLanguage property
|
|
||||||
* @throws IllegalStateException if the key cannot be resolved
|
* @throws IllegalStateException if the key cannot be resolved
|
||||||
*/
|
*/
|
||||||
public MarkupLanguage getRequiredMarkupLanguage(String key) {
|
public MarkupLanguage getRequiredMarkupLanguage(String key) {
|
||||||
@@ -329,7 +325,6 @@ public class Schema2MarkupProperties {
|
|||||||
/**
|
/**
|
||||||
* Return the String property value associated with the given key (never {@code null}).
|
* Return the String property value associated with the given key (never {@code null}).
|
||||||
*
|
*
|
||||||
* @param key the property name to resolve
|
|
||||||
* @return The String property
|
* @return The String property
|
||||||
* @throws IllegalStateException if the key cannot be resolved
|
* @throws IllegalStateException if the key cannot be resolved
|
||||||
*/
|
*/
|
||||||
@@ -372,13 +367,17 @@ public class Schema2MarkupProperties {
|
|||||||
|
|
||||||
public List<PageBreakLocations> getPageBreakLocations(String key) {
|
public List<PageBreakLocations> getPageBreakLocations(String key) {
|
||||||
List<PageBreakLocations> result = configuration.getList(PageBreakLocations.class, key);
|
List<PageBreakLocations> result = configuration.getList(PageBreakLocations.class, key);
|
||||||
if (result == null) result = new ArrayList<>();
|
if(result == null) result = new ArrayList<PageBreakLocations>();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Pattern> getHeaderPattern(String key) {
|
public Optional<Pattern> getHeaderPattern(String key) {
|
||||||
Optional<String> property = getString(key);
|
Optional<String> property = getString(key);
|
||||||
return property.map(Pattern::compile);
|
if (property.isPresent()) {
|
||||||
|
return Optional.of(Pattern.compile(property.get()));
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,116 +14,112 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package io.github.swagger2markup.config.builder;
|
package io.github.swagger2markup.builder;
|
||||||
|
|
||||||
import com.google.common.collect.Ordering;
|
import com.google.common.collect.Ordering;
|
||||||
import io.github.swagger2markup.*;
|
import io.github.swagger2markup.*;
|
||||||
import io.github.swagger2markup.config.*;
|
import io.github.swagger2markup.markup.builder.LineSeparator;
|
||||||
import io.github.swagger2markup.model.Parameter;
|
import io.github.swagger2markup.markup.builder.MarkupLanguage;
|
||||||
import io.github.swagger2markup.model.PathOperation;
|
import io.github.swagger2markup.model.PathOperation;
|
||||||
import org.apache.commons.configuration2.AbstractConfiguration;
|
import io.swagger.models.HttpMethod;
|
||||||
import org.apache.commons.configuration2.CompositeConfiguration;
|
import io.swagger.models.parameters.Parameter;
|
||||||
import org.apache.commons.configuration2.Configuration;
|
import org.apache.commons.configuration2.*;
|
||||||
import org.apache.commons.configuration2.SystemConfiguration;
|
|
||||||
import org.apache.commons.configuration2.builder.fluent.Configurations;
|
import org.apache.commons.configuration2.builder.fluent.Configurations;
|
||||||
import org.apache.commons.configuration2.convert.DefaultListDelimiterHandler;
|
import org.apache.commons.configuration2.convert.DefaultListDelimiterHandler;
|
||||||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.regex.PatternSyntaxException;
|
import java.util.regex.PatternSyntaxException;
|
||||||
|
|
||||||
import static io.github.swagger2markup.Schema2MarkupProperties.*;
|
import static io.github.swagger2markup.Swagger2MarkupProperties.*;
|
||||||
|
|
||||||
public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBuilder, C extends Schema2MarkupConfigBuilder.DefaultSchema2MarkupConfig> {
|
public class Swagger2MarkupConfigBuilder {
|
||||||
|
|
||||||
public static final Ordering<PathOperation> OPERATION_METHOD_NATURAL_ORDERING = Ordering
|
static final Ordering<PathOperation> OPERATION_METHOD_NATURAL_ORDERING = Ordering
|
||||||
.explicit("POST", "GET", "PUT",
|
.explicit(HttpMethod.POST, HttpMethod.GET, HttpMethod.PUT, HttpMethod.DELETE, HttpMethod.PATCH, HttpMethod.HEAD, HttpMethod.OPTIONS)
|
||||||
"DELETE", "PATCH", "HEAD", "OPTIONS")
|
.onResultOf(PathOperation::getMethod);
|
||||||
.onResultOf(PathOperation::getHttpMethod);
|
static final Ordering<PathOperation> OPERATION_PATH_NATURAL_ORDERING = Ordering
|
||||||
public static final Ordering<PathOperation> OPERATION_PATH_NATURAL_ORDERING = Ordering
|
|
||||||
.natural()
|
.natural()
|
||||||
.onResultOf(PathOperation::getPath);
|
.onResultOf(PathOperation::getPath);
|
||||||
public static final Ordering<Parameter> PARAMETER_IN_NATURAL_ORDERING = Ordering
|
static final Ordering<Parameter> PARAMETER_IN_NATURAL_ORDERING = Ordering
|
||||||
.explicit("header", "path", "query", "formData", "body")
|
.explicit("header", "path", "query", "formData", "body")
|
||||||
.onResultOf(Parameter::getIn);
|
.onResultOf(Parameter::getIn);
|
||||||
public static final Ordering<Parameter> PARAMETER_NAME_NATURAL_ORDERING = Ordering
|
static final Ordering<Parameter> PARAMETER_NAME_NATURAL_ORDERING = Ordering
|
||||||
.natural()
|
.natural()
|
||||||
.onResultOf(Parameter::getName);
|
.onResultOf(Parameter::getName);
|
||||||
|
private static final String PROPERTIES_DEFAULT = "io/github/swagger2markup/config/default.properties";
|
||||||
|
DefaultSwagger2MarkupConfig config = new DefaultSwagger2MarkupConfig();
|
||||||
|
|
||||||
static final String PROPERTIES_DEFAULT = "io/github/swagger2markup/config/default.properties";
|
public Swagger2MarkupConfigBuilder() {
|
||||||
protected C config;
|
this(new PropertiesConfiguration());
|
||||||
|
}
|
||||||
|
|
||||||
//reference to self as the subclass type
|
public Swagger2MarkupConfigBuilder(Properties properties) {
|
||||||
private final T self;
|
this(ConfigurationConverter.getConfiguration(properties));
|
||||||
|
}
|
||||||
|
|
||||||
public Schema2MarkupConfigBuilder(final Class<T> selfClass,
|
public Swagger2MarkupConfigBuilder(Map<String, String> map) {
|
||||||
C config,
|
this(new MapConfiguration(map));
|
||||||
Schema2MarkupProperties schema2MarkupProperties,
|
}
|
||||||
Configuration configuration) {
|
|
||||||
this.self = selfClass.cast(this);
|
|
||||||
this.config = config;
|
|
||||||
|
|
||||||
config.listDelimiterEnabled = schema2MarkupProperties.getBoolean(LIST_DELIMITER_ENABLED, false);
|
public Swagger2MarkupConfigBuilder(Configuration configuration) {
|
||||||
config.listDelimiter = schema2MarkupProperties.getString(LIST_DELIMITER, ",").charAt(0);
|
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.basePathPrefixEnabled = swagger2MarkupProperties.getRequiredBoolean(BASE_PATH_PREFIX_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());
|
||||||
|
}
|
||||||
|
|
||||||
|
config.pageBreakLocations = swagger2MarkupProperties.getPageBreakLocations(PAGE_BREAK_LOCATIONS);
|
||||||
|
|
||||||
|
Optional<Pattern> headerPattern = swagger2MarkupProperties.getHeaderPattern(HEADER_REGEX);
|
||||||
|
|
||||||
|
config.headerPattern = headerPattern.orElse(null);
|
||||||
|
|
||||||
|
config.listDelimiterEnabled = swagger2MarkupProperties.getBoolean(LIST_DELIMITER_ENABLED, false);
|
||||||
|
config.listDelimiter = swagger2MarkupProperties.getString(LIST_DELIMITER, ",").charAt(0);
|
||||||
|
|
||||||
if (config.listDelimiterEnabled && configuration instanceof AbstractConfiguration) {
|
if (config.listDelimiterEnabled && configuration instanceof AbstractConfiguration) {
|
||||||
((AbstractConfiguration) configuration).setListDelimiterHandler(new DefaultListDelimiterHandler(config.listDelimiter));
|
((AbstractConfiguration) configuration).setListDelimiterHandler(new DefaultListDelimiterHandler(config.listDelimiter));
|
||||||
}
|
}
|
||||||
|
|
||||||
config.requestExamplesFormat = schema2MarkupProperties.getRequiredString(REQUEST_EXAMPLES_FORMAT);
|
Configuration swagger2markupConfiguration = compositeConfiguration.subset(PROPERTIES_PREFIX);
|
||||||
config.requestExamplesSourceFormat = schema2MarkupProperties.getRequiredString(REQUEST_EXAMPLES_SOURCE_FORMAT);
|
|
||||||
config.requestExamplesHost = schema2MarkupProperties.getRequiredString(REQUEST_EXAMPLES_HOST);
|
|
||||||
config.requestExamplesSchema = schema2MarkupProperties.getRequiredString(REQUEST_EXAMPLES_SCHEMA);
|
|
||||||
config.requestExamplesHideBasePath = schema2MarkupProperties.getRequiredBoolean(REQUEST_EXAMPLES_HIDE_BASE_PATH);
|
|
||||||
config.requestExamplesQueryArrayStyle = schema2MarkupProperties.getRequiredString(REQUEST_EXAMPLES_QUERY_ARRAY_STYLE);
|
|
||||||
config.requestExamplesIncludeAllQueryParams = schema2MarkupProperties.getRequiredBoolean(REQUEST_EXAMPLES_INCLUDE_ALL_QUERY_PARAMS);
|
|
||||||
config.markupLanguage = schema2MarkupProperties.getRequiredMarkupLanguage(MARKUP_LANGUAGE);
|
|
||||||
config.schemaMarkupLanguage = schema2MarkupProperties.getRequiredMarkupLanguage(SWAGGER_MARKUP_LANGUAGE);
|
|
||||||
config.generatedExamplesEnabled = schema2MarkupProperties.getRequiredBoolean(GENERATED_EXAMPLES_ENABLED);
|
|
||||||
config.hostnameEnabled = schema2MarkupProperties.getRequiredBoolean(HOSTNAME_ENABLED);
|
|
||||||
config.basePathPrefixEnabled = schema2MarkupProperties.getRequiredBoolean(BASE_PATH_PREFIX_ENABLED);
|
|
||||||
config.separatedDefinitionsEnabled = schema2MarkupProperties.getRequiredBoolean(SEPARATED_DEFINITIONS_ENABLED);
|
|
||||||
config.separatedOperationsEnabled = schema2MarkupProperties.getRequiredBoolean(SEPARATED_OPERATIONS_ENABLED);
|
|
||||||
config.pathsGroupedBy = schema2MarkupProperties.getGroupBy(PATHS_GROUPED_BY);
|
|
||||||
config.language = schema2MarkupProperties.getLanguage(OUTPUT_LANGUAGE);
|
|
||||||
config.inlineSchemaEnabled = schema2MarkupProperties.getRequiredBoolean(INLINE_SCHEMA_ENABLED);
|
|
||||||
config.interDocumentCrossReferencesEnabled = schema2MarkupProperties.getRequiredBoolean(INTER_DOCUMENT_CROSS_REFERENCES_ENABLED);
|
|
||||||
config.interDocumentCrossReferencesPrefix = schema2MarkupProperties.getString(INTER_DOCUMENT_CROSS_REFERENCES_PREFIX, null);
|
|
||||||
config.flatBodyEnabled = schema2MarkupProperties.getRequiredBoolean(FLAT_BODY_ENABLED);
|
|
||||||
config.pathSecuritySectionEnabled = schema2MarkupProperties.getRequiredBoolean(PATH_SECURITY_SECTION_ENABLED);
|
|
||||||
config.anchorPrefix = schema2MarkupProperties.getString(ANCHOR_PREFIX, null);
|
|
||||||
config.overviewDocument = schema2MarkupProperties.getRequiredString(OVERVIEW_DOCUMENT);
|
|
||||||
config.pathsDocument = schema2MarkupProperties.getRequiredString(PATHS_DOCUMENT);
|
|
||||||
config.definitionsDocument = schema2MarkupProperties.getRequiredString(DEFINITIONS_DOCUMENT);
|
|
||||||
config.securityDocument = schema2MarkupProperties.getRequiredString(SECURITY_DOCUMENT);
|
|
||||||
config.separatedOperationsFolder = schema2MarkupProperties.getRequiredString(SEPARATED_OPERATIONS_FOLDER);
|
|
||||||
config.separatedDefinitionsFolder = schema2MarkupProperties.getRequiredString(SEPARATED_DEFINITIONS_FOLDER);
|
|
||||||
config.tagOrderBy = schema2MarkupProperties.getOrderBy(TAG_ORDER_BY);
|
|
||||||
config.operationOrderBy = schema2MarkupProperties.getOrderBy(OPERATION_ORDER_BY);
|
|
||||||
config.definitionOrderBy = schema2MarkupProperties.getOrderBy(DEFINITION_ORDER_BY);
|
|
||||||
config.parameterOrderBy = schema2MarkupProperties.getOrderBy(PARAMETER_ORDER_BY);
|
|
||||||
config.propertyOrderBy = schema2MarkupProperties.getOrderBy(PROPERTY_ORDER_BY);
|
|
||||||
config.responseOrderBy = schema2MarkupProperties.getOrderBy(RESPONSE_ORDER_BY);
|
|
||||||
Optional<String> lineSeparator = schema2MarkupProperties.getString(LINE_SEPARATOR);
|
|
||||||
if (lineSeparator.isPresent() && StringUtils.isNoneBlank(lineSeparator.get())) {
|
|
||||||
config.lineSeparator = LineSeparator.valueOf(lineSeparator.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
config.pageBreakLocations = schema2MarkupProperties.getPageBreakLocations(PAGE_BREAK_LOCATIONS);
|
|
||||||
|
|
||||||
Optional<Pattern> headerPattern = schema2MarkupProperties.getHeaderPattern(HEADER_REGEX);
|
|
||||||
|
|
||||||
config.headerPattern = headerPattern.orElse(null);
|
|
||||||
|
|
||||||
Configuration swagger2markupConfiguration = schema2MarkupProperties.getConfiguration().subset(PROPERTIES_PREFIX);
|
|
||||||
Configuration extensionsConfiguration = swagger2markupConfiguration.subset(EXTENSION_PREFIX);
|
Configuration extensionsConfiguration = swagger2markupConfiguration.subset(EXTENSION_PREFIX);
|
||||||
config.extensionsProperties = new Schema2MarkupProperties(extensionsConfiguration);
|
config.extensionsProperties = new Swagger2MarkupProperties(extensionsConfiguration);
|
||||||
config.asciidocPegdownTimeoutMillis = schema2MarkupProperties.getRequiredInt(ASCIIDOC_PEGDOWN_TIMEOUT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -131,7 +127,7 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
*
|
*
|
||||||
* @return the default properties
|
* @return the default properties
|
||||||
*/
|
*/
|
||||||
public static Configuration getDefaultConfiguration() {
|
private Configuration getDefaultConfiguration() {
|
||||||
Configurations configs = new Configurations();
|
Configurations configs = new Configurations();
|
||||||
try {
|
try {
|
||||||
return configs.properties(PROPERTIES_DEFAULT);
|
return configs.properties(PROPERTIES_DEFAULT);
|
||||||
@@ -140,7 +136,18 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void buildNaturalOrdering() {
|
/**
|
||||||
|
* Builds the Swagger2MarkupConfig.
|
||||||
|
*
|
||||||
|
* @return the Swagger2MarkupConfig
|
||||||
|
*/
|
||||||
|
public Swagger2MarkupConfig build() {
|
||||||
|
buildNaturalOrdering();
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildNaturalOrdering() {
|
||||||
if (config.tagOrderBy == OrderBy.NATURAL)
|
if (config.tagOrderBy == OrderBy.NATURAL)
|
||||||
config.tagOrdering = Ordering.natural();
|
config.tagOrdering = Ordering.natural();
|
||||||
if (config.operationOrderBy == OrderBy.NATURAL)
|
if (config.operationOrderBy == OrderBy.NATURAL)
|
||||||
@@ -155,35 +162,28 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
config.responseOrdering = Ordering.natural();
|
config.responseOrdering = Ordering.natural();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the OpenApi2MarkupConfig.
|
|
||||||
*
|
|
||||||
* @return the OpenApi2MarkupConfig
|
|
||||||
*/
|
|
||||||
public abstract C build();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the markup language which should be used to generate the files.
|
* Specifies the markup language which should be used to generate the files.
|
||||||
*
|
*
|
||||||
* @param markupLanguage the markup language which is used to generate the files
|
* @param markupLanguage the markup language which is used to generate the files
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withMarkupLanguage(MarkupLanguage markupLanguage) {
|
public Swagger2MarkupConfigBuilder withMarkupLanguage(MarkupLanguage markupLanguage) {
|
||||||
Validate.notNull(markupLanguage, "%s must not be null", "outputLanguage");
|
Validate.notNull(markupLanguage, "%s must not be null", "markupLanguage");
|
||||||
config.markupLanguage = markupLanguage;
|
config.markupLanguage = markupLanguage;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the markup language used in Swagger descriptions.
|
* Specifies the markup language used in Swagger descriptions.
|
||||||
*
|
*
|
||||||
* @param markupLanguage the markup language used in Swagger descriptions
|
* @param swaggerMarkupLanguage the markup language used in Swagger descriptions
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withSwaggerMarkupLanguage(MarkupLanguage markupLanguage) {
|
public Swagger2MarkupConfigBuilder withSwaggerMarkupLanguage(MarkupLanguage swaggerMarkupLanguage) {
|
||||||
Validate.notNull(markupLanguage, "%s must not be null", "outputLanguage");
|
Validate.notNull(swaggerMarkupLanguage, "%s must not be null", "swaggerMarkupLanguage");
|
||||||
config.schemaMarkupLanguage = markupLanguage;
|
config.swaggerMarkupLanguage = swaggerMarkupLanguage;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -191,9 +191,9 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
*
|
*
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withGeneratedExamples() {
|
public Swagger2MarkupConfigBuilder withGeneratedExamples() {
|
||||||
config.generatedExamplesEnabled = true;
|
config.generatedExamplesEnabled = true;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -201,9 +201,9 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
*
|
*
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withSeparatedDefinitions() {
|
public Swagger2MarkupConfigBuilder withSeparatedDefinitions() {
|
||||||
config.separatedDefinitionsEnabled = true;
|
config.separatedDefinitionsEnabled = true;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -212,9 +212,9 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
*
|
*
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withSeparatedOperations() {
|
public Swagger2MarkupConfigBuilder withSeparatedOperations() {
|
||||||
config.separatedOperationsEnabled = true;
|
config.separatedOperationsEnabled = true;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -222,9 +222,9 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
*
|
*
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withListDelimiter() {
|
public Swagger2MarkupConfigBuilder withListDelimiter() {
|
||||||
config.listDelimiterEnabled = true;
|
config.listDelimiterEnabled = true;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -233,11 +233,11 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
* @param delimiter the delimiter
|
* @param delimiter the delimiter
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withListDelimiter(Character delimiter) {
|
public Swagger2MarkupConfigBuilder withListDelimiter(Character delimiter) {
|
||||||
Validate.notNull(delimiter, "%s must not be null", "delimiter");
|
Validate.notNull(delimiter, "%s must not be null", "delimiter");
|
||||||
config.listDelimiter = delimiter;
|
config.listDelimiter = delimiter;
|
||||||
config.listDelimiterEnabled = true;
|
config.listDelimiterEnabled = true;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -247,10 +247,10 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
* @param pathsGroupedBy the GroupBy enum
|
* @param pathsGroupedBy the GroupBy enum
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withPathsGroupedBy(GroupBy pathsGroupedBy) {
|
public Swagger2MarkupConfigBuilder withPathsGroupedBy(GroupBy pathsGroupedBy) {
|
||||||
Validate.notNull(pathsGroupedBy, "%s must not be null", "pathsGroupedBy");
|
Validate.notNull(pathsGroupedBy, "%s must not be null", "pathsGroupedBy");
|
||||||
config.pathsGroupedBy = pathsGroupedBy;
|
config.pathsGroupedBy = pathsGroupedBy;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -260,10 +260,10 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
* @return this builder
|
* @return this builder
|
||||||
* @throws PatternSyntaxException when pattern cannot be compiled
|
* @throws PatternSyntaxException when pattern cannot be compiled
|
||||||
*/
|
*/
|
||||||
public T withHeaderRegex(String headerRegex) {
|
public Swagger2MarkupConfigBuilder withHeaderRegex(String headerRegex) {
|
||||||
Validate.notNull(headerRegex, "%s must not be null", headerRegex);
|
Validate.notNull(headerRegex, "%s must not be null", headerRegex);
|
||||||
config.headerPattern = Pattern.compile(headerRegex);
|
config.headerPattern = Pattern.compile(headerRegex);
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -272,10 +272,10 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
* @param language the enum
|
* @param language the enum
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withOutputLanguage(Language language) {
|
public Swagger2MarkupConfigBuilder withOutputLanguage(Language language) {
|
||||||
Validate.notNull(language, "%s must not be null", "language");
|
Validate.notNull(language, "%s must not be null", "language");
|
||||||
config.language = language;
|
config.outputLanguage = language;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -283,24 +283,24 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
*
|
*
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withoutInlineSchema() {
|
public Swagger2MarkupConfigBuilder withoutInlineSchema() {
|
||||||
config.inlineSchemaEnabled = false;
|
config.inlineSchemaEnabled = false;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies tag ordering.<br>
|
* Specifies tag ordering.<br>
|
||||||
* By default tag ordering == {@link OrderBy#NATURAL}.<br>
|
* By default tag ordering == {@link io.github.swagger2markup.OrderBy#NATURAL}.<br>
|
||||||
* Use {@link #withTagOrdering(Comparator)} to set a custom ordering.
|
* Use {@link #withTagOrdering(Comparator)} to set a custom ordering.
|
||||||
*
|
*
|
||||||
* @param orderBy tag ordering
|
* @param orderBy tag ordering
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withTagOrdering(OrderBy orderBy) {
|
public Swagger2MarkupConfigBuilder withTagOrdering(OrderBy orderBy) {
|
||||||
Validate.notNull(orderBy, "%s must not be null", "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");
|
Validate.isTrue(orderBy != OrderBy.CUSTOM, "You must provide a custom comparator if orderBy == OrderBy.CUSTOM");
|
||||||
config.tagOrderBy = orderBy;
|
config.tagOrderBy = orderBy;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -309,26 +309,26 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
* @param tagOrdering tag ordering
|
* @param tagOrdering tag ordering
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withTagOrdering(Comparator<String> tagOrdering) {
|
public Swagger2MarkupConfigBuilder withTagOrdering(Comparator<String> tagOrdering) {
|
||||||
Validate.notNull(tagOrdering, "%s must not be null", "tagOrdering");
|
Validate.notNull(tagOrdering, "%s must not be null", "tagOrdering");
|
||||||
config.tagOrderBy = OrderBy.CUSTOM;
|
config.tagOrderBy = OrderBy.CUSTOM;
|
||||||
config.tagOrdering = tagOrdering;
|
config.tagOrdering = tagOrdering;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies operation ordering.<br>
|
* Specifies operation ordering.<br>
|
||||||
* By default operation ordering == {@link OrderBy#AS_IS}.<br>
|
* By default operation ordering == {@link io.github.swagger2markup.OrderBy#AS_IS}.<br>
|
||||||
* Use {@link #withOperationOrdering(Comparator)} to set a custom ordering.
|
* Use {@link #withOperationOrdering(Comparator)} to set a custom ordering.
|
||||||
*
|
*
|
||||||
* @param orderBy operation ordering
|
* @param orderBy operation ordering
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withOperationOrdering(OrderBy orderBy) {
|
public Swagger2MarkupConfigBuilder withOperationOrdering(OrderBy orderBy) {
|
||||||
Validate.notNull(orderBy, "%s must not be null", "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");
|
Validate.isTrue(orderBy != OrderBy.CUSTOM, "You must provide a custom comparator if orderBy == OrderBy.CUSTOM");
|
||||||
config.operationOrderBy = orderBy;
|
config.operationOrderBy = orderBy;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -337,26 +337,26 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
* @param operationOrdering operation ordering
|
* @param operationOrdering operation ordering
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withOperationOrdering(Comparator<PathOperation> operationOrdering) {
|
public Swagger2MarkupConfigBuilder withOperationOrdering(Comparator<PathOperation> operationOrdering) {
|
||||||
Validate.notNull(operationOrdering, "%s must not be null", "operationOrdering");
|
Validate.notNull(operationOrdering, "%s must not be null", "operationOrdering");
|
||||||
config.operationOrderBy = OrderBy.CUSTOM;
|
config.operationOrderBy = OrderBy.CUSTOM;
|
||||||
config.operationOrdering = operationOrdering;
|
config.operationOrdering = operationOrdering;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies definition ordering.<br>
|
* Specifies definition ordering.<br>
|
||||||
* By default definition ordering == {@link OrderBy#NATURAL}.<br>
|
* By default definition ordering == {@link io.github.swagger2markup.OrderBy#NATURAL}.<br>
|
||||||
* Use {@link #withDefinitionOrdering(Comparator)} to set a custom ordering.
|
* Use {@link #withDefinitionOrdering(Comparator)} to set a custom ordering.
|
||||||
*
|
*
|
||||||
* @param orderBy definition ordering
|
* @param orderBy definition ordering
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withDefinitionOrdering(OrderBy orderBy) {
|
public Swagger2MarkupConfigBuilder withDefinitionOrdering(OrderBy orderBy) {
|
||||||
Validate.notNull(orderBy, "%s must not be null", "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");
|
Validate.isTrue(orderBy != OrderBy.CUSTOM, "You must provide a custom comparator if orderBy == OrderBy.CUSTOM");
|
||||||
config.definitionOrderBy = orderBy;
|
config.definitionOrderBy = orderBy;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -365,11 +365,11 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
* @param definitionOrdering definition ordering
|
* @param definitionOrdering definition ordering
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withDefinitionOrdering(Comparator<String> definitionOrdering) {
|
public Swagger2MarkupConfigBuilder withDefinitionOrdering(Comparator<String> definitionOrdering) {
|
||||||
Validate.notNull(definitionOrdering, "%s must not be null", "definitionOrdering");
|
Validate.notNull(definitionOrdering, "%s must not be null", "definitionOrdering");
|
||||||
config.definitionOrderBy = OrderBy.CUSTOM;
|
config.definitionOrderBy = OrderBy.CUSTOM;
|
||||||
config.definitionOrdering = definitionOrdering;
|
config.definitionOrdering = definitionOrdering;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -380,11 +380,11 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
* @param orderBy parameter ordering
|
* @param orderBy parameter ordering
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withParameterOrdering(OrderBy orderBy) {
|
public Swagger2MarkupConfigBuilder withParameterOrdering(OrderBy orderBy) {
|
||||||
Validate.notNull(orderBy, "%s must not be null", "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");
|
Validate.isTrue(orderBy != OrderBy.CUSTOM, "You must provide a custom comparator if orderBy == OrderBy.CUSTOM");
|
||||||
config.parameterOrderBy = orderBy;
|
config.parameterOrderBy = orderBy;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -393,27 +393,27 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
* @param parameterOrdering parameter ordering
|
* @param parameterOrdering parameter ordering
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withParameterOrdering(Comparator<Parameter> parameterOrdering) {
|
public Swagger2MarkupConfigBuilder withParameterOrdering(Comparator<Parameter> parameterOrdering) {
|
||||||
Validate.notNull(parameterOrdering, "%s must not be null", "parameterOrdering");
|
Validate.notNull(parameterOrdering, "%s must not be null", "parameterOrdering");
|
||||||
|
|
||||||
config.parameterOrderBy = OrderBy.CUSTOM;
|
config.parameterOrderBy = OrderBy.CUSTOM;
|
||||||
config.parameterOrdering = parameterOrdering;
|
config.parameterOrdering = parameterOrdering;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies property ordering.<br>
|
* Specifies property ordering.<br>
|
||||||
* By default property ordering == {@link OrderBy#NATURAL}.<br>
|
* By default property ordering == {@link io.github.swagger2markup.OrderBy#NATURAL}.<br>
|
||||||
* Use {@link #withPropertyOrdering(Comparator)} to set a custom ordering.
|
* Use {@link #withPropertyOrdering(Comparator)} to set a custom ordering.
|
||||||
*
|
*
|
||||||
* @param orderBy property ordering
|
* @param orderBy property ordering
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withPropertyOrdering(OrderBy orderBy) {
|
public Swagger2MarkupConfigBuilder withPropertyOrdering(OrderBy orderBy) {
|
||||||
Validate.notNull(orderBy, "%s must not be null", "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");
|
Validate.isTrue(orderBy != OrderBy.CUSTOM, "You must provide a custom comparator if orderBy == OrderBy.CUSTOM");
|
||||||
config.propertyOrderBy = orderBy;
|
config.propertyOrderBy = orderBy;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -422,27 +422,27 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
* @param propertyOrdering property ordering
|
* @param propertyOrdering property ordering
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withPropertyOrdering(Comparator<String> propertyOrdering) {
|
public Swagger2MarkupConfigBuilder withPropertyOrdering(Comparator<String> propertyOrdering) {
|
||||||
Validate.notNull(propertyOrdering, "%s must not be null", "propertyOrdering");
|
Validate.notNull(propertyOrdering, "%s must not be null", "propertyOrdering");
|
||||||
|
|
||||||
config.propertyOrderBy = OrderBy.CUSTOM;
|
config.propertyOrderBy = OrderBy.CUSTOM;
|
||||||
config.propertyOrdering = propertyOrdering;
|
config.propertyOrdering = propertyOrdering;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies response ordering.<br>
|
* Specifies response ordering.<br>
|
||||||
* By default response ordering == {@link OrderBy#NATURAL}.<br>
|
* By default response ordering == {@link io.github.swagger2markup.OrderBy#NATURAL}.<br>
|
||||||
* Use {@link #withResponseOrdering(Comparator)} to set a custom ordering.
|
* Use {@link #withResponseOrdering(Comparator)} to set a custom ordering.
|
||||||
*
|
*
|
||||||
* @param orderBy response ordering
|
* @param orderBy response ordering
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withResponseOrdering(OrderBy orderBy) {
|
public Swagger2MarkupConfigBuilder withResponseOrdering(OrderBy orderBy) {
|
||||||
Validate.notNull(orderBy, "%s must not be null", "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");
|
Validate.isTrue(orderBy != OrderBy.CUSTOM, "You must provide a custom comparator if orderBy == OrderBy.CUSTOM");
|
||||||
config.responseOrderBy = orderBy;
|
config.responseOrderBy = orderBy;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -451,12 +451,12 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
* @param responseOrdering response ordering
|
* @param responseOrdering response ordering
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withResponseOrdering(Comparator<String> responseOrdering) {
|
public Swagger2MarkupConfigBuilder withResponseOrdering(Comparator<String> responseOrdering) {
|
||||||
Validate.notNull(responseOrdering, "%s must not be null", "responseOrdering");
|
Validate.notNull(responseOrdering, "%s must not be null", "responseOrdering");
|
||||||
|
|
||||||
config.responseOrderBy = OrderBy.CUSTOM;
|
config.responseOrderBy = OrderBy.CUSTOM;
|
||||||
config.responseOrdering = responseOrdering;
|
config.responseOrdering = responseOrdering;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -465,11 +465,11 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
* @param prefix Prefix to document in all inter-document cross-references.
|
* @param prefix Prefix to document in all inter-document cross-references.
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withInterDocumentCrossReferences(String prefix) {
|
public Swagger2MarkupConfigBuilder withInterDocumentCrossReferences(String prefix) {
|
||||||
Validate.notNull(prefix, "%s must not be null", "prefix");
|
Validate.notNull(prefix, "%s must not be null", "prefix");
|
||||||
config.interDocumentCrossReferencesEnabled = true;
|
config.interDocumentCrossReferencesEnabled = true;
|
||||||
config.interDocumentCrossReferencesPrefix = prefix;
|
config.interDocumentCrossReferencesPrefix = prefix;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -477,9 +477,9 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
*
|
*
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withInterDocumentCrossReferences() {
|
public Swagger2MarkupConfigBuilder withInterDocumentCrossReferences() {
|
||||||
config.interDocumentCrossReferencesEnabled = true;
|
config.interDocumentCrossReferencesEnabled = true;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -487,9 +487,9 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
*
|
*
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withFlatBody() {
|
public Swagger2MarkupConfigBuilder withFlatBody() {
|
||||||
config.flatBodyEnabled = true;
|
config.flatBodyEnabled = true;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -497,9 +497,9 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
*
|
*
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withoutPathSecuritySection() {
|
public Swagger2MarkupConfigBuilder withoutPathSecuritySection() {
|
||||||
config.pathSecuritySectionEnabled = false;
|
config.pathSecuritySectionEnabled = false;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -507,9 +507,9 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
*
|
*
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withBasePathPrefix() {
|
public Swagger2MarkupConfigBuilder withBasePathPrefix() {
|
||||||
config.basePathPrefixEnabled = true;
|
config.basePathPrefixEnabled = true;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -518,10 +518,10 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
* @param anchorPrefix anchor prefix.
|
* @param anchorPrefix anchor prefix.
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withAnchorPrefix(String anchorPrefix) {
|
public Swagger2MarkupConfigBuilder withAnchorPrefix(String anchorPrefix) {
|
||||||
Validate.notNull(anchorPrefix, "%s must not be null", "anchorPrefix");
|
Validate.notNull(anchorPrefix, "%s must not be null", "anchorPrefix");
|
||||||
config.anchorPrefix = anchorPrefix;
|
config.anchorPrefix = anchorPrefix;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -530,10 +530,10 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
* @param locations List of locations to create new pages
|
* @param locations List of locations to create new pages
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withPageBreaks(List<PageBreakLocations> locations) {
|
public Swagger2MarkupConfigBuilder withPageBreaks(List<PageBreakLocations> locations) {
|
||||||
Validate.notNull(locations, "%s must not be null", "locations");
|
Validate.notNull(locations, "%s must not be null", "locations");
|
||||||
config.pageBreakLocations = locations;
|
config.pageBreakLocations = locations;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -542,162 +542,56 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
* @param lineSeparator the lineSeparator
|
* @param lineSeparator the lineSeparator
|
||||||
* @return this builder
|
* @return this builder
|
||||||
*/
|
*/
|
||||||
public T withLineSeparator(LineSeparator lineSeparator) {
|
public Swagger2MarkupConfigBuilder withLineSeparator(LineSeparator lineSeparator) {
|
||||||
Validate.notNull(lineSeparator, "%s must no be null", "lineSeparator");
|
Validate.notNull(lineSeparator, "%s must no be null", "lineSeparator");
|
||||||
config.lineSeparator = lineSeparator;
|
config.lineSeparator = lineSeparator;
|
||||||
return self;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static class DefaultSwagger2MarkupConfig implements Swagger2MarkupConfig {
|
||||||
* Specifies the request examples format to use.
|
|
||||||
*
|
|
||||||
* @param requestExamplesFormat `basic`, `curl` or `invoke-webrequest`
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public T withRequestExamplesFormat(String requestExamplesFormat) {
|
|
||||||
Validate.notNull(requestExamplesFormat, "%s must not be null", requestExamplesFormat);
|
|
||||||
config.requestExamplesFormat = requestExamplesFormat;
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
private MarkupLanguage markupLanguage;
|
||||||
* format name which should be used to highlight source block with request example string
|
private MarkupLanguage swaggerMarkupLanguage;
|
||||||
*
|
private boolean generatedExamplesEnabled;
|
||||||
* @param requestExamplesSourceFormat any string or `default`
|
private boolean basePathPrefixEnabled;
|
||||||
* @return this builder
|
private boolean separatedDefinitionsEnabled;
|
||||||
*/
|
private boolean separatedOperationsEnabled;
|
||||||
public T withRequestExamplesSourceFormat(String requestExamplesSourceFormat) {
|
private GroupBy pathsGroupedBy;
|
||||||
Validate.notNull(requestExamplesSourceFormat, "%s must not be null", requestExamplesSourceFormat);
|
private Language outputLanguage;
|
||||||
config.requestExamplesSourceFormat = requestExamplesSourceFormat;
|
private boolean inlineSchemaEnabled;
|
||||||
return self;
|
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;
|
||||||
* Should we hide, inherit or override hostname (e.g. with google.com) from yml file
|
private String pathsDocument;
|
||||||
*
|
private String definitionsDocument;
|
||||||
* @param requestExamplesHost `hide`, `inherit` or string with hostname to be used in request example
|
private String securityDocument;
|
||||||
* @return this builder
|
private String separatedOperationsFolder;
|
||||||
*/
|
private String separatedDefinitionsFolder;
|
||||||
public T withRequestExamplesHost(String requestExamplesHost) {
|
private Character listDelimiter;
|
||||||
Validate.notNull(requestExamplesHost, "%s must not ber null", requestExamplesHost);
|
private boolean listDelimiterEnabled;
|
||||||
config.requestExamplesHost = requestExamplesHost;
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
private List<PageBreakLocations> pageBreakLocations;
|
||||||
* Should we hide, inherit or override schema (http, https name it) from yml file
|
|
||||||
*
|
|
||||||
* @param requestExamplesSchema `hide`, `inherit` or string with schema name to be used in request example
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public T withRequestExamplesSchema(String requestExamplesSchema) {
|
|
||||||
Validate.notNull(requestExamplesSchema, "%s must not be null", requestExamplesSchema);
|
|
||||||
config.requestExamplesSchema = requestExamplesSchema;
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
private Pattern headerPattern;
|
||||||
* Should we hide or show base path in example request endpoint address
|
|
||||||
*
|
|
||||||
* @param requestExamplesHideBasePath true or false
|
|
||||||
* @return this builder
|
|
||||||
* @throws PatternSyntaxException when pattern cannot be compiled
|
|
||||||
*/
|
|
||||||
public T withRequestExamplesHideBasePath(boolean requestExamplesHideBasePath) {
|
|
||||||
config.requestExamplesHideBasePath = requestExamplesHideBasePath;
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
private Swagger2MarkupProperties extensionsProperties;
|
||||||
* Should we output optional query params in source block with request example string
|
|
||||||
*
|
|
||||||
* @param requestExamplesIncludeAllQueryParams false if example request should contain only required params
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public T withRequestExamplesIncludeAllQueryParams(boolean requestExamplesIncludeAllQueryParams) {
|
|
||||||
config.requestExamplesIncludeAllQueryParams = requestExamplesIncludeAllQueryParams;
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* How we should output array query params
|
|
||||||
*
|
|
||||||
* @param requestExamplesQueryArrayStyle `single` — single time (similar to basic types), `commaSeparated` — single time with multiple comma
|
|
||||||
* separated values, `multiple` times with same param name and different values, `multiple[]` times with array
|
|
||||||
* brackets as param name suffix.
|
|
||||||
* @return this builder
|
|
||||||
*/
|
|
||||||
public T withRequestExamplesQueryArrayStyle(String requestExamplesQueryArrayStyle) {
|
|
||||||
Validate.notNull(requestExamplesQueryArrayStyle, "%s must not be null", requestExamplesQueryArrayStyle);
|
|
||||||
config.requestExamplesQueryArrayStyle = requestExamplesQueryArrayStyle;
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static CompositeConfiguration getCompositeConfiguration(Configuration configuration) {
|
|
||||||
CompositeConfiguration compositeConfiguration = new CompositeConfiguration();
|
|
||||||
compositeConfiguration.addConfiguration(new SystemConfiguration());
|
|
||||||
compositeConfiguration.addConfiguration(configuration);
|
|
||||||
compositeConfiguration.addConfiguration(getDefaultConfiguration());
|
|
||||||
return compositeConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Default implementation of {@link Schema2MarkupConfig}
|
|
||||||
*/
|
|
||||||
public static class DefaultSchema2MarkupConfig implements Schema2MarkupConfig {
|
|
||||||
MarkupLanguage markupLanguage;
|
|
||||||
MarkupLanguage schemaMarkupLanguage;
|
|
||||||
boolean generatedExamplesEnabled;
|
|
||||||
|
|
||||||
String requestExamplesFormat;
|
|
||||||
String requestExamplesSourceFormat;
|
|
||||||
String requestExamplesHost;
|
|
||||||
String requestExamplesSchema;
|
|
||||||
boolean requestExamplesHideBasePath;
|
|
||||||
boolean requestExamplesIncludeAllQueryParams;
|
|
||||||
String requestExamplesQueryArrayStyle;
|
|
||||||
|
|
||||||
boolean hostnameEnabled;
|
|
||||||
boolean basePathPrefixEnabled;
|
|
||||||
boolean separatedDefinitionsEnabled;
|
|
||||||
boolean separatedOperationsEnabled;
|
|
||||||
GroupBy pathsGroupedBy;
|
|
||||||
Language language;
|
|
||||||
boolean inlineSchemaEnabled;
|
|
||||||
OrderBy tagOrderBy;
|
|
||||||
Comparator<String> tagOrdering;
|
|
||||||
OrderBy operationOrderBy;
|
|
||||||
Comparator<PathOperation> operationOrdering;
|
|
||||||
OrderBy definitionOrderBy;
|
|
||||||
Comparator<String> definitionOrdering;
|
|
||||||
OrderBy parameterOrderBy;
|
|
||||||
Comparator<Parameter> parameterOrdering;
|
|
||||||
OrderBy propertyOrderBy;
|
|
||||||
Comparator<String> propertyOrdering;
|
|
||||||
OrderBy responseOrderBy;
|
|
||||||
Comparator<String> responseOrdering;
|
|
||||||
boolean interDocumentCrossReferencesEnabled;
|
|
||||||
String interDocumentCrossReferencesPrefix;
|
|
||||||
boolean flatBodyEnabled;
|
|
||||||
boolean pathSecuritySectionEnabled;
|
|
||||||
String anchorPrefix;
|
|
||||||
LineSeparator lineSeparator;
|
|
||||||
|
|
||||||
String overviewDocument;
|
|
||||||
String pathsDocument;
|
|
||||||
String definitionsDocument;
|
|
||||||
String securityDocument;
|
|
||||||
String separatedOperationsFolder;
|
|
||||||
String separatedDefinitionsFolder;
|
|
||||||
Character listDelimiter;
|
|
||||||
boolean listDelimiterEnabled;
|
|
||||||
int asciidocPegdownTimeoutMillis;
|
|
||||||
|
|
||||||
List<PageBreakLocations> pageBreakLocations;
|
|
||||||
|
|
||||||
Pattern headerPattern;
|
|
||||||
|
|
||||||
Schema2MarkupProperties extensionsProperties;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MarkupLanguage getMarkupLanguage() {
|
public MarkupLanguage getMarkupLanguage() {
|
||||||
@@ -705,8 +599,8 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MarkupLanguage getSchemaMarkupLanguage() {
|
public MarkupLanguage getSwaggerMarkupLanguage() {
|
||||||
return schemaMarkupLanguage;
|
return swaggerMarkupLanguage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -730,8 +624,8 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Language getLanguage() {
|
public Language getOutputLanguage() {
|
||||||
return language;
|
return outputLanguage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -875,15 +769,10 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Schema2MarkupProperties getExtensionsProperties() {
|
public Swagger2MarkupProperties getExtensionsProperties() {
|
||||||
return extensionsProperties;
|
return extensionsProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isHostnameEnabled() {
|
|
||||||
return hostnameEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isBasePathPrefixEnabled() {
|
public boolean isBasePathPrefixEnabled() {
|
||||||
return basePathPrefixEnabled;
|
return basePathPrefixEnabled;
|
||||||
@@ -893,44 +782,5 @@ public abstract class Schema2MarkupConfigBuilder<T extends Schema2MarkupConfigBu
|
|||||||
public List<PageBreakLocations> getPageBreakLocations() {
|
public List<PageBreakLocations> getPageBreakLocations() {
|
||||||
return pageBreakLocations;
|
return pageBreakLocations;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAsciidocPegdownTimeoutMillis() {
|
|
||||||
return asciidocPegdownTimeoutMillis;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRequestExamplesFormat() {
|
|
||||||
return requestExamplesFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRequestExamplesSourceFormat() {
|
|
||||||
return requestExamplesSourceFormat;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getRequestExamplesIncludeAllQueryParams() {
|
|
||||||
return requestExamplesIncludeAllQueryParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRequestExamplesQueryArrayStyle() {
|
|
||||||
return requestExamplesQueryArrayStyle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRequestExamplesHost() {
|
|
||||||
return requestExamplesHost;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRequestExamplesSchema() {
|
|
||||||
return requestExamplesSchema;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public boolean getRequestExamplesHideBasePath() {
|
|
||||||
return requestExamplesHideBasePath;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package io.github.swagger2markup.builder;
|
package io.github.swagger2markup.builder;
|
||||||
|
|
||||||
|
import io.github.swagger2markup.Swagger2MarkupExtensionRegistry;
|
||||||
import io.github.swagger2markup.spi.*;
|
import io.github.swagger2markup.spi.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -106,17 +107,17 @@ public class Swagger2MarkupExtensionRegistryBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class Context {
|
private static class Context {
|
||||||
final List<SwaggerModelExtension> swaggerModelExtensions;
|
public final List<SwaggerModelExtension> swaggerModelExtensions;
|
||||||
final List<OverviewDocumentExtension> overviewDocumentExtensions;
|
public final List<OverviewDocumentExtension> overviewDocumentExtensions;
|
||||||
final List<DefinitionsDocumentExtension> definitionsDocumentExtensions;
|
public final List<DefinitionsDocumentExtension> definitionsDocumentExtensions;
|
||||||
final List<PathsDocumentExtension> pathsDocumentExtensions;
|
public final List<PathsDocumentExtension> pathsDocumentExtensions;
|
||||||
final List<SecurityDocumentExtension> securityDocumentExtensions;
|
public final List<SecurityDocumentExtension> securityDocumentExtensions;
|
||||||
|
|
||||||
Context(List<SwaggerModelExtension> swaggerModelExtensions,
|
public Context(List<SwaggerModelExtension> swaggerModelExtensions,
|
||||||
List<OverviewDocumentExtension> overviewDocumentExtensions,
|
List<OverviewDocumentExtension> overviewDocumentExtensions,
|
||||||
List<DefinitionsDocumentExtension> definitionsDocumentExtensions,
|
List<DefinitionsDocumentExtension> definitionsDocumentExtensions,
|
||||||
List<PathsDocumentExtension> pathsDocumentExtensions,
|
List<PathsDocumentExtension> pathsDocumentExtensions,
|
||||||
List<SecurityDocumentExtension> securityDocumentExtensions) {
|
List<SecurityDocumentExtension> securityDocumentExtensions) {
|
||||||
this.swaggerModelExtensions = swaggerModelExtensions;
|
this.swaggerModelExtensions = swaggerModelExtensions;
|
||||||
this.overviewDocumentExtensions = overviewDocumentExtensions;
|
this.overviewDocumentExtensions = overviewDocumentExtensions;
|
||||||
this.definitionsDocumentExtensions = definitionsDocumentExtensions;
|
this.definitionsDocumentExtensions = definitionsDocumentExtensions;
|
||||||
@@ -17,21 +17,22 @@ package io.github.swagger2markup.internal.adapter;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import io.github.swagger2markup.Swagger2MarkupConfig;
|
import io.github.swagger2markup.Swagger2MarkupConfig;
|
||||||
import io.github.swagger2markup.Swagger2MarkupConverter.SwaggerContext;
|
import io.github.swagger2markup.Swagger2MarkupConverter;
|
||||||
import io.github.swagger2markup.internal.resolver.DocumentResolver;
|
import io.github.swagger2markup.internal.resolver.DocumentResolver;
|
||||||
import io.github.swagger2markup.internal.type.*;
|
import io.github.swagger2markup.internal.type.*;
|
||||||
import io.github.swagger2markup.internal.utils.ExamplesUtil;
|
|
||||||
import io.github.swagger2markup.internal.utils.InlineSchemaUtils;
|
import io.github.swagger2markup.internal.utils.InlineSchemaUtils;
|
||||||
import io.github.swagger2markup.internal.utils.ModelUtils;
|
import io.github.swagger2markup.internal.utils.ModelUtils;
|
||||||
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
|
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
|
||||||
import io.github.swagger2markup.markup.builder.MarkupLanguage;
|
|
||||||
import io.github.swagger2markup.model.PathOperation;
|
import io.github.swagger2markup.model.PathOperation;
|
||||||
import io.swagger.models.Model;
|
import io.swagger.models.Model;
|
||||||
import io.swagger.models.parameters.*;
|
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 io.swagger.util.Json;
|
import io.swagger.util.Json;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.apache.commons.text.WordUtils;
|
import org.apache.commons.lang3.text.WordUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -47,13 +48,13 @@ public class ParameterAdapter {
|
|||||||
private final Swagger2MarkupConfig config;
|
private final Swagger2MarkupConfig config;
|
||||||
private Type type;
|
private Type type;
|
||||||
|
|
||||||
public ParameterAdapter(SwaggerContext context,
|
public ParameterAdapter(Swagger2MarkupConverter.Context context,
|
||||||
PathOperation operation,
|
PathOperation operation,
|
||||||
Parameter parameter,
|
Parameter parameter,
|
||||||
DocumentResolver definitionDocumentResolver) {
|
DocumentResolver definitionDocumentResolver) {
|
||||||
Validate.notNull(parameter, "parameter must not be null");
|
Validate.notNull(parameter, "parameter must not be null");
|
||||||
this.parameter = parameter;
|
this.parameter = parameter;
|
||||||
type = getType(context.getSchema().getDefinitions(), definitionDocumentResolver);
|
type = getType(context.getSwagger().getDefinitions(), definitionDocumentResolver);
|
||||||
config = context.getConfig();
|
config = context.getConfig();
|
||||||
if (config.isInlineSchemaEnabled()) {
|
if (config.isInlineSchemaEnabled()) {
|
||||||
if (config.isFlatBodyEnabled()) {
|
if (config.isFlatBodyEnabled()) {
|
||||||
@@ -72,7 +73,7 @@ public class ParameterAdapter {
|
|||||||
* @param parameter parameter
|
* @param parameter parameter
|
||||||
* @return a generated example for the parameter
|
* @return a generated example for the parameter
|
||||||
*/
|
*/
|
||||||
public static Object generateExample(AbstractSerializableParameter<?> parameter) {
|
public static Object generateExample(AbstractSerializableParameter parameter) {
|
||||||
switch (parameter.getType()) {
|
switch (parameter.getType()) {
|
||||||
case "integer":
|
case "integer":
|
||||||
return 0;
|
return 0;
|
||||||
@@ -81,7 +82,7 @@ public class ParameterAdapter {
|
|||||||
case "boolean":
|
case "boolean":
|
||||||
return true;
|
return true;
|
||||||
case "string":
|
case "string":
|
||||||
return ExamplesUtil.generateStringExample(parameter.getFormat(), parameter.getEnum());
|
return "string";
|
||||||
default:
|
default:
|
||||||
return parameter.getType();
|
return parameter.getType();
|
||||||
}
|
}
|
||||||
@@ -109,8 +110,7 @@ public class ParameterAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String displayDescription(MarkupDocBuilder markupDocBuilder) {
|
public String displayDescription(MarkupDocBuilder markupDocBuilder) {
|
||||||
io.github.swagger2markup.MarkupLanguage schemaMarkupLanguage = config.getSchemaMarkupLanguage();
|
return markupDescription(config.getSwaggerMarkupLanguage(), markupDocBuilder, getDescription());
|
||||||
return markupDescription(MarkupLanguage.valueOf(schemaMarkupLanguage.name()), markupDocBuilder, getDescription());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String displayType(MarkupDocBuilder markupDocBuilder) {
|
public String displayType(MarkupDocBuilder markupDocBuilder) {
|
||||||
@@ -202,19 +202,4 @@ public class ParameterAdapter {
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Integer> getMinItems() {
|
|
||||||
if (parameter instanceof SerializableParameter) {
|
|
||||||
Integer minItems = ((SerializableParameter) parameter).getMinItems();
|
|
||||||
return Optional.ofNullable(minItems);
|
|
||||||
}
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<Integer> getMaxItems() {
|
|
||||||
if (parameter instanceof SerializableParameter) {
|
|
||||||
Integer maxItems = ((SerializableParameter) parameter).getMaxItems();
|
|
||||||
return Optional.ofNullable(maxItems);
|
|
||||||
}
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -16,29 +16,9 @@
|
|||||||
package io.github.swagger2markup.internal.adapter;
|
package io.github.swagger2markup.internal.adapter;
|
||||||
|
|
||||||
import io.github.swagger2markup.internal.resolver.DocumentResolver;
|
import io.github.swagger2markup.internal.resolver.DocumentResolver;
|
||||||
import io.github.swagger2markup.internal.type.ArrayType;
|
import io.github.swagger2markup.internal.type.*;
|
||||||
import io.github.swagger2markup.internal.type.BasicType;
|
|
||||||
import io.github.swagger2markup.internal.type.EnumType;
|
|
||||||
import io.github.swagger2markup.internal.type.MapType;
|
|
||||||
import io.github.swagger2markup.internal.type.ObjectType;
|
|
||||||
import io.github.swagger2markup.internal.type.RefType;
|
|
||||||
import io.github.swagger2markup.internal.type.Type;
|
|
||||||
import io.github.swagger2markup.internal.utils.ExamplesUtil;
|
|
||||||
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
|
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
|
||||||
import io.swagger.models.properties.AbstractNumericProperty;
|
import io.swagger.models.properties.*;
|
||||||
import io.swagger.models.properties.ArrayProperty;
|
|
||||||
import io.swagger.models.properties.BaseIntegerProperty;
|
|
||||||
import io.swagger.models.properties.BooleanProperty;
|
|
||||||
import io.swagger.models.properties.DoubleProperty;
|
|
||||||
import io.swagger.models.properties.FloatProperty;
|
|
||||||
import io.swagger.models.properties.IntegerProperty;
|
|
||||||
import io.swagger.models.properties.LongProperty;
|
|
||||||
import io.swagger.models.properties.MapProperty;
|
|
||||||
import io.swagger.models.properties.ObjectProperty;
|
|
||||||
import io.swagger.models.properties.Property;
|
|
||||||
import io.swagger.models.properties.RefProperty;
|
|
||||||
import io.swagger.models.properties.StringProperty;
|
|
||||||
import io.swagger.models.properties.UUIDProperty;
|
|
||||||
import io.swagger.models.refs.RefFormat;
|
import io.swagger.models.refs.RefFormat;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
@@ -47,12 +27,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||||
|
|
||||||
@@ -75,19 +50,15 @@ public final class PropertyAdapter {
|
|||||||
*/
|
*/
|
||||||
public static Object generateExample(Property property, MarkupDocBuilder markupDocBuilder) {
|
public static Object generateExample(Property property, MarkupDocBuilder markupDocBuilder) {
|
||||||
|
|
||||||
if (property.getType() == null) {
|
|
||||||
return "untyped";
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (property.getType()) {
|
switch (property.getType()) {
|
||||||
case "integer":
|
case "integer":
|
||||||
return ExamplesUtil.generateIntegerExample(property instanceof IntegerProperty ? ((IntegerProperty) property).getEnum() : null);
|
return 0;
|
||||||
case "number":
|
case "number":
|
||||||
return 0.0;
|
return 0.0;
|
||||||
case "boolean":
|
case "boolean":
|
||||||
return true;
|
return true;
|
||||||
case "string":
|
case "string":
|
||||||
return ExamplesUtil.generateStringExample(property.getFormat(), property instanceof StringProperty ? ((StringProperty) property).getEnum() : null);
|
return "string";
|
||||||
case "ref":
|
case "ref":
|
||||||
if (property instanceof RefProperty) {
|
if (property instanceof RefProperty) {
|
||||||
if (logger.isDebugEnabled()) logger.debug("generateExample RefProperty for " + property.getName());
|
if (logger.isDebugEnabled()) logger.debug("generateExample RefProperty for " + property.getName());
|
||||||
@@ -168,13 +139,8 @@ public final class PropertyAdapter {
|
|||||||
Property items = arrayProperty.getItems();
|
Property items = arrayProperty.getItems();
|
||||||
if (items == null)
|
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)
|
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 {
|
else
|
||||||
Type arrayType = new PropertyAdapter(items).getType(definitionDocumentResolver);
|
type = new ArrayType(arrayProperty.getTitle(), new PropertyAdapter(items).getType(definitionDocumentResolver));
|
||||||
if (arrayType == 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(), new PropertyAdapter(items).getType(definitionDocumentResolver));
|
|
||||||
}
|
|
||||||
} else if (property instanceof MapProperty) {
|
} else if (property instanceof MapProperty) {
|
||||||
MapProperty mapProperty = (MapProperty) property;
|
MapProperty mapProperty = (MapProperty) property;
|
||||||
Property additionalProperties = mapProperty.getAdditionalProperties();
|
Property additionalProperties = mapProperty.getAdditionalProperties();
|
||||||
@@ -194,22 +160,8 @@ public final class PropertyAdapter {
|
|||||||
}
|
}
|
||||||
} else if (property instanceof ObjectProperty) {
|
} else if (property instanceof ObjectProperty) {
|
||||||
type = new ObjectType(property.getTitle(), ((ObjectProperty) property).getProperties());
|
type = new ObjectType(property.getTitle(), ((ObjectProperty) property).getProperties());
|
||||||
} else if (property instanceof IntegerProperty) {
|
|
||||||
IntegerProperty integerProperty = (IntegerProperty) property;
|
|
||||||
List<Integer> enums = integerProperty.getEnum();
|
|
||||||
if (CollectionUtils.isNotEmpty(enums)) {
|
|
||||||
// first, convert integer enum values to strings
|
|
||||||
List<String> enumValuesAsString = enums.stream().map(String::valueOf).collect(Collectors.toList());
|
|
||||||
type = new EnumType(integerProperty.getTitle(), enumValuesAsString);
|
|
||||||
} else if (isNotBlank(integerProperty.getFormat())) {
|
|
||||||
type = new BasicType(integerProperty.getType(), integerProperty.getTitle(), integerProperty.getFormat());
|
|
||||||
} else {
|
|
||||||
type = new BasicType(property.getType(), property.getTitle());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (property.getType() == null) {
|
if (isNotBlank(property.getFormat())) {
|
||||||
return null;
|
|
||||||
} else if (isNotBlank(property.getFormat())) {
|
|
||||||
type = new BasicType(property.getType(), property.getTitle(), property.getFormat());
|
type = new BasicType(property.getType(), property.getTitle(), property.getFormat());
|
||||||
} else {
|
} else {
|
||||||
type = new BasicType(property.getType(), property.getTitle());
|
type = new BasicType(property.getType(), property.getTitle());
|
||||||
@@ -327,9 +279,9 @@ public final class PropertyAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the maximum value of a property
|
* Retrieves the minimum value of a property
|
||||||
*
|
*
|
||||||
* @return the maximum value of the property
|
* @return the minimum value of the property
|
||||||
*/
|
*/
|
||||||
public Optional<BigDecimal> getMax() {
|
public Optional<BigDecimal> getMax() {
|
||||||
if (property instanceof BaseIntegerProperty) {
|
if (property instanceof BaseIntegerProperty) {
|
||||||