diff --git a/.github/workflows/convert-examples-to-json.yaml b/.github/workflows/convert-examples-to-json.yaml index b0cc894..1e20d72 100644 --- a/.github/workflows/convert-examples-to-json.yaml +++ b/.github/workflows/convert-examples-to-json.yaml @@ -36,6 +36,9 @@ jobs: - name: convert YAML examples to JSON run: find examples/v3* -type f -name "*.yaml" | xargs node scripts/yaml2json/yaml2json.js + - name: pretty-print JSON examples + run: npx prettier --write examples/**/*.json + - name: git diff run: | git add examples/**/*.json diff --git a/.github/workflows/examples-tests.yaml b/.github/workflows/examples-tests.yaml index 9e416b4..e112673 100644 --- a/.github/workflows/examples-tests.yaml +++ b/.github/workflows/examples-tests.yaml @@ -1,4 +1,4 @@ -name: schema-test +name: examples-test # Author: @MikeRalphson / runs @jdesrosiers tests # Issue: https://github.com/OAI/OpenAPI-Specification/pull/2489 diff --git a/Gemfile.lock b/Gemfile.lock index 3a00189..6148dc9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -77,6 +77,7 @@ GEM PLATFORMS arm64-darwin-21 + arm64-darwin-23 x86_64-darwin-23 x86_64-linux diff --git a/_includes/example-api-description.md b/_includes/example-api-description.md new file mode 100644 index 0000000..23bfb77 --- /dev/null +++ b/_includes/example-api-description.md @@ -0,0 +1,15 @@ +# {{ include.name }} + +{{ include.description }} + +## JSON + +```json +{% include_relative {{ include.name | append: ".json" }} %} +``` + +## YAML + +```yaml +{% include_relative {{ include.name | append: ".yaml" }} %} +``` diff --git a/_sass/custom/custom.scss b/_sass/custom/custom.scss index eb8d500..82921f9 100644 --- a/_sass/custom/custom.scss +++ b/_sass/custom/custom.scss @@ -2,7 +2,11 @@ object { width: 100%; } - .nav-list .nav-list-item .nav-list-expander { color: #1d781d !important; -} \ No newline at end of file +} + +.highlight .err { + color: inherit; + background-color: inherit; +} diff --git a/examples/index.md b/examples/index.md new file mode 100644 index 0000000..de34a50 --- /dev/null +++ b/examples/index.md @@ -0,0 +1,9 @@ +--- +layout: default +title: Example API Descriptions +nav_order: 6 +has_children: true +has_toc: true +--- + +# Example API Descriptions diff --git a/examples/v3.0/api-with-examples.json b/examples/v3.0/api-with-examples.json index 0fd2077..31d2e9b 100644 --- a/examples/v3.0/api-with-examples.json +++ b/examples/v3.0/api-with-examples.json @@ -53,7 +53,32 @@ "application/json": { "examples": { "foo": { - "value": "{\n \"versions\": [\n {\n \"status\": \"CURRENT\",\n \"updated\": \"2011-01-21T11:33:21Z\",\n \"id\": \"v2.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v2/\",\n \"rel\": \"self\"\n }\n ]\n },\n {\n \"status\": \"EXPERIMENTAL\",\n \"updated\": \"2013-07-23T11:33:21Z\",\n \"id\": \"v3.0\",\n \"links\": [\n {\n \"href\": \"http://127.0.0.1:8774/v3/\",\n \"rel\": \"self\"\n }\n ]\n }\n ]\n}\n" + "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" + } + ] + } + ] + } } } } @@ -164,4 +189,4 @@ } } } -} \ No newline at end of file +} diff --git a/examples/v3.0/api-with-examples.md b/examples/v3.0/api-with-examples.md new file mode 100644 index 0000000..073e9a2 --- /dev/null +++ b/examples/v3.0/api-with-examples.md @@ -0,0 +1,13 @@ +--- +layout: default +title: api-with-examples +parent: Example API Descriptions +--- + +{% comment %} +{% capture description %} +Insert description here, then remove comment tag above and endcomment tag below +{% endcapture %} +{% endcomment %} + +{% include example-api-description.md name=page.title description=description %} diff --git a/examples/v3.0/api-with-examples.yaml b/examples/v3.0/api-with-examples.yaml index 18726a5..a94b294 100644 --- a/examples/v3.0/api-with-examples.yaml +++ b/examples/v3.0/api-with-examples.yaml @@ -1,4 +1,4 @@ -openapi: "3.0.0" +openapi: 3.0.0 info: title: Simple API overview version: 2.0.0 @@ -9,162 +9,170 @@ paths: summary: List API versions responses: '200': - description: |- - 200 response + description: 200 response content: application/json: - examples: + examples: foo: value: { - "versions": [ - { + "versions": + [ + { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0", - "links": [ + "links": + [ { - "href": "http://127.0.0.1:8774/v2/", - "rel": "self" + "href": "http://127.0.0.1:8774/v2/", + "rel": "self" } - ] - }, - { + ] + }, + { "status": "EXPERIMENTAL", "updated": "2013-07-23T11:33:21Z", "id": "v3.0", - "links": [ + "links": + [ { - "href": "http://127.0.0.1:8774/v3/", - "rel": "self" + "href": "http://127.0.0.1:8774/v3/", + "rel": "self" } - ] - } - ] + ] + } + ] } '300': - description: |- - 300 response + description: 300 response content: - application/json: - examples: + application/json: + examples: foo: - value: | - { - "versions": [ + value: + { + "versions": + [ { "status": "CURRENT", "updated": "2011-01-21T11:33:21Z", "id": "v2.0", - "links": [ + "links": + [ { - "href": "http://127.0.0.1:8774/v2/", - "rel": "self" + "href": "http://127.0.0.1:8774/v2/", + "rel": "self" } - ] - }, - { + ] + }, + { "status": "EXPERIMENTAL", "updated": "2013-07-23T11:33:21Z", "id": "v3.0", - "links": [ + "links": + [ { - "href": "http://127.0.0.1:8774/v3/", - "rel": "self" + "href": "http://127.0.0.1:8774/v3/", + "rel": "self" } - ] - } - ] - } + ] + } + ] + } /v2: get: operationId: getVersionDetailsv2 summary: Show API version details responses: - '200': - description: |- - 200 response + "200": + description: 200 response content: - application/json: + 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" - } - ] - } + "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 + description: 203 response content: - application/json: + 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" - } - ] - } + "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" + } + ] + } } diff --git a/examples/v3.0/callback-example.json b/examples/v3.0/callback-example.json index 9a4df39..edae06a 100644 --- a/examples/v3.0/callback-example.json +++ b/examples/v3.0/callback-example.json @@ -28,9 +28,7 @@ "application/json": { "schema": { "description": "subscription information", - "required": [ - "subscriptionId" - ], + "required": ["subscriptionId"], "properties": { "subscriptionId": { "description": "this unique identifier allows management of the subscription", @@ -81,4 +79,4 @@ } } } -} \ No newline at end of file +} diff --git a/examples/v3.0/callback-example.md b/examples/v3.0/callback-example.md new file mode 100644 index 0000000..70deefd --- /dev/null +++ b/examples/v3.0/callback-example.md @@ -0,0 +1,13 @@ +--- +layout: default +title: callback-example +parent: Example API Descriptions +--- + +{% comment %} +{% capture description %} +Insert description here, then remove comment tag above and endcomment tag below +{% endcapture %} +{% endcomment %} + +{% include example-api-description.md name=page.title description=description %} diff --git a/examples/v3.0/link-example.json b/examples/v3.0/link-example.json index bc98e63..e230387 100644 --- a/examples/v3.0/link-example.json +++ b/examples/v3.0/link-example.json @@ -137,11 +137,7 @@ "in": "query", "schema": { "type": "string", - "enum": [ - "open", - "merged", - "declined" - ] + "enum": ["open", "merged", "declined"] } } ], @@ -320,4 +316,4 @@ } } } -} \ No newline at end of file +} diff --git a/examples/v3.0/link-example.md b/examples/v3.0/link-example.md new file mode 100644 index 0000000..9881ccc --- /dev/null +++ b/examples/v3.0/link-example.md @@ -0,0 +1,13 @@ +--- +layout: default +title: link-example +parent: Example API Descriptions +--- + +{% comment %} +{% capture description %} +Insert description here, then remove comment tag above and endcomment tag below +{% endcapture %} +{% endcomment %} + +{% include example-api-description.md name=page.title description=description %} diff --git a/examples/v3.0/link-example.yaml b/examples/v3.0/link-example.yaml index 5837d70..ea90bdc 100644 --- a/examples/v3.0/link-example.yaml +++ b/examples/v3.0/link-example.yaml @@ -1,23 +1,23 @@ openapi: 3.0.0 -info: +info: title: Link Example version: 1.0.0 -paths: - /2.0/users/{username}: - get: +paths: + /2.0/users/{username}: + get: operationId: getUserByName - parameters: - - name: username - in: path - required: true - schema: - type: string - responses: + parameters: + - name: username + in: path + required: true + schema: + type: string + responses: '200': description: The User content: application/json: - schema: + schema: $ref: '#/components/schemas/user' links: userRepositories: @@ -34,7 +34,7 @@ paths: responses: '200': description: repositories owned by the supplied user - content: + content: application/json: schema: type: array @@ -43,10 +43,10 @@ paths: links: userRepository: $ref: '#/components/links/UserRepository' - /2.0/repositories/{username}/{slug}: - get: + /2.0/repositories/{username}/{slug}: + get: operationId: getRepository - parameters: + parameters: - name: username in: path required: true @@ -57,96 +57,96 @@ paths: required: true schema: type: string - responses: + responses: '200': description: The repository content: - application/json: - schema: - $ref: '#/components/schemas/repository' + application/json: + schema: + $ref: '#/components/schemas/repository' links: repositoryPullRequests: $ref: '#/components/links/RepositoryPullRequests' - /2.0/repositories/{username}/{slug}/pullrequests: - get: + /2.0/repositories/{username}/{slug}/pullrequests: + get: operationId: getPullRequestsByRepository - parameters: - - name: username - in: path - required: true - schema: - type: string - - name: slug - in: path - required: true - schema: - type: string - - name: state - in: query - schema: - type: string - enum: - - open - - merged - - declined - responses: + parameters: + - name: username + in: path + required: true + schema: + type: string + - name: slug + in: path + required: true + schema: + type: string + - name: state + in: query + schema: + type: string + enum: + - open + - merged + - declined + responses: '200': description: an array of pull request objects content: - application/json: - schema: + application/json: + schema: type: array - items: + items: $ref: '#/components/schemas/pullrequest' - /2.0/repositories/{username}/{slug}/pullrequests/{pid}: - get: + /2.0/repositories/{username}/{slug}/pullrequests/{pid}: + get: operationId: getPullRequestsById - parameters: - - name: username - in: path - required: true - schema: - type: string - - name: slug - in: path - required: true - schema: - type: string - - name: pid - in: path - required: true - schema: - type: string - responses: + parameters: + - name: username + in: path + required: true + schema: + type: string + - name: slug + in: path + required: true + schema: + type: string + - name: pid + in: path + required: true + schema: + type: string + responses: '200': description: a pull request object content: - application/json: - schema: + application/json: + schema: $ref: '#/components/schemas/pullrequest' links: pullRequestMerge: $ref: '#/components/links/PullRequestMerge' - /2.0/repositories/{username}/{slug}/pullrequests/{pid}/merge: - post: + /2.0/repositories/{username}/{slug}/pullrequests/{pid}/merge: + post: operationId: mergePullRequest - parameters: - - name: username - in: path - required: true - schema: - type: string - - name: slug - in: path - required: true - schema: - type: string - - name: pid - in: path - required: true - schema: - type: string - responses: + parameters: + - name: username + in: path + required: true + schema: + type: string + - name: slug + in: path + required: true + schema: + type: string + - name: pid + in: path + required: true + schema: + type: string + responses: '204': description: the PR was successfully merged components: @@ -165,9 +165,9 @@ components: RepositoryPullRequests: # returns '#/components/schemas/pullrequest' operationId: getPullRequestsByRepository - parameters: - username: $response.body#/owner/username - slug: $response.body#/slug + parameters: + username: $response.body#/owner/username + slug: $response.body#/slug PullRequestMerge: # executes /2.0/repositories/{username}/{slug}/pullrequests/{pid}/merge operationId: mergePullRequest @@ -175,29 +175,29 @@ components: username: $response.body#/author/username slug: $response.body#/repository/slug pid: $response.body#/id - schemas: - user: + schemas: + user: type: object - properties: - username: + properties: + username: type: string - uuid: + uuid: type: string - repository: + repository: type: object - properties: - slug: + properties: + slug: type: string - owner: + owner: $ref: '#/components/schemas/user' - pullrequest: + pullrequest: type: object - properties: - id: + properties: + id: type: integer - title: + title: type: string - repository: + repository: $ref: '#/components/schemas/repository' - author: + author: $ref: '#/components/schemas/user' diff --git a/examples/v3.0/petstore-expanded.json b/examples/v3.0/petstore-expanded.json index 420eede..7315872 100644 --- a/examples/v3.0/petstore-expanded.json +++ b/examples/v3.0/petstore-expanded.json @@ -195,9 +195,7 @@ }, { "type": "object", - "required": [ - "id" - ], + "required": ["id"], "properties": { "id": { "type": "integer", @@ -209,9 +207,7 @@ }, "NewPet": { "type": "object", - "required": [ - "name" - ], + "required": ["name"], "properties": { "name": { "type": "string" @@ -223,10 +219,7 @@ }, "Error": { "type": "object", - "required": [ - "code", - "message" - ], + "required": ["code", "message"], "properties": { "code": { "type": "integer", @@ -239,4 +232,4 @@ } } } -} \ No newline at end of file +} diff --git a/examples/v3.0/petstore-expanded.md b/examples/v3.0/petstore-expanded.md new file mode 100644 index 0000000..62ef8e9 --- /dev/null +++ b/examples/v3.0/petstore-expanded.md @@ -0,0 +1,13 @@ +--- +layout: default +title: petstore-expanded +parent: Example API Descriptions +--- + +{% comment %} +{% capture description %} +Insert description here, then remove comment tag above and endcomment tag below +{% endcapture %} +{% endcomment %} + +{% include example-api-description.md name=page.title description=description %} diff --git a/examples/v3.0/petstore-expanded.yaml b/examples/v3.0/petstore-expanded.yaml index 7e5bff0..1b5a6ce 100644 --- a/examples/v3.0/petstore-expanded.yaml +++ b/examples/v3.0/petstore-expanded.yaml @@ -1,4 +1,4 @@ -openapi: "3.0.0" +openapi: 3.0.0 info: version: 1.0.0 title: Swagger Petstore @@ -129,22 +129,20 @@ components: - $ref: '#/components/schemas/NewPet' - type: object required: - - id + - id properties: id: type: integer format: int64 - NewPet: type: object required: - - name + - name properties: name: type: string tag: - type: string - + type: string Error: type: object required: diff --git a/examples/v3.0/petstore.json b/examples/v3.0/petstore.json index d14eb5e..9d717b6 100644 --- a/examples/v3.0/petstore.json +++ b/examples/v3.0/petstore.json @@ -17,9 +17,7 @@ "get": { "summary": "List all pets", "operationId": "listPets", - "tags": [ - "pets" - ], + "tags": ["pets"], "parameters": [ { "name": "limit", @@ -67,9 +65,7 @@ "post": { "summary": "Create a pet", "operationId": "createPets", - "tags": [ - "pets" - ], + "tags": ["pets"], "requestBody": { "content": { "application/json": { @@ -101,9 +97,7 @@ "get": { "summary": "Info for a specific pet", "operationId": "showPetById", - "tags": [ - "pets" - ], + "tags": ["pets"], "parameters": [ { "name": "petId", @@ -144,10 +138,7 @@ "schemas": { "Pet": { "type": "object", - "required": [ - "id", - "name" - ], + "required": ["id", "name"], "properties": { "id": { "type": "integer", @@ -170,10 +161,7 @@ }, "Error": { "type": "object", - "required": [ - "code", - "message" - ], + "required": ["code", "message"], "properties": { "code": { "type": "integer", @@ -186,4 +174,4 @@ } } } -} \ No newline at end of file +} diff --git a/examples/v3.0/petstore.md b/examples/v3.0/petstore.md new file mode 100644 index 0000000..e385167 --- /dev/null +++ b/examples/v3.0/petstore.md @@ -0,0 +1,13 @@ +--- +layout: default +title: petstore +parent: Example API Descriptions +--- + +{% comment %} +{% capture description %} +Insert description here, then remove comment tag above and endcomment tag below +{% endcapture %} +{% endcomment %} + +{% include example-api-description.md name=page.title description=description %} diff --git a/examples/v3.0/petstore.yaml b/examples/v3.0/petstore.yaml index 7ed987f..98f62c1 100644 --- a/examples/v3.0/petstore.yaml +++ b/examples/v3.0/petstore.yaml @@ -1,4 +1,4 @@ -openapi: "3.0.0" +openapi: 3.0.0 info: version: 1.0.0 title: Swagger Petstore @@ -31,15 +31,15 @@ paths: schema: type: string content: - application/json: + application/json: schema: - $ref: "#/components/schemas/Pets" + $ref: '#/components/schemas/Pets' default: description: unexpected error content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: '#/components/schemas/Error' post: summary: Create a pet operationId: createPets @@ -59,7 +59,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: '#/components/schemas/Error' /pets/{petId}: get: summary: Info for a specific pet @@ -79,13 +79,13 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Pet" + $ref: '#/components/schemas/Pet' default: description: unexpected error content: application/json: schema: - $ref: "#/components/schemas/Error" + $ref: '#/components/schemas/Error' components: schemas: Pet: @@ -105,7 +105,7 @@ components: type: array maxItems: 100 items: - $ref: "#/components/schemas/Pet" + $ref: '#/components/schemas/Pet' Error: type: object required: diff --git a/examples/v3.0/uspto.json b/examples/v3.0/uspto.json index cd32f64..5c687e2 100644 --- a/examples/v3.0/uspto.json +++ b/examples/v3.0/uspto.json @@ -6,10 +6,7 @@ "variables": { "scheme": { "description": "The Data Set API is accessible via https and http", - "enum": [ - "https", - "http" - ], + "enum": ["https", "http"], "default": "https" } } @@ -38,9 +35,7 @@ "paths": { "/": { "get": { - "tags": [ - "metadata" - ], + "tags": ["metadata"], "operationId": "list-data-sets", "summary": "List available data sets", "responses": { @@ -76,9 +71,7 @@ }, "/{dataset}/{version}/fields": { "get": { - "tags": [ - "metadata" - ], + "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", @@ -130,9 +123,7 @@ }, "/{dataset}/{version}/records": { "post": { - "tags": [ - "search" - ], + "tags": ["search"], "summary": "Provides search capability for the data set with the given search criteria.", "description": "This API is based on Solr/Lucene 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", @@ -201,9 +192,7 @@ "default": 100 } }, - "required": [ - "criteria" - ] + "required": ["criteria"] } } } @@ -249,4 +238,4 @@ } } } -} \ No newline at end of file +} diff --git a/examples/v3.0/uspto.md b/examples/v3.0/uspto.md new file mode 100644 index 0000000..f5a5f50 --- /dev/null +++ b/examples/v3.0/uspto.md @@ -0,0 +1,13 @@ +--- +layout: default +title: uspto +parent: Example API Descriptions +--- + +{% comment %} +{% capture description %} +Insert description here, then remove comment tag above and endcomment tag below +{% endcapture %} +{% endcomment %} + +{% include example-api-description.md name=page.title description=description %} diff --git a/examples/v3.0/uspto.yaml b/examples/v3.0/uspto.yaml index d301152..9187113 100644 --- a/examples/v3.0/uspto.yaml +++ b/examples/v3.0/uspto.yaml @@ -3,11 +3,11 @@ servers: - url: '{scheme}://developer.uspto.gov/ds-api' variables: scheme: - description: 'The Data Set API is accessible via https and http' + description: The Data Set API is accessible via https and http enum: - - 'https' - - 'http' - default: 'https' + - https + - http + default: https info: description: >- The Data Set API (DSAPI) allows the public users to discover and search @@ -23,7 +23,7 @@ info: title: USPTO Data Set API contact: name: Open Data Portal - url: 'https://developer.uspto.gov' + url: https://developer.uspto.gov email: developer@uspto.gov tags: - name: metadata @@ -78,16 +78,16 @@ paths: parameters: - name: dataset in: path - description: 'Name of the dataset.' + description: Name of the dataset. required: true - example: "oa_citations" + example: oa_citations schema: type: string - name: version in: path description: Version of the dataset. required: true - example: "v1" + example: v1 schema: type: string responses: @@ -134,7 +134,7 @@ paths: default: v1 - name: dataset in: path - description: 'Name of the dataset. In this case, the default value is oa_citations' + description: Name of the dataset. In this case, the default value is oa_citations required: true schema: type: string @@ -203,7 +203,7 @@ components: apiUrl: type: string format: uriref - description: "The URL describing the dataset's fields" + description: The URL describing the dataset's fields apiDocumentationUrl: type: string format: uriref diff --git a/examples/v3.1/non-oauth-scopes.json b/examples/v3.1/non-oauth-scopes.json index b3e5990..6a39a72 100644 --- a/examples/v3.1/non-oauth-scopes.json +++ b/examples/v3.1/non-oauth-scopes.json @@ -9,10 +9,7 @@ "get": { "security": [ { - "bearerAuth": [ - "read:users", - "public" - ] + "bearerAuth": ["read:users", "public"] } ] } @@ -28,4 +25,4 @@ } } } -} \ No newline at end of file +} diff --git a/examples/v3.1/non-oauth-scopes.md b/examples/v3.1/non-oauth-scopes.md new file mode 100644 index 0000000..7b1cd8c --- /dev/null +++ b/examples/v3.1/non-oauth-scopes.md @@ -0,0 +1,13 @@ +--- +layout: default +title: non-oauth-scopes +parent: Example API Descriptions +--- + +{% comment %} +{% capture description %} +Insert description here, then remove comment tag above and endcomment tag below +{% endcapture %} +{% endcomment %} + +{% include example-api-description.md name=page.title description=description %} diff --git a/examples/v3.1/non-oauth-scopes.yaml b/examples/v3.1/non-oauth-scopes.yaml index e757452..ac9fc8d 100644 --- a/examples/v3.1/non-oauth-scopes.yaml +++ b/examples/v3.1/non-oauth-scopes.yaml @@ -7,8 +7,8 @@ paths: get: security: - bearerAuth: - - 'read:users' - - 'public' + - read:users + - public components: securitySchemes: bearerAuth: @@ -16,4 +16,3 @@ components: scheme: bearer bearerFormat: jwt description: 'note: non-oauth scopes are not defined at the securityScheme level' - diff --git a/examples/v3.1/tictactoe.json b/examples/v3.1/tictactoe.json index 9ec11f7..901b5ae 100644 --- a/examples/v3.1/tictactoe.json +++ b/examples/v3.1/tictactoe.json @@ -15,9 +15,7 @@ "get": { "summary": "Get the whole board", "description": "Retrieves the current state of the board and the winner.", - "tags": [ - "Gameplay" - ], + "tags": ["Gameplay"], "operationId": "get-board", "responses": { "200": { @@ -36,9 +34,7 @@ "apiKey": [] }, { - "app2AppOauth": [ - "board:read" - ] + "app2AppOauth": ["board:read"] } ] } @@ -55,9 +51,7 @@ "get": { "summary": "Get a single board square", "description": "Retrieves the requested square.", - "tags": [ - "Gameplay" - ], + "tags": ["Gameplay"], "operationId": "get-square", "responses": { "200": { @@ -87,18 +81,14 @@ "bearerHttpAuthentication": [] }, { - "user2AppOauth": [ - "board:read" - ] + "user2AppOauth": ["board:read"] } ] }, "put": { "summary": "Set a single board square", "description": "Places a mark on the board and retrieves the whole board and the winner (if any).", - "tags": [ - "Gameplay" - ], + "tags": ["Gameplay"], "operationId": "put-square", "requestBody": { "required": true, @@ -148,9 +138,7 @@ "bearerHttpAuthentication": [] }, { - "user2AppOauth": [ - "board:write" - ] + "user2AppOauth": ["board:write"] } ] } @@ -191,11 +179,7 @@ }, "mark": { "type": "string", - "enum": [ - ".", - "X", - "O" - ], + "enum": [".", "X", "O"], "description": "Possible values for a board square. `.` means empty square.", "example": "." }, @@ -214,11 +198,7 @@ }, "winner": { "type": "string", - "enum": [ - ".", - "X", - "O" - ], + "enum": [".", "X", "O"], "description": "Winner of the game. `.` means nobody has won yet.", "example": "." }, @@ -278,4 +258,4 @@ } } } -} \ No newline at end of file +} diff --git a/examples/v3.1/tictactoe.md b/examples/v3.1/tictactoe.md new file mode 100644 index 0000000..9d98f07 --- /dev/null +++ b/examples/v3.1/tictactoe.md @@ -0,0 +1,13 @@ +--- +layout: default +title: tictactoe +parent: Example API Descriptions +--- + +{% comment %} +{% capture description %} +Insert description here, then remove comment tag above and endcomment tag below +{% endcapture %} +{% endcomment %} + +{% include example-api-description.md name=page.title description=description %} diff --git a/examples/v3.1/tictactoe.yaml b/examples/v3.1/tictactoe.yaml index 7f0e4fd..84047bd 100644 --- a/examples/v3.1/tictactoe.yaml +++ b/examples/v3.1/tictactoe.yaml @@ -17,22 +17,21 @@ paths: - Gameplay operationId: get-board responses: - "200": - description: "OK" + '200': + description: OK content: application/json: schema: - $ref: "#/components/schemas/status" + $ref: '#/components/schemas/status' security: - apiKey: [] - app2AppOauth: - - board:read - + - board:read # Single square operations /board/{row}/{column}: parameters: - - $ref: "#/components/parameters/rowParam" - - $ref: "#/components/parameters/columnParam" + - $ref: '#/components/parameters/rowParam' + - $ref: '#/components/parameters/columnParam' get: summary: Get a single board square description: Retrieves the requested square. @@ -40,23 +39,23 @@ paths: - Gameplay operationId: get-square responses: - "200": - description: "OK" + '200': + description: OK content: application/json: schema: - $ref: "#/components/schemas/mark" - "400": + $ref: '#/components/schemas/mark' + '400': description: The provided parameters are incorrect content: text/html: schema: - $ref: "#/components/schemas/errorMessage" - example: "Illegal coordinates" + $ref: '#/components/schemas/errorMessage' + example: Illegal coordinates security: - bearerHttpAuthentication: [] - user2AppOauth: - - board:read + - board:read put: summary: Set a single board square description: Places a mark on the board and retrieves the whole board and the winner (if any). @@ -68,32 +67,31 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/mark" + $ref: '#/components/schemas/mark' responses: - "200": - description: "OK" + '200': + description: OK content: application/json: schema: - $ref: "#/components/schemas/status" - "400": + $ref: '#/components/schemas/status' + '400': description: The provided parameters are incorrect content: text/html: schema: - $ref: "#/components/schemas/errorMessage" + $ref: '#/components/schemas/errorMessage' examples: illegalCoordinates: - value: "Illegal coordinates." + value: Illegal coordinates. notEmpty: - value: "Square is not empty." + value: Square is not empty. invalidMark: - value: "Invalid Mark (X or O)." + value: Invalid Mark (X or O). security: - bearerHttpAuthentication: [] - user2AppOauth: - - board:write - + - board:write components: parameters: rowParam: @@ -102,14 +100,14 @@ components: in: path required: true schema: - $ref: "#/components/schemas/coordinate" + $ref: '#/components/schemas/coordinate' columnParam: description: Board column (horizontal coordinate) name: column in: path required: true schema: - $ref: "#/components/schemas/coordinate" + $ref: '#/components/schemas/coordinate' schemas: errorMessage: type: string @@ -122,9 +120,12 @@ components: example: 1 mark: type: string - enum: [".", "X", "O"] + enum: + - . + - X + - O description: Possible values for a board square. `.` means empty square. - example: "." + example: . board: type: array maxItems: 3 @@ -134,19 +135,22 @@ components: maxItems: 3 minItems: 3 items: - $ref: "#/components/schemas/mark" + $ref: '#/components/schemas/mark' winner: type: string - enum: [".", "X", "O"] + enum: + - . + - X + - O description: Winner of the game. `.` means nobody has won yet. - example: "." + example: . status: type: object properties: winner: - $ref: "#/components/schemas/winner" + $ref: '#/components/schemas/winner' board: - $ref: "#/components/schemas/board" + $ref: '#/components/schemas/board' securitySchemes: defaultApiKey: description: API key provided in console @@ -179,4 +183,4 @@ components: scopes: # Reads and writes permitted via authorization code flow board:read: Read the board - board:write: Write to the board \ No newline at end of file + board:write: Write to the board diff --git a/examples/v3.1/webhook-example.json b/examples/v3.1/webhook-example.json index 712a42f..d39d129 100644 --- a/examples/v3.1/webhook-example.json +++ b/examples/v3.1/webhook-example.json @@ -28,10 +28,7 @@ "components": { "schemas": { "Pet": { - "required": [ - "id", - "name" - ], + "required": ["id", "name"], "properties": { "id": { "type": "integer", @@ -47,4 +44,4 @@ } } } -} \ No newline at end of file +} diff --git a/examples/v3.1/webhook-example.md b/examples/v3.1/webhook-example.md new file mode 100644 index 0000000..c3ce2ed --- /dev/null +++ b/examples/v3.1/webhook-example.md @@ -0,0 +1,13 @@ +--- +layout: default +title: webhook-example +parent: Example API Descriptions +--- + +{% comment %} +{% capture description %} +Insert description here, then remove comment tag above and endcomment tag below +{% endcapture %} +{% endcomment %} + +{% include example-api-description.md name=page.title description=description %} diff --git a/examples/v3.1/webhook-example.yaml b/examples/v3.1/webhook-example.yaml index 2ac1cda..9d69684 100644 --- a/examples/v3.1/webhook-example.yaml +++ b/examples/v3.1/webhook-example.yaml @@ -13,11 +13,10 @@ webhooks: content: application/json: schema: - $ref: "#/components/schemas/Pet" + $ref: '#/components/schemas/Pet' responses: - "200": + '200': description: Return a 200 status to indicate that the data was received successfully - components: schemas: Pet: @@ -32,4 +31,3 @@ components: type: string tag: type: string - diff --git a/package-lock.json b/package-lock.json index 28ee457..cfa4ba0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "Apache-2.0", "dependencies": { "@hyperjump/json-schema": "^1.9.2", + "prettier": "^3.3.3", "vitest": "^1.6.0", "yaml": "^2.4.3" } @@ -1183,6 +1184,21 @@ "node": "^10 || ^12 || >=14" } }, + "node_modules/prettier": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/pretty-format": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", diff --git a/package.json b/package.json index 9dcbf1f..fec81c2 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "homepage": "https://learn.openapis.org", "dependencies": { "@hyperjump/json-schema": "^1.9.2", + "prettier": "^3.3.3", "vitest": "^1.6.0", "yaml": "^2.4.3" }