diff --git a/_archive_/schemas/v3.0/README.md b/_archive_/schemas/v3.0/README.md deleted file mode 100644 index 5bda66cf5a..0000000000 --- a/_archive_/schemas/v3.0/README.md +++ /dev/null @@ -1,43 +0,0 @@ -# OpenAPI 3.0.X JSON Schema - -This directory contains the YAML source for generating the JSON Schema for validating OpenAPI definitions of versions 3.0.X, which is published on [https://spec.openapis.org](https://spec.openapis.org). - -Due to limitations of GitHub pages, the schemas on the spec site are served with `Content-Type: application/octet-stream`, but should be interpreted as `application/schema+json`. - -The source in this directory, which has `WORK-IN-PROGRESS` in its `id`, is _not intended for direct use_. - -## Schema `id` dates - -The published schemas on the spec site have an _iteration date_ in their `id`s. -This allows the schemas for a release line (in this case 3.0) to be updated independent of the spec patch release cycle. - -The iteration version of the JSON Schema can be found in the `id` field. -For example, the value of `id: https://spec.openapis.org/oas/3.0/schema/2019-04-02` means this iteration was created on April 2nd, 2019. - -We are [working on](https://github.com/OAI/OpenAPI-Specification/issues/4152) how to best provide programmatic access for determining the latest date for each schema. - -## Improving the schema - -As a reminder, the JSON Schema is not the source of truth for the Specification. -In cases of conflicts between the Specification itself and the JSON Schema, the Specification wins. -Also, some Specification constraints cannot be represented with the JSON Schema so it's highly recommended to employ other methods to ensure compliance. - -The schema only validates the mandatory aspects of the OAS. -Validating requirements that are optional, or field usage that has undefined or ignored behavior are not within the scope of this schema. -Schemas to perform additional optional validation are [under consideration](https://github.com/OAI/OpenAPI-Specification/issues/4141). - -Improvements can be submitted by opening a PR against the `main` branch. - -Modify the `schema.yaml` file and add test cases for your changes. - -The TSC will then: -- Run tests on the updated schema -- Update the iteration version -- Publish the new version - -The [test suite](../../tests/v3.0) is part of this package. - -```bash -npm install -npm test -``` diff --git a/_archive_/schemas/v3.0/schema.test.mjs b/_archive_/schemas/v3.0/schema.test.mjs deleted file mode 100644 index fd413ed0a5..0000000000 --- a/_archive_/schemas/v3.0/schema.test.mjs +++ /dev/null @@ -1,42 +0,0 @@ -import { readdirSync, readFileSync } from "node:fs"; -import YAML from "yaml"; -import { validate, setMetaSchemaOutputFormat } from "@hyperjump/json-schema/openapi-3-0"; -import { BASIC } from "@hyperjump/json-schema/experimental"; -import { describe, test, expect } from "vitest"; - -import contentTypeParser from "content-type"; -import { addMediaTypePlugin } from "@hyperjump/browser"; -import { buildSchemaDocument } from "@hyperjump/json-schema/experimental"; - -addMediaTypePlugin("application/schema+yaml", { - parse: async (response) => { - const contentType = contentTypeParser.parse(response.headers.get("content-type") ?? ""); - const contextDialectId = contentType.parameters.schema ?? contentType.parameters.profile; - - const foo = YAML.parse(await response.text()); - return buildSchemaDocument(foo, response.url, contextDialectId); - }, - fileMatcher: (path) => path.endsWith(".yaml") - }); - -const parseYamlFromFile = (filePath) => { - const schemaYaml = readFileSync(filePath, "utf8"); - return YAML.parse(schemaYaml, { prettyErrors: true }); -}; - -setMetaSchemaOutputFormat(BASIC); - -const validateOpenApi = await validate("./_archive_/schemas/v3.0/schema.yaml"); -const folder = './_archive_/schemas/v3.0/pass/'; - -describe("pass", async () => { - readdirSync(folder, { withFileTypes: true }) - .filter((entry) => entry.isFile() && /\.yaml$/.test(entry.name)) - .forEach((entry) => { - test(entry.name, () => { - const instance = parseYamlFromFile(folder + entry.name); - const output = validateOpenApi(instance, BASIC); - expect(output.valid).to.equal(true); - }); - }); -}); diff --git a/_archive_/schemas/v3.0/schema.yaml b/_archive_/schemas/v3.0/schema.yaml deleted file mode 100644 index acaf506eb5..0000000000 --- a/_archive_/schemas/v3.0/schema.yaml +++ /dev/null @@ -1,1031 +0,0 @@ -id: https://spec.openapis.org/oas/3.0/schema/WORK-IN-PROGRESS -$schema: http://json-schema.org/draft-04/schema# -description: The description of OpenAPI v3.0.x Documents -type: object -required: - - openapi - - info - - paths -properties: - openapi: - type: string - pattern: ^3\.0\.\d(-.+)?$ - info: - $ref: '#/definitions/Info' - externalDocs: - $ref: '#/definitions/ExternalDocumentation' - servers: - type: array - items: - $ref: '#/definitions/Server' - security: - type: array - items: - $ref: '#/definitions/SecurityRequirement' - tags: - type: array - items: - $ref: '#/definitions/Tag' - uniqueItems: true - paths: - $ref: '#/definitions/Paths' - components: - $ref: '#/definitions/Components' -patternProperties: - '^x-': {} -additionalProperties: false -definitions: - Reference: - type: object - required: - - $ref - patternProperties: - '^\$ref$': - type: string - format: uri-reference - Info: - type: object - required: - - title - - version - properties: - title: - type: string - description: - type: string - termsOfService: - type: string - format: uri-reference - contact: - $ref: '#/definitions/Contact' - license: - $ref: '#/definitions/License' - version: - type: string - patternProperties: - '^x-': {} - additionalProperties: false - - - Contact: - type: object - properties: - name: - type: string - url: - type: string - format: uri-reference - email: - type: string - format: email - patternProperties: - '^x-': {} - additionalProperties: false - - License: - type: object - required: - - name - properties: - name: - type: string - url: - type: string - format: uri-reference - patternProperties: - '^x-': {} - additionalProperties: false - - Server: - type: object - required: - - url - properties: - url: - type: string - description: - type: string - variables: - type: object - additionalProperties: - $ref: '#/definitions/ServerVariable' - patternProperties: - '^x-': {} - additionalProperties: false - - ServerVariable: - type: object - required: - - default - properties: - enum: - type: array - items: - type: string - default: - type: string - description: - type: string - patternProperties: - '^x-': {} - additionalProperties: false - - Components: - type: object - properties: - schemas: - type: object - patternProperties: - '^[a-zA-Z0-9\.\-_]+$': - oneOf: - - $ref: '#/definitions/Schema' - - $ref: '#/definitions/Reference' - responses: - type: object - patternProperties: - '^[a-zA-Z0-9\.\-_]+$': - oneOf: - - $ref: '#/definitions/Reference' - - $ref: '#/definitions/Response' - parameters: - type: object - patternProperties: - '^[a-zA-Z0-9\.\-_]+$': - oneOf: - - $ref: '#/definitions/Reference' - - $ref: '#/definitions/Parameter' - examples: - type: object - patternProperties: - '^[a-zA-Z0-9\.\-_]+$': - oneOf: - - $ref: '#/definitions/Reference' - - $ref: '#/definitions/Example' - requestBodies: - type: object - patternProperties: - '^[a-zA-Z0-9\.\-_]+$': - oneOf: - - $ref: '#/definitions/Reference' - - $ref: '#/definitions/RequestBody' - headers: - type: object - patternProperties: - '^[a-zA-Z0-9\.\-_]+$': - oneOf: - - $ref: '#/definitions/Reference' - - $ref: '#/definitions/Header' - securitySchemes: - type: object - patternProperties: - '^[a-zA-Z0-9\.\-_]+$': - oneOf: - - $ref: '#/definitions/Reference' - - $ref: '#/definitions/SecurityScheme' - links: - type: object - patternProperties: - '^[a-zA-Z0-9\.\-_]+$': - oneOf: - - $ref: '#/definitions/Reference' - - $ref: '#/definitions/Link' - callbacks: - type: object - patternProperties: - '^[a-zA-Z0-9\.\-_]+$': - oneOf: - - $ref: '#/definitions/Reference' - - $ref: '#/definitions/Callback' - patternProperties: - '^x-': {} - additionalProperties: false - - Schema: - type: object - properties: - title: - type: string - multipleOf: - type: number - minimum: 0 - exclusiveMinimum: true - maximum: - type: number - exclusiveMaximum: - type: boolean - default: false - minimum: - type: number - exclusiveMinimum: - type: boolean - default: false - maxLength: - type: integer - minimum: 0 - minLength: - type: integer - minimum: 0 - default: 0 - pattern: - type: string - format: regex - maxItems: - type: integer - minimum: 0 - minItems: - type: integer - minimum: 0 - default: 0 - uniqueItems: - type: boolean - default: false - maxProperties: - type: integer - minimum: 0 - minProperties: - type: integer - minimum: 0 - default: 0 - required: - type: array - items: - type: string - minItems: 1 - uniqueItems: true - enum: - type: array - items: {} - minItems: 1 - uniqueItems: false - type: - type: string - enum: - - array - - boolean - - integer - - number - - object - - string - not: - oneOf: - - $ref: '#/definitions/Schema' - - $ref: '#/definitions/Reference' - allOf: - type: array - items: - oneOf: - - $ref: '#/definitions/Schema' - - $ref: '#/definitions/Reference' - oneOf: - type: array - items: - oneOf: - - $ref: '#/definitions/Schema' - - $ref: '#/definitions/Reference' - anyOf: - type: array - items: - oneOf: - - $ref: '#/definitions/Schema' - - $ref: '#/definitions/Reference' - items: - oneOf: - - $ref: '#/definitions/Schema' - - $ref: '#/definitions/Reference' - properties: - type: object - additionalProperties: - oneOf: - - $ref: '#/definitions/Schema' - - $ref: '#/definitions/Reference' - additionalProperties: - oneOf: - - $ref: '#/definitions/Schema' - - $ref: '#/definitions/Reference' - - type: boolean - default: true - description: - type: string - format: - type: string - default: {} - nullable: - type: boolean - default: false - discriminator: - $ref: '#/definitions/Discriminator' - readOnly: - type: boolean - default: false - writeOnly: - type: boolean - default: false - example: {} - externalDocs: - $ref: '#/definitions/ExternalDocumentation' - deprecated: - type: boolean - default: false - xml: - $ref: '#/definitions/XML' - patternProperties: - '^x-': {} - additionalProperties: false - - Discriminator: - type: object - required: - - propertyName - properties: - propertyName: - type: string - mapping: - type: object - additionalProperties: - type: string - - XML: - type: object - properties: - name: - type: string - namespace: - type: string - format: uri - prefix: - type: string - attribute: - type: boolean - default: false - wrapped: - type: boolean - default: false - patternProperties: - '^x-': {} - additionalProperties: false - - Response: - type: object - required: - - description - properties: - description: - type: string - headers: - type: object - additionalProperties: - oneOf: - - $ref: '#/definitions/Header' - - $ref: '#/definitions/Reference' - content: - type: object - additionalProperties: - $ref: '#/definitions/MediaType' - links: - type: object - additionalProperties: - oneOf: - - $ref: '#/definitions/Link' - - $ref: '#/definitions/Reference' - patternProperties: - '^x-': {} - additionalProperties: false - - MediaType: - type: object - properties: - schema: - oneOf: - - $ref: '#/definitions/Schema' - - $ref: '#/definitions/Reference' - example: {} - examples: - type: object - additionalProperties: - oneOf: - - $ref: '#/definitions/Example' - - $ref: '#/definitions/Reference' - encoding: - type: object - additionalProperties: - $ref: '#/definitions/Encoding' - patternProperties: - '^x-': {} - additionalProperties: false - allOf: - - $ref: '#/definitions/ExampleXORExamples' - - Example: - type: object - properties: - summary: - type: string - description: - type: string - value: {} - externalValue: - type: string - format: uri-reference - patternProperties: - '^x-': {} - additionalProperties: false - - Header: - type: object - properties: - description: - type: string - required: - type: boolean - default: false - deprecated: - type: boolean - default: false - allowEmptyValue: - type: boolean - default: false - style: - type: string - enum: - - simple - default: simple - explode: - type: boolean - allowReserved: - type: boolean - default: false - schema: - oneOf: - - $ref: '#/definitions/Schema' - - $ref: '#/definitions/Reference' - content: - type: object - additionalProperties: - $ref: '#/definitions/MediaType' - minProperties: 1 - maxProperties: 1 - example: {} - examples: - type: object - additionalProperties: - oneOf: - - $ref: '#/definitions/Example' - - $ref: '#/definitions/Reference' - patternProperties: - '^x-': {} - additionalProperties: false - allOf: - - $ref: '#/definitions/ExampleXORExamples' - - $ref: '#/definitions/SchemaXORContent' - - Paths: - type: object - patternProperties: - '^\/': - $ref: '#/definitions/PathItem' - '^x-': {} - additionalProperties: false - - PathItem: - type: object - properties: - $ref: - type: string - summary: - type: string - description: - type: string - get: - $ref: '#/definitions/Operation' - put: - $ref: '#/definitions/Operation' - post: - $ref: '#/definitions/Operation' - delete: - $ref: '#/definitions/Operation' - options: - $ref: '#/definitions/Operation' - head: - $ref: '#/definitions/Operation' - patch: - $ref: '#/definitions/Operation' - trace: - $ref: '#/definitions/Operation' - servers: - type: array - items: - $ref: '#/definitions/Server' - parameters: - type: array - items: - oneOf: - - $ref: '#/definitions/Parameter' - - $ref: '#/definitions/Reference' - uniqueItems: true - patternProperties: - '^x-': {} - additionalProperties: false - - Operation: - type: object - required: - - responses - properties: - tags: - type: array - items: - type: string - summary: - type: string - description: - type: string - externalDocs: - $ref: '#/definitions/ExternalDocumentation' - operationId: - type: string - parameters: - type: array - items: - oneOf: - - $ref: '#/definitions/Parameter' - - $ref: '#/definitions/Reference' - uniqueItems: true - requestBody: - oneOf: - - $ref: '#/definitions/RequestBody' - - $ref: '#/definitions/Reference' - responses: - $ref: '#/definitions/Responses' - callbacks: - type: object - additionalProperties: - oneOf: - - $ref: '#/definitions/Callback' - - $ref: '#/definitions/Reference' - deprecated: - type: boolean - default: false - security: - type: array - items: - $ref: '#/definitions/SecurityRequirement' - servers: - type: array - items: - $ref: '#/definitions/Server' - patternProperties: - '^x-': {} - additionalProperties: false - - Responses: - type: object - properties: - default: - oneOf: - - $ref: '#/definitions/Response' - - $ref: '#/definitions/Reference' - patternProperties: - '^[1-5](?:\d{2}|XX)$': - oneOf: - - $ref: '#/definitions/Response' - - $ref: '#/definitions/Reference' - '^x-': {} - minProperties: 1 - additionalProperties: false - - - SecurityRequirement: - type: object - additionalProperties: - type: array - items: - type: string - - Tag: - type: object - required: - - name - properties: - name: - type: string - description: - type: string - externalDocs: - $ref: '#/definitions/ExternalDocumentation' - patternProperties: - '^x-': {} - additionalProperties: false - - ExternalDocumentation: - type: object - required: - - url - properties: - description: - type: string - url: - type: string - format: uri-reference - patternProperties: - '^x-': {} - additionalProperties: false - - ExampleXORExamples: - description: Example and examples are mutually exclusive - not: - required: [example, examples] - - SchemaXORContent: - description: Schema and content are mutually exclusive, at least one is required - not: - required: [schema, content] - oneOf: - - required: [schema] - - required: [content] - description: Some properties are not allowed if content is present - allOf: - - not: - required: [style] - - not: - required: [explode] - - not: - required: [allowReserved] - - not: - required: [example] - - not: - required: [examples] - - Parameter: - type: object - properties: - name: - type: string - in: - type: string - description: - type: string - required: - type: boolean - default: false - deprecated: - type: boolean - default: false - allowEmptyValue: - type: boolean - default: false - style: - type: string - explode: - type: boolean - allowReserved: - type: boolean - default: false - schema: - oneOf: - - $ref: '#/definitions/Schema' - - $ref: '#/definitions/Reference' - content: - type: object - additionalProperties: - $ref: '#/definitions/MediaType' - minProperties: 1 - maxProperties: 1 - example: {} - examples: - type: object - additionalProperties: - oneOf: - - $ref: '#/definitions/Example' - - $ref: '#/definitions/Reference' - patternProperties: - '^x-': {} - additionalProperties: false - required: - - name - - in - allOf: - - $ref: '#/definitions/ExampleXORExamples' - - $ref: '#/definitions/SchemaXORContent' - oneOf: - - $ref: '#/definitions/PathParameter' - - $ref: '#/definitions/QueryParameter' - - $ref: '#/definitions/HeaderParameter' - - $ref: '#/definitions/CookieParameter' - - PathParameter: - description: Parameter in path - required: - - required - properties: - in: - enum: [path] - style: - enum: [matrix, label, simple] - default: simple - required: - enum: [true] - - QueryParameter: - description: Parameter in query - properties: - in: - enum: [query] - style: - enum: [form, spaceDelimited, pipeDelimited, deepObject] - default: form - - HeaderParameter: - description: Parameter in header - properties: - in: - enum: [header] - style: - enum: [simple] - default: simple - - CookieParameter: - description: Parameter in cookie - properties: - in: - enum: [cookie] - style: - enum: [form] - default: form - - RequestBody: - type: object - required: - - content - properties: - description: - type: string - content: - type: object - additionalProperties: - $ref: '#/definitions/MediaType' - required: - type: boolean - default: false - patternProperties: - '^x-': {} - additionalProperties: false - - SecurityScheme: - oneOf: - - $ref: '#/definitions/APIKeySecurityScheme' - - $ref: '#/definitions/HTTPSecurityScheme' - - $ref: '#/definitions/OAuth2SecurityScheme' - - $ref: '#/definitions/OpenIdConnectSecurityScheme' - - APIKeySecurityScheme: - type: object - required: - - type - - name - - in - properties: - type: - type: string - enum: - - apiKey - name: - type: string - in: - type: string - enum: - - header - - query - - cookie - description: - type: string - patternProperties: - '^x-': {} - additionalProperties: false - - HTTPSecurityScheme: - type: object - required: - - scheme - - type - properties: - scheme: - type: string - bearerFormat: - type: string - description: - type: string - type: - type: string - enum: - - http - patternProperties: - '^x-': {} - additionalProperties: false - oneOf: - - description: Bearer - properties: - scheme: - type: string - pattern: ^[Bb][Ee][Aa][Rr][Ee][Rr]$ - - - description: Non Bearer - not: - required: [bearerFormat] - properties: - scheme: - not: - type: string - pattern: ^[Bb][Ee][Aa][Rr][Ee][Rr]$ - - OAuth2SecurityScheme: - type: object - required: - - type - - flows - properties: - type: - type: string - enum: - - oauth2 - flows: - $ref: '#/definitions/OAuthFlows' - description: - type: string - patternProperties: - '^x-': {} - additionalProperties: false - - OpenIdConnectSecurityScheme: - type: object - required: - - type - - openIdConnectUrl - properties: - type: - type: string - enum: - - openIdConnect - openIdConnectUrl: - type: string - format: uri-reference - description: - type: string - patternProperties: - '^x-': {} - additionalProperties: false - - OAuthFlows: - type: object - properties: - implicit: - $ref: '#/definitions/ImplicitOAuthFlow' - password: - $ref: '#/definitions/PasswordOAuthFlow' - clientCredentials: - $ref: '#/definitions/ClientCredentialsFlow' - authorizationCode: - $ref: '#/definitions/AuthorizationCodeOAuthFlow' - patternProperties: - '^x-': {} - additionalProperties: false - - ImplicitOAuthFlow: - type: object - required: - - authorizationUrl - - scopes - properties: - authorizationUrl: - type: string - format: uri-reference - refreshUrl: - type: string - format: uri-reference - scopes: - type: object - additionalProperties: - type: string - patternProperties: - '^x-': {} - additionalProperties: false - - PasswordOAuthFlow: - type: object - required: - - tokenUrl - - scopes - properties: - tokenUrl: - type: string - format: uri-reference - refreshUrl: - type: string - format: uri-reference - scopes: - type: object - additionalProperties: - type: string - patternProperties: - '^x-': {} - additionalProperties: false - - ClientCredentialsFlow: - type: object - required: - - tokenUrl - - scopes - properties: - tokenUrl: - type: string - format: uri-reference - refreshUrl: - type: string - format: uri-reference - scopes: - type: object - additionalProperties: - type: string - patternProperties: - '^x-': {} - additionalProperties: false - - AuthorizationCodeOAuthFlow: - type: object - required: - - authorizationUrl - - tokenUrl - - scopes - properties: - authorizationUrl: - type: string - format: uri-reference - tokenUrl: - type: string - format: uri-reference - refreshUrl: - type: string - format: uri-reference - scopes: - type: object - additionalProperties: - type: string - patternProperties: - '^x-': {} - additionalProperties: false - - Link: - type: object - properties: - operationId: - type: string - operationRef: - type: string - format: uri-reference - parameters: - type: object - additionalProperties: {} - requestBody: {} - description: - type: string - server: - $ref: '#/definitions/Server' - patternProperties: - '^x-': {} - additionalProperties: false - not: - description: Operation Id and Operation Ref are mutually exclusive - required: [operationId, operationRef] - - Callback: - type: object - additionalProperties: - $ref: '#/definitions/PathItem' - patternProperties: - '^x-': {} - - Encoding: - type: object - properties: - contentType: - type: string - headers: - type: object - additionalProperties: - oneOf: - - $ref: '#/definitions/Header' - - $ref: '#/definitions/Reference' - style: - type: string - enum: - - form - - spaceDelimited - - pipeDelimited - - deepObject - explode: - type: boolean - allowReserved: - type: boolean - default: false - patternProperties: - '^x-': {} - additionalProperties: false diff --git a/src/schemas/validation/README.md b/src/schemas/validation/README.md index 57501dfc51..5bda66cf5a 100644 --- a/src/schemas/validation/README.md +++ b/src/schemas/validation/README.md @@ -1,58 +1,32 @@ -# OpenAPI 3.X.Y JSON Schema +# OpenAPI 3.0.X JSON Schema -This directory contains the YAML sources for generating the JSON Schemas for validating OpenAPI definitions of versions 3.X.Y, which are published on [https://spec.openapis.org](https://spec.openapis.org). +This directory contains the YAML source for generating the JSON Schema for validating OpenAPI definitions of versions 3.0.X, which is published on [https://spec.openapis.org](https://spec.openapis.org). Due to limitations of GitHub pages, the schemas on the spec site are served with `Content-Type: application/octet-stream`, but should be interpreted as `application/schema+json`. -The sources in this directory, which have `WORK-IN-PROGRESS` in their `$id`s, are _not intended for direct use_. +The source in this directory, which has `WORK-IN-PROGRESS` in its `id`, is _not intended for direct use_. -## Schema `$id` dates +## Schema `id` dates The published schemas on the spec site have an _iteration date_ in their `id`s. -This allows the schemas for a release line to be updated independent of the spec patch release cycle. +This allows the schemas for a release line (in this case 3.0) to be updated independent of the spec patch release cycle. -The iteration version of the JSON Schema can be found in the `$id` field. -For example, the value of `$id: https://spec.openapis.org/oas/3.1/schema/2021-03-02` means this iteration was created on March 2nd, 2021. +The iteration version of the JSON Schema can be found in the `id` field. +For example, the value of `id: https://spec.openapis.org/oas/3.0/schema/2019-04-02` means this iteration was created on April 2nd, 2019. We are [working on](https://github.com/OAI/OpenAPI-Specification/issues/4152) how to best provide programmatic access for determining the latest date for each schema. -## Choosing which schema to use +## Improving the schema -There are two schemas to choose from for versions 3.1 and greater, both of which have an `$id` that starts with `https://spec.openapis.org/oas/3.X/` and ends with the iteration date: - -* `https://spec.openapis.org/oas/3.X/schema/{date}`, source: `schema.yaml` — A self-contained schema that _does not_ validate Schema Objects beyond `type: [object, boolean]` -* `https://spec.openapis.org/oas/3.1/schema-base/{date}`, source: `schema-base.yaml` — A schema that combines the self-contained schema and the "base" dialect schema to validate Schema Objects with the dialect; this schema does not allow changing `$schema` or `jsonSchemaDialect` to other dialects - -Two metaschemas define the OAS "base" dialect: - -* `https://spec.openapis.org/oas/3.X/meta/{date}`, source: `meta.yaml` — The vocabulary metaschema for OAS 3.X's extensions to draft 2020-12 -* `https://spec.openapis.org/oas/3.X/dialect/{date}`, source: `dialect.yaml` — The dialect metaschema that extends the standard `draft/2020-12` metaschema by adding the OAS "base" vocabulary - -The name "base" for the dialect was intended to indicate that the OAS dialect could be further extended. - -~~~mermaid -flowchart LR - schema_base - schema - dialect - meta - schema --> |default| dialect - schema_base --> |$ref| schema - schema_base --> |$ref| dialect - dialect --> |$ref| meta -~~~ - -An additional schema that validates the Schema Object with the OAS 3.X dialect but does not restrict changing `$schema` is [under consideration](https://github.com/OAI/OpenAPI-Specification/issues/4147). - -## Improving the schemas - -As a reminder, the JSON Schema is not the source of truth for the Specification. In cases of conflicts between the Specification itself and the JSON Schema, the Specification wins. Also, some Specification constraints cannot be represented with the JSON Schema so it's highly recommended to employ other methods to ensure compliance. +As a reminder, the JSON Schema is not the source of truth for the Specification. +In cases of conflicts between the Specification itself and the JSON Schema, the Specification wins. +Also, some Specification constraints cannot be represented with the JSON Schema so it's highly recommended to employ other methods to ensure compliance. The schema only validates the mandatory aspects of the OAS. Validating requirements that are optional, or field usage that has undefined or ignored behavior are not within the scope of this schema. Schemas to perform additional optional validation are [under consideration](https://github.com/OAI/OpenAPI-Specification/issues/4141). -Improvements can be submitted by opening a PR against the `vX.Y-dev` branch of the respective specification version. +Improvements can be submitted by opening a PR against the `main` branch. Modify the `schema.yaml` file and add test cases for your changes. @@ -61,7 +35,7 @@ The TSC will then: - Update the iteration version - Publish the new version -The [test suite](../../../tests/schema) is part of this package. +The [test suite](../../tests/v3.0) is part of this package. ```bash npm install diff --git a/src/schemas/validation/dialect.yaml b/src/schemas/validation/dialect.yaml deleted file mode 100644 index d300d94feb..0000000000 --- a/src/schemas/validation/dialect.yaml +++ /dev/null @@ -1,21 +0,0 @@ -$id: https://spec.openapis.org/oas/3.1/dialect/WORK-IN-PROGRESS -$schema: https://json-schema.org/draft/2020-12/schema - -title: OpenAPI 3.1 Schema Object Dialect -description: A JSON Schema dialect describing schemas found in OpenAPI v3.1 Descriptions - -$dynamicAnchor: meta - -$vocabulary: - https://json-schema.org/draft/2020-12/vocab/applicator: true - https://json-schema.org/draft/2020-12/vocab/content: true - https://json-schema.org/draft/2020-12/vocab/core: true - https://json-schema.org/draft/2020-12/vocab/format-annotation: true - https://json-schema.org/draft/2020-12/vocab/meta-data: true - https://json-schema.org/draft/2020-12/vocab/unevaluated: true - https://json-schema.org/draft/2020-12/vocab/validation: true - https://spec.openapis.org/oas/3.1/vocab/base: false - -allOf: - - $ref: https://json-schema.org/draft/2020-12/schema - - $ref: https://spec.openapis.org/oas/3.1/meta/WORK-IN-PROGRESS diff --git a/src/schemas/validation/meta.yaml b/src/schemas/validation/meta.yaml deleted file mode 100644 index 6cfce4976d..0000000000 --- a/src/schemas/validation/meta.yaml +++ /dev/null @@ -1,70 +0,0 @@ -$id: https://spec.openapis.org/oas/3.1/meta/WORK-IN-PROGRESS -$schema: https://json-schema.org/draft/2020-12/schema - -title: OAS Base Vocabulary -description: A JSON Schema Vocabulary used in the OpenAPI Schema Dialect - -$dynamicAnchor: meta - -$vocabulary: - https://spec.openapis.org/oas/3.1/vocab/base: true - -type: - - object - - boolean -properties: - discriminator: - $ref: '#/$defs/discriminator' - example: true - externalDocs: - $ref: '#/$defs/external-docs' - xml: - $ref: '#/$defs/xml' - -$defs: - discriminator: - $ref: '#/$defs/extensible' - properties: - mapping: - additionalProperties: - type: string - type: object - propertyName: - type: string - required: - - propertyName - type: object - unevaluatedProperties: false - - extensible: - patternProperties: - ^x-: true - external-docs: - $ref: '#/$defs/extensible' - properties: - description: - type: string - url: - format: uri-reference - type: string - required: - - url - type: object - unevaluatedProperties: false - - xml: - $ref: '#/$defs/extensible' - properties: - attribute: - type: boolean - name: - type: string - namespace: - format: uri - type: string - prefix: - type: string - wrapped: - type: boolean - type: object - unevaluatedProperties: false diff --git a/src/schemas/validation/schema-base.yaml b/src/schemas/validation/schema-base.yaml deleted file mode 100644 index ea239c03e9..0000000000 --- a/src/schemas/validation/schema-base.yaml +++ /dev/null @@ -1,20 +0,0 @@ -$id: 'https://spec.openapis.org/oas/3.1/schema-base/WORK-IN-PROGRESS' -$schema: 'https://json-schema.org/draft/2020-12/schema' - -description: The description of OpenAPI v3.1.x Documents using the OpenAPI JSON Schema dialect - -$ref: 'https://spec.openapis.org/oas/3.1/schema/WORK-IN-PROGRESS' -properties: - jsonSchemaDialect: - $ref: '#/$defs/dialect' - -$defs: - dialect: - const: 'https://spec.openapis.org/oas/3.1/dialect/WORK-IN-PROGRESS' - - schema: - $dynamicAnchor: meta - $ref: 'https://spec.openapis.org/oas/3.1/dialect/WORK-IN-PROGRESS' - properties: - $schema: - $ref: '#/$defs/dialect' diff --git a/src/schemas/validation/schema.yaml b/src/schemas/validation/schema.yaml index 54c49a2f97..5cf4a7a913 100644 --- a/src/schemas/validation/schema.yaml +++ b/src/schemas/validation/schema.yaml @@ -1,121 +1,105 @@ -$id: 'https://spec.openapis.org/oas/3.1/schema/WORK-IN-PROGRESS' -$schema: 'https://json-schema.org/draft/2020-12/schema' - -description: The description of OpenAPI v3.1.x Documents without Schema Object validation - +id: https://spec.openapis.org/oas/3.0/schema/WORK-IN-PROGRESS +$schema: http://json-schema.org/draft-04/schema# +description: The description of OpenAPI v3.0.x Documents type: object +required: + - openapi + - info + - paths properties: openapi: type: string - pattern: '^3\.1\.\d+(-.+)?$' + pattern: ^3\.0\.\d(-.+)?$ info: - $ref: '#/$defs/info' - jsonSchemaDialect: - type: string - format: uri - default: 'https://spec.openapis.org/oas/3.1/dialect/WORK-IN-PROGRESS' + $ref: '#/definitions/Info' + externalDocs: + $ref: '#/definitions/ExternalDocumentation' servers: type: array items: - $ref: '#/$defs/server' - default: - - url: / - paths: - $ref: '#/$defs/paths' - webhooks: - type: object - additionalProperties: - $ref: '#/$defs/path-item' - components: - $ref: '#/$defs/components' + $ref: '#/definitions/Server' security: type: array items: - $ref: '#/$defs/security-requirement' + $ref: '#/definitions/SecurityRequirement' tags: type: array items: - $ref: '#/$defs/tag' - externalDocs: - $ref: '#/$defs/external-documentation' -required: - - openapi - - info -anyOf: - - required: - - paths - - required: - - components - - required: - - webhooks -$ref: '#/$defs/specification-extensions' -unevaluatedProperties: false - -$defs: - info: - $comment: https://spec.openapis.org/oas/v3.1#info-object + $ref: '#/definitions/Tag' + uniqueItems: true + paths: + $ref: '#/definitions/Paths' + components: + $ref: '#/definitions/Components' +patternProperties: + '^x-': {} +additionalProperties: false +definitions: + Reference: + type: object + required: + - $ref + patternProperties: + '^\$ref$': + type: string + format: uri-reference + Info: type: object + required: + - title + - version properties: title: type: string - summary: - type: string description: type: string termsOfService: type: string - format: uri + format: uri-reference contact: - $ref: '#/$defs/contact' + $ref: '#/definitions/Contact' license: - $ref: '#/$defs/license' + $ref: '#/definitions/License' version: type: string - required: - - title - - version - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false + patternProperties: + '^x-': {} + additionalProperties: false - contact: - $comment: https://spec.openapis.org/oas/v3.1#contact-object + + Contact: type: object properties: name: type: string url: type: string - format: uri + format: uri-reference email: type: string format: email - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false + patternProperties: + '^x-': {} + additionalProperties: false - license: - $comment: https://spec.openapis.org/oas/v3.1#license-object + License: type: object + required: + - name properties: name: type: string - identifier: - type: string url: type: string - format: uri - required: - - name - dependentSchemas: - identifier: - not: - required: - - url - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false + format: uri-reference + patternProperties: + '^x-': {} + additionalProperties: false - server: - $comment: https://spec.openapis.org/oas/v3.1#server-object + Server: type: object + required: + - url properties: url: type: string @@ -124,132 +108,437 @@ $defs: variables: type: object additionalProperties: - $ref: '#/$defs/server-variable' - required: - - url - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false + $ref: '#/definitions/ServerVariable' + patternProperties: + '^x-': {} + additionalProperties: false - server-variable: - $comment: https://spec.openapis.org/oas/v3.1#server-variable-object + ServerVariable: type: object + required: + - default properties: enum: type: array items: type: string - minItems: 1 default: type: string description: type: string - required: - - default - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false + patternProperties: + '^x-': {} + additionalProperties: false - components: - $comment: https://spec.openapis.org/oas/v3.1#components-object + Components: type: object properties: schemas: type: object - additionalProperties: - $dynamicRef: '#meta' + patternProperties: + '^[a-zA-Z0-9\.\-_]+$': + oneOf: + - $ref: '#/definitions/Schema' + - $ref: '#/definitions/Reference' + additionalProperties: false responses: type: object - additionalProperties: - $ref: '#/$defs/response-or-reference' + patternProperties: + '^[a-zA-Z0-9\.\-_]+$': + oneOf: + - $ref: '#/definitions/Reference' + - $ref: '#/definitions/Response' + additionalProperties: false parameters: type: object - additionalProperties: - $ref: '#/$defs/parameter-or-reference' + patternProperties: + '^[a-zA-Z0-9\.\-_]+$': + oneOf: + - $ref: '#/definitions/Reference' + - $ref: '#/definitions/Parameter' + additionalProperties: false examples: type: object - additionalProperties: - $ref: '#/$defs/example-or-reference' + patternProperties: + '^[a-zA-Z0-9\.\-_]+$': + oneOf: + - $ref: '#/definitions/Reference' + - $ref: '#/definitions/Example' + additionalProperties: false requestBodies: + type: object + patternProperties: + '^[a-zA-Z0-9\.\-_]+$': + oneOf: + - $ref: '#/definitions/Reference' + - $ref: '#/definitions/RequestBody' + additionalProperties: false + headers: + type: object + patternProperties: + '^[a-zA-Z0-9\.\-_]+$': + oneOf: + - $ref: '#/definitions/Reference' + - $ref: '#/definitions/Header' + additionalProperties: false + securitySchemes: + type: object + patternProperties: + '^[a-zA-Z0-9\.\-_]+$': + oneOf: + - $ref: '#/definitions/Reference' + - $ref: '#/definitions/SecurityScheme' + additionalProperties: false + links: + type: object + patternProperties: + '^[a-zA-Z0-9\.\-_]+$': + oneOf: + - $ref: '#/definitions/Reference' + - $ref: '#/definitions/Link' + additionalProperties: false + callbacks: + type: object + patternProperties: + '^[a-zA-Z0-9\.\-_]+$': + oneOf: + - $ref: '#/definitions/Reference' + - $ref: '#/definitions/Callback' + additionalProperties: false + patternProperties: + '^x-': {} + additionalProperties: false + + Schema: + type: object + properties: + title: + type: string + multipleOf: + type: number + minimum: 0 + exclusiveMinimum: true + maximum: + type: number + exclusiveMaximum: + type: boolean + default: false + minimum: + type: number + exclusiveMinimum: + type: boolean + default: false + maxLength: + type: integer + minimum: 0 + minLength: + type: integer + minimum: 0 + default: 0 + pattern: + type: string + format: regex + maxItems: + type: integer + minimum: 0 + minItems: + type: integer + minimum: 0 + default: 0 + uniqueItems: + type: boolean + default: false + maxProperties: + type: integer + minimum: 0 + minProperties: + type: integer + minimum: 0 + default: 0 + required: + type: array + items: + type: string + minItems: 1 + uniqueItems: true + enum: + type: array + items: {} + minItems: 1 + uniqueItems: false + type: + type: string + enum: + - array + - boolean + - integer + - number + - object + - string + not: + oneOf: + - $ref: '#/definitions/Schema' + - $ref: '#/definitions/Reference' + allOf: + type: array + items: + oneOf: + - $ref: '#/definitions/Schema' + - $ref: '#/definitions/Reference' + oneOf: + type: array + items: + oneOf: + - $ref: '#/definitions/Schema' + - $ref: '#/definitions/Reference' + anyOf: + type: array + items: + oneOf: + - $ref: '#/definitions/Schema' + - $ref: '#/definitions/Reference' + items: + oneOf: + - $ref: '#/definitions/Schema' + - $ref: '#/definitions/Reference' + properties: + type: object + additionalProperties: + oneOf: + - $ref: '#/definitions/Schema' + - $ref: '#/definitions/Reference' + additionalProperties: + oneOf: + - $ref: '#/definitions/Schema' + - $ref: '#/definitions/Reference' + - type: boolean + default: true + description: + type: string + format: + type: string + default: {} + nullable: + type: boolean + default: false + discriminator: + $ref: '#/definitions/Discriminator' + readOnly: + type: boolean + default: false + writeOnly: + type: boolean + default: false + example: {} + externalDocs: + $ref: '#/definitions/ExternalDocumentation' + deprecated: + type: boolean + default: false + xml: + $ref: '#/definitions/XML' + patternProperties: + '^x-': {} + additionalProperties: false + + Discriminator: + type: object + required: + - propertyName + properties: + propertyName: + type: string + mapping: type: object additionalProperties: - $ref: '#/$defs/request-body-or-reference' + type: string + + XML: + type: object + properties: + name: + type: string + namespace: + type: string + format: uri + prefix: + type: string + attribute: + type: boolean + default: false + wrapped: + type: boolean + default: false + patternProperties: + '^x-': {} + additionalProperties: false + + Response: + type: object + required: + - description + properties: + description: + type: string headers: type: object additionalProperties: - $ref: '#/$defs/header-or-reference' - securitySchemes: + oneOf: + - $ref: '#/definitions/Header' + - $ref: '#/definitions/Reference' + content: type: object additionalProperties: - $ref: '#/$defs/security-scheme-or-reference' + $ref: '#/definitions/MediaType' links: type: object additionalProperties: - $ref: '#/$defs/link-or-reference' - callbacks: + oneOf: + - $ref: '#/definitions/Link' + - $ref: '#/definitions/Reference' + patternProperties: + '^x-': {} + additionalProperties: false + + MediaType: + type: object + properties: + schema: + oneOf: + - $ref: '#/definitions/Schema' + - $ref: '#/definitions/Reference' + example: {} + examples: type: object additionalProperties: - $ref: '#/$defs/callbacks-or-reference' - pathItems: + oneOf: + - $ref: '#/definitions/Example' + - $ref: '#/definitions/Reference' + encoding: type: object additionalProperties: - $ref: '#/$defs/path-item' + $ref: '#/definitions/Encoding' patternProperties: - '^(schemas|responses|parameters|examples|requestBodies|headers|securitySchemes|links|callbacks|pathItems)$': - $comment: Enumerating all of the property names in the regex above is necessary for unevaluatedProperties to work as expected - propertyNames: - pattern: '^[a-zA-Z0-9._-]+$' - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false + '^x-': {} + additionalProperties: false + allOf: + - $ref: '#/definitions/ExampleXORExamples' - paths: - $comment: https://spec.openapis.org/oas/v3.1#paths-object + Example: + type: object + properties: + summary: + type: string + description: + type: string + value: {} + externalValue: + type: string + format: uri-reference + patternProperties: + '^x-': {} + additionalProperties: false + + Header: + type: object + properties: + description: + type: string + required: + type: boolean + default: false + deprecated: + type: boolean + default: false + allowEmptyValue: + type: boolean + default: false + style: + type: string + enum: + - simple + default: simple + explode: + type: boolean + allowReserved: + type: boolean + default: false + schema: + oneOf: + - $ref: '#/definitions/Schema' + - $ref: '#/definitions/Reference' + content: + type: object + additionalProperties: + $ref: '#/definitions/MediaType' + minProperties: 1 + maxProperties: 1 + example: {} + examples: + type: object + additionalProperties: + oneOf: + - $ref: '#/definitions/Example' + - $ref: '#/definitions/Reference' + patternProperties: + '^x-': {} + additionalProperties: false + allOf: + - $ref: '#/definitions/ExampleXORExamples' + - $ref: '#/definitions/SchemaXORContent' + + Paths: type: object patternProperties: - '^/': - $ref: '#/$defs/path-item' - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false + '^\/': + $ref: '#/definitions/PathItem' + '^x-': {} + additionalProperties: false - path-item: - $comment: https://spec.openapis.org/oas/v3.1#path-item-object + PathItem: type: object properties: $ref: type: string - format: uri-reference summary: type: string description: type: string - servers: - type: array - items: - $ref: '#/$defs/server' - parameters: - type: array - items: - $ref: '#/$defs/parameter-or-reference' get: - $ref: '#/$defs/operation' + $ref: '#/definitions/Operation' put: - $ref: '#/$defs/operation' + $ref: '#/definitions/Operation' post: - $ref: '#/$defs/operation' + $ref: '#/definitions/Operation' delete: - $ref: '#/$defs/operation' + $ref: '#/definitions/Operation' options: - $ref: '#/$defs/operation' + $ref: '#/definitions/Operation' head: - $ref: '#/$defs/operation' + $ref: '#/definitions/Operation' patch: - $ref: '#/$defs/operation' + $ref: '#/definitions/Operation' trace: - $ref: '#/$defs/operation' - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false + $ref: '#/definitions/Operation' + servers: + type: array + items: + $ref: '#/definitions/Server' + parameters: + type: array + items: + oneOf: + - $ref: '#/definitions/Parameter' + - $ref: '#/definitions/Reference' + uniqueItems: true + patternProperties: + '^x-': {} + additionalProperties: false - operation: - $comment: https://spec.openapis.org/oas/v3.1#operation-object + Operation: type: object + required: + - responses properties: tags: type: array @@ -260,715 +549,492 @@ $defs: description: type: string externalDocs: - $ref: '#/$defs/external-documentation' + $ref: '#/definitions/ExternalDocumentation' operationId: type: string parameters: type: array items: - $ref: '#/$defs/parameter-or-reference' + oneOf: + - $ref: '#/definitions/Parameter' + - $ref: '#/definitions/Reference' + uniqueItems: true requestBody: - $ref: '#/$defs/request-body-or-reference' + oneOf: + - $ref: '#/definitions/RequestBody' + - $ref: '#/definitions/Reference' responses: - $ref: '#/$defs/responses' + $ref: '#/definitions/Responses' callbacks: type: object additionalProperties: - $ref: '#/$defs/callbacks-or-reference' + oneOf: + - $ref: '#/definitions/Callback' + - $ref: '#/definitions/Reference' deprecated: - default: false type: boolean + default: false security: type: array items: - $ref: '#/$defs/security-requirement' + $ref: '#/definitions/SecurityRequirement' servers: type: array items: - $ref: '#/$defs/server' - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false + $ref: '#/definitions/Server' + patternProperties: + '^x-': {} + additionalProperties: false - external-documentation: - $comment: https://spec.openapis.org/oas/v3.1#external-documentation-object + Responses: type: object properties: - description: + default: + oneOf: + - $ref: '#/definitions/Response' + - $ref: '#/definitions/Reference' + patternProperties: + '^[1-5](?:\d{2}|XX)$': + oneOf: + - $ref: '#/definitions/Response' + - $ref: '#/definitions/Reference' + '^x-': {} + minProperties: 1 + additionalProperties: false + + + SecurityRequirement: + type: object + additionalProperties: + type: array + items: type: string - url: + + Tag: + type: object + required: + - name + properties: + name: type: string - format: uri + description: + type: string + externalDocs: + $ref: '#/definitions/ExternalDocumentation' + patternProperties: + '^x-': {} + additionalProperties: false + + ExternalDocumentation: + type: object required: - url - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false + properties: + description: + type: string + url: + type: string + format: uri-reference + patternProperties: + '^x-': {} + additionalProperties: false + + ExampleXORExamples: + description: Example and examples are mutually exclusive + not: + required: [example, examples] + + SchemaXORContent: + description: Schema and content are mutually exclusive, at least one is required + not: + required: [schema, content] + oneOf: + - required: [schema] + - required: [content] + description: Some properties are not allowed if content is present + allOf: + - not: + required: [style] + - not: + required: [explode] + - not: + required: [allowReserved] + - not: + required: [example] + - not: + required: [examples] - parameter: - $comment: https://spec.openapis.org/oas/v3.1#parameter-object + Parameter: type: object properties: name: type: string in: - enum: - - query - - header - - path - - cookie + type: string description: type: string required: - default: false type: boolean + default: false deprecated: + type: boolean default: false + allowEmptyValue: type: boolean + default: false + style: + type: string + explode: + type: boolean + allowReserved: + type: boolean + default: false schema: - $dynamicRef: '#meta' + oneOf: + - $ref: '#/definitions/Schema' + - $ref: '#/definitions/Reference' content: - $ref: '#/$defs/content' + type: object + additionalProperties: + $ref: '#/definitions/MediaType' minProperties: 1 maxProperties: 1 + example: {} + examples: + type: object + additionalProperties: + oneOf: + - $ref: '#/definitions/Example' + - $ref: '#/definitions/Reference' + patternProperties: + '^x-': {} + additionalProperties: false required: - name - in + allOf: + - $ref: '#/definitions/ExampleXORExamples' + - $ref: '#/definitions/SchemaXORContent' oneOf: - - required: - - schema - - required: - - content - if: - properties: - in: - const: query - required: - - in - then: - properties: - allowEmptyValue: - default: false - type: boolean - dependentSchemas: - schema: - properties: - style: - type: string - explode: - type: boolean - allOf: - - $ref: '#/$defs/examples' - - $ref: '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-path' - - $ref: '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-header' - - $ref: '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-query' - - $ref: '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-cookie' - - $ref: '#/$defs/styles-for-form' - - $defs: - styles-for-path: - if: - properties: - in: - const: path - required: - - in - then: - properties: - style: - default: simple - enum: - - matrix - - label - - simple - required: - const: true - required: - - required - - styles-for-header: - if: - properties: - in: - const: header - required: - - in - then: - properties: - style: - default: simple - const: simple - - styles-for-query: - if: - properties: - in: - const: query - required: - - in - then: - properties: - style: - default: form - enum: - - form - - spaceDelimited - - pipeDelimited - - deepObject - allowReserved: - default: false - type: boolean - - styles-for-cookie: - if: - properties: - in: - const: cookie - required: - - in - then: - properties: - style: - default: form - const: form - - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - parameter-or-reference: - if: - type: object - required: - - $ref - then: - $ref: '#/$defs/reference' - else: - $ref: '#/$defs/parameter' + - $ref: '#/definitions/PathParameter' + - $ref: '#/definitions/QueryParameter' + - $ref: '#/definitions/HeaderParameter' + - $ref: '#/definitions/CookieParameter' - request-body: - $comment: https://spec.openapis.org/oas/v3.1#request-body-object - type: object - properties: - description: - type: string - content: - $ref: '#/$defs/content' - required: - default: false - type: boolean + PathParameter: + description: Parameter in path required: - - content - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - request-body-or-reference: - if: - type: object + - required + properties: + in: + enum: [path] + style: + enum: [matrix, label, simple] + default: simple required: - - $ref - then: - $ref: '#/$defs/reference' - else: - $ref: '#/$defs/request-body' + enum: [true] - content: - $comment: https://spec.openapis.org/oas/v3.1#fixed-fields-10 - type: object - additionalProperties: - $ref: '#/$defs/media-type' - propertyNames: - format: media-range - - media-type: - $comment: https://spec.openapis.org/oas/v3.1#media-type-object - type: object + QueryParameter: + description: Parameter in query properties: - schema: - $dynamicRef: '#meta' - encoding: - type: object - additionalProperties: - $ref: '#/$defs/encoding' - allOf: - - $ref: '#/$defs/specification-extensions' - - $ref: '#/$defs/examples' - unevaluatedProperties: false + in: + enum: [query] + style: + enum: [form, spaceDelimited, pipeDelimited, deepObject] + default: form - encoding: - $comment: https://spec.openapis.org/oas/v3.1#encoding-object - type: object + HeaderParameter: + description: Parameter in header properties: - contentType: - type: string - format: media-range - headers: - type: object - additionalProperties: - $ref: '#/$defs/header-or-reference' + in: + enum: [header] style: - default: form - enum: - - form - - spaceDelimited - - pipeDelimited - - deepObject - explode: - type: boolean - allowReserved: - default: false - type: boolean - allOf: - - $ref: '#/$defs/specification-extensions' - - $ref: '#/$defs/styles-for-form' - unevaluatedProperties: false + enum: [simple] + default: simple - responses: - $comment: https://spec.openapis.org/oas/v3.1#responses-object - type: object + CookieParameter: + description: Parameter in cookie properties: - default: - $ref: '#/$defs/response-or-reference' - patternProperties: - '^[1-5](?:[0-9]{2}|XX)$': - $ref: '#/$defs/response-or-reference' - minProperties: 1 - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - if: - $comment: either default, or at least one response code property must exist - patternProperties: - '^[1-5](?:[0-9]{2}|XX)$': false - then: - required: [default] + in: + enum: [cookie] + style: + enum: [form] + default: form - response: - $comment: https://spec.openapis.org/oas/v3.1#response-object + RequestBody: type: object + required: + - content properties: description: type: string - headers: - type: object - additionalProperties: - $ref: '#/$defs/header-or-reference' content: - $ref: '#/$defs/content' - links: type: object additionalProperties: - $ref: '#/$defs/link-or-reference' - required: - - description - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - response-or-reference: - if: - type: object + $ref: '#/definitions/MediaType' required: - - $ref - then: - $ref: '#/$defs/reference' - else: - $ref: '#/$defs/response' - - callbacks: - $comment: https://spec.openapis.org/oas/v3.1#callback-object - type: object - $ref: '#/$defs/specification-extensions' - additionalProperties: - $ref: '#/$defs/path-item' + type: boolean + default: false + patternProperties: + '^x-': {} + additionalProperties: false - callbacks-or-reference: - if: - type: object - required: - - $ref - then: - $ref: '#/$defs/reference' - else: - $ref: '#/$defs/callbacks' + SecurityScheme: + oneOf: + - $ref: '#/definitions/APIKeySecurityScheme' + - $ref: '#/definitions/HTTPSecurityScheme' + - $ref: '#/definitions/OAuth2SecurityScheme' + - $ref: '#/definitions/OpenIdConnectSecurityScheme' - example: - $comment: https://spec.openapis.org/oas/v3.1#example-object + APIKeySecurityScheme: type: object + required: + - type + - name + - in properties: - summary: + type: type: string - description: + enum: + - apiKey + name: type: string - value: true - externalValue: + in: type: string - format: uri - not: - required: - - value - - externalValue - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - example-or-reference: - if: - type: object - required: - - $ref - then: - $ref: '#/$defs/reference' - else: - $ref: '#/$defs/example' + enum: + - header + - query + - cookie + description: + type: string + patternProperties: + '^x-': {} + additionalProperties: false - link: - $comment: https://spec.openapis.org/oas/v3.1#link-object + HTTPSecurityScheme: type: object + required: + - scheme + - type properties: - operationRef: + scheme: type: string - format: uri-reference - operationId: + bearerFormat: type: string - parameters: - $ref: '#/$defs/map-of-strings' - requestBody: true description: type: string - body: - $ref: '#/$defs/server' - oneOf: - - required: - - operationRef - - required: - - operationId - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - link-or-reference: - if: - type: object - required: - - $ref - then: - $ref: '#/$defs/reference' - else: - $ref: '#/$defs/link' - - header: - $comment: https://spec.openapis.org/oas/v3.1#header-object - type: object - properties: - description: + type: type: string - required: - default: false - type: boolean - deprecated: - default: false - type: boolean - schema: - $dynamicRef: '#meta' - content: - $ref: '#/$defs/content' - minProperties: 1 - maxProperties: 1 + enum: + - http + patternProperties: + '^x-': {} + additionalProperties: false oneOf: - - required: - - schema - - required: - - content - dependentSchemas: - schema: + - description: Bearer properties: - style: - default: simple - const: simple - explode: - default: false - type: boolean - $ref: '#/$defs/examples' - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - header-or-reference: - if: - type: object - required: - - $ref - then: - $ref: '#/$defs/reference' - else: - $ref: '#/$defs/header' + scheme: + type: string + pattern: ^[Bb][Ee][Aa][Rr][Ee][Rr]$ - tag: - $comment: https://spec.openapis.org/oas/v3.1#tag-object - type: object - properties: - name: - type: string - description: - type: string - externalDocs: - $ref: '#/$defs/external-documentation' - required: - - name - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false + - description: Non Bearer + not: + required: [bearerFormat] + properties: + scheme: + not: + type: string + pattern: ^[Bb][Ee][Aa][Rr][Ee][Rr]$ - reference: - $comment: https://spec.openapis.org/oas/v3.1#reference-object + OAuth2SecurityScheme: type: object + required: + - type + - flows properties: - $ref: - type: string - format: uri-reference - summary: + type: type: string + enum: + - oauth2 + flows: + $ref: '#/definitions/OAuthFlows' description: type: string + patternProperties: + '^x-': {} + additionalProperties: false - schema: - $comment: https://spec.openapis.org/oas/v3.1#schema-object - $dynamicAnchor: meta - type: - - object - - boolean - - security-scheme: - $comment: https://spec.openapis.org/oas/v3.1#security-scheme-object + OpenIdConnectSecurityScheme: type: object + required: + - type + - openIdConnectUrl properties: type: + type: string enum: - - apiKey - - http - - mutualTLS - - oauth2 - openIdConnect + openIdConnectUrl: + type: string + format: uri-reference description: type: string - required: - - type - allOf: - - $ref: '#/$defs/specification-extensions' - - $ref: '#/$defs/security-scheme/$defs/type-apikey' - - $ref: '#/$defs/security-scheme/$defs/type-http' - - $ref: '#/$defs/security-scheme/$defs/type-http-bearer' - - $ref: '#/$defs/security-scheme/$defs/type-oauth2' - - $ref: '#/$defs/security-scheme/$defs/type-oidc' - unevaluatedProperties: false - - $defs: - type-apikey: - if: - properties: - type: - const: apiKey - required: - - type - then: - properties: - name: - type: string - in: - enum: - - query - - header - - cookie - required: - - name - - in - - type-http: - if: - properties: - type: - const: http - required: - - type - then: - properties: - scheme: - type: string - required: - - scheme - - type-http-bearer: - if: - properties: - type: - const: http - scheme: - type: string - pattern: ^[Bb][Ee][Aa][Rr][Ee][Rr]$ - required: - - type - - scheme - then: - properties: - bearerFormat: - type: string - - type-oauth2: - if: - properties: - type: - const: oauth2 - required: - - type - then: - properties: - flows: - $ref: '#/$defs/oauth-flows' - required: - - flows - - type-oidc: - if: - properties: - type: - const: openIdConnect - required: - - type - then: - properties: - openIdConnectUrl: - type: string - format: uri - required: - - openIdConnectUrl - - security-scheme-or-reference: - if: - type: object - required: - - $ref - then: - $ref: '#/$defs/reference' - else: - $ref: '#/$defs/security-scheme' + patternProperties: + '^x-': {} + additionalProperties: false - oauth-flows: + OAuthFlows: type: object properties: implicit: - $ref: '#/$defs/oauth-flows/$defs/implicit' + $ref: '#/definitions/ImplicitOAuthFlow' password: - $ref: '#/$defs/oauth-flows/$defs/password' + $ref: '#/definitions/PasswordOAuthFlow' clientCredentials: - $ref: '#/$defs/oauth-flows/$defs/client-credentials' + $ref: '#/definitions/ClientCredentialsFlow' authorizationCode: - $ref: '#/$defs/oauth-flows/$defs/authorization-code' - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false + $ref: '#/definitions/AuthorizationCodeOAuthFlow' + patternProperties: + '^x-': {} + additionalProperties: false - $defs: - implicit: + ImplicitOAuthFlow: + type: object + required: + - authorizationUrl + - scopes + properties: + authorizationUrl: + type: string + format: uri-reference + refreshUrl: + type: string + format: uri-reference + scopes: type: object - properties: - authorizationUrl: - type: string - format: uri - refreshUrl: - type: string - format: uri - scopes: - $ref: '#/$defs/map-of-strings' - required: - - authorizationUrl - - scopes - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false + additionalProperties: + type: string + patternProperties: + '^x-': {} + additionalProperties: false - password: - type: object - properties: - tokenUrl: - type: string - format: uri - refreshUrl: - type: string - format: uri - scopes: - $ref: '#/$defs/map-of-strings' - required: - - tokenUrl - - scopes - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - client-credentials: - type: object - properties: - tokenUrl: - type: string - format: uri - refreshUrl: - type: string - format: uri - scopes: - $ref: '#/$defs/map-of-strings' - required: - - tokenUrl - - scopes - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - authorization-code: - type: object - properties: - authorizationUrl: - type: string - format: uri - tokenUrl: - type: string - format: uri - refreshUrl: - type: string - format: uri - scopes: - $ref: '#/$defs/map-of-strings' - required: - - authorizationUrl - - tokenUrl - - scopes - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - security-requirement: - $comment: https://spec.openapis.org/oas/v3.1#security-requirement-object + PasswordOAuthFlow: type: object - additionalProperties: - type: array - items: + required: + - tokenUrl + - scopes + properties: + tokenUrl: type: string + format: uri-reference + refreshUrl: + type: string + format: uri-reference + scopes: + type: object + additionalProperties: + type: string + patternProperties: + '^x-': {} + additionalProperties: false - specification-extensions: - $comment: https://spec.openapis.org/oas/v3.1#specification-extensions + ClientCredentialsFlow: + type: object + required: + - tokenUrl + - scopes + properties: + tokenUrl: + type: string + format: uri-reference + refreshUrl: + type: string + format: uri-reference + scopes: + type: object + additionalProperties: + type: string patternProperties: - '^x-': true + '^x-': {} + additionalProperties: false - examples: + AuthorizationCodeOAuthFlow: + type: object + required: + - authorizationUrl + - tokenUrl + - scopes properties: - example: true - examples: + authorizationUrl: + type: string + format: uri-reference + tokenUrl: + type: string + format: uri-reference + refreshUrl: + type: string + format: uri-reference + scopes: type: object additionalProperties: - $ref: '#/$defs/example-or-reference' + type: string + patternProperties: + '^x-': {} + additionalProperties: false + + Link: + type: object + properties: + operationId: + type: string + operationRef: + type: string + format: uri-reference + parameters: + type: object + additionalProperties: {} + requestBody: {} + description: + type: string + server: + $ref: '#/definitions/Server' + patternProperties: + '^x-': {} + additionalProperties: false + not: + description: Operation Id and Operation Ref are mutually exclusive + required: [operationId, operationRef] - map-of-strings: + Callback: type: object additionalProperties: - type: string + $ref: '#/definitions/PathItem' + patternProperties: + '^x-': {} - styles-for-form: - if: - properties: - style: - const: form - required: - - style - then: - properties: - explode: - default: true - else: - properties: - explode: - default: false + Encoding: + type: object + properties: + contentType: + type: string + headers: + type: object + additionalProperties: + oneOf: + - $ref: '#/definitions/Header' + - $ref: '#/definitions/Reference' + style: + type: string + enum: + - form + - spaceDelimited + - pipeDelimited + - deepObject + explode: + type: boolean + allowReserved: + type: boolean + default: false + patternProperties: + '^x-': {} + additionalProperties: false diff --git a/tests/schema/fail/invalid_schema_types.yaml b/tests/schema/fail/invalid_schema_types.yaml deleted file mode 100644 index d295b1f0ed..0000000000 --- a/tests/schema/fail/invalid_schema_types.yaml +++ /dev/null @@ -1,13 +0,0 @@ -openapi: 3.1.1 - -# this example shows invalid types for the schemaObject - -info: - title: API - version: 1.0.0 -components: - schemas: - invalid_null: null - invalid_number: 0 - invalid_array: [] - diff --git a/tests/schema/fail/no_containers.yaml b/tests/schema/fail/no_containers.yaml deleted file mode 100644 index c158bcb2b6..0000000000 --- a/tests/schema/fail/no_containers.yaml +++ /dev/null @@ -1,7 +0,0 @@ -openapi: 3.1.0 - -# this example should fail as there are no paths, components or webhooks containers (at least one of which must be present) - -info: - title: API - version: 1.0.0 diff --git a/tests/schema/fail/server_enum_empty.yaml b/tests/schema/fail/server_enum_empty.yaml deleted file mode 100644 index cd6d30eb3e..0000000000 --- a/tests/schema/fail/server_enum_empty.yaml +++ /dev/null @@ -1,14 +0,0 @@ -openapi: 3.1.0 - -# this example should fail as the server variable enum is empty, and so does not contain the default value - -info: - title: API - version: 1.0.0 -servers: - - url: https://example.com/{var} - variables: - var: - enum: [] - default: a -components: {} diff --git a/tests/schema/fail/servers.yaml b/tests/schema/fail/servers.yaml deleted file mode 100644 index 1470fe1ec8..0000000000 --- a/tests/schema/fail/servers.yaml +++ /dev/null @@ -1,11 +0,0 @@ -openapi: 3.1.0 - -# this example should fail, as servers must be an array, not an object - -info: - title: API - version: 1.0.0 -paths: {} -servers: - url: /v1 - description: Run locally. diff --git a/tests/schema/fail/unknown_container.yaml b/tests/schema/fail/unknown_container.yaml deleted file mode 100644 index 7f31e86053..0000000000 --- a/tests/schema/fail/unknown_container.yaml +++ /dev/null @@ -1,8 +0,0 @@ -openapi: 3.1.0 - -# this example should fail as overlays is not a valid top-level object/keyword - -info: - title: API - version: 1.0.0 -overlays: {} diff --git a/_archive_/schemas/v3.0/pass/api-with-examples.yaml b/tests/schema/pass/api-with-examples.yaml similarity index 100% rename from _archive_/schemas/v3.0/pass/api-with-examples.yaml rename to tests/schema/pass/api-with-examples.yaml diff --git a/_archive_/schemas/v3.0/pass/callback-example.yaml b/tests/schema/pass/callback-example.yaml similarity index 100% rename from _archive_/schemas/v3.0/pass/callback-example.yaml rename to tests/schema/pass/callback-example.yaml diff --git a/tests/schema/pass/comp_pathitems.yaml b/tests/schema/pass/comp_pathitems.yaml deleted file mode 100644 index 502ca1fca2..0000000000 --- a/tests/schema/pass/comp_pathitems.yaml +++ /dev/null @@ -1,6 +0,0 @@ -openapi: 3.1.0 -info: - title: API - version: 1.0.0 -components: - pathItems: {} diff --git a/tests/schema/pass/info_summary.yaml b/tests/schema/pass/info_summary.yaml deleted file mode 100644 index 30d224afc2..0000000000 --- a/tests/schema/pass/info_summary.yaml +++ /dev/null @@ -1,6 +0,0 @@ -openapi: 3.1.0 -info: - title: API - summary: My lovely API - version: 1.0.0 -components: {} diff --git a/tests/schema/pass/json_schema_dialect.yaml b/tests/schema/pass/json_schema_dialect.yaml deleted file mode 100644 index ae0ed863b3..0000000000 --- a/tests/schema/pass/json_schema_dialect.yaml +++ /dev/null @@ -1,15 +0,0 @@ -openapi: 3.1.0 -info: - summary: Testing jsonSchemaDialect - title: My API - version: 1.0.0 - license: - name: Apache 2.0 - identifier: Apache-2.0 -jsonSchemaDialect: https://spec.openapis.org/oas/3.1/dialect/WORK-IN-PROGRESS -components: - schemas: - WithDollarSchema: - $id: "locked-metaschema" - $schema: https://spec.openapis.org/oas/3.1/dialect/WORK-IN-PROGRESS -paths: {} diff --git a/tests/schema/pass/license_identifier.yaml b/tests/schema/pass/license_identifier.yaml deleted file mode 100644 index fbdba5efbe..0000000000 --- a/tests/schema/pass/license_identifier.yaml +++ /dev/null @@ -1,9 +0,0 @@ -openapi: 3.1.0 -info: - title: API - summary: My lovely API - version: 1.0.0 - license: - name: Apache - identifier: Apache-2.0 -components: {} diff --git a/_archive_/schemas/v3.0/pass/link-example.yaml b/tests/schema/pass/link-example.yaml similarity index 100% rename from _archive_/schemas/v3.0/pass/link-example.yaml rename to tests/schema/pass/link-example.yaml diff --git a/tests/schema/pass/mega.yaml b/tests/schema/pass/mega.yaml deleted file mode 100644 index 98ce577dce..0000000000 --- a/tests/schema/pass/mega.yaml +++ /dev/null @@ -1,48 +0,0 @@ -openapi: 3.1.0 -info: - summary: My API's summary - title: My API - version: 1.0.0 - license: - name: Apache 2.0 - identifier: Apache-2.0 -paths: - /: - get: - parameters: [] - /{pathTest}: {} -webhooks: - myWebhook: - $ref: '#/components/pathItems/myPathItem' - description: Overriding description -components: - securitySchemes: - mtls: - type: mutualTLS - pathItems: - myPathItem: - post: - requestBody: - required: true - content: - 'application/json': - schema: - type: object - properties: - type: - type: string - int: - type: integer - exclusiveMaximum: 100 - exclusiveMinimum: 0 - none: - type: 'null' - arr: - type: array - $comment: Array without items keyword - either: - type: ['string','null'] - discriminator: - propertyName: type - x-extension: true - myArbitraryKeyword: true diff --git a/tests/schema/pass/minimal_comp.yaml b/tests/schema/pass/minimal_comp.yaml deleted file mode 100644 index 4553689ab4..0000000000 --- a/tests/schema/pass/minimal_comp.yaml +++ /dev/null @@ -1,5 +0,0 @@ -openapi: 3.1.0 -info: - title: API - version: 1.0.0 -components: {} diff --git a/tests/schema/pass/minimal_hooks.yaml b/tests/schema/pass/minimal_hooks.yaml deleted file mode 100644 index e67b2889de..0000000000 --- a/tests/schema/pass/minimal_hooks.yaml +++ /dev/null @@ -1,5 +0,0 @@ -openapi: 3.1.0 -info: - title: API - version: 1.0.0 -webhooks: {} diff --git a/tests/schema/pass/minimal_paths.yaml b/tests/schema/pass/minimal_paths.yaml deleted file mode 100644 index 016e86796f..0000000000 --- a/tests/schema/pass/minimal_paths.yaml +++ /dev/null @@ -1,5 +0,0 @@ -openapi: 3.1.0 -info: - title: API - version: 1.0.0 -paths: {} diff --git a/tests/schema/pass/non-oauth-scopes.yaml b/tests/schema/pass/non-oauth-scopes.yaml deleted file mode 100644 index e757452f38..0000000000 --- a/tests/schema/pass/non-oauth-scopes.yaml +++ /dev/null @@ -1,19 +0,0 @@ -openapi: 3.1.0 -info: - title: Non-oAuth Scopes example - version: 1.0.0 -paths: - /users: - get: - security: - - bearerAuth: - - 'read:users' - - 'public' -components: - securitySchemes: - bearerAuth: - type: http - scheme: bearer - bearerFormat: jwt - description: 'note: non-oauth scopes are not defined at the securityScheme level' - diff --git a/tests/schema/pass/path_no_response.yaml b/tests/schema/pass/path_no_response.yaml deleted file mode 100644 index 334608f111..0000000000 --- a/tests/schema/pass/path_no_response.yaml +++ /dev/null @@ -1,7 +0,0 @@ -openapi: 3.1.0 -info: - title: API - version: 1.0.0 -paths: - /: - get: {} diff --git a/tests/schema/pass/path_var_empty_pathitem.yaml b/tests/schema/pass/path_var_empty_pathitem.yaml deleted file mode 100644 index ba92742f10..0000000000 --- a/tests/schema/pass/path_var_empty_pathitem.yaml +++ /dev/null @@ -1,6 +0,0 @@ -openapi: 3.1.0 -info: - title: API - version: 1.0.0 -paths: - /{var}: {} diff --git a/_archive_/schemas/v3.0/pass/petstore-expanded.yaml b/tests/schema/pass/petstore-expanded.yaml similarity index 100% rename from _archive_/schemas/v3.0/pass/petstore-expanded.yaml rename to tests/schema/pass/petstore-expanded.yaml diff --git a/_archive_/schemas/v3.0/pass/petstore.yaml b/tests/schema/pass/petstore.yaml similarity index 100% rename from _archive_/schemas/v3.0/pass/petstore.yaml rename to tests/schema/pass/petstore.yaml diff --git a/tests/schema/pass/schema.yaml b/tests/schema/pass/schema.yaml deleted file mode 100644 index e192529a68..0000000000 --- a/tests/schema/pass/schema.yaml +++ /dev/null @@ -1,55 +0,0 @@ -openapi: 3.1.0 -info: - title: API - version: 1.0.0 -paths: {} -components: - schemas: - model: - type: object - properties: - one: - description: type array - type: - - integer - - string - two: - description: type 'null' - type: "null" - three: - description: type array including 'null' - type: - - string - - "null" - four: - description: array with no items - type: array - five: - description: singular example - type: string - examples: - - exampleValue - six: - description: exclusiveMinimum true - exclusiveMinimum: 10 - seven: - description: exclusiveMinimum false - minimum: 10 - eight: - description: exclusiveMaximum true - exclusiveMaximum: 20 - nine: - description: exclusiveMaximum false - maximum: 20 - ten: - description: nullable string - type: - - string - - "null" - eleven: - description: x-nullable string - type: - - string - - "null" - twelve: - description: file/binary diff --git a/tests/schema/pass/servers.yaml b/tests/schema/pass/servers.yaml deleted file mode 100644 index 77a20498da..0000000000 --- a/tests/schema/pass/servers.yaml +++ /dev/null @@ -1,10 +0,0 @@ -openapi: 3.1.0 -info: - title: API - version: 1.0.0 -paths: {} -servers: - - url: /v1 - description: Run locally. - - url: https://production.com/v1 - description: Run on production server. diff --git a/_archive_/schemas/v3.0/pass/uspto.yaml b/tests/schema/pass/uspto.yaml similarity index 100% rename from _archive_/schemas/v3.0/pass/uspto.yaml rename to tests/schema/pass/uspto.yaml diff --git a/tests/schema/pass/valid_schema_types.yaml b/tests/schema/pass/valid_schema_types.yaml deleted file mode 100644 index 4431adcda5..0000000000 --- a/tests/schema/pass/valid_schema_types.yaml +++ /dev/null @@ -1,14 +0,0 @@ -openapi: 3.1.1 - -# this example shows that top-level schemaObjects MAY be booleans - -info: - title: API - version: 1.0.0 -components: - schemas: - anything_boolean: true - nothing_boolean: false - anything_object: {} - nothing_object: { not: {} } - diff --git a/tests/schema/pass/webhook-example.yaml b/tests/schema/pass/webhook-example.yaml deleted file mode 100644 index 2ac1cda985..0000000000 --- a/tests/schema/pass/webhook-example.yaml +++ /dev/null @@ -1,35 +0,0 @@ -openapi: 3.1.0 -info: - title: Webhook Example - version: 1.0.0 -# Since OAS 3.1.0 the paths element isn't necessary. Now a valid OpenAPI Document can describe only paths, webhooks, or even only reusable components -webhooks: - # Each webhook needs a name - newPet: - # This is a Path Item Object, the only difference is that the request is initiated by the API provider - post: - requestBody: - description: Information about a new pet in the system - content: - application/json: - schema: - $ref: "#/components/schemas/Pet" - responses: - "200": - description: Return a 200 status to indicate that the data was received successfully - -components: - schemas: - Pet: - required: - - id - - name - properties: - id: - type: integer - format: int64 - name: - type: string - tag: - type: string - diff --git a/tests/schema/schema.test.mjs b/tests/schema/schema.test.mjs index e7b84f0a74..fd413ed0a5 100644 --- a/tests/schema/schema.test.mjs +++ b/tests/schema/schema.test.mjs @@ -1,38 +1,42 @@ import { readdirSync, readFileSync } from "node:fs"; import YAML from "yaml"; +import { validate, setMetaSchemaOutputFormat } from "@hyperjump/json-schema/openapi-3-0"; +import { BASIC } from "@hyperjump/json-schema/experimental"; import { describe, test, expect } from "vitest"; -import { registerSchema } from "@hyperjump/json-schema-coverage/vitest"; -import registerOasSchema from "./oas-schema.mjs"; + +import contentTypeParser from "content-type"; +import { addMediaTypePlugin } from "@hyperjump/browser"; +import { buildSchemaDocument } from "@hyperjump/json-schema/experimental"; + +addMediaTypePlugin("application/schema+yaml", { + parse: async (response) => { + const contentType = contentTypeParser.parse(response.headers.get("content-type") ?? ""); + const contextDialectId = contentType.parameters.schema ?? contentType.parameters.profile; + + const foo = YAML.parse(await response.text()); + return buildSchemaDocument(foo, response.url, contextDialectId); + }, + fileMatcher: (path) => path.endsWith(".yaml") + }); const parseYamlFromFile = (filePath) => { - const schemaYaml = readFileSync(filePath, "utf8"); - return YAML.parse(schemaYaml, { prettyErrors: true }); + const schemaYaml = readFileSync(filePath, "utf8"); + return YAML.parse(schemaYaml, { prettyErrors: true }); }; -await registerOasSchema(); -await registerSchema("./src/schemas/validation/schema.yaml"); -const fixtures = './tests/schema'; +setMetaSchemaOutputFormat(BASIC); -describe("v3.1", () => { - describe("Pass", () => { - readdirSync(`${fixtures}/pass`, { withFileTypes: true }) - .filter((entry) => entry.isFile() && /\.yaml$/.test(entry.name)) - .forEach((entry) => { - test(entry.name, async () => { - const instance = parseYamlFromFile(`${fixtures}/pass/${entry.name}`); - await expect(instance).to.matchJsonSchema("./src/schemas/validation/schema-base.yaml"); - }); - }); - }); +const validateOpenApi = await validate("./_archive_/schemas/v3.0/schema.yaml"); +const folder = './_archive_/schemas/v3.0/pass/'; - describe("Fail", () => { - readdirSync(`${fixtures}/fail`, { withFileTypes: true }) - .filter((entry) => entry.isFile() && /\.yaml$/.test(entry.name)) - .forEach((entry) => { - test(entry.name, async () => { - const instance = parseYamlFromFile(`${fixtures}/fail/${entry.name}`); - await expect(instance).to.not.matchJsonSchema("./src/schemas/validation/schema-base.yaml"); +describe("pass", async () => { + readdirSync(folder, { withFileTypes: true }) + .filter((entry) => entry.isFile() && /\.yaml$/.test(entry.name)) + .forEach((entry) => { + test(entry.name, () => { + const instance = parseYamlFromFile(folder + entry.name); + const output = validateOpenApi(instance, BASIC); + expect(output.valid).to.equal(true); + }); }); - }); - }); });