diff --git a/tests/schema/fail/link-object-no-body.yaml b/tests/schema/fail/link-object-no-body.yaml new file mode 100644 index 0000000000..2c327694f5 --- /dev/null +++ b/tests/schema/fail/link-object-no-body.yaml @@ -0,0 +1,11 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +components: + links: + Link-Object-with-body-property: + operationId: getThing + description: The "server" property was misspelled as "body" in a previous schema iteration, now fixed + body: + url: https://things.example.com diff --git a/tests/schema/pass/callback-object-examples.yaml b/tests/schema/pass/callback-object-examples.yaml new file mode 100644 index 0000000000..641a79ea99 --- /dev/null +++ b/tests/schema/pass/callback-object-examples.yaml @@ -0,0 +1,30 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +components: + callbacks: + myCallback: + '{$request.query.queryUrl}': + post: + requestBody: + description: Callback payload + content: + application/json: + schema: + $ref: '#/components/schemas/SomePayload' + responses: + '200': + description: callback successfully processed + transactionCallback: + 'http://notificationServer.com?transactionId={$request.body#/id}&email={$request.body#/email}': + post: + requestBody: + description: Callback payload + content: + application/json: + schema: + $ref: '#/components/schemas/SomePayload' + responses: + '200': + description: callback successfully processed \ No newline at end of file diff --git a/tests/schema/pass/components-object-example.yaml b/tests/schema/pass/components-object-example.yaml new file mode 100644 index 0000000000..9ef0c17665 --- /dev/null +++ b/tests/schema/pass/components-object-example.yaml @@ -0,0 +1,71 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +components: + schemas: + GeneralError: + type: object + properties: + code: + type: integer + format: int32 + message: + type: string + Category: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + Tag: + type: object + properties: + id: + type: integer + format: int64 + name: + type: string + parameters: + skipParam: + name: skip + in: query + description: number of items to skip + required: true + schema: + type: integer + format: int32 + limitParam: + name: limit + in: query + description: max records to return + required: true + schema: + type: integer + format: int32 + responses: + NotFound: + description: Entity not found. + IllegalInput: + description: Illegal input for operation. + GeneralError: + description: General Error + content: + application/json: + schema: + $ref: '#/components/schemas/GeneralError' + securitySchemes: + api_key: + type: apiKey + name: api-key + in: header + petstore_auth: + type: oauth2 + flows: + implicit: + authorizationUrl: https://example.org/api/oauth/dialog + scopes: + write:pets: modify pets in your account + read:pets: read your pets \ No newline at end of file diff --git a/tests/schema/pass/example-object-examples.yaml b/tests/schema/pass/example-object-examples.yaml new file mode 100644 index 0000000000..664b22f429 --- /dev/null +++ b/tests/schema/pass/example-object-examples.yaml @@ -0,0 +1,63 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +components: + requestBodies: + with-example: + content: + 'application/json': + schema: + $ref: '#/components/schemas/Address' + examples: + foo: + summary: A foo example + value: + foo: bar + bar: + summary: A bar example + value: + bar: baz + application/xml: + examples: + xmlExample: + summary: This is an example in XML + externalValue: https://example.org/examples/address-example.xml + text/plain: + examples: + textExample: + summary: This is a text example + externalValue: https://foo.bar/examples/address-example.txt + parameters: + with-example: + name: zipCode + in: query + schema: + type: string + format: zip-code + examples: + zip-example: + $ref: '#/components/examples/zip-example' + responses: + '200': + description: your car appointment has been booked + content: + application/json: + schema: + $ref: '#/components/schemas/SuccessResponse' + examples: + confirmation-success: + $ref: '#/components/examples/confirmation-success' + application/x-www-form-urlencoded: + schema: + type: object + properties: + jsonValue: + type: string + encoding: + jsonValue: + contentType: application/json + examples: + jsonFormValue: + description: 'The JSON string "json" as a form value' + value: jsonValue=%22json%22 diff --git a/tests/schema/pass/header-object-examples.yaml b/tests/schema/pass/header-object-examples.yaml new file mode 100644 index 0000000000..7b91efbbae --- /dev/null +++ b/tests/schema/pass/header-object-examples.yaml @@ -0,0 +1,25 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +components: + headers: + X-Rate-Limit-Limit: + description: The number of allowed requests in the current period + deprecated: false + schema: + type: integer + ETag: + required: true + content: + text/plain: + schema: + type: string + pattern: ^" + Reference: + $ref: '#/components/schemas/ETag' + Style: + schema: + type: array + style: simple + explode: true \ No newline at end of file diff --git a/tests/schema/pass/info-object-example.yaml b/tests/schema/pass/info-object-example.yaml new file mode 100644 index 0000000000..2c32cd9c10 --- /dev/null +++ b/tests/schema/pass/info-object-example.yaml @@ -0,0 +1,19 @@ +# including External Documentation Object Example +openapi: 3.1.0 +info: + title: Example Pet Store App + summary: A pet store manager. + description: This is an example server for a pet store. + termsOfService: https://example.com/terms/ + contact: + name: API Support + url: https://www.example.com/support + email: support@example.com + license: + name: Apache 2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html + version: 1.0.1 +externalDocs: + description: Find more info here + url: https://example.com +components: {} diff --git a/tests/schema/pass/link-object-examples.yaml b/tests/schema/pass/link-object-examples.yaml new file mode 100644 index 0000000000..92142a94a6 --- /dev/null +++ b/tests/schema/pass/link-object-examples.yaml @@ -0,0 +1,62 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +paths: + /users/{id}: + parameters: + - name: id + in: path + required: true + description: the user identifier, as userId + schema: + type: string + get: + responses: + '200': + description: the user being returned + content: + application/json: + schema: + type: object + properties: + uuid: # the unique user id + type: string + format: uuid + links: + address: + # the target link operationId + operationId: getUserAddress + parameters: + # get the `id` field from the request path parameter named `id` + userid: $request.path.id + address2: + operationId: getUserAddressByUUID + parameters: + # get the `uuid` field from the `uuid` field in the response body + userUuid: $response.body#/uuid + UserRepositories: + # returns array of '#/components/schemas/repository' + operationRef: '#/paths/~12.0~1repositories~1%7Busername%7D/get' + parameters: + username: $response.body#/username + UserRepositories2: + # returns array of '#/components/schemas/repository' + operationRef: https://na2.gigantic-server.com/#/paths/~12.0~1repositories~1%7Busername%7D/get + parameters: + username: $response.body#/username + # the path item of the linked operation + /users/{userid}/address: + parameters: + - name: userid + in: path + required: true + description: the user identifier, as userId + schema: + type: string + # linked operation + get: + operationId: getUserAddress + responses: + '200': + description: the user's address \ No newline at end of file diff --git a/tests/schema/pass/media-type-examples.yaml b/tests/schema/pass/media-type-examples.yaml new file mode 100644 index 0000000000..061a848b3f --- /dev/null +++ b/tests/schema/pass/media-type-examples.yaml @@ -0,0 +1,97 @@ +# including Encoding Object examples +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +paths: + /something: + put: + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + examples: + cat: + summary: An example of a cat + value: + name: Fluffy + petType: Cat + color: White + gender: male + breed: Persian + dog: + summary: An example of a dog with a cat's name + value: + name: Puma + petType: Dog + color: Black + gender: Female + breed: Mixed + frog: + $ref: '#/components/examples/frog-example' + application/x-www-form-urlencoded: + schema: + type: object + properties: + id: + type: string + format: uuid + address: + # complex types are stringified to support RFC 1866 + type: object + properties: {} + icon: + # The default with "contentEncoding" is application/octet-stream, + # so we need to set image media type(s) in the Encoding Object. + type: string + contentEncoding: base64url + encoding: + icon: + contentType: image/png, image/jpeg + multipart/form-data: + schema: + type: object + properties: + id: + # default is `text/plain` + type: string + format: uuid + addresses: + # default based on the `items` subschema would be + # `application/json`, but we want these address objects + # serialized as `application/xml` instead + description: addresses in XML format + type: array + items: + $ref: '#/components/schemas/Address' + profileImage: + # default is application/octet-stream, but we can declare + # a more specific image type or types + type: string + format: binary + forCoverage: + type: string + forCoverage2: + type: string + encoding: + addresses: + # require XML Content-Type in utf-8 encoding + # This is applied to each address part corresponding + # to each address in he array + contentType: application/xml; charset=utf-8 + profileImage: + # only accept png or jpeg + contentType: image/png, image/jpeg + headers: + X-Rate-Limit-Limit: + description: The number of allowed requests in the current period + schema: + type: integer + forCoverage: + style: form + explode: false + allowReserved: true + forCoverage2: + style: spaceDelimited + explode: true \ No newline at end of file diff --git a/tests/schema/pass/operation-object-example.yaml b/tests/schema/pass/operation-object-example.yaml new file mode 100644 index 0000000000..9a5c76d0a0 --- /dev/null +++ b/tests/schema/pass/operation-object-example.yaml @@ -0,0 +1,47 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +paths: + /pets/{id}: + put: + tags: + - pet + summary: Updates a pet in the store with form data + operationId: updatePetWithForm + parameters: + - name: petId + in: path + description: ID of pet that needs to be updated + required: true + schema: + type: string + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string + required: + - status + responses: + '200': + description: Pet updated. + content: + application/json: {} + application/xml: {} + '405': + description: Method Not Allowed + content: + application/json: {} + application/xml: {} + security: + - petstore_auth: + - write:pets + - read:pets \ No newline at end of file diff --git a/tests/schema/pass/parameter-object-examples.yaml b/tests/schema/pass/parameter-object-examples.yaml new file mode 100644 index 0000000000..fe6a13ea7c --- /dev/null +++ b/tests/schema/pass/parameter-object-examples.yaml @@ -0,0 +1,54 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +paths: + /user/{username}: + parameters: + - name: token + in: header + description: token to be passed as a header + required: true + schema: + type: array + items: + type: integer + format: int64 + style: simple + - name: username + in: path + description: username to fetch + required: true + schema: + type: string + - name: id + in: query + description: ID of the object to fetch + required: false + schema: + type: array + items: + type: string + style: form + explode: true + - in: query + name: freeForm + schema: + type: object + additionalProperties: + type: integer + style: form + - in: query + name: coordinates + content: + application/json: + schema: + type: object + required: + - lat + - long + properties: + lat: + type: number + long: + type: number \ No newline at end of file diff --git a/tests/schema/pass/path-item-object-example.yaml b/tests/schema/pass/path-item-object-example.yaml new file mode 100644 index 0000000000..41a86ec230 --- /dev/null +++ b/tests/schema/pass/path-item-object-example.yaml @@ -0,0 +1,35 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +paths: + /pets/{id}: + get: + description: Returns pets based on ID + summary: Find pets by ID + operationId: getPetsById + responses: + '200': + description: pet response + content: + '*/*': + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + default: + description: error payload + content: + text/html: + schema: + $ref: '#/components/schemas/ErrorModel' + parameters: + - name: id + in: path + description: ID of pet to use + required: true + schema: + type: array + items: + type: string + style: simple \ No newline at end of file diff --git a/tests/schema/pass/paths-object-example.yaml b/tests/schema/pass/paths-object-example.yaml new file mode 100644 index 0000000000..ec56acdb13 --- /dev/null +++ b/tests/schema/pass/paths-object-example.yaml @@ -0,0 +1,17 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +paths: + /pets: + get: + description: Returns all pets from the system that the user has access to + responses: + '200': + description: A list of pets. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/pet' \ No newline at end of file diff --git a/tests/schema/pass/request-body-examples.yaml b/tests/schema/pass/request-body-examples.yaml new file mode 100644 index 0000000000..da1b0056ad --- /dev/null +++ b/tests/schema/pass/request-body-examples.yaml @@ -0,0 +1,34 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +paths: + /something: + put: + requestBody: + description: user to add to the system + content: + application/json: + schema: + $ref: '#/components/schemas/User' + examples: + user: + summary: User example + externalValue: https://foo.bar/examples/user-example.json + application/xml: + schema: + $ref: '#/components/schemas/User' + examples: + user: + summary: User example in XML + externalValue: https://foo.bar/examples/user-example.xml + text/plain: + examples: + user: + summary: User example in plain text + externalValue: https://foo.bar/examples/user-example.txt + '*/*': + examples: + user: + summary: User example in other format + externalValue: https://foo.bar/examples/user-example.whatever \ No newline at end of file diff --git a/tests/schema/pass/response-object-examples.yaml b/tests/schema/pass/response-object-examples.yaml new file mode 100644 index 0000000000..a63e995d48 --- /dev/null +++ b/tests/schema/pass/response-object-examples.yaml @@ -0,0 +1,42 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +components: + responses: + complex-object-array: + description: A complex object array response + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/VeryComplexType' + simple-string: + description: A simple string response + content: + text/plain: + schema: + type: string + plain-text-with-headers: + description: A simple string response + content: + text/plain: + schema: + type: string + example: 'whoa!' + headers: + X-Rate-Limit-Limit: + description: The number of allowed requests in the current period + schema: + type: integer + X-Rate-Limit-Remaining: + description: The number of remaining requests in the current period + schema: + type: integer + X-Rate-Limit-Reset: + description: The number of seconds left in the current period + schema: + type: integer + no-return-value: + description: object created \ No newline at end of file diff --git a/tests/schema/pass/security-scheme-object-examples.yaml b/tests/schema/pass/security-scheme-object-examples.yaml new file mode 100644 index 0000000000..0b0e9900a6 --- /dev/null +++ b/tests/schema/pass/security-scheme-object-examples.yaml @@ -0,0 +1,59 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +security: + - basic: [] + - apiKey: [] + - JWT-bearer: [] + - mutualTLS: [] + - OAuth2: + - write:pets + - read:pets +components: + securitySchemes: + basic: + type: http + scheme: basic + apiKey: + type: apiKey + name: api-key + in: header + JWT-bearer: + type: http + scheme: bearer + bearerFormat: JWT + mutualTLS: + type: mutualTLS + description: Cert must be signed by example.com CA + OAuth2: + type: oauth2 + flows: + implicit: + authorizationUrl: https://example.com/api/oauth/dialog + scopes: + write:pets: modify pets in your account + read:pets: read your pets + refreshUrl: https://example.com/api/oauth/refresh + authorizationCode: + authorizationUrl: https://example.com/api/oauth/dialog + refreshUrl: https://example.com/api/oauth/refresh + tokenUrl: https://example.com/api/oauth/token + scopes: + write:pets: modify pets in your account + read:pets: read your pets + password: + tokenUrl: https://example.com/api/oauth/token + scopes: + read:pets: read your pets + refreshUrl: https://example.com/api/oauth/refresh + clientCredentials: + tokenUrl: https://example.com/api/oauth/token + scopes: + read:pets: read your pets + refreshUrl: https://example.com/api/oauth/refresh + OpenIdConnect: + type: openIdConnect + openIdConnectUrl: https://example.com/api/oauth/openid + external: + $ref: 'https://example.com/api/openapi.json#/components/externalDocs/ThingExternalDocs' \ No newline at end of file diff --git a/tests/schema/pass/servers.yaml b/tests/schema/pass/servers.yaml index 77a20498da..ca68a88b96 100644 --- a/tests/schema/pass/servers.yaml +++ b/tests/schema/pass/servers.yaml @@ -8,3 +8,18 @@ servers: description: Run locally. - url: https://production.com/v1 description: Run on production server. + - url: https://{username}.gigantic-server.com:{port}/{basePath} + description: The production API server + variables: + username: + # note! no enum here means it is an open value + default: demo + description: A user-specific subdomain. Use `demo` for a free sandbox environment. + port: + enum: + - '8443' + - '443' + default: '8443' + basePath: + # open meaning there is the opportunity to use special base paths as assigned by the provider, default is `v2` + default: v2 \ No newline at end of file diff --git a/tests/schema/pass/tag-object-example.yaml b/tests/schema/pass/tag-object-example.yaml new file mode 100644 index 0000000000..aba0c7d7d5 --- /dev/null +++ b/tests/schema/pass/tag-object-example.yaml @@ -0,0 +1,15 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +paths: {} +tags: + + - name: pet + description: Pets operations + + - name: external + description: Operations available to external consumers + externalDocs: + description: Find more info here + url: https://example.com