This commit is contained in:
2024-05-24 15:27:07 +03:00
parent 17df2ce6a9
commit fc1da2c238
643 changed files with 110185 additions and 231 deletions

View File

@ -0,0 +1,7 @@
env:
mocha: true
rules:
"react/prop-types": 1 # bah humbug
"react/require-render-return": 1
"no-unused-vars": 1 # unused vars in tests can be useful for indicating a full signature
"no-global-assign": 1

View File

@ -0,0 +1,14 @@
{
"rules": {
"import/no-unresolved": 0,
"import/extensions": 0,
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
}

View File

@ -0,0 +1,8 @@
import { describe, expect, test } from '@jest/globals';
import SwaggerUI from '../../dist/swagger-ui-es-bundle-core';
describe('webpack browser es-bundle-core build', () => {
test('should export a function for es-bundle-core', () => {
expect(SwaggerUI).toBeInstanceOf(Function);
});
});

View File

@ -0,0 +1,8 @@
import { describe, expect, test } from '@jest/globals';
import SwaggerUI from '../../dist/swagger-ui-es-bundle';
describe('webpack browser es-bundle build', () => {
test('should export a function for es-bundle', () => {
expect(SwaggerUI).toBeInstanceOf(Function);
});
});

View File

@ -0,0 +1,8 @@
import { describe, expect, test } from '@jest/globals';
import SwaggerUI from '../../dist/swagger-ui-bundle';
describe('webpack browser umd build', () => {
test('should export a function for (umd) bundle', () => {
expect(SwaggerUI).toBeInstanceOf(Function);
});
});

View File

@ -0,0 +1,30 @@
import React from "react"
import expect from "expect"
import { shallow } from "enzyme"
import HighlightCode from "components/highlight-code"
const fakeGetConfigs = () => ({syntaxHighlight: {activated: true, theme: "agate"}})
describe("<HighlightCode />", () => {
it("should render a Download button if downloadable", () => {
const props = {downloadable: true, getConfigs: fakeGetConfigs }
const wrapper = shallow(<HighlightCode {...props} />)
expect(wrapper.find(".download-contents").length).toEqual(1)
})
it("should render a Copy To Clipboard button if copyable", () => {
const props = {canCopy: true, getConfigs: fakeGetConfigs }
const wrapper = shallow(<HighlightCode {...props} />)
expect(wrapper.find("CopyToClipboard").length).toEqual(1)
})
it("should render values in a preformatted element", () => {
const value = "test text"
const props = {value: value, getConfigs: fakeGetConfigs}
const wrapper = shallow(<HighlightCode {...props} />)
const preTag = wrapper.find("pre")
expect(preTag.length).toEqual(1)
expect(preTag.contains(value)).toEqual(true)
})
})

View File

@ -0,0 +1,41 @@
import React from "react"
import expect from "expect"
import { shallow } from "enzyme"
import ResponseBody from "components/response-body"
describe("<ResponseBody />", function() {
const highlightCodeComponent = () => null
const components = {
highlightCode: highlightCodeComponent
}
const props = {
getComponent: c => components[c],
}
it("renders ResponseBody as 'application/json'", function() {
props.contentType = "application/json"
props.content = "{\"key\": \"a test value\"}"
const wrapper = shallow(<ResponseBody {...props}/>)
expect(wrapper.find("highlightCodeComponent").length).toEqual(1)
})
it("renders ResponseBody as 'text/html'", function() {
props.contentType = "application/json"
props.content = "<b>Result</b>"
const wrapper = shallow(<ResponseBody {...props}/>)
expect(wrapper.find("highlightCodeComponent").length).toEqual(1)
})
it("renders ResponseBody as 'image/svg'", function() {
props.contentType = "image/svg"
const wrapper = shallow(<ResponseBody {...props}/>)
expect(wrapper.find("highlightCodeComponent").length).toEqual(0)
})
it("should render a copyable highlightCodeComponent for text types", function() {
props.contentType = "text/plain"
props.content = "test text"
const wrapper = shallow(<ResponseBody {...props}/>)
expect(wrapper.find("highlightCodeComponent[canCopy]").length).toEqual(1)
})
})

View File

@ -0,0 +1,8 @@
globals:
cy: false
Cypress: false
expect: false
assert: false
rules:
"no-console": 0

View File

@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}

View File

@ -0,0 +1,679 @@
module.exports = {
ParameterPrimitiveTestCases,
RequestBodyPrimitiveTestCases,
ResponsePrimitiveTestCases,
}
function ParameterPrimitiveTestCases({
operationDomId,
parameterName,
exampleA, // { value, key }
exampleB, // { value, key }
exampleC,
customUserInput,
customExpectedUrlSubstring,
}) {
it("should render examples options without Modified Value by default", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
.get(operationDomId)
.click()
.get(`tr[data-param-name="${parameterName}"]`)
.find(".examples-select option")
.should("have.length", exampleC ? 3 : 2)
// Ensure the relevant input is disabled
.get(
`tr[data-param-name="${parameterName}"] input, tr[data-param-name="${parameterName}"] textarea`
)
.should("have.attr", "disabled")
// Switch to Try-It-Out
.get(".try-out__btn")
.click()
.get(`.opblock-section-request-body`)
.find(".examples-select option")
.should("have.length", exampleC ? 3 : 2)
})
it("should set default static and Try-It-Out values based on the first member", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
// Expand the operation
.get(operationDomId)
.click()
// Assert on the static docs value
.get(
`tr[data-param-name="${parameterName}"] input,tr[data-param-name="${parameterName}"] textarea`
)
.should("have.value", exampleA.value)
// Switch to Try-It-Out
.get(".try-out__btn")
.click()
// Assert on the Try-It-Out value
.get(
`tr[data-param-name="${parameterName}"] input,tr[data-param-name="${parameterName}"] textarea`
)
.should("have.value", exampleA.value)
// Execute the operation
.get(".execute")
.click()
// Assert on the request URL
.get(".request-url")
.contains(
exampleA.serializedValue || `?message=${escape(exampleA.value)}`
)
})
it("should set static and Try-It-Out values based on the second member", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
// Expand the operation
.get(operationDomId)
.click()
// Choose the second example
.get("table.parameters .examples-select > select")
.select(exampleB.key)
// Assert on the static docs value
.get(
`tr[data-param-name="${parameterName}"] input,tr[data-param-name="${parameterName}"] textarea`
)
.should("have.value", exampleB.value)
// Switch to Try-It-Out
.get(".try-out__btn")
.click()
// Assert on the Try-It-Out value
.get(
`tr[data-param-name="${parameterName}"] input,tr[data-param-name="${parameterName}"] textarea`
)
.should("have.value", exampleB.value)
// Execute the operation
.get(".execute")
.click()
// Assert on the request URL
.get(".request-url")
.contains(
exampleB.serializedValue
? `?${exampleB.serializedValue}`
: `?message=${escape(exampleB.value)}`
)
})
it("should handle user-entered values correctly", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
// Expand the operation
.get(operationDomId)
.click()
// Switch to Try-It-Out
.get(".try-out__btn")
.click()
// Modify the input value
.get(
`tr[data-param-name="${parameterName}"] input,tr[data-param-name="${parameterName}"] textarea`
)
.clear()
.type(customUserInput)
// Assert on the active select menu item
.get("table.parameters .examples-select > select")
.find(":selected")
.should("have.text", "[Modified value]")
// Execute the operation
.get(".execute")
.click()
// Assert on the request URL
.get(".request-url")
.contains(
customExpectedUrlSubstring || `?message=${escape(customUserInput)}`
)
})
it("should retain user-entered values correctly", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
// Expand the operation
.get(operationDomId)
.click()
// Switch to Try-It-Out
.get(".try-out__btn")
.click()
// Modify the input value
.get(
`tr[data-param-name="${parameterName}"] input,tr[data-param-name="${parameterName}"] textarea`
)
.clear()
.type(customUserInput)
// Select the first example
.get("table.parameters .examples-select > select")
.select(exampleA.key)
// Execute the operation
.get(".execute")
.click()
// Assert on the request URL
.get(".request-url")
.contains(
exampleA.serializedValue
? `?${exampleA.serializedValue}`
: `?message=${escape(exampleA.value)}`
)
// Select the modified value
.get("table.parameters .examples-select > select")
.select("__MODIFIED__VALUE__")
// Execute the operation
.get(".execute")
.click()
// Assert on the request URL
.get(".request-url")
.contains(
customExpectedUrlSubstring || `?message=${escape(customUserInput)}`
)
})
}
function RequestBodyPrimitiveTestCases({
operationDomId,
exampleA, // { value, key, summary }
exampleB, // { value, key, summary }
exampleC,
customUserInput,
customUserInputExpectedCurlSubstring,
primaryMediaType = "text/plain",
secondaryMediaType = "text/plain+other",
}) {
it("should render examples options without Modified Value by default", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
.get(operationDomId)
.click()
.get(`.opblock-section-request-body`)
.find(".examples-select option")
.should("have.length", exampleC ? 3 : 2)
// Switch to Try-It-Out
.get(".try-out__btn")
.click()
.get(`.opblock-section-request-body`)
.find(".examples-select option")
.should("have.length", exampleC ? 3 : 2)
})
it("should set default static and Try-It-Out values based on the first member", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
// Expand the operation
.get(operationDomId)
.click()
// Assert on the static docs value
.get(`.opblock-section-request-body .microlight`)
.should("include.text", exampleA.value)
// Switch to Try-It-Out
.get(".try-out__btn")
.click()
// Assert on the Try-It-Out value
.get(`.opblock-section-request-body textarea`)
.should("have.value", exampleA.value)
// Execute the operation
.get(".execute")
.click()
// Assert on the curl body
// TODO: use an interceptor instead of curl
.get(".curl")
.contains(`-d '${exampleA.serializedValue || exampleA.value}'`)
})
it("should set default static and Try-It-Out values based on choosing the second member in static mode", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
// Expand the operation
.get(operationDomId)
.click()
// Choose the second example
.get(".opblock-section-request-body .examples-select > select")
.select(exampleB.key)
// Assert on the static docs value
.get(`.opblock-section-request-body .microlight`)
.should("include.text", exampleB.value)
// Switch to Try-It-Out
.get(".try-out__btn")
.click()
// Assert on the Try-It-Out value
.get(`.opblock-section-request-body textarea`)
.should("have.value", exampleB.value)
// Execute the operation
.get(".execute")
.click()
// Assert on the request URL
// TODO: use an interceptor instead of curl
.get(".curl")
.contains(`-d '${exampleB.serializedValue || exampleB.value}'`)
})
it("should set default static and Try-It-Out values based on choosing the second member in Try-It-Out mode", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
// Expand the operation
.get(operationDomId)
.click()
// Switch to Try-It-Out
.get(".try-out__btn")
.click()
// Choose the second example
.get(".opblock-section-request-body .examples-select > select")
.select(exampleB.key)
// Assert on the Try-It-Out value
.get(`.opblock-section-request-body textarea`)
.should("have.value", exampleB.value)
// Execute the operation
.get(".execute")
.click()
// Assert on the request URL
// TODO: use an interceptor instead of curl
.get(".curl")
.contains(`-d '${exampleB.serializedValue || exampleB.value}'`)
// Switch to static docs
.get(".try-out__btn")
.click()
// Assert on the static docs value
.get(`.opblock-section-request-body .microlight`)
.should("include.text", exampleB.value)
})
it("should return the dropdown entry for an example when manually returning to its value", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
// Expand the operation
.get(operationDomId)
.click()
// Assert on the static docs value
.get(`.opblock-section-request-body .microlight`)
.should("include.text", exampleA.value)
// Switch to Try-It-Out
.get(".try-out__btn")
.click()
// Assert on the Try-It-Out value
.get(`.opblock-section-request-body textarea`)
.should("have.value", exampleA.value)
// Clear the Try-It-Out value, replace it with custom value
.clear()
.type(customUserInput)
// Assert on the dropdown value
.get(".opblock-section-request-body .examples-select > select")
.find(":selected")
.should("have.text", "[Modified value]")
// Modify the value again, going back to the example value
.get(`.opblock-section-request-body textarea`)
.clear()
.type(exampleA.value)
// Assert on the dropdown value returning to the example value
.get(".opblock-section-request-body .examples-select > select")
.find(":selected")
.should("include.text", exampleA.summary)
})
it("should retain choosing a member in static docs when changing the media type", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
// Expand the operation
.get(operationDomId)
.click()
// Choose the second example
.get(".opblock-section-request-body .examples-select > select")
.select(exampleB.key)
// Change the media type
.get(".opblock-section-request-body .content-type")
.select(secondaryMediaType)
// Assert on the static docs value
.get(`.opblock-section-request-body .microlight`)
.should("include.text", exampleB.value)
// Switch to Try-It-Out
.get(".try-out__btn")
.click()
// Assert on the Try-It-Out value
.get(`.opblock-section-request-body textarea`)
.should("have.value", exampleB.value)
// Execute the operation
.get(".execute")
.click()
// Assert on the request URL
// TODO: use an interceptor instead of curl
.get(".curl")
.contains(`-d '${exampleB.serializedValue || exampleB.value}'`)
})
it("should use the first example for the media type when changing the media type without prior interactions with the value", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
// Expand the operation
.get(operationDomId)
.click()
// Change the media type
.get(".opblock-section-request-body .content-type")
.select(secondaryMediaType)
// Assert on the static docs value
.get(`.opblock-section-request-body .microlight`)
.should("include.text", exampleA.value)
// Switch to Try-It-Out
.get(".try-out__btn")
.click()
// Assert on the Try-It-Out value
.get(`.opblock-section-request-body textarea`)
.should("have.value", exampleA.value)
// Execute the operation
.get(".execute")
.click()
// Assert on the request URL
// TODO: use an interceptor instead of curl
.get(".curl")
.contains(`-d '${exampleA.serializedValue || exampleA.value}'`)
})
it("static mode toggling: mediaType -> example -> mediaType -> example", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
// Expand the operation
.get(operationDomId)
.click()
// Change the media type
.get(".opblock-section-request-body .content-type")
.select(secondaryMediaType)
// Assert on the static docs value
.get(`.opblock-section-request-body .microlight`)
.should("include.text", exampleA.value)
// Assert on the dropdown value
.get(".opblock-section-request-body .examples-select > select")
.find(":selected")
.should("include.text", exampleA.summary)
// Choose exampleB
.get(".opblock-section-request-body .examples-select > select")
.select(exampleB.key)
// Assert on the static docs value
.get(`.opblock-section-request-body .microlight`)
.should("include.text", exampleB.value)
// Assert on the dropdown value
.get(".opblock-section-request-body .examples-select > select")
.find(":selected")
.should("include.text", exampleB.summary)
// Change the media type
.get(".opblock-section-request-body .content-type")
.select(primaryMediaType)
// Assert that the static docs value didn't change
.get(`.opblock-section-request-body .microlight`)
.should("include.text", exampleB.value)
// Assert that the dropdown value didn't change
.get(".opblock-section-request-body .examples-select > select")
.find(":selected")
.should("include.text", exampleB.summary)
// Choose exampleA
.get(".opblock-section-request-body .examples-select > select")
.select(exampleA.key)
// Assert on the static docs value
.get(`.opblock-section-request-body .microlight`)
.should("include.text", exampleA.value)
// Assert on the dropdown value
.get(".opblock-section-request-body .examples-select > select")
.find(":selected")
.should("include.text", exampleA.summary)
})
it("Try-It-Out toggling: mediaType -> example -> mediaType -> example", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
// Expand the operation
.get(operationDomId)
.click()
// Switch to Try-It-Out
.get(".try-out__btn")
.click()
// Change the media type
.get(".opblock-section-request-body .content-type")
.select(secondaryMediaType)
// Assert on the static docs value
.get(`.opblock-section-request-body textarea`)
.should("include.text", exampleA.value)
// Assert on the dropdown value
.get(".opblock-section-request-body .examples-select > select")
.find(":selected")
.should("include.text", exampleA.summary)
// Choose exampleB
.get(".opblock-section-request-body .examples-select > select")
.select(exampleB.key)
// Assert on the static docs value
.get(`.opblock-section-request-body textarea`)
.should("include.text", exampleB.value)
// Assert on the dropdown value
.get(".opblock-section-request-body .examples-select > select")
.find(":selected")
.should("include.text", exampleB.summary)
// Change the media type
.get(".opblock-section-request-body .content-type")
.select(primaryMediaType)
// Assert that the static docs value didn't change
.get(`.opblock-section-request-body textarea`)
.should("include.text", exampleB.value)
// Assert that the dropdown value didn't change
.get(".opblock-section-request-body .examples-select > select")
.find(":selected")
.should("include.text", exampleB.summary)
// Choose exampleA
.get(".opblock-section-request-body .examples-select > select")
.select(exampleA.key)
// Assert on the static docs value
.get(`.opblock-section-request-body textarea`)
.should("include.text", exampleA.value)
// Assert on the dropdown value
.get(".opblock-section-request-body .examples-select > select")
.find(":selected")
.should("include.text", exampleA.summary)
})
it("Try-It-Out toggling and execution with modified values: mediaType -> modified value -> example -> mediaType -> example", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
// Expand the operation
.get(operationDomId)
.click()
// Switch to Try-It-Out
.get(".try-out__btn")
.click()
// Change the media type
.get(".opblock-section-request-body .content-type")
.select(secondaryMediaType)
// Assert on the static docs value
.get(`.opblock-section-request-body textarea`)
.should("include.text", exampleA.value)
// Assert on the dropdown value
.get(".opblock-section-request-body .examples-select > select")
.find(":selected")
.should("include.text", exampleA.summary)
// Modify the value
.get(`.opblock-section-request-body textarea`)
.clear()
.type(customUserInput)
// Assert on the dropdown value
.get(".opblock-section-request-body .examples-select > select")
.find(":selected")
.should("have.text", "[Modified value]")
// Fire the operation
.get(".execute")
.click()
// Assert on the curl body
// TODO: use an interceptor instead of curl
.get(".curl")
.contains(
`-d '${customUserInputExpectedCurlSubstring || customUserInput}'`
)
// Choose exampleB
.get(".opblock-section-request-body .examples-select > select")
.select(exampleB.key)
// Assert on the static docs value
.get(`.opblock-section-request-body textarea`)
.should("include.text", exampleB.value)
// Assert on the dropdown value
.get(".opblock-section-request-body .examples-select > select")
.find(":selected")
.should("include.text", exampleB.summary)
// Fire the operation
.get(".execute")
.click()
// Assert on the curl body
// TODO: use an interceptor instead of curl
.get(".curl")
.contains(`-d '${exampleB.serializedValue || exampleB.value}'`)
// Ensure the modified value is still accessible
.get(".opblock-section-request-body .examples-select > select")
.contains("[Modified value]")
// Change the media type to text/plain
.get(".opblock-section-request-body .content-type")
.select(primaryMediaType)
// Assert that the static docs value didn't change
.get(`.opblock-section-request-body textarea`)
.should("include.text", exampleB.value)
// Assert that the dropdown value didn't change
.get(".opblock-section-request-body .examples-select > select")
.find(":selected")
.should("include.text", exampleB.summary)
// Fire the operation
.get(".execute")
.click()
// Assert on the curl body
// TODO: use an interceptor instead of curl
.get(".curl")
.contains(`-d '${exampleB.serializedValue || exampleB.value}'`)
// Ensure the modified value is still accessible
.get(".opblock-section-request-body .examples-select > select")
.contains("[Modified value]")
// Choose exampleA
.get(".opblock-section-request-body .examples-select > select")
.select(exampleA.key)
// Assert on the static docs value
.get(`.opblock-section-request-body textarea`)
.should("include.text", exampleA.value)
// Assert on the dropdown value
.get(".opblock-section-request-body .examples-select > select")
.find(":selected")
.should("include.text", exampleA.summary)
// Fire the operation
.get(".execute")
.click()
// Assert on the curl body
// TODO: use an interceptor instead of curl
.get(".curl")
.contains(`-d '${exampleA.serializedValue || exampleA.value}'`)
// Ensure the modified value is still the same value
.get(".opblock-section-request-body .examples-select > select")
.select("__MODIFIED__VALUE__")
// Assert on the static docs value
.get(`.opblock-section-request-body textarea`)
.should("have.text", customUserInput.replace(/{{}/g, "{"))
// Assert on the dropdown value
.get(".opblock-section-request-body .examples-select > select")
.find(":selected")
.should("have.text", "[Modified value]")
// Fire the operation
.get(".execute")
.click()
// Assert on the curl body
// TODO: use an interceptor instead of curl
.get(".curl")
.contains(
`-d '${customUserInputExpectedCurlSubstring || customUserInput}'`
)
})
// TODO: Try-It-Out + Try-It-Out media type changes
}
function ResponsePrimitiveTestCases({
operationDomId,
exampleA, // { value, key, summary }
exampleB, // { value, key, summary }
exampleC, // { value, key, summary }
}) {
it("should render the first example by default", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
.get(operationDomId)
.click()
.get(".responses-wrapper")
.within(() => {
cy.get(".examples-select > select")
.find(":selected")
.should("include.text", exampleA.summary)
.get(".microlight")
.should("include.text", exampleA.value)
})
})
it("should render the second example", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
.get(operationDomId)
.click()
.get(".responses-wrapper")
.within(() => {
cy.get(".examples-select > select")
.select(exampleB.key)
.find(":selected")
.should("include.text", exampleB.summary)
.get(".microlight")
.should("include.text", exampleB.value)
})
})
it("should retain an example choice across media types if they share the same example", () => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
.get(operationDomId)
.click()
.get(".responses-wrapper")
.within(() => {
cy
// Change examples
.get(".examples-select > select")
.select(exampleB.key)
// Assert against dropdown value
.find(":selected")
.should("include.text", exampleB.summary)
// Assert against example value
.get(".microlight")
.should("include.text", exampleB.value)
// Change media types
.get(".content-type")
.select("text/plain+other")
// Assert against dropdown value
.get(".examples-select > select")
.find(":selected")
.should("include.text", exampleB.summary)
// Assert against example value
.get(".microlight")
.should("include.text", exampleB.value)
})
})
;(exampleC ? it : it.skip)(
"should reset to the first example if the new media type lacks the current example",
() => {
cy.visit("/?url=/documents/features/multiple-examples-core.openapi.yaml")
.get(operationDomId)
.click()
.get(".responses-wrapper")
.within(() => {
cy
// Change media types
.get(".content-type")
.select("text/plain+other")
// Change examples
.get(".examples-select > select")
.select(exampleC.key)
// Assert against dropdown value
.find(":selected")
.should("include.text", exampleC.summary || exampleC.key)
// Assert against example value
.get(".microlight")
.should("include.text", exampleC.value)
// Change media types
.get(".content-type")
.select("text/plain")
// Assert against dropdown value
.get(".examples-select > select")
.find(":selected")
.should("include.text", exampleA.summary)
// Assert against example value
.get(".microlight")
.should("include.text", exampleA.value)
})
}
)
}

View File

@ -0,0 +1,50 @@
// from https://github.com/pedroetb/node-oauth2-server-example
let Http = require("http")
let path = require("path")
let express = require("express")
let bodyParser = require("body-parser")
let oauthserver = require("oauth2-server")
let cors = require("cors")
let app = express()
app.use(cors())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())
app.oauth = oauthserver({
model: require("./model.js"),
grants: ["password", "client_credentials", "implicit"],
debug: true
})
app.all("/oauth/token", app.oauth.grant())
app.get("/swagger.yaml", function (req, res) {
res.sendFile(path.join(__dirname, "swagger.yaml"))
})
app.get("*", app.oauth.authorise(), function (req, res) {
res.send("Secret secrets are no fun, secret secrets hurt someone.")
})
app.use(app.oauth.errorHandler())
function startServer() {
let httpServer = Http.createServer(app)
httpServer.listen("3231")
return function stopServer() {
httpServer.close()
}
}
module.exports = startServer
if (require.main === module) {
// for debugging
startServer()
}

View File

@ -0,0 +1,141 @@
// from https://github.com/pedroetb/node-oauth2-server-example
let config = {
clients: [{
clientId: "application",
clientSecret: "secret"
}],
confidentialClients: [{
clientId: "confidentialApplication",
clientSecret: "topSecret"
}],
tokens: [],
users: [{
id: "123",
username: "swagger",
password: "password"
}]
}
/**
* Dump the memory storage content (for debug).
*/
let dump = function () {
console.log("clients", config.clients)
console.log("confidentialClients", config.confidentialClients)
console.log("tokens", config.tokens)
console.log("users", config.users)
}
/*
* Methods used by all grant types.
*/
let getAccessToken = function (bearerToken, callback) {
let tokens = config.tokens.filter(function (token) {
return token.accessToken === bearerToken
})
return callback(false, tokens[0])
}
let getClient = function (clientId, clientSecret, callback) {
let clients = config.clients.filter(function (client) {
return client.clientId === clientId && client.clientSecret === clientSecret
})
let confidentialClients = config.confidentialClients.filter(function (client) {
return client.clientId === clientId && client.clientSecret === clientSecret
})
callback(false, clients[0] || confidentialClients[0])
}
let grantTypeAllowed = function (clientId, grantType, callback) {
let clientsSource,
clients = []
if (grantType === "password") {
clientsSource = config.clients
} else if (grantType === "client_credentials") {
clientsSource = config.confidentialClients
}
if (clientsSource) {
clients = clientsSource.filter(function (client) {
return client.clientId === clientId
})
}
callback(false, clients.length)
}
let saveAccessToken = function (accessToken, clientId, expires, user, callback) {
config.tokens.push({
accessToken: accessToken,
expires: expires,
clientId: clientId,
user: user
})
callback(false)
}
/*
* Method used only by password grant type.
*/
let getUser = function (username, password, callback) {
let users = config.users.filter(function (user) {
return user.username === username && user.password === password
})
callback(false, users[0])
}
/*
* Method used only by client_credentials grant type.
*/
let getUserFromClient = function (clientId, clientSecret, callback) {
let clients = config.confidentialClients.filter(function (client) {
return client.clientId === clientId && client.clientSecret === clientSecret
})
let user
if (clients.length) {
user = {
username: clientId
}
}
callback(false, user)
}
/**
* Export model definition object.
*/
module.exports = {
getAccessToken: getAccessToken,
getClient: getClient,
grantTypeAllowed: grantTypeAllowed,
saveAccessToken: saveAccessToken,
getUser: getUser,
getUserFromClient: getUserFromClient
}

View File

@ -0,0 +1,36 @@
swagger: "2.0"
host: localhost:3231
paths:
/password:
get:
summary: OAuth2 Password
security:
- oauthPassword: []
responses:
200:
description: OK
schema:
type: string
/application:
get:
summary: OAuth2 Application
security:
- oauthApplication: []
responses:
200:
description: OK
schema:
type: string
securityDefinitions:
oauthPassword:
type: oauth2
flow: password
tokenUrl: /oauth/token
oauthApplication:
type: oauth2
flow: application
tokenUrl: /oauth/token
oauthImplicit:
type: oauth2
flow: implicit
authorizationUrl: /oauth/token

View File

@ -0,0 +1,19 @@
const startOAuthServer = require("../helpers/oauth2-server")
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
module.exports = (on, config) => {
startOAuthServer()
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}

View File

@ -0,0 +1,6 @@
urls:
- name: One
url: /documents/features/urls/1.yaml
- name: Two
url: /documents/features/urls/2.yaml
urls.primaryName: Two

View File

@ -0,0 +1,5 @@
urls:
- name: One
url: /documents/features/urls/server-variables-1.yaml
- name: Two
url: /documents/features/urls/server-variables-2.yaml

View File

@ -0,0 +1,5 @@
urls:
- name: One
url: /documents/features/urls/1.yaml
- name: Two
url: /documents/features/urls/2.yaml

View File

@ -0,0 +1,41 @@
openapi: "3.0.0"
paths:
/:
get:
parameters:
- name: users
in: query
description: List of users to query for
content:
application/json:
example:
- userId: 1
currency: USD
- userId: 2
currency: CAD
schema:
$ref: "#/components/schemas/UserArray"
responses:
200:
description: OK!
components:
schemas:
UserArray:
type: array
items:
$ref: "#/components/schemas/User"
User:
type: object
required:
- userId
- currency
properties:
userId:
type: integer
format: int32
currency:
type: string

View File

@ -0,0 +1,47 @@
openapi: 3.0.0
info:
title: Demo API
description: First test
termsOfService: 'http://demo.io/terms-of-service/'
contact:
name: Demo Support
email: support@demo.io
version: 1.0.0
paths:
/4641_1:
get:
summary: Returns a 200
security:
- api_key_1: []
responses:
'200':
description: A 200
content:
application/text:
schema:
type: string
/4641_2:
get:
summary: Returns a 200
security:
- api_key_1: []
- api_key_2: []
responses:
'200':
description: A 200
content:
application/text:
schema:
type: string
components:
securitySchemes:
api_key_1:
type: apiKey
name: api_key_1
in: header
api_key_2:
type: apiKey
name: api_key_2
in: header

View File

@ -0,0 +1,12 @@
openapi: "3.0.0"
paths:
/some/route:
post:
description: This should be visible
tags:
- Some
requestBody: {}
responses:
'200':
description: Description

View File

@ -0,0 +1,24 @@
openapi: 3.0.1
info:
title: test
version: "0.1"
paths:
/test:
post:
operationId: myOp
responses:
default:
description: ok
callbacks:
subscription:
http://$request.query.url:
post:
description: myCallback
parameters:
- name: myParam
in: query
schema:
type: string
responses:
default:
description: ok

View File

@ -0,0 +1,43 @@
openapi: 3.0.0
info:
description: Test API
version: v1
title: Test API
tags:
- name: Test
description: Test API
servers:
- url: /v1
paths:
/test:
post:
tags:
- Test
summary: Test endpoint
description: Test
operationId: postTest
responses:
'200':
description: Returns response
content:
application/xml:
schema:
$ref: '#/components/schemas/test'
components:
schemas:
test:
type: object
properties:
a:
type: string
b:
type: integer
c:
oneOf:
- type: object
- type: array
items:
type: string
- type: boolean
- type: integer
- type: number

View File

@ -0,0 +1,17 @@
---
paths:
findByStatus:
get:
tags:
- "pet"
summary: "Finds Pets by status"
description: "Multiple status values can be provided with comma separated strings"
operationId: "findPetsByStatus"
parameters:
- name: "status"
in: "body"
schema:
type: string
responses:
200:
description: ok

View File

@ -0,0 +1,44 @@
swagger: "2.0"
info:
description: "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). 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:
email: "apiteam@swagger.io"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io"
basePath: "/v2"
produces:
- application/json
- application/xml
- text/csv
consumes:
- application/json
- application/xml
- text/csv
schemes:
- "https"
- "http"
paths:
/pet:
post:
tags:
- "pet"
summary: "Add a new pet to the store"
description: ""
operationId: "addPet"
parameters:
- in: "body"
name: "body"
description: "Pet object that needs to be added to the store"
required: true
schema:
$ref: "#/definitions/Pet"
responses:
405:
description: "Invalid input"
/pet/findByStatus:
$ref: "status.yaml#/paths/findByStatus"

View File

@ -0,0 +1,10 @@
---
swagger: '2.0'
info:
title: Foobar Service
description: '<br><p>Example of a simple GET request via curl with bearer HTTP Authentication:</p><pre>curl
-X GET "https://foobar.com/stuff" -H "Accept: application/json" -H "Authorization:
Bearer abc123.xyz.789"</pre>'
version: '2.0'
paths: {}

View File

@ -0,0 +1,35 @@
openapi: "3.0.0"
info:
description: "A sample API for "
version: "1.0.0"
title: "Sample"
contact:
name: ""
url: "http://website.com"
email: "admin@mail.com"
paths:
/:
post:
summary: Create/modify object
operationId: postObject
parameters:
- name: filterParams
in: query
description: Additional filter fields
required: false
schema:
type: object
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
additionalProperties:
type: string
responses:
'200':
description: Status message
content:
application/json:
schema:
type: object

View File

@ -0,0 +1,33 @@
openapi: "3.0.0"
info:
description: "A sample API for "
version: "1.0.0"
title: "Sample"
contact:
name: ""
url: "http://website.com"
email: "admin@mail.com"
paths:
/:
post:
summary: Create/modify object
operationId: postObject
parameters:
- name: filterParams
in: query
description: Additional filter fields
required: false
schema:
type: object
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
responses:
'200':
description: Status message
content:
application/json:
schema:
type: object

View File

@ -0,0 +1,26 @@
openapi: "3.0.0"
paths:
/aev:
get:
parameters:
- name: param
in: query
allowEmptyValue: true
schema:
type: string
responses:
200:
description: ok
/aev/and/required:
get:
parameters:
- name: param
in: query
allowEmptyValue: true
required: true
schema:
type: string
responses:
200:
description: ok

View File

@ -0,0 +1,23 @@
openapi: "3.0.0"
paths:
/:
post:
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
first:
type: object
example:
one: abc
two: 123
second:
type: array
items:
type: string
example:
- "hi"

View File

@ -0,0 +1,27 @@
info:
title: Required parameter missing, doesn't block request from executing.
version: '1'
openapi: 3.0.0
servers:
- url: http://httpbin.org/anything
paths:
/foos:
post:
requestBody:
content:
application/x-www-form-urlencoded:
# application/json:
# application/xml:
schema:
properties:
foo:
type: string
bar:
type: string
required:
- foo
type: object
required: true # Note this doesn't have an impact
responses:
default:
description: ok

View File

@ -0,0 +1,24 @@
openapi: 3.0.0
servers: []
info:
description: sdf
version: "1.0.0"
title: Swagger Petstore
paths:
/pet:
get:
tags:
- default
summary:
whatever: 123
operationId: objectSummary
responses:
'405':
description: Invalid input
post:
tags:
- default
operationId: noSummary
responses:
'405':
description: Invalid input

View File

@ -0,0 +1,20 @@
openapi: "3.0.0"
info:
title: Testcase API
version: 2.0.0
paths:
'/endpoint':
get:
parameters:
- name: type
in: query
example: fruit
schema:
type: string
enum:
- fruit
- vegetable
- drink
responses:
'200':
description: 200 response

View File

@ -0,0 +1,19 @@
swagger: "2.0"
info:
title: Testcase API
version: 2.0.0
paths:
'/endpoint':
get:
parameters:
- name: type
in: query
x-example: fruit
type: string
enum:
- fruit
- vegetable
- drink
responses:
'200':
description: 200 response

View File

@ -0,0 +1,10 @@
openapi: 3.0.2
info:
title: Response without a schema
version: 1.0.0
paths:
/foo:
get:
responses:
'200':
description: OK

View File

@ -0,0 +1,25 @@
openapi: 3.0.2
info:
title: test
version: 1.0.0
paths:
/foo:
post:
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Foo'
responses:
201:
description: Created
components:
schemas:
Foo:
type: object
properties:
foo:
type: string
example: bar

View File

@ -0,0 +1,37 @@
swagger: "2.0"
info:
title: test
version: 1.0.0
paths:
/foo1:
get:
summary: Response without a schema
produces:
- application/json
responses:
200:
description: Successful response
examples:
application/json:
foo: custom value
/foo2:
get:
summary: Response with schema
produces:
- application/json
responses:
200:
description: Successful response
schema:
$ref: '#/definitions/Foo'
examples:
application/json:
foo: custom value
definitions:
Foo:
type: object
properties:
foo:
type: string
example: bar

View File

@ -0,0 +1,14 @@
openapi: 3.0.2
info:
title: test
description: Nullable model itself
version: '1.0'
paths: {}
components:
schemas:
SomeObject:
type: object
properties:
name:
type: string
nullable: true

View File

@ -0,0 +1,17 @@
openapi: 3.0.2
info:
title: test
description: Nullable object in model property
version: '1.0'
paths: {}
components:
schemas:
SomeObject:
type: object
properties:
meta:
type: object
properties:
tag:
type: string
nullable: true

View File

@ -0,0 +1,28 @@
swagger: "2.0"
info:
description: "OAS2 sample with entries as property name"
version: "0.0.1"
title: "Swagger Sample"
paths:
/pet:
post:
summary: "Add a new pet to the store"
description: ""
parameters:
- in: "body"
name: "body"
schema:
$ref: "#/definitions/Pet"
responses:
"405":
description: "Invalid input"
definitions:
Pet:
type: "object"
properties:
id:
type: "integer"
entries: # <-- evaluate
type: "array"
items:
type: "string"

View File

@ -0,0 +1,31 @@
openapi: 3.0.2
info:
title: OAS 3.0 sample with entries as property name
version: 0.1.0
paths:
/test/:
get:
summary: Test
operationId: test_test__get
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/Testmodel'
components:
schemas:
Testmodel:
title: Testmodel
required:
- name
- entries
type: object
properties:
name:
title: Name
type: string
entries:
title: Entries
type: integer

View File

@ -0,0 +1,57 @@
openapi: 3.0.0
info:
title: "Swagger Test"
version: "1.0.0"
servers:
- url: https://api.example.com/v1
paths:
/users:
get:
tags:
- User
summary: Get Users
responses:
200:
description: User List
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/User'
post:
tags:
- User
summary: Create a user
requestBody:
content:
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/User'
responses:
201:
description: Created successfully
put:
tags:
- User
summary: Update user
requestBody:
content:
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/User'
responses:
201:
description: Created successfully
components:
schemas:
User:
type: object
properties:
id:
type: integer
readOnly: true
name:
type: string
required:
- name

View File

@ -0,0 +1,37 @@
swagger: "2.0"
info:
title: Response headers test
version: 1.0.0
host: httpbin.org
schemes: [https]
paths:
/response-headers:
get:
summary: Run the request using the default parameter values
parameters:
- in: query
name: X-Header1
type: string
x-example: 'value1,value2'
required: true
- in: query
name: X-Header2
type: string
x-example: 'value3, value4'
required: true
- in: query
name: X-Header3
type: array
items:
type: string
x-example: [value5, value6]
collectionFormat: multi
required: true
- in: query
name: Access-Control-Expose-Headers
type: string
x-example: 'X-Header1, X-Header2, X-Header3, Access-Control-Expose-Headers'
required: true
responses:
200:
description: ok

View File

@ -0,0 +1,13 @@
openapi: 3.0.2
info:
title: OAS 3.0 sample with multiple servers
version: 0.1.0
servers:
- url: http://testserver1.com
- url: http://testserver2.com
paths:
/test/:
get:
responses:
'200':
description: Successful Response

View File

@ -0,0 +1,26 @@
swagger: "2.0"
info:
description: "OAS 2.0 sample with Object Model deprecated: true"
version: "0.0.1"
title: "Swagger Sample"
paths:
/test/:
get:
responses:
'200':
description: Successful Response
definitions:
IdentificationProfile:
type: object
deprecated: true
properties:
code:
type: integer
format: int32
message:
type: string
IDP2:
type: array
deprecated: true
items:
type: string

View File

@ -0,0 +1,26 @@
swagger: "2.0"
info:
description: "OAS 2.0 sample with Object Model deprecated: true"
version: "0.0.1"
title: "Swagger Sample"
paths:
/test/:
get:
responses:
'200':
description: Successful Response
definitions:
IdentificationProfile:
type: object
deprecated: false
properties:
code:
type: integer
format: int32
message:
type: string
IDP2:
type: array
deprecated: true
items:
type: string

View File

@ -0,0 +1,28 @@
openapi: 3.0.2
info:
title: "OAS 3.0 sample with Object Model deprecated: true"
version: 0.1.0
servers:
- url: http://testserver1.com
paths:
/test/:
get:
responses:
'200':
description: Successful Response
components:
schemas:
IdentificationProfile:
type: object
deprecated: true
properties:
code:
type: integer
format: int32
message:
type: string
IDP2:
type: array
deprecated: true
items:
type: string

View File

@ -0,0 +1,28 @@
openapi: 3.0.2
info:
title: "OAS 3.0 sample with Object Model deprecated: true"
version: 0.1.0
servers:
- url: http://testserver1.com
paths:
/test/:
get:
responses:
'200':
description: Successful Response
components:
schemas:
IdentificationProfile:
type: object
deprecated: false
properties:
code:
type: integer
format: int32
message:
type: string
IDP2:
type: array
deprecated: true
items:
type: string

View File

@ -0,0 +1,52 @@
openapi: 3.0.1
info:
title: Example Swagger
version: '1.0'
servers:
- url: /api/v1
paths:
/xmlTest:
get:
summary: subscribes to a siri vm stream
operationId: xmlTest
parameters: []
responses:
'200':
description: Simple example
content:
application/xml:
schema:
type: object
xml:
name: root
properties:
x:
type: string
example:
x: what the f
examples:
x2:
summary: "xml not rendered via 'examples' keyword"
value:
x: should be xml
/xmlTest2:
get:
summary: subscribes to a siri vm stream
operationId: xmlTest2
parameters: []
responses:
'200':
description: Simple example
content:
application/xml:
schema:
type: object
xml:
name: root
properties:
x:
type: string
example:
x: what the f
example:
x: should be xml

View File

@ -0,0 +1,57 @@
openapi: 3.0.1
info:
title: Example Swagger
version: '1.0'
servers:
- url: /api/v1
paths:
/xmlTest/examples:
post:
summary: sample issues
operationId: xmlTest_examples
parameters: []
requestBody:
description: Simple Test xml examples
content:
application/xml:
schema:
$ref: "#/components/schemas/Test"
examples:
test:
value:
x: should be xml
responses:
'200':
description: Simple Test xml examples
content: {}
/xmlTest/example:
post:
summary: sample issues
operationId: xmlTest_example
parameters: []
requestBody:
description: Simple Test xml example
content:
application/xml:
schema:
$ref: "#/components/schemas/Test"
example:
x: should be xml
responses:
'200':
description: Simple Test xml example
content: {}
components:
schemas:
Test:
type: object
xml:
name: root
properties:
x:
type: string
other:
type: string
format: email
example:
x: what the f

View File

@ -0,0 +1,85 @@
openapi: 3.0.0
info:
description: Test API
version: v1
title: Test API
tags:
- name: Test
description: Test API
servers:
- url: /v1
paths:
/test:
post:
tags:
- Test
summary: Test endpoint
description: Test
operationId: postTest
responses:
'200':
description: Returns response
content:
application/xml:
schema:
$ref: '#/components/schemas/test'
components:
schemas:
test:
type: object
properties:
a:
type: string
b:
type: integer
c:
type: array
items:
$ref: '#/components/schemas/Things'
d:
type: array
items:
anyOf:
- $ref: '#/components/schemas/TextObject'
- $ref: '#/components/schemas/ImageObject'
Things:
type: object
oneOf:
- $ref: '#/components/schemas/TextObject'
- $ref: '#/components/schemas/ImageObject'
TextObject:
required:
- data
type: object
properties:
objectType:
type: string
example: Text
xml:
name: ObjectType
data:
type: string
example: This is a text
xml:
name: Data
description: Contains a text
ImageObject:
required:
- data
type: object
properties:
objectType:
type: string
example: image
xml:
name: ObjectType
data:
type: string
example: This is a image
xml:
name: Data
description: Contains a image

View File

@ -0,0 +1,41 @@
openapi: 3.0.1
info:
title: XML array schema with array-level example
version: 1.0.0
paths:
/users:
get:
responses:
"200":
description: ''
content:
application/xml:
schema:
$ref: '#/components/schemas/Users'
components:
schemas:
Users:
type: array
example:
- id: 123
name: bob
- id: 456
name: jane
xml:
name: Users
wrapped: true
items:
type: object
xml:
name: User
properties:
id:
type: integer
xml:
attribute: true
name:
type: string
xml:
attribute: true

View File

@ -0,0 +1,28 @@
openapi: 3.0.2
info:
title: "This is an example highlighting a display issue related to `tags` and `description` entries therein. It contains tag descriptions with & without externalDocs."
version: 1.0.0
tags:
- name: "foo"
description: "Foo: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex\
ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
externalDocs:
description: "Find out more"
url: "http://swagger.io"
- name: "bar"
description: "Bar: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex \
ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
- name: "baz"
description: "Baz: has less description text"
externalDocs:
description: "Find out more about our store"
url: "http://swagger.io"
paths:
/foobar:
get:
tags:
- "foo"
- "bar"
responses:
'200':
description: OK

View File

@ -0,0 +1,28 @@
openapi: 3.0.1
info:
title: Example Swagger with required default body parameter
version: 1.0.0
paths:
/pet:
post:
operationId: addPet
requestBody:
content:
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/BodyParameter'
required: true
responses:
405:
description: Invalid input
content: {}
components:
schemas:
BodyParameter:
required:
- bodyParameter
type: object
properties:
bodyParameter:
type: string
default: default

View File

@ -0,0 +1,13 @@
swagger: "2.0"
paths:
/:
get:
description: wow
definitions:
MyModel:
type: object
properties:
a:
type: string

View File

@ -0,0 +1,20 @@
openapi: 3.0.0
info:
title: Bearer auth test
version: 1.0.0
servers:
# - url: https://httpbin.org # live external url
- url: http://localhost:3231 # will need to mock
paths:
/get:
get:
responses:
'200':
description: ok
security:
- bearerAuth: []
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer

View File

@ -0,0 +1,25 @@
openapi: 3.0.0
info:
version: "1.0"
title: PKCE Flow
paths:
/:
get:
summary: dummy operation
responses:
"200":
description: OK
components:
securitySchemes:
testAuthCodeFlow:
type: oauth2
flows:
authorizationCode:
authorizationUrl: /oauth/authorize
tokenUrl: /oauth/token
scopes:
read: read whatever you want
write: write whatever you want

View File

@ -0,0 +1,58 @@
openapi: "3.0.0"
paths:
/:
get:
operationId: "myOperation"
tags: ["myTag"]
summary: an operation
responses:
'200':
description: a pet to be returned
content:
application/json:
schema:
type: object
/withSpaces:
post:
operationId: "my Operation"
tags: ["my Tag"]
summary: an operation
responses:
'200':
description: a pet to be returned
content:
application/json:
schema:
type: object
/utf16fragments:
head:
operationId: "пошел"
tags: ["шеллы"]
summary: an operation
responses:
"200":
description: ok
/withUnderscores:
patch:
operationId: "underscore_Operation"
tags: ["underscore_Tag"]
summary: an operation
responses:
'200':
description: a pet to be returned
content:
application/json:
schema:
type: object
/noOperationId:
put:
tags: ["tagTwo"]
summary: some operations are anonymous...
responses:
'200':
description: a pet to be returned
content:
application/json:
schema:
type: object

View File

@ -0,0 +1,34 @@
swagger: "2.0"
paths:
/:
get:
operationId: "myOperation"
tags: ["myTag"]
summary: an operation
responses:
"200":
description: ok
/withSpaces:
post:
operationId: "my Operation"
tags: ["my Tag"]
summary: an operation
responses:
"200":
description: ok
/utf16fragments:
head:
operationId: "пошел"
tags: ["шеллы"]
/withUnderscores:
patch:
operationId: "underscore_Operation"
tags: ["underscore_Tag"]
summary: an operation
responses:
"200":
description: ok
/noOperationId:
put:
tags: ["tagTwo"]

View File

@ -0,0 +1,148 @@
openapi: 3.0.2
info:
title: External Docs
version: "1"
externalDocs:
description: Read external docs
url: http://swagger.io
tags:
- name: pet
description: Everything about your Pets
externalDocs:
description: Pet Documentation
url: http://swagger.io
- name: petWithoutDescription
externalDocs:
url: http://swagger.io
paths:
/pet:
put:
externalDocs:
description: More details about putting a pet
url: http://swagger.io
tags:
- pet
summary: Update an existing pet
description: Update an existing pet by Id
operationId: updatePet
requestBody:
description: Update an existent pet in the store
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
required: true
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
"400":
description: Invalid ID supplied
"404":
description: Pet not found
"405":
description: Validation exception
post:
externalDocs:
url: http://swagger.io
tags:
- pet
summary: Add a new pet to the store
description: Add a new pet to the store
operationId: addPet
requestBody:
description: Create a new pet in the store
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
required: true
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
"405":
description: Invalid input
components:
schemas:
Pet:
required:
- name
- photoUrls
type: object
description: This is a Pet
externalDocs:
description: More Docs About Pet
url: http://swagger.io
deprecated: true
properties:
id:
type: integer
format: int64
example: 10
name:
type: string
example: doggie
photoUrls:
type: array
items:
type: string
status:
type: string
description: pet status in the store
enum:
- available
- pending
- sold
Object:
type: object
externalDocs:
description: Object Docs
url: http://swagger.io
properties:
name:
type: string
ObjectWithoutDescription:
type: object
externalDocs:
url: http://swagger.io
properties:
name:
type: string
Primitive:
description: Just a string schema
type: string
externalDocs:
description: Primitive Docs
url: http://swagger.io
PrimitiveWithoutDescription:
description: Just a string schema
type: string
externalDocs:
url: http://swagger.io
Array:
description: Just an array schema
type: array
externalDocs:
description: Array Docs
url: http://swagger.io
items:
type: string
ArrayWithoutDescription:
description: Just an array schema
type: array
externalDocs:
url: http://swagger.io
items:
type: string

View File

@ -0,0 +1,116 @@
swagger: "2.0"
info:
title: External Docs
version: "1"
externalDocs:
description: Read external docs
url: http://swagger.io
tags:
- name: pet
description: Everything about your Pets
externalDocs:
description: Pet Documentation
url: http://swagger.io
- name: petWithoutDescription
externalDocs:
url: http://swagger.io
paths:
/pet:
put:
externalDocs:
description: More details about putting a pet
url: http://swagger.io
tags:
- pet
summary: Update an existing pet
description: Update an existing pet by Id
operationId: updatePet
responses:
200:
description: OK
post:
externalDocs:
url: http://swagger.io
tags:
- pet
summary: Add a new pet to the store
description: Add a new pet to the store
operationId: addPet
responses:
201:
description: Created
definitions:
Pet:
required:
- name
- photoUrls
type: object
description: This is a Pet
externalDocs:
description: More Docs About Pet
url: http://swagger.io
properties:
id:
type: integer
format: int64
example: 10
name:
type: string
example: doggie
photoUrls:
type: array
items:
type: string
status:
type: string
description: pet status in the store
enum:
- available
- pending
- sold
Object:
type: object
externalDocs:
description: Object Docs
url: http://swagger.io
properties:
name:
type: string
ObjectWithoutDescription:
type: object
externalDocs:
url: http://swagger.io
properties:
name:
type: string
Primitive:
description: Just a string schema
type: string
externalDocs:
description: Primitive Docs
url: http://swagger.io
PrimitiveWithoutDescription:
description: Just a string schema
type: string
externalDocs:
url: http://swagger.io
Array:
description: Just an array schema
type: array
externalDocs:
description: Array Docs
url: http://swagger.io
items:
type: string
ArrayWithoutDescription:
description: Just an array schema
type: array
externalDocs:
url: http://swagger.io
items:
type: string

View File

@ -0,0 +1,93 @@
openapi: "3.0.0"
components:
schemas:
Order:
type: object
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
enum:
- placed
- approved
- delivered
complete:
type: boolean
default: false
xml:
name: Order
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
xml:
name: User
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
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
enum:
- available
- pending
- sold
xml:
name: Pet

View File

@ -0,0 +1,92 @@
swagger: "2.0"
definitions:
Order:
type: object
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
enum:
- placed
- approved
- delivered
complete:
type: boolean
default: false
xml:
name: Order
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
xml:
name: User
Pet:
type: object
required:
- name
- photoUrls
properties:
id:
type: integer
format: int64
category:
$ref: '#/definitions/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: '#/definitions/Tag'
status:
type: string
description: pet status in the store
enum:
- available
- pending
- sold
xml:
name: Pet

View File

@ -0,0 +1,400 @@
openapi: 3.0.0
info:
title: "Multiple Examples: Core Document"
description: |
This document has examples for straightforward usage of `examples` in...
* Parameter Object positions
* Response Object positions
* Request Body Object positions
It includes:
* cases for each JSON Schema type as an example value (except null) in each position
* variously-sized `examples` objects
* multi-paragraph descriptions within each example
It **does not** include the following out-of-scope items:
* usage of `examples` within `Parameter.content` or `Response.content`
* `externalValue` (might change)
It also lacks edge cases, which will be covered in the "Corner" Document:
* `examples` n=1, which presents an interesting UI problem w/ the dropdown
* `example` and `examples` both present
* example item value that doesn't match the input type
* e.g., `Parameter.type === "number"`, but `Parameter.examples.[key].value` is an object
* `null` as an example value
version: "1.0.2"
paths:
/String:
post:
summary: "Bonus: contains two requestBody media types"
parameters:
- in: query
name: message
required: true
description: This parameter just so happens to have a one-line description.
schema:
type: string
examples:
StringExampleA:
$ref: '#/components/examples/StringExampleA'
StringExampleB:
$ref: '#/components/examples/StringExampleB'
requestBody:
description: the wonderful payload of my request
content:
text/plain:
schema:
type: string
examples:
StringExampleA:
$ref: '#/components/examples/StringExampleA'
StringExampleB:
$ref: '#/components/examples/StringExampleB'
text/plain+other:
schema:
type: string
examples:
StringExampleA:
$ref: '#/components/examples/StringExampleA'
StringExampleB:
$ref: '#/components/examples/StringExampleB'
responses:
200:
description: has two media types; the second has a third example!
content:
text/plain:
schema:
type: string
examples:
StringExampleA:
$ref: '#/components/examples/StringExampleA'
StringExampleB:
$ref: '#/components/examples/StringExampleB'
text/plain+other:
schema:
type: string
examples:
StringExampleA:
$ref: '#/components/examples/StringExampleA'
StringExampleB:
$ref: '#/components/examples/StringExampleB'
StringExampleC:
$ref: '#/components/examples/StringExampleC'
/Number:
post:
parameters:
- in: query
name: message
required: true
schema:
type: number
examples:
NumberExampleA:
$ref: '#/components/examples/NumberExampleA'
NumberExampleB:
$ref: '#/components/examples/NumberExampleB'
NumberExampleC:
$ref: '#/components/examples/NumberExampleC'
requestBody:
description: the wonderful payload of my request
content:
text/plain:
schema:
type: number
examples:
NumberExampleA:
$ref: '#/components/examples/NumberExampleA'
NumberExampleB:
$ref: '#/components/examples/NumberExampleB'
NumberExampleC:
$ref: '#/components/examples/NumberExampleC'
text/plain+other:
schema:
type: number
examples:
NumberExampleA:
$ref: '#/components/examples/NumberExampleA'
NumberExampleB:
$ref: '#/components/examples/NumberExampleB'
NumberExampleC:
$ref: '#/components/examples/NumberExampleC'
responses:
200:
description: OK!
content:
text/plain:
schema:
type: number
examples:
NumberExampleA:
$ref: '#/components/examples/NumberExampleA'
NumberExampleB:
$ref: '#/components/examples/NumberExampleB'
text/plain+other:
schema:
type: number
examples:
NumberExampleA:
$ref: '#/components/examples/NumberExampleA'
NumberExampleB:
$ref: '#/components/examples/NumberExampleB'
NumberExampleC:
$ref: '#/components/examples/NumberExampleC'
/Boolean:
post:
parameters:
- in: query
name: message
required: true
schema:
type: boolean
examples:
BooleanExampleA:
$ref: '#/components/examples/BooleanExampleA'
BooleanExampleB:
$ref: '#/components/examples/BooleanExampleB'
requestBody:
description: the wonderful payload of my request
content:
text/plain:
schema:
type: boolean
examples:
BooleanExampleA:
$ref: '#/components/examples/BooleanExampleA'
BooleanExampleB:
$ref: '#/components/examples/BooleanExampleB'
text/plain+other:
schema:
type: boolean
examples:
BooleanExampleA:
$ref: '#/components/examples/BooleanExampleA'
BooleanExampleB:
$ref: '#/components/examples/BooleanExampleB'
responses:
200:
description: OK!
content:
text/plain:
schema:
type: boolean
examples:
BooleanExampleA:
$ref: '#/components/examples/BooleanExampleA'
BooleanExampleB:
$ref: '#/components/examples/BooleanExampleB'
text/plain+other:
schema:
type: boolean
examples:
BooleanExampleA:
$ref: '#/components/examples/BooleanExampleA'
BooleanExampleB:
$ref: '#/components/examples/BooleanExampleB'
/Array:
post:
parameters:
- in: query
name: message
required: true
schema:
type: array
items: {} # intentionally empty; don't want to assert on the items
examples:
ArrayExampleA:
$ref: '#/components/examples/ArrayExampleA'
ArrayExampleB:
$ref: '#/components/examples/ArrayExampleB'
ArrayExampleC:
$ref: '#/components/examples/ArrayExampleC'
requestBody:
description: the wonderful payload of my request
content:
application/json:
schema:
type: array
items: {} # intentionally empty; don't want to assert on the items
examples:
ArrayExampleA:
$ref: '#/components/examples/ArrayExampleA'
ArrayExampleB:
$ref: '#/components/examples/ArrayExampleB'
ArrayExampleC:
$ref: '#/components/examples/ArrayExampleC'
responses:
200:
description: OK!
content:
application/json:
schema:
type: array
items: {} # intentionally empty; don't want to assert on the items
examples:
ArrayExampleA:
$ref: '#/components/examples/ArrayExampleA'
ArrayExampleB:
$ref: '#/components/examples/ArrayExampleB'
ArrayExampleC:
$ref: '#/components/examples/ArrayExampleC'
/Object:
post:
parameters:
- in: query
name: data
required: true
schema:
type: object
examples:
ObjectExampleA:
$ref: '#/components/examples/ObjectExampleA'
ObjectExampleB:
$ref: '#/components/examples/ObjectExampleB'
requestBody:
description: the wonderful payload of my request
content:
application/json:
schema:
type: object
examples:
ObjectExampleA:
$ref: '#/components/examples/ObjectExampleA'
ObjectExampleB:
$ref: '#/components/examples/ObjectExampleB'
text/plain+other:
schema:
type: object
examples:
ObjectExampleA:
$ref: '#/components/examples/ObjectExampleA'
ObjectExampleB:
$ref: '#/components/examples/ObjectExampleB'
responses:
200:
description: OK!
content:
application/json:
schema:
type: object
examples:
ObjectExampleA:
$ref: '#/components/examples/ObjectExampleA'
ObjectExampleB:
$ref: '#/components/examples/ObjectExampleB'
text/plain+other:
schema:
type: object
examples:
ObjectExampleA:
$ref: '#/components/examples/ObjectExampleA'
ObjectExampleB:
$ref: '#/components/examples/ObjectExampleB'
components:
examples:
StringExampleA:
value: "hello world"
summary: Don't just string me along...
description: |
A string in C is actually a character array. As an individual character variable can store only one character, we need an array of characters to store strings. Thus, in C string is stored in an array of characters. Each character in a string occupies one location in an array. The null character \0 is put after the last character. This is done so that program can tell when the end of the string has been reached.
For example, the string “Hello” is stored as follows...
![](http://www.tutorialspoint.com/computer_programming/images/string_representation.jpg)
Since the string contains 5 characters. it requires a character array of size 6 to store it. the last character in a string is always a NULL('\0') character. Always keep in mind that the '\0' is not included in the length if the string, so here the length of the string is 5 only. Notice above that the indexes of the string starts from 0 not one so don't confuse yourself with index and length of string.
Thus, in C, a string is a one-dimensional array of characters terminated a null character. The terminating null character is important. In fact, a string not terminated by \0 is not really a string, but merely a collection of characters.
StringExampleB:
value: "The quick brown fox jumps over the lazy dog"
summary: "I'm a pangram!"
description: |
A pangram (Greek: παν γράμμα, pan gramma, "every letter") or holoalphabetic sentence is a sentence using every letter of a given alphabet at least once. Pangrams have been used to display typefaces, test equipment, and develop skills in handwriting, calligraphy, and keyboarding.
The best-known English pangram is "The quick brown fox jumps over the lazy dog". It has been used since at least the late 19th century, was utilized by Western Union to test Telex / TWX data communication equipment for accuracy and reliability, and is now used by a number of computer programs (most notably the font viewer built into Microsoft Windows) to display computer fonts.
Pangrams exist in practically every alphabet-based language. An example from German is _Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich_, which contains all letters, including every umlaut (ä, ö, ü) plus the ß. It has been used since before 1800.
In a sense, the pangram is the opposite of the lipogram, in which the aim is to omit one or more letters.
A perfect pangram contains every letter of the alphabet only once and
can be considered an anagram of the alphabet. The only perfect pangrams
that are known either use abbreviations, such as "Mr Jock, TV quiz PhD,
bags few lynx", or use words so obscure that the phrase is hard to
understand, such as "Cwm fjord bank glyphs vext quiz", where cwm is a
loan word from the Welsh language meaning a steep-sided valley, and vext
is an uncommon way to spell vexed.
StringExampleC:
value: "JavaScript rules"
summary: "A third example, for use in special places..."
NumberExampleA:
value: 7710263025
summary: "World population"
description: |
In demographics, the world population is the total number of humans currently living, and was estimated to have reached 7.7 billion people as of April 2019. It took over 200,000 years of human history for the world's population to reach 1 billion; and only 200 years more to reach 7 billion.
World population has experienced continuous growth since the end of the Great Famine of 13151317 and the Black Death in 1350, when it was near 370 million. The highest population growth rates global population increases above 1.8% per year occurred between 1955 and 1975, peaking to 2.1% between 1965 and 1970. The growth rate has declined to 1.2% between 2010 and 2015 and is projected to decline further in the course of the 21st century. However, the global population is still growing and is projected to reach about 10 billion in 2050 and more than 11 billion in 2100.
Total annual births were highest in the late 1980s at about 139 million, and as of 2011 were expected to remain essentially constant at a level of 135 million, while deaths numbered 56 million per year and were expected to increase to 80 million per year by 2040. The median age of the world's population was estimated to be 30.4 years in 2018.
NumberExampleB:
value: 9007199254740991
summary: "Number.MAX_SAFE_INTEGER"
description: |
The `MAX_SAFE_INTEGER` constant has a value of `9007199254740991` (9,007,199,254,740,991 or ~9 quadrillion). The reasoning behind that number is that JavaScript uses double-precision floating-point format numbers as specified in IEEE 754 and can only safely represent numbers between `-(2^53 - 1)` and `2^53 - 1`.
Safe in this context refers to the ability to represent integers exactly and to correctly compare them. For example, `Number.MAX_SAFE_INTEGER + 1 === Number.MAX_SAFE_INTEGER + 2` will evaluate to `true`, which is mathematically incorrect. See `Number.isSafeInteger()` for more information.
Because `MAX_SAFE_INTEGER` is a static property of `Number`, you always use it as `Number.MAX_SAFE_INTEGER`, rather than as a property of a `Number` object you created.
NumberExampleC:
# `description` and `summary` intentionally omitted
value: 0
BooleanExampleA:
value: true
summary: The truth will set you free
description: |
In some programming languages, any expression can be evaluated in a context that expects a Boolean data type. Typically (though this varies by programming language) expressions like the number zero, the empty string, empty lists, and null evaluate to false, and strings with content (like "abc"), other numbers, and objects evaluate to true. Sometimes these classes of expressions are called "truthy" and "falsey".
BooleanExampleB:
# `description` intentionally omitted
value: false
summary: Friends don't lie to friends
ArrayExampleA:
value: [a, b, c]
summary: A lowly array of strings
description: |
In computer science, a list or sequence is an abstract data type that represents a countable number of ordered values, where the same value may occur more than once. An instance of a list is a computer representation of the mathematical concept of a finite sequence; the (potentially) infinite analog of a list is a stream.[1]:§3.5 Lists are a basic example of containers, as they contain other values. If the same value occurs multiple times, each occurrence is considered a distinct item.
ArrayExampleB:
value: [1, 2, 3, 4]
summary: A lowly array of numbers
description: |
Many programming languages provide support for list data types, and have special syntax and semantics for lists and list operations. A list can often be constructed by writing the items in sequence, separated by commas, semicolons, and/or spaces, within a pair of delimiters such as parentheses '()', brackets '[]', braces '{}', or angle brackets '<>'. Some languages may allow list types to be indexed or sliced like array types, in which case the data type is more accurately described as an array. In object-oriented programming languages, lists are usually provided as instances of subclasses of a generic "list" class, and traversed via separate iterators. List data types are often implemented using array data structures or linked lists of some sort, but other data structures may be more appropriate for some applications. In some contexts, such as in Lisp programming, the term list may refer specifically to a linked list rather than an array.
In type theory and functional programming, abstract lists are usually defined inductively by two operations: nil that yields the empty list, and cons, which adds an item at the beginning of a list.
ArrayExampleC:
# `summary` intentionally omitted
value: []
description: An empty array value should clear the current value
ObjectExampleA:
value:
firstName: Kyle
lastName: Shockey
email: kyle.shockey@smartbear.com
summary: A user's contact info
description: Who is this guy, anyways?
ObjectExampleB:
value:
name: Abbey
type: kitten
color: calico
gender: female
age: 11 weeks
summary: A wonderful kitten's info
description: |
Todays domestic cats are physically very similar to their wild
ancestors. “Domestic cats and wildcats share a majority of their
characteristics,” Lyons says, but there are a few key differences:
wildcats were and are typically larger than their domestic kin, with
brown, tabby-like fur. “Wildcats have to have camouflage thats going to
keep them very inconspicuous in the wild,” Lyons says. “So you cant
have cats with orange and white running around—theyre going to be
snatched up by their predators.” As cats were domesticated, they began
to be selected and bred for more interesting colorations, thus giving us
todays range of beautiful cat breeds.

View File

@ -0,0 +1,50 @@
openapi: 3.0.0
info:
title: Switching between multiple content-type test
version: 1.0.0
servers:
- url: https://httpbin.org
paths:
/post:
post:
requestBody:
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/Bar'
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/Foo'
application/json:
schema:
$ref: '#/components/schemas/FooBar'
responses:
'200':
description: ok
components:
schemas:
Foo:
type: object
properties:
foo:
type: string
example: ''
Bar:
type: object
required: [bar]
properties:
bar:
type: integer
example: 1
FooBar:
type: object
required:
- bar
properties:
foo:
type: string
example: ''
bar:
type: integer
example: 1

View File

@ -0,0 +1,16 @@
openapi: 3.0.2
servers:
- url: /test-url-switch-1
- url: /test-url-switch-2
info:
title: multi-server test, switch
version: 0.0.1
description: |-
a simple test to select different servers
paths:
/:
get:
summary: an operation
responses:
"200":
description: OK

View File

@ -0,0 +1,16 @@
openapi: 3.0.2
servers:
- url: /test-url-1
- url: /test-url-2
info:
title: multi-server test
version: 0.0.1
description: |-
a simple test to select different servers
paths:
/:
get:
summary: an operation
responses:
"200":
description: OK

View File

@ -0,0 +1,309 @@
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "XML definition with oneOf & anyOf",
"description": "Definition to cover multiple XML examples"
},
"paths": {
"/foo": {
"post": {
"requestBody": {
"content": {
"text/xml": {
"schema": {
"description": "XML schema with oneOf for /foo request and mediaType text/xml",
"oneOf": [
{
"$ref": "#/components/schemas/OneOfOne"
},
{
"$ref": "#/components/schemas/OneOfTwo"
},
{
"$ref": "#/components/schemas/OneOfThree"
},
{
"$ref": "#/components/schemas/OneOfFour"
}
]
}
},
"application/xml": {
"schema": {
"description": "fallback XML schema with mediaType application/xml",
"$ref": "#/components/schemas/OneOfTwo"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"text/xml": {
"schema": {
"description": "XML schema with mediaType text/xml",
"$ref": "#/components/schemas/foobarResponse"
}
}
}
}
}
}
},
"/bar": {
"post": {
"requestBody": {
"content": {
"text/xml": {
"schema": {
"description": "XML schema with anyOf for /bar request and mediaType text/xml",
"anyOf": [
{
"$ref": "#/components/schemas/OneOfOne"
},
{
"$ref": "#/components/schemas/OneOfTwo"
},
{
"$ref": "#/components/schemas/OneOfThree"
},
{
"$ref": "#/components/schemas/OneOfFour"
}
]
}
},
"application/xml": {
"schema": {
"description": "fallback XML schema with mediaType application/xml",
"$ref": "#/components/schemas/OneOfTwo"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"text/xml": {
"schema": {
"description": "XML schema with mediaType text/xml",
"$ref": "#/components/schemas/foobarResponse"
}
}
}
}
}
}
},
"/foobar": {
"post": {
"requestBody": {
"content": {
"application/xml": {
"schema": {
"description": "XML schema with oneOf for /foobar request and mediaType application/xml",
"oneOf": [
{
"$ref": "#/components/schemas/OneOfOne"
},
{
"$ref": "#/components/schemas/OneOfTwo"
},
{
"$ref": "#/components/schemas/OneOfThree"
},
{
"$ref": "#/components/schemas/OneOfFour"
}
]
}
},
"text/xml": {
"schema": {
"description": "fallback XML schema with mediaType text/xml",
"$ref": "#/components/schemas/OneOfThree"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"text/xml": {
"schema": {
"description": "XML schema with mediaType application/xml",
"$ref": "#/components/schemas/foobarResponse"
}
}
}
}
}
}
},
"/barfoo": {
"post": {
"requestBody": {
"content": {
"application/xml": {
"schema": {
"description": "XML schema with anyOf for /barfoo request and mediaType application/xml",
"anyOf": [
{
"$ref": "#/components/schemas/OneOfOne"
},
{
"$ref": "#/components/schemas/OneOfTwo"
},
{
"$ref": "#/components/schemas/OneOfThree"
},
{
"$ref": "#/components/schemas/OneOfFour"
}
]
}
},
"text/xml": {
"schema": {
"description": "fallback XML schema with mediaType text/xml",
"$ref": "#/components/schemas/OneOfThree"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/xml": {
"schema": {
"description": "XML schema with mediaType application/xml",
"$ref": "#/components/schemas/foobarResponse"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"OneOfOne": {
"type": "object",
"properties": {
"Body": {
"type": "object",
"properties": {
"fooOne": {}
},
"additionalProperties": false,
"xml": {
"prefix": "soapenv"
}
}
},
"additionalProperties": false,
"xml": {
"prefix": "soapenv",
"namespace": "http://schemas.xmlsoap.org/soap/envelope/",
"name": "Envelope"
}
},
"OneOfTwo": {
"type": "object",
"properties": {
"Body": {
"type": "object",
"properties": {
"fooTwo": {}
},
"additionalProperties": false,
"xml": {
"prefix": "soapenv"
}
}
},
"additionalProperties": false,
"xml": {
"prefix": "soapenv",
"namespace": "http://schemas.xmlsoap.org/soap/envelope/",
"name": "Envelope"
}
},
"OneOfThree": {
"type": "object",
"properties": {
"Body": {
"type": "object",
"properties": {
"fooThree": {}
},
"additionalProperties": false,
"xml": {
"prefix": "soapenv"
}
}
},
"additionalProperties": false,
"xml": {
"prefix": "soapenv",
"namespace": "http://schemas.xmlsoap.org/soap/envelope/",
"name": "Envelope"
}
},
"OneOfFour": {
"type": "object",
"properties": {
"Body": {
"type": "object",
"properties": {
"fooFour": {}
},
"additionalProperties": false,
"xml": {
"prefix": "soapenv"
}
}
},
"additionalProperties": false,
"xml": {
"prefix": "soapenv",
"namespace": "http://schemas.xmlsoap.org/soap/envelope/",
"name": "Envelope"
}
},
"foobarResponse": {
"type": "object",
"properties": {
"Body": {
"type": "object",
"properties": {
"foobarResObj": {
"type": "object"
}
},
"additionalProperties": false,
"xml": {
"prefix": "soapenv"
}
}
},
"additionalProperties": false,
"xml": {
"prefix": "soapenv",
"namespace": "http://schemas.xmlsoap.org/soap/envelope/",
"name": "Envelope"
}
}
}
}
}

View File

@ -0,0 +1,24 @@
openapi: 3.0.0
info:
title: test
version: "1.0.0"
paths:
/example1:
get:
description: test fetching
parameters:
- in: query
name: basicName
content:
application/json:
schema:
type: object
properties:
color:
oneOf:
- type: array # invalid definition b/c type: array is missing 'items'
- type: string
- type: integer
responses:
'200':
description: successful fetch

View File

@ -0,0 +1,63 @@
openapi: 3.0.1
info:
title: Example Swagger
version: '1.0'
servers:
- url: /api/v1
paths:
/test/{id}/related/{relatedId}:
post:
parameters:
- in: path
name: relatedId
required: true
schema:
type: integer
default: 1
description: The related ID
- in: header
name: TRACE-ID
required: true
schema:
type: integer
default: 1
description: The trace ID
- in: cookie
name: debug
required: true
schema:
type: number
enum:
- 0
- 1
description: debug flag
- in: header
name: USER-ID
required: true
schema:
type: integer
default: 1
description: The user ID
- in: query
name: asc
required: true
schema:
type: boolean
default: true
description: sort asc
- in: path
name: id
required: true
schema:
type: integer
default: 1
description: The ID
requestBody:
description: Some
content:
application/json:
schema:
type: string
responses:
200:
description: Some

View File

@ -0,0 +1,418 @@
openapi: 3.0.2
servers:
- url: /v3
info:
description: |-
This is a sample Pet Store Server based on the OpenAPI 3.0 specification. You can find out more about
Swagger at [http://swagger.io](http://swagger.io). In the third iteration of the pet store, we've switched to the design first approach!
You can now help us improve the API whether it's by making changes to the definition itself or to the code.
That way, with time, we can improve the API in general, and expose some of the new features in OAS3.
Some useful links:
- [The Pet Store repository](https://github.com/swagger-api/swagger-petstore)
- [The source API definition for the Pet Store](https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml)
version: 1.0.5-SNAPSHOT
title: Swagger Petstore - OpenAPI 3.0
termsOfService: 'http://swagger.io/terms/'
contact:
email: apiteam@swagger.io
license:
name: Apache 2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
tags:
- name: pet
description: Everything about your Pets
externalDocs:
description: Find out more
url: 'http://swagger.io'
paths:
/pet:
post:
tags:
- pet
summary: Add a new pet to the store
description: Add a new pet to the store
operationId: addPet
responses:
'200':
description: Successful operation
content:
application/xml:
schema:
$ref: '#/components/schemas/Pet'
application/json:
schema:
$ref: '#/components/schemas/Pet'
'405':
description: Invalid input
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
requestBody:
description: Create a new pet in the store
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
application/xml:
schema:
$ref: '#/components/schemas/Pet'
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/Pet'
put:
tags:
- pet
summary: Update an existing pet
description: Update an existing pet by Id
operationId: updatePet
responses:
'200':
description: Successful operation
content:
application/xml:
schema:
$ref: '#/components/schemas/Pet'
application/json:
schema:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid ID supplied
'404':
description: Pet not found
'405':
description: Validation exception
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
requestBody:
description: Update an existent pet in the store
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
application/xml:
schema:
$ref: '#/components/schemas/Pet'
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/Pet'
/pet/findByStatus:
get:
tags:
- pet
summary: Finds Pets by status
description: Multiple status values can be provided with comma separated strings
operationId: findPetsByStatus
parameters:
- name: status
in: query
description: Status values that need to be considered for filter
required: false
explode: true
schema:
type: string
enum:
- available
- pending
- sold
default: available
responses:
'200':
description: successful operation
content:
application/xml:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid status value
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
/pet/findByTags:
get:
tags:
- pet
summary: Finds Pets by tags
description: >-
Multiple tags can be provided with comma separated 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/xml:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
application/json:
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 single pet
operationId: getPetById
parameters:
- name: petId
in: path
description: ID of pet to return
required: true
schema:
type: integer
format: int64
responses:
'200':
description: successful operation
content:
application/xml:
schema:
$ref: '#/components/schemas/Pet'
application/json:
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: integer
format: int64
- name: name
in: query
description: Name of pet that needs to be updated
required: true
schema:
type: string
- name: status
in: query
description: Status of pet that needs to be updated
schema:
type: string
responses:
'405':
description: Invalid input
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
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'
'/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
- name: additionalMetadata
in: query
description: Additional Metadata
required: false
schema:
type: string
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
requestBody:
content:
application/octet-stream:
schema:
type: string
format: binary
externalDocs:
description: Find out more about Swagger
url: 'http://swagger.io'
components:
schemas:
Category:
x-swagger-router-model: io.swagger.petstore.model.Category
properties:
id:
type: integer
format: int64
example: 1
name:
type: string
example: Dogs
xml:
name: category
type: object
Tag:
x-swagger-router-model: io.swagger.petstore.model.Tag
properties:
id:
type: integer
format: int64
name:
type: string
xml:
name: tag
type: object
Pet:
x-swagger-router-model: io.swagger.petstore.model.Pet
required:
- name
- photoUrls
properties:
id:
type: integer
format: int64
example: 10
name:
type: string
example: doggie
category:
$ref: '#/components/schemas/Category'
photoUrls:
type: array
xml:
wrapped: true
items:
type: string
xml:
name: photoUrl
tags:
type: array
xml:
wrapped: true
items:
$ref: '#/components/schemas/Tag'
xml:
name: tag
status:
type: string
description: pet status in the store
enum:
- available
- pending
- sold
xml:
name: pet
type: object
ApiResponse:
properties:
code:
type: integer
format: int32
type:
type: string
message:
type: string
xml:
name: '##default'
type: object
requestBodies:
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:
petstore_auth:
type: oauth2
flows:
implicit:
authorizationUrl: 'https://petstore.swagger.io/oauth/authorize'
scopes:
'write:pets': modify pets in your account
'read:pets': read your pets
api_key:
type: apiKey
name: api_key
in: header

View File

@ -0,0 +1,105 @@
openapi: 3.0.0
info:
title: "Request body file upload"
description: |-
This document has examples for examining the `schema` or content type for request bodies requiring a file upload
* `application/octect-stream` content type (no matter what schema format)
* `audio/*` content type (no matter what schema format)
* `image/*` content type (no matter what schema format)
* `video/*` content type (no matter what schema format)
* schema format is `base64` (no matter what content type)
* schema format is `binary` (no matter what content type)
version: "1.0.0"
paths:
/upload-application-octet-stream:
post:
operationId: uploadApplicationOctetStream
requestBody:
content:
application/octet-stream:
schema:
type: string
responses:
'200':
description: successful operation
content:
text/plain:
schema:
type: string
/upload-image-png:
post:
operationId: uploadImagePng
requestBody:
content:
image/png:
schema:
type: string
responses:
'200':
description: successful operation
content:
text/plain:
schema:
type: string
/upload-audio-wav:
post:
operationId: uploadAudioWav
requestBody:
content:
audio/wav:
schema:
type: string
responses:
'200':
description: successful operation
content:
text/plain:
schema:
type: string
/upload-video-mpeg:
post:
operationId: uploadVideoMpeg
requestBody:
content:
video/mpeg:
schema:
type: string
responses:
'200':
description: successful operation
content:
text/plain:
schema:
type: string
/upload-schema-format-binary:
post:
operationId: uploadSchemaFormatBinary
requestBody:
content:
application/x-custom:
schema:
type: string
format: binary
responses:
'200':
description: successful operation
content:
text/plain:
schema:
type: string
/upload-schema-format-base64:
post:
operationId: uploadSchemaFormatBase64
requestBody:
content:
application/x-custom:
schema:
type: string
format: base64
responses:
'200':
description: successful operation
content:
text/plain:
schema:
type: string

View File

@ -0,0 +1,28 @@
openapi: 3.0.3
info:
title: multipart/form-data schema object
version: 0.0.1
paths:
/test:
post:
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
parameters:
"$ref": "#/components/schemas/TestBody"
responses:
200:
description: ok
components:
schemas:
TestBody:
type: object
properties:
stuff:
type: string

View File

@ -0,0 +1,29 @@
openapi: 3.0.3
info:
title: asd
version: 0.0.1
paths:
/test:
post:
requestBody:
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/TestBody'
responses:
200:
description: ok
components:
schemas:
TestBody:
required:
- test_enum
type: object
properties:
test_enum:
allOf:
- $ref: "#/components/schemas/TestEnum"
TestEnum:
enum:
- A
- B

View File

@ -0,0 +1,19 @@
openapi: "3.0.0"
paths:
/:
get:
operationId: "myOperation"
tags: ["myTag"]
summary: an operation
responses:
'200':
description: a pet to be returned
content:
application/json:
schema:
type: object
'404':
x-error: true
x-error-codes: [NOT_FOUND]
description: Not found

View File

@ -0,0 +1,15 @@
swagger: "2.0"
paths:
/:
get:
operationId: "myOperation"
tags: ["myTag"]
summary: an operation
responses:
"200":
description: ok
'404':
x-error: true
x-error-codes: [NOT_FOUND]
description: Not found

View File

@ -0,0 +1,339 @@
openapi: 3.0.0
info:
title: "Schema in Parameters"
description: |-
This document has examples for examining the `schema` within a set of parameters
* String Enum (/pet/findByStatus)
* Array of Strings (/pet/findByTags)
* Array of Boolean (/petOwner/listOfServiceTrainer)
* Array of Objects (/petOwners/createWithList)
* Array of Enum (/petOwner/findByPreference)
This document also covers a debounce test for `schema` type `string
* String (/petOwner)
This documents does not cover:
* Array of Arrays
Additional notes
* Provides additional coverage and examples not covered in the Multiple Examples Core Document (Test)
* Code component reference `JsonSchemaForm`
* `pet` and `tag` schemas are reduced from Swagger Petstore
version: "1.0.0"
paths:
/pet/findByStatus:
get:
summary: Finds Pets by status
description: Multiple status values can be provided with comma separated strings
operationId: findPetsByStatus
parameters:
- name: status
in: query
description: Status values that need to be considered for filter
required: false
explode: true
schema:
type: string
enum:
- available
- pending
- sold
default: available
responses:
'200':
description: successful operation
content:
application/xml:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid status value
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
/pet/findByTags:
get:
tags:
- pet
summary: Finds Pets by tags
description: >-
Multiple tags can be provided with comma separated 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/xml:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
'400':
description: Invalid tag value
security:
- petstore_auth:
- 'write:pets'
- 'read:pets'
'/petOwner/{petOwnerId}':
get:
tags:
- petOwner
summary: Find pet owner by ID
description: Returns a single pet owner if ID found, list if no ID provided
operationId: getPetOwnerById
parameters:
- name: petOwnerId
in: path
description: ID of pet owner to return
required: false
schema:
type: integer
format: int64
responses:
'200':
description: successful operation
content:
application/xml:
schema:
$ref: '#/components/schemas/PetOwner'
application/json:
schema:
$ref: '#/components/schemas/PetOwner'
'400':
description: Invalid ID supplied
'404':
description: Pet not found
/petOwner/listOfServiceTrainer:
get:
tags:
- petOwner
summary: List of Service Trainers
description: >-
Expect boolean, but allow both true and false
operationId: listOfServiceTrainer
parameters:
- name: tags
in: query
description: Boolean to filter by
required: false
explode: true
schema:
type: array
items:
type: boolean
responses:
'200':
description: successful operation
content:
application/xml:
schema:
type: array
items:
$ref: '#/components/schemas/PetOwner'
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/PetOwner'
'400':
description: Invalid tag value
/petOwner/findByPreference:
get:
tags:
- petOwner
summary: Find by Pet Owner Preferences
description: >-
Expect enum
operationId: findByPreference
parameters:
- name: tags
in: query
description: Enum to filter by
required: false
explode: true
schema:
type: array
items:
type: string
enum:
- dog
- cat
- bird
- fish
- other
default: dog
responses:
'200':
description: successful operation
content:
application/xml:
schema:
type: array
items:
$ref: '#/components/schemas/PetOwner'
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/PetOwner'
'400':
description: Invalid tag value
components:
/petOwner/createWithList:
post:
tags:
- petOwner
summary: Creates list of pet owners with given input array
operationId: petOwnerCreateWithList
requestBody:
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/PetOwner'
responses:
'200':
description: successful operation
content:
application/xml:
schema:
type: array
items:
$ref: '#/components/schemas/PetOwner'
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/PetOwner'
'400':
description: Invalid values
schemas:
Pet:
x-swagger-router-model: io.swagger.petstore.model.Pet
required:
- name
- photoUrls
properties:
id:
type: integer
format: int64
example: 10
name:
type: string
example: doggie
# remove category property
petOwners:
type: array
items:
$ref: '#/components/schemas/PetOwner'
photoUrls:
type: array
xml:
wrapped: true
items:
type: string
xml:
name: photoUrl
tags:
type: array
xml:
wrapped: true
items:
$ref: '#/components/schemas/Tag'
xml:
name: tag
status:
type: string
description: pet status in the store
enum:
- available
- pending
- sold
xml:
name: pet
type: object
# remove ApiResponse
PetOwner:
type: "object"
properties:
id:
type: "integer"
format: "int64"
example: 10
petId:
type: "integer"
format: "int64"
example: 201
petOwnerFirstName:
type: "string"
example: "John"
petOwnerLastName:
type: "string"
example: "Smith"
petOwnerContact:
type: "string"
example: "john.smith@fakeemail.co"
petOwnerStatus:
type: "integer"
format: "int32"
description: "Pet Owner Status"
example: 302
petOwnerPreferences:
type: "string"
description: "Pet Owner Preferred Pet Types"
enum:
- "dog"
- "cat"
- "bird"
- "fish"
- "other"
petOwnerServiceTrainer:
type: "boolean"
description: "Pet Onwer is Service Trainer"
default: false
Tag:
x-swagger-router-model: io.swagger.petstore.model.Tag
properties:
id:
type: integer
format: int64
name:
type: string
xml:
name: tag
type: object
requestBodies:
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

View File

@ -0,0 +1,87 @@
swagger: "2.0"
info:
description: "Test Required Enum and Boolean with Execute"
version: "1.0.0"
title: "Swagger Petstore"
termsOfService: "http://swagger.io/terms/"
contact:
email: "apiteam@swagger.io"
license:
name: "Apache 2.0"
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io"
basePath: "/v2"
tags:
- name: "pet"
description: "Everything about your Pets"
externalDocs:
description: "Find out more"
url: "http://swagger.io"
schemes:
- "https"
- "http"
paths:
/pet/findByStatus:
get:
tags:
- "pet"
summary: "Finds Pets by status"
description: "Multiple status values can be provided with comma separated strings"
operationId: "findPetsByStatus"
produces:
- "application/xml"
- "application/json"
parameters:
- name: "status"
in: "query"
description: "Status values that need to be considered for filter"
required: true
type: "array"
items:
type: "string"
enum:
- "available"
- "pending"
- "sold"
default: "available"
collectionFormat: "multi"
- name: "expectIsOptional"
in: "query"
description: "this field should be optional"
required: false
type: boolean
- name: "expectIsRequired"
in: "query"
description: "this field should be required"
required: true
type: boolean
responses:
"200":
description: "successful operation"
schema:
type: "array"
items:
$ref: "#/definitions/Pet"
"400":
description: "Invalid status value"
definitions:
Pet:
type: "object"
required:
- "name"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
example: "doggie"
status:
type: "string"
description: "pet status in the store"
enum:
- "available"
- "pending"
- "sold"
xml:
name: "Pet"

View File

@ -0,0 +1,119 @@
openapi: 3.0.0
info:
description: No type for schema
version: "1"
title: "No type"
paths:
/case-one-no-schema:
parameters:
- name: namespace
description: The custom resource's namespace
# schema:
in: path
required: true
get:
description: sf
responses:
default:
description: one
/case-one-no-type-or-format:
parameters:
- name: namespace
description: The custom resource's namespace
schema:
in: path
required: true
get:
description: sf
responses:
default:
description: one
/case-one-type-only-no-format:
parameters:
- name: namespace
description: The custom resource's namespace
schema:
type: integer
in: path
required: true
get:
description: sf
responses:
default:
description: one
/case-one-format-only-no-type:
parameters:
- name: namespace
description: The custom resource's namespace
schema:
format: int64
in: path
required: true
get:
description: sf
responses:
default:
description: one
/case-two-no-schema:
get:
description: sf
responses:
default:
description: one
parameters:
- name: namespace
in: path
description: The custom resource's namespace
required: true
# schema:
/case-two-no-type-or-format:
get:
description: sf
responses:
default:
description: one
parameters:
- name: namespace
in: path
description: The custom resource's namespace
required: true
schema:
/case-two-type-only-no-format:
get:
description: sf
responses:
default:
description: one
parameters:
- name: namespace
in: path
description: The custom resource's namespace
required: true
schema:
type: integer
/case-two-format-only-no-type:
get:
description: sf
responses:
default:
description: one
parameters:
- name: namespace
in: path
description: The custom resource's namespace
required: true
schema:
format: int64
/case-two-not-a-real-type:
get:
description: sf
responses:
default:
description: one
parameters:
- name: namespace
in: path
description: The custom resource's namespace
required: true
schema:
type: "NotARealType"

View File

@ -0,0 +1,26 @@
openapi: 3.0.0
info:
version: 1.0.0
title: Native date formats in YAML
paths:
/foo:
get:
description: Has date without quotes
responses:
'200':
description: Ok
content:
application/json:
schema:
type: object
properties:
without-quotes:
type: string
format: date
example: 1999-11-31
with-quotes:
type: string
format: date
example: "1999-12-31"

View File

@ -0,0 +1,97 @@
swagger: '2.0'
info:
description: sample OAS 2 definition to test syntax highlighting
version: 1.0.0
title: json syntax highlighting
host: "localhost:3200"
basePath: /v1
schemes:
- https
- http
paths:
/setServices:
post:
summary: "simple service"
produces:
- application/json
parameters:
- in: body
name: body
required: true
schema:
$ref: '#/definitions/setServicesBody'
responses:
200:
description: OK
schema:
$ref: '#/definitions/setServicesResponse'
404:
description: "Page not found"
definitions:
setServicesBody:
type: object
required:
- appid
- key
- userid
- station_objectid
- details
properties:
appid:
type: string
example: "Website"
description: "application ID"
userid:
type: integer
example: "79daf5b4-aa4b-1452-eae5-42c231477ba7"
description: "user id available to test"
station_objectid:
type: string
example: "22a124b4-594b-4452-bdf5-fc3ef1477ba7"
description: "station id available to test"
details:
type: array
items:
type: object
properties:
station_serviceid:
type: integer
example: "34"
description: "optional service id"
name:
type: string
example: "hooray"
amount:
type: string
example: "0.00"
quantity:
type: integer
example: "999999"
date:
type: string
format: date-time
example: "2020-11-12 18:52:29"
setServicesResponse:
type: object
properties:
status:
type: boolean
example: true
count:
type: boolean
example: 1
response:
type: object
properties:
status:
type: integer
example: 200
station_serviceid:
type: integer
example: "3"
userid:
type: integer
example: "5ff06f632bb165394501b05d3a833355"
statusId:
type: string
example: "f0009babde9dbe204540d79cf754408e"

View File

@ -0,0 +1,94 @@
openapi: 3.0.1
info:
title: json syntax highlighting
description: sample OAS 3 definition to test syntax highlighting
version: 1.0.0
servers:
- url: https://localhost:3200/v1
- url: http://localhost:3200/v1
paths:
/setServices:
post:
summary: simple service
requestBody:
content:
'*/*':
schema:
$ref: '#/components/schemas/setServicesBody'
required: true
responses:
200:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/setServicesResponse'
404:
description: Page not found
content: {}
x-codegen-request-body-name: body
components:
schemas:
setServicesBody:
required:
- appid
- details
- station_objectid
- userid
type: object
properties:
appid:
type: string
description: application ID
example: Website
userid:
type: integer
description: user id available to test
station_objectid:
type: string
description: station id available to test
example: 22a124b4-594b-4452-bdf5-fc3ef1477ba7
details:
type: array
items:
type: object
properties:
station_serviceid:
type: integer
description: optional service id
example: 34
name:
type: string
example: hooray
amount:
type: string
example: "0.00"
quantity:
type: integer
example: 999999
date:
type: string
format: date-time
setServicesResponse:
type: object
properties:
status:
type: boolean
example: true
count:
type: boolean
example: false
response:
type: object
properties:
status:
type: integer
example: 200
station_serviceid:
type: integer
example: 3
userid:
type: integer
statusId:
type: string
example: f0009babde9dbe204540d79cf754408e

View File

@ -0,0 +1,13 @@
openapi: 3.0.2
info:
title: try it out enabled test
version: 0.0.1
description: |-
a simple test to ensure tryItOutEnabled=true expands "Try it out"
paths:
/:
get:
summary: an operation
responses:
"200":
description: OK

View File

@ -0,0 +1,34 @@
swagger: '2.0'
info:
version: '1.0'
title: "schema required properties should not be treated like required: true"
paths:
'/v1/any-path':
put:
summary: lorem
operationId: setDeliveryLocation
produces:
- application/json
parameters:
- in: body
name: body
description: ipsum
required: false
schema:
$ref: '#/definitions/TopModel'
responses:
'200':
description: successful operation
definitions:
TopModel:
type: object
properties:
testProperty:
$ref: '#/definitions/NestedModel'
NestedModel:
type: object
required:
- validated
properties:
validated:
type: boolean

View File

@ -0,0 +1,12 @@
swagger: "2.0"
info:
title: One
paths:
/:
get:
summary: an operation
responses:
"200":
description: OK

View File

@ -0,0 +1,12 @@
openapi: "3.0.0"
info:
title: Two
paths:
/:
get:
summary: an operation
responses:
"200":
description: OK

View File

@ -0,0 +1,38 @@
openapi: 3.0.1
info:
title: Server Variables - One
description: sample OAS 3 definition to test server variables with urls
version: 1.0.0
servers:
- url: "https://localhost:3200{basePath}"
variables:
basePath:
default: "/oneFirstUrl"
- url: "http://localhost:3201{basePath}"
variables:
basePath:
default: "/oneSecondUrl"
paths:
/a:
post:
summary: simple service A
requestBody:
content:
'application/json':
schema:
properties:
foo:
type: string
bar:
type: string
required:
- foo
type: object
required: true
responses:
200:
description: OK
content:
application/json:
schema:
type: 'string'

View File

@ -0,0 +1,38 @@
openapi: 3.0.1
info:
title: Server Variables - Two
description: sample OAS 3 definition to test server variables with urls
version: 1.0.0
servers:
- url: "https://localhost:3200{basePath}"
variables:
basePath:
default: "/twoFirstUrl"
- url: "http://localhost:3201{basePath}"
variables:
basePath:
default: "/twoSecondUrl"
paths:
/b:
post:
summary: simple service B
requestBody:
content:
'application/json':
schema:
properties:
foo:
type: string
bar:
type: string
required:
- foo
type: object
required: true
responses:
200:
description: OK
content:
application/json:
schema:
type: 'string'

View File

@ -0,0 +1,166 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
description: A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification
termsOfService: http://swagger.io/terms/
contact:
name: Swagger API Team
email: apiteam@swagger.io
url: http://swagger.io
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
servers:
- url: http://petstore.swagger.io/api
security:
- Petstore: []
paths:
/pets:
get:
description: |
Returns all pets from the system that the user has access to
Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia.
Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien.
operationId: findPets
parameters:
- name: tags
in: query
description: tags to filter by
required: false
style: form
schema:
type: array
items:
type: string
- name: limit
in: query
description: maximum number of results to return
required: false
schema:
type: integer
format: int32
responses:
'200':
description: pet response
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Pet'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
description: Creates a new pet in the store. Duplicates are allowed
operationId: addPet
requestBody:
description: Pet to add to the store
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/NewPet'
responses:
'200':
description: pet response
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
/pets/{id}:
get:
description: Returns a user based on a single ID, if the user does not have access to the pet
operationId: find pet by id
parameters:
- name: id
in: path
description: ID of pet to fetch
required: true
schema:
type: integer
format: int64
responses:
'200':
description: pet response
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
delete:
description: deletes a single pet based on the ID supplied
operationId: deletePet
parameters:
- name: id
in: path
description: ID of pet to delete
required: true
schema:
type: integer
format: int64
responses:
'204':
description: pet deleted
default:
description: unexpected error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
schemas:
Pet:
allOf:
- $ref: '#/components/schemas/NewPet'
- required:
- id
properties:
id:
type: integer
format: int64
NewPet:
required:
- name
properties:
name:
type: string
tag:
type: string
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
securitySchemes:
Petstore:
type: oauth2
flows:
implicit:
authorizationUrl: https://example.com/api/oauth/dialog
scopes:
write:pets: modify pets in your account
read:pets: read your pets

View File

@ -0,0 +1,707 @@
# As found on https://petstore.swagger.io, August 2018
---
swagger: '2.0'
info:
description: 'This is a sample server Petstore server. You can find out more about
Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). 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:
email: apiteam@swagger.io
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
host: petstore.swagger.io
basePath: "/v2"
tags:
- name: pet
description: Everything about your Pets
externalDocs:
description: Find out more
url: http://swagger.io
- name: store
description: Access to Petstore orders
- name: user
description: Operations about user
externalDocs:
description: Find out more about our store
url: http://swagger.io
schemes:
- https
- http
paths:
"/pet":
post:
tags:
- pet
summary: Add a new pet to the store
description: ''
operationId: addPet
consumes:
- application/json
- application/xml
produces:
- application/xml
- application/json
parameters:
- in: body
name: body
description: Pet object that needs to be added to the store
required: true
schema:
"$ref": "#/definitions/Pet"
responses:
'405':
description: Invalid input
security:
- petstore_auth:
- write:pets
- read:pets
put:
tags:
- pet
summary: Update an existing pet
description: ''
operationId: updatePet
consumes:
- application/json
- application/xml
produces:
- application/xml
- application/json
parameters:
- in: body
name: body
description: Pet object that needs to be added to the store
required: true
schema:
"$ref": "#/definitions/Pet"
responses:
'400':
description: Invalid ID supplied
'404':
description: Pet not found
'405':
description: Validation exception
security:
- petstore_auth:
- write:pets
- read:pets
"/pet/findByStatus":
get:
tags:
- pet
summary: Finds Pets by status
description: Multiple status values can be provided with comma separated strings
operationId: findPetsByStatus
produces:
- application/xml
- application/json
parameters:
- name: status
in: query
description: Status values that need to be considered for filter
required: true
type: array
items:
type: string
enum:
- available
- pending
- sold
default: available
collectionFormat: multi
responses:
'200':
description: successful operation
schema:
type: array
items:
"$ref": "#/definitions/Pet"
'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 separated strings. Use
tag1, tag2, tag3 for testing.
operationId: findPetsByTags
produces:
- application/xml
- application/json
parameters:
- name: tags
in: query
description: Tags to filter by
required: true
type: array
items:
type: string
collectionFormat: multi
responses:
'200':
description: successful operation
schema:
type: array
items:
"$ref": "#/definitions/Pet"
'400':
description: Invalid tag value
security:
- petstore_auth:
- write:pets
- read:pets
deprecated: true
"/pet/{petId}":
get:
tags:
- pet
summary: Find pet by ID
description: Returns a single pet
operationId: getPetById
produces:
- application/xml
- application/json
parameters:
- name: petId
in: path
description: ID of pet to return
required: true
type: integer
format: int64
responses:
'200':
description: successful operation
schema:
"$ref": "#/definitions/Pet"
'400':
description: Invalid ID supplied
'404':
description: Pet not found
security:
- api_key: []
post:
tags:
- pet
summary: Updates a pet in the store with form data
description: ''
operationId: updatePetWithForm
consumes:
- application/x-www-form-urlencoded
produces:
- application/xml
- application/json
parameters:
- name: petId
in: path
description: ID of pet that needs to be updated
required: true
type: integer
format: int64
- name: name
in: formData
description: Updated name of the pet
required: false
type: string
- name: status
in: formData
description: Updated status of the pet
required: false
type: string
responses:
'405':
description: Invalid input
security:
- petstore_auth:
- write:pets
- read:pets
delete:
tags:
- pet
summary: Deletes a pet
description: ''
operationId: deletePet
produces:
- application/xml
- application/json
parameters:
- name: api_key
in: header
required: false
type: string
- name: petId
in: path
description: Pet id to delete
required: true
type: integer
format: int64
responses:
'400':
description: Invalid ID supplied
'404':
description: Pet not found
security:
- petstore_auth:
- write:pets
- read:pets
"/pet/{petId}/uploadImage":
post:
tags:
- pet
summary: uploads an image
description: ''
operationId: uploadFile
consumes:
- multipart/form-data
produces:
- application/json
parameters:
- name: petId
in: path
description: ID of pet to update
required: true
type: integer
format: int64
- name: additionalMetadata
in: formData
description: Additional data to pass to server
required: false
type: string
- name: file
in: formData
description: file to upload
required: false
type: file
responses:
'200':
description: successful operation
schema:
"$ref": "#/definitions/ApiResponse"
security:
- petstore_auth:
- write:pets
- read:pets
"/store/inventory":
get:
tags:
- store
summary: Returns pet inventories by status
description: Returns a map of status codes to quantities
operationId: getInventory
produces:
- application/json
parameters: []
responses:
'200':
description: successful operation
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
produces:
- application/xml
- application/json
parameters:
- in: body
name: body
description: order placed for purchasing the pet
required: true
schema:
"$ref": "#/definitions/Order"
responses:
'200':
description: successful operation
schema:
"$ref": "#/definitions/Order"
'400':
description: Invalid Order
"/store/order/{orderId}":
get:
tags:
- store
summary: Find purchase order by ID
description: For valid response try integer IDs with value >= 1 and <= 10. Other
values will generated exceptions
operationId: getOrderById
produces:
- application/xml
- application/json
parameters:
- name: orderId
in: path
description: ID of pet that needs to be fetched
required: true
type: integer
maximum: 10
minimum: 1
format: int64
responses:
'200':
description: successful operation
schema:
"$ref": "#/definitions/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 positive integer value.
Negative or non-integer values will generate API errors
operationId: deleteOrder
produces:
- application/xml
- application/json
parameters:
- name: orderId
in: path
description: ID of the order that needs to be deleted
required: true
type: integer
minimum: 1
format: int64
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
produces:
- application/xml
- application/json
parameters:
- in: body
name: body
description: Created user object
required: true
schema:
"$ref": "#/definitions/User"
responses:
default:
description: successful operation
"/user/createWithArray":
post:
tags:
- user
summary: Creates list of users with given input array
description: ''
operationId: createUsersWithArrayInput
produces:
- application/xml
- application/json
parameters:
- in: body
name: body
description: List of user object
required: true
schema:
type: array
items:
"$ref": "#/definitions/User"
responses:
default:
description: successful operation
"/user/createWithList":
post:
tags:
- user
summary: Creates list of users with given input array
description: ''
operationId: createUsersWithListInput
produces:
- application/xml
- application/json
parameters:
- in: body
name: body
description: List of user object
required: true
schema:
type: array
items:
"$ref": "#/definitions/User"
responses:
default:
description: successful operation
"/user/login":
get:
tags:
- user
summary: Logs user into the system
description: ''
operationId: loginUser
produces:
- application/xml
- application/json
parameters:
- name: username
in: query
description: The user name for login
required: true
type: string
- name: password
in: query
description: The password for login in clear text
required: true
type: string
responses:
'200':
description: successful operation
schema:
type: string
headers:
X-Rate-Limit:
type: integer
format: int32
description: calls per hour allowed by the user
X-Expires-After:
type: string
format: date-time
description: date in UTC when token expires
'400':
description: Invalid username/password supplied
"/user/logout":
get:
tags:
- user
summary: Logs out current logged in user session
description: ''
operationId: logoutUser
produces:
- application/xml
- application/json
parameters: []
responses:
default:
description: successful operation
"/user/{username}":
get:
tags:
- user
summary: Get user by user name
description: ''
operationId: getUserByName
produces:
- application/xml
- application/json
parameters:
- name: username
in: path
description: 'The name that needs to be fetched. Use user1 for testing. '
required: true
type: string
responses:
'200':
description: successful operation
schema:
"$ref": "#/definitions/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
produces:
- application/xml
- application/json
parameters:
- name: username
in: path
description: name that need to be updated
required: true
type: string
- in: body
name: body
description: Updated user object
required: true
schema:
"$ref": "#/definitions/User"
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
produces:
- application/xml
- application/json
parameters:
- name: username
in: path
description: The name that needs to be deleted
required: true
type: string
responses:
'400':
description: Invalid username supplied
'404':
description: User not found
securityDefinitions:
petstore_auth:
type: oauth2
authorizationUrl: https://petstore.swagger.io/oauth/dialog
flow: implicit
scopes:
write:pets: modify pets in your account
read:pets: read your pets
api_key:
type: apiKey
name: api_key
in: header
definitions:
Order:
type: object
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
enum:
- placed
- approved
- delivered
complete:
type: boolean
default: false
xml:
name: Order
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
xml:
name: User
Category:
type: object
properties:
id:
type: integer
format: int64
name:
type: string
xml:
name: Category
Tag:
type: object
properties:
id:
type: integer
format: int64
name:
type: string
xml:
name: Tag
Pet:
type: object
required:
- name
- photoUrls
properties:
id:
type: integer
format: int64
category:
"$ref": "#/definitions/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": "#/definitions/Tag"
status:
type: string
description: pet status in the store
enum:
- available
- pending
- sold
xml:
name: Pet
ApiResponse:
type: object
properties:
code:
type: integer
format: int32
type:
type: string
message:
type: string
externalDocs:
description: Find out more about Swagger
url: http://swagger.io

View File

@ -0,0 +1,35 @@
openapi: 3.0.0
info:
title: Test anonymous operations
version: 1.0.0
paths:
/withBoth:
get:
security: [{}, {"apikeyScheme": []}, {"apikeyScheme2": []}]
responses:
200:
description: asdadasd
/onlyEmpty:
get:
security: [{}]
responses:
200:
description: asdadasd
/required:
get:
security: [{"apikeyScheme": []}]
responses:
200:
description: asdadasd
security:
- apikeyScheme: []
components:
securitySchemes:
apikeyScheme:
name: test
type: apiKey
in: header
apikeyScheme2:
name: test2
type: apiKey
in: header

View File

@ -0,0 +1,7 @@
* {
color: red !important; /* for humans */
}
h4 {
display: none; /* for machines, used to trace whether this sheet is applied */
}

View File

@ -0,0 +1,10 @@
openapi: "3.0.0"
info:
title: Sequential Import Chaining
description: >
<h4>This h4 would be hidden by the injected CSS</h4>
This document tests the ability of a `<style>` tag in a Markdown field to pull in a remote stylesheet using an `@import` directive.
<style>@import url(/documents/security/sequential-import-chaining/injection.css);</style>

View File

@ -0,0 +1,10 @@
swagger: "2.0"
info:
title: Sequential Import Chaining
description: >
<h4>This h4 would be hidden by the injected CSS</h4>
This document tests the ability of a `<style>` tag in a Markdown field to pull in a remote stylesheet using an `@import` directive.
<style>@import url(/documents/security/sequential-import-chaining/injection.css);</style>

View File

@ -0,0 +1,5 @@
swagger: '2.0'
securityDefinitions:
a:
type: oauth2
authorizationUrl: javascript:alert(document.domain)//

View File

@ -0,0 +1,77 @@
<!-- HTML for dev server -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after
{
box-sizing: inherit;
}
body {
margin:0;
background: #fafafa;
}
</style>
</head>
<body>
<div id="swagger-ui"></div>
<script src="./swagger-ui-bundle.js" charset="UTF-8"> </script>
<script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
<script>
window.onload = function() {
window["SwaggerUIBundle"] = window["swagger-ui-bundle"]
window["SwaggerUIStandalonePreset"] = window["swagger-ui-standalone-preset"]
// Build a system
const ui = SwaggerUIBundle({
url: "",
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: SwaggerUIStandalonePreset ? "StandaloneLayout" : "BaseLayout",
onComplete: () => {
if(window.completeCount) {
window.completeCount++
} else {
window.completeCount = 1
}
},
queryConfigEnabled: true,
})
window.ui = ui
ui.initOAuth({
clientId: "your-client-id",
clientSecret: "your-client-secret-if-required",
realm: "your-realms",
appName: "your-app-name",
scopeSeparator: " ",
additionalQueryStringParams: {}
})
}
</script>
</body>
</html>

View File

@ -0,0 +1,67 @@
<!-- HTML for dev server -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="/swagger-ui.css" >
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16" />
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after
{
box-sizing: inherit;
}
body {
margin:0;
background: #fafafa;
}
</style>
</head>
<body>
<div id="swagger-ui"></div>
<script src="/swagger-ui-bundle.js" charset="UTF-8"> </script>
<script src="/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
<script>
window.onload = function() {
window["SwaggerUIBundle"] = window["swagger-ui-bundle"]
window["SwaggerUIStandalonePreset"] = window["swagger-ui-standalone-preset"]
// Build a system
const ui = SwaggerUIBundle({
url: "https://petstore.swagger.io/v2/swagger.json",
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: SwaggerUIStandalonePreset ? "StandaloneLayout" : "BaseLayout",
onComplete: () => {
if(window.completeCount) {
window.completeCount++
} else {
window.completeCount = 1
}
}
})
window.ui = ui
}
</script>
</body>
</html>

View File

@ -0,0 +1,167 @@
openapi: "3.0.0"
info:
title: Simple API overview
version: 2.0.0
paths:
/:
get:
operationId: listVersionsv2
summary: List API versions
responses:
'200':
description: |-
200 response
content:
application/json:
examples:
foo:
value: {
"versions": [
{
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"href": "http://127.0.0.1:8774/v2/",
"rel": "self"
}
]
},
{
"status": "EXPERIMENTAL",
"updated": "2013-07-23T11:33:21Z",
"id": "v3.0",
"links": [
{
"href": "http://127.0.0.1:8774/v3/",
"rel": "self"
}
]
}
]
}
'300':
description: |-
300 response
content:
application/json:
examples:
foo:
value: |
{
"versions": [
{
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"href": "http://127.0.0.1:8774/v2/",
"rel": "self"
}
]
},
{
"status": "EXPERIMENTAL",
"updated": "2013-07-23T11:33:21Z",
"id": "v3.0",
"links": [
{
"href": "http://127.0.0.1:8774/v3/",
"rel": "self"
}
]
}
]
}
/v2:
get:
operationId: getVersionDetailsv2
summary: Show API version details
responses:
'200':
description: |-
200 response
content:
application/json:
examples:
foo:
value: {
"version": {
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"media-types": [
{
"base": "application/xml",
"type": "application/vnd.openstack.compute+xml;version=2"
},
{
"base": "application/json",
"type": "application/vnd.openstack.compute+json;version=2"
}
],
"id": "v2.0",
"links": [
{
"href": "http://127.0.0.1:8774/v2/",
"rel": "self"
},
{
"href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf",
"type": "application/pdf",
"rel": "describedby"
},
{
"href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
"type": "application/vnd.sun.wadl+xml",
"rel": "describedby"
},
{
"href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
"type": "application/vnd.sun.wadl+xml",
"rel": "describedby"
}
]
}
}
'203':
description: |-
203 response
content:
application/json:
examples:
foo:
value: {
"version": {
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"media-types": [
{
"base": "application/xml",
"type": "application/vnd.openstack.compute+xml;version=2"
},
{
"base": "application/json",
"type": "application/vnd.openstack.compute+json;version=2"
}
],
"id": "v2.0",
"links": [
{
"href": "http://23.253.228.211:8774/v2/",
"rel": "self"
},
{
"href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf",
"type": "application/pdf",
"rel": "describedby"
},
{
"href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl",
"type": "application/vnd.sun.wadl+xml",
"rel": "describedby"
}
]
}
}

View File

@ -0,0 +1,77 @@
<!-- HTML for dev server -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="/swagger-ui.css">
<style>
html {
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin: 0;
background: #fafafa;
}
</style>
</head>
<body>
<div id="swagger-ui"></div>
<script src="/swagger-ui-bundle.js" charset="UTF-8"> </script>
<script src="/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
<script>
window.onload = function () {
window["SwaggerUIBundle"] = window["swagger-ui-bundle"]
window["SwaggerUIStandalonePreset"] = window["swagger-ui-standalone-preset"]
// Build a system
const ui = SwaggerUIBundle({
url: "https://petstore.swagger.io/v2/swagger.json",
urls: [
{
name: "USPTO",
url: "./uspto.yaml"
},
{
name: "Examples",
url: "./api-with-examples.yaml"
},
],
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout",
onComplete: () => {
if (window.completeCount) {
window.completeCount++
} else {
window.completeCount = 1
}
},
queryConfigEnabled: true,
})
window.ui = ui
}
</script>
</body>
</html>

View File

@ -0,0 +1,210 @@
openapi: 3.0.1
servers:
- url: '{scheme}://developer.uspto.gov/ds-api'
variables:
scheme:
description: 'The Data Set API is accessible via https and http'
enum:
- 'https'
- 'http'
default: 'https'
info:
description: >-
The Data Set API (DSAPI) allows the public users to discover and search
USPTO exported data sets. This is a generic API that allows USPTO users to
make any CSV based data files searchable through API. With the help of GET
call, it returns the list of data fields that are searchable. With the help
of POST call, data can be fetched based on the filters on the field names.
Please note that POST call is used to search the actual data. The reason for
the POST call is that it allows users to specify any complex search criteria
without worry about the GET size limitations as well as encoding of the
input parameters.
version: 1.0.0
title: USPTO Data Set API
contact:
name: Open Data Portal
url: 'https://developer.uspto.gov'
email: developer@uspto.gov
tags:
- name: metadata
description: Find out about the data sets
- name: search
description: Search a data set
paths:
/:
get:
tags:
- metadata
operationId: list-data-sets
summary: List available data sets
responses:
'200':
description: Returns a list of data sets
content:
application/json:
schema:
$ref: '#/components/schemas/dataSetList'
example:
{
"total": 2,
"apis": [
{
"apiKey": "oa_citations",
"apiVersionNumber": "v1",
"apiUrl": "https://developer.uspto.gov/ds-api/oa_citations/v1/fields",
"apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/oa_citations.json"
},
{
"apiKey": "cancer_moonshot",
"apiVersionNumber": "v1",
"apiUrl": "https://developer.uspto.gov/ds-api/cancer_moonshot/v1/fields",
"apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/cancer_moonshot.json"
}
]
}
/{dataset}/{version}/fields:
get:
tags:
- metadata
summary: >-
Provides the general information about the API and the list of fields
that can be used to query the dataset.
description: >-
This GET API returns the list of all the searchable field names that are
in the oa_citations. Please see the 'fields' attribute which returns an
array of field names. Each field or a combination of fields can be
searched using the syntax options shown below.
operationId: list-searchable-fields
parameters:
- name: dataset
in: path
description: 'Name of the dataset.'
required: true
example: "oa_citations"
schema:
type: string
- name: version
in: path
description: Version of the dataset.
required: true
example: "v1"
schema:
type: string
responses:
'200':
description: >-
The dataset API for the given version is found and it is accessible
to consume.
content:
application/json:
schema:
type: string
'404':
description: >-
The combination of dataset name and version is not found in the
system or it is not published yet to be consumed by public.
content:
application/json:
schema:
type: string
/{dataset}/{version}/records:
post:
tags:
- search
summary: >-
Provides search capability for the data set with the given search
criteria.
description: >-
This API is based on Solr/Lucense Search. The data is indexed using
SOLR. This GET API returns the list of all the searchable field names
that are in the Solr Index. Please see the 'fields' attribute which
returns an array of field names. Each field or a combination of fields
can be searched using the Solr/Lucene Syntax. Please refer
https://lucene.apache.org/core/3_6_2/queryparsersyntax.html#Overview for
the query syntax. List of field names that are searchable can be
determined using above GET api.
operationId: perform-search
parameters:
- name: version
in: path
description: Version of the dataset.
required: true
schema:
type: string
default: v1
- name: dataset
in: path
description: 'Name of the dataset. In this case, the default value is oa_citations'
required: true
schema:
type: string
default: oa_citations
responses:
'200':
description: successful operation
content:
application/json:
schema:
type: array
items:
type: object
additionalProperties:
type: object
'404':
description: No matching record found for the given criteria.
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
criteria:
description: >-
Uses Lucene Query Syntax in the format of
propertyName:value, propertyName:[num1 TO num2] and date
range format: propertyName:[yyyyMMdd TO yyyyMMdd]. In the
response please see the 'docs' element which has the list of
record objects. Each record structure would consist of all
the fields and their corresponding values.
type: string
default: '*:*'
start:
description: Starting record number. Default value is 0.
type: integer
default: 0
rows:
description: >-
Specify number of rows to be returned. If you run the search
with default values, in the response you will see 'numFound'
attribute which will tell the number of records available in
the dataset.
type: integer
default: 100
required:
- criteria
components:
schemas:
dataSetList:
type: object
properties:
total:
type: integer
apis:
type: array
items:
type: object
properties:
apiKey:
type: string
description: To be used as a dataset parameter value
apiVersionNumber:
type: string
description: To be used as a version parameter value
apiUrl:
type: string
format: uriref
description: "The URL describing the dataset's fields"
apiDocumentationUrl:
type: string
format: uriref
description: A URL to the API console for each API

View File

@ -0,0 +1,80 @@
<!-- HTML for dev server -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="/swagger-ui.css" >
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16" />
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after
{
box-sizing: inherit;
}
body {
margin:0;
background: #fafafa;
}
</style>
</head>
<body>
<div id="swagger-ui"></div>
<script src="/swagger-ui-bundle.js" charset="UTF-8"> </script>
<script src="/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
<script>
window.onload = function() {
window["SwaggerUIBundle"] = window["swagger-ui-bundle"]
window["SwaggerUIStandalonePreset"] = window["swagger-ui-standalone-preset"]
// Build a system
const ui = SwaggerUIBundle({
urls: [
{ name: "Petstore OAS", url: "/documents/petstore-expanded.openapi.yaml" },
{ name: "Petstore Swagger", url: "/documents/petstore.swagger.yaml" }
],
dom_id: '#swagger-ui',
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout",
onComplete: () => {
if(window.completeCount) {
window.completeCount++
} else {
window.completeCount = 1
}
},
queryConfigEnabled: false,
})
window.ui = ui
ui.initOAuth({
clientId: "your-client-id",
clientSecret: "your-client-secret-if-required",
realm: "your-realms",
appName: "your-app-name",
scopeSeparator: " ",
additionalQueryStringParams: {}
})
}
</script>
</body>
</html>

Some files were not shown because too many files have changed in this diff Show More