From cb37ec78d088430b51fb6610257b2534701c6133 Mon Sep 17 00:00:00 2001 From: Ralf Handl Date: Thu, 13 Mar 2025 20:28:56 +0100 Subject: [PATCH 1/4] Move old schemas to _archive_ Update schema-test-coverage.sh --- .gitignore | 2 +- _archive_/schemas/README.md | 9 + {schemas => _archive_/schemas}/v1.2/README.md | 0 .../schemas}/v1.2/apiDeclaration.json | 0 .../schemas}/v1.2/authorizationObject.json | 0 .../schemas}/v1.2/dataType.json | 0 .../schemas}/v1.2/dataTypeBase.json | 0 .../schemas}/v1.2/infoObject.json | 0 .../schemas}/v1.2/modelsObject.json | 0 .../schemas}/v1.2/oauth2GrantType.json | 0 .../schemas}/v1.2/operationObject.json | 0 .../schemas}/v1.2/parameterObject.json | 0 .../schemas}/v1.2/resourceListing.json | 0 .../schemas}/v1.2/resourceObject.json | 0 {schemas => _archive_/schemas}/v2.0/README.md | 0 .../schemas}/v2.0/schema.json | 0 {schemas => _archive_/schemas}/v3.0/README.md | 0 .../schemas}/v3.0/pass/api-with-examples.yaml | 0 .../schemas}/v3.0/pass/callback-example.yaml | 0 .../schemas}/v3.0/pass/link-example.yaml | 0 .../schemas}/v3.0/pass/petstore-expanded.yaml | 0 .../schemas}/v3.0/pass/petstore.yaml | 0 .../schemas}/v3.0/pass/uspto.yaml | 0 .../schemas}/v3.0/schema.test.mjs | 0 .../schemas}/v3.0/schema.yaml | 0 schemas/v3.1/README.md | 54 - schemas/v3.1/dialect.yaml | 21 - schemas/v3.1/meta.yaml | 70 -- schemas/v3.1/schema-base.yaml | 20 - schemas/v3.1/schema.yaml | 974 ------------------ scripts/schema-test-coverage.sh | 11 +- tests/v3.1/fail/invalid_schema_types.yaml | 13 - tests/v3.1/fail/no_containers.yaml | 7 - tests/v3.1/fail/server_enum_empty.yaml | 14 - tests/v3.1/fail/servers.yaml | 11 - tests/v3.1/fail/unknown_container.yaml | 8 - tests/v3.1/pass/comp_pathitems.yaml | 6 - tests/v3.1/pass/info_summary.yaml | 6 - tests/v3.1/pass/license_identifier.yaml | 9 - tests/v3.1/pass/mega.yaml | 49 - tests/v3.1/pass/minimal_comp.yaml | 5 - tests/v3.1/pass/minimal_hooks.yaml | 5 - tests/v3.1/pass/minimal_paths.yaml | 5 - tests/v3.1/pass/non-oauth-scopes.yaml | 19 - tests/v3.1/pass/path_no_response.yaml | 7 - tests/v3.1/pass/path_var_empty_pathitem.yaml | 6 - tests/v3.1/pass/schema.yaml | 55 - tests/v3.1/pass/servers.yaml | 10 - tests/v3.1/pass/valid_schema_types.yaml | 14 - tests/v3.1/pass/webhook-example.yaml | 35 - tests/v3.1/schema.test.mjs | 55 - vitest.config.mjs | 1 + 52 files changed, 14 insertions(+), 1487 deletions(-) create mode 100644 _archive_/schemas/README.md rename {schemas => _archive_/schemas}/v1.2/README.md (100%) rename {schemas => _archive_/schemas}/v1.2/apiDeclaration.json (100%) rename {schemas => _archive_/schemas}/v1.2/authorizationObject.json (100%) rename {schemas => _archive_/schemas}/v1.2/dataType.json (100%) rename {schemas => _archive_/schemas}/v1.2/dataTypeBase.json (100%) rename {schemas => _archive_/schemas}/v1.2/infoObject.json (100%) rename {schemas => _archive_/schemas}/v1.2/modelsObject.json (100%) rename {schemas => _archive_/schemas}/v1.2/oauth2GrantType.json (100%) rename {schemas => _archive_/schemas}/v1.2/operationObject.json (100%) rename {schemas => _archive_/schemas}/v1.2/parameterObject.json (100%) rename {schemas => _archive_/schemas}/v1.2/resourceListing.json (100%) rename {schemas => _archive_/schemas}/v1.2/resourceObject.json (100%) rename {schemas => _archive_/schemas}/v2.0/README.md (100%) rename {schemas => _archive_/schemas}/v2.0/schema.json (100%) rename {schemas => _archive_/schemas}/v3.0/README.md (100%) rename {tests => _archive_/schemas}/v3.0/pass/api-with-examples.yaml (100%) rename {tests => _archive_/schemas}/v3.0/pass/callback-example.yaml (100%) rename {tests => _archive_/schemas}/v3.0/pass/link-example.yaml (100%) rename {tests => _archive_/schemas}/v3.0/pass/petstore-expanded.yaml (100%) rename {tests => _archive_/schemas}/v3.0/pass/petstore.yaml (100%) rename {tests => _archive_/schemas}/v3.0/pass/uspto.yaml (100%) rename {tests => _archive_/schemas}/v3.0/schema.test.mjs (100%) rename {schemas => _archive_/schemas}/v3.0/schema.yaml (100%) delete mode 100644 schemas/v3.1/README.md delete mode 100644 schemas/v3.1/dialect.yaml delete mode 100644 schemas/v3.1/meta.yaml delete mode 100644 schemas/v3.1/schema-base.yaml delete mode 100644 schemas/v3.1/schema.yaml delete mode 100644 tests/v3.1/fail/invalid_schema_types.yaml delete mode 100644 tests/v3.1/fail/no_containers.yaml delete mode 100644 tests/v3.1/fail/server_enum_empty.yaml delete mode 100644 tests/v3.1/fail/servers.yaml delete mode 100644 tests/v3.1/fail/unknown_container.yaml delete mode 100644 tests/v3.1/pass/comp_pathitems.yaml delete mode 100644 tests/v3.1/pass/info_summary.yaml delete mode 100644 tests/v3.1/pass/license_identifier.yaml delete mode 100644 tests/v3.1/pass/mega.yaml delete mode 100644 tests/v3.1/pass/minimal_comp.yaml delete mode 100644 tests/v3.1/pass/minimal_hooks.yaml delete mode 100644 tests/v3.1/pass/minimal_paths.yaml delete mode 100644 tests/v3.1/pass/non-oauth-scopes.yaml delete mode 100644 tests/v3.1/pass/path_no_response.yaml delete mode 100644 tests/v3.1/pass/path_var_empty_pathitem.yaml delete mode 100644 tests/v3.1/pass/schema.yaml delete mode 100644 tests/v3.1/pass/servers.yaml delete mode 100644 tests/v3.1/pass/valid_schema_types.yaml delete mode 100644 tests/v3.1/pass/webhook-example.yaml delete mode 100644 tests/v3.1/schema.test.mjs diff --git a/.gitignore b/.gitignore index f3ff4ab93f..0bbd5a8cb8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,5 @@ node_modules/ deploy/ deploy-preview/ coverage/ -history +_site/ Gemfile.lock diff --git a/_archive_/schemas/README.md b/_archive_/schemas/README.md new file mode 100644 index 0000000000..78d9c18db0 --- /dev/null +++ b/_archive_/schemas/README.md @@ -0,0 +1,9 @@ +# Archive of outdated JSON Schema Files + +> [!TIP] +> JSON Schema files for validating OpenAPI descriptions using current OpenAPI versions are available on https://spec.openapis.org/#openapi-specification-schemas. +> +> These schema files are maintained in the `src/schemas` folder of the corresponding `vX.Y-dev` branch in this repository. + +> [!CAUTION] +> Schema files in this folder are not maintained any more and are not intended for productive use. diff --git a/schemas/v1.2/README.md b/_archive_/schemas/v1.2/README.md similarity index 100% rename from schemas/v1.2/README.md rename to _archive_/schemas/v1.2/README.md diff --git a/schemas/v1.2/apiDeclaration.json b/_archive_/schemas/v1.2/apiDeclaration.json similarity index 100% rename from schemas/v1.2/apiDeclaration.json rename to _archive_/schemas/v1.2/apiDeclaration.json diff --git a/schemas/v1.2/authorizationObject.json b/_archive_/schemas/v1.2/authorizationObject.json similarity index 100% rename from schemas/v1.2/authorizationObject.json rename to _archive_/schemas/v1.2/authorizationObject.json diff --git a/schemas/v1.2/dataType.json b/_archive_/schemas/v1.2/dataType.json similarity index 100% rename from schemas/v1.2/dataType.json rename to _archive_/schemas/v1.2/dataType.json diff --git a/schemas/v1.2/dataTypeBase.json b/_archive_/schemas/v1.2/dataTypeBase.json similarity index 100% rename from schemas/v1.2/dataTypeBase.json rename to _archive_/schemas/v1.2/dataTypeBase.json diff --git a/schemas/v1.2/infoObject.json b/_archive_/schemas/v1.2/infoObject.json similarity index 100% rename from schemas/v1.2/infoObject.json rename to _archive_/schemas/v1.2/infoObject.json diff --git a/schemas/v1.2/modelsObject.json b/_archive_/schemas/v1.2/modelsObject.json similarity index 100% rename from schemas/v1.2/modelsObject.json rename to _archive_/schemas/v1.2/modelsObject.json diff --git a/schemas/v1.2/oauth2GrantType.json b/_archive_/schemas/v1.2/oauth2GrantType.json similarity index 100% rename from schemas/v1.2/oauth2GrantType.json rename to _archive_/schemas/v1.2/oauth2GrantType.json diff --git a/schemas/v1.2/operationObject.json b/_archive_/schemas/v1.2/operationObject.json similarity index 100% rename from schemas/v1.2/operationObject.json rename to _archive_/schemas/v1.2/operationObject.json diff --git a/schemas/v1.2/parameterObject.json b/_archive_/schemas/v1.2/parameterObject.json similarity index 100% rename from schemas/v1.2/parameterObject.json rename to _archive_/schemas/v1.2/parameterObject.json diff --git a/schemas/v1.2/resourceListing.json b/_archive_/schemas/v1.2/resourceListing.json similarity index 100% rename from schemas/v1.2/resourceListing.json rename to _archive_/schemas/v1.2/resourceListing.json diff --git a/schemas/v1.2/resourceObject.json b/_archive_/schemas/v1.2/resourceObject.json similarity index 100% rename from schemas/v1.2/resourceObject.json rename to _archive_/schemas/v1.2/resourceObject.json diff --git a/schemas/v2.0/README.md b/_archive_/schemas/v2.0/README.md similarity index 100% rename from schemas/v2.0/README.md rename to _archive_/schemas/v2.0/README.md diff --git a/schemas/v2.0/schema.json b/_archive_/schemas/v2.0/schema.json similarity index 100% rename from schemas/v2.0/schema.json rename to _archive_/schemas/v2.0/schema.json diff --git a/schemas/v3.0/README.md b/_archive_/schemas/v3.0/README.md similarity index 100% rename from schemas/v3.0/README.md rename to _archive_/schemas/v3.0/README.md diff --git a/tests/v3.0/pass/api-with-examples.yaml b/_archive_/schemas/v3.0/pass/api-with-examples.yaml similarity index 100% rename from tests/v3.0/pass/api-with-examples.yaml rename to _archive_/schemas/v3.0/pass/api-with-examples.yaml diff --git a/tests/v3.0/pass/callback-example.yaml b/_archive_/schemas/v3.0/pass/callback-example.yaml similarity index 100% rename from tests/v3.0/pass/callback-example.yaml rename to _archive_/schemas/v3.0/pass/callback-example.yaml diff --git a/tests/v3.0/pass/link-example.yaml b/_archive_/schemas/v3.0/pass/link-example.yaml similarity index 100% rename from tests/v3.0/pass/link-example.yaml rename to _archive_/schemas/v3.0/pass/link-example.yaml diff --git a/tests/v3.0/pass/petstore-expanded.yaml b/_archive_/schemas/v3.0/pass/petstore-expanded.yaml similarity index 100% rename from tests/v3.0/pass/petstore-expanded.yaml rename to _archive_/schemas/v3.0/pass/petstore-expanded.yaml diff --git a/tests/v3.0/pass/petstore.yaml b/_archive_/schemas/v3.0/pass/petstore.yaml similarity index 100% rename from tests/v3.0/pass/petstore.yaml rename to _archive_/schemas/v3.0/pass/petstore.yaml diff --git a/tests/v3.0/pass/uspto.yaml b/_archive_/schemas/v3.0/pass/uspto.yaml similarity index 100% rename from tests/v3.0/pass/uspto.yaml rename to _archive_/schemas/v3.0/pass/uspto.yaml diff --git a/tests/v3.0/schema.test.mjs b/_archive_/schemas/v3.0/schema.test.mjs similarity index 100% rename from tests/v3.0/schema.test.mjs rename to _archive_/schemas/v3.0/schema.test.mjs diff --git a/schemas/v3.0/schema.yaml b/_archive_/schemas/v3.0/schema.yaml similarity index 100% rename from schemas/v3.0/schema.yaml rename to _archive_/schemas/v3.0/schema.yaml diff --git a/schemas/v3.1/README.md b/schemas/v3.1/README.md deleted file mode 100644 index a3d4c87ea0..0000000000 --- a/schemas/v3.1/README.md +++ /dev/null @@ -1,54 +0,0 @@ -# OpenAPI 3.1.X JSON Schema - -This directory contains the YAML sources for generating the JSON Schemas for validating OpenAPI definitions of versions 3.1.X, which are 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, is _not intended for direct use_. - -## Choosing which schema to use - -There are two schemas to choose from for 3.1 usage, both of which have an `$id` that starts with `https://spec.openapis.org/oas/3.1/` and end with date or the `WORK-IN-PROGRESS` placeholder: - -* `https://spec.openapis.org/oas/3.1/schema/{date}` — A self-contained schema that _does not_ validate Schema Objects beyond `type: [object, boolean]` -* `https://spec.openapis.org/oas/3.1/meta/base/{date}` — The vocabulary metaschema for OAS 3.1's extensions to draft 2020-12 -* `https://spec.openapis.org/oas/3.1/dialect/base/{date}` — The dialect metaschema that extends the standard `draft/2020-12` metaschema by adding the OAS "base" vocabulary -* `https://spec.openapis.org/oas/3.1/schema-base/{date}` — 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 - -The name "base" for the dialect was intended to indicate that the OAS dialect could be further extended. - -An additional schema that validates the Schema Object with the OAS 3.1 dialect but does not restrict changing `$schema` is [under consideration](https://github.com/OAI/OpenAPI-Specification/issues/4147). - -## 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.1/schema/2021-03-02` means this iteration was created on March 2nd, 2021. - -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 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. - -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` files 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.1) is part of this package. - -```bash -npm install -npm test -``` diff --git a/schemas/v3.1/dialect.yaml b/schemas/v3.1/dialect.yaml deleted file mode 100644 index d300d94feb..0000000000 --- a/schemas/v3.1/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/schemas/v3.1/meta.yaml b/schemas/v3.1/meta.yaml deleted file mode 100644 index 6cfce4976d..0000000000 --- a/schemas/v3.1/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/schemas/v3.1/schema-base.yaml b/schemas/v3.1/schema-base.yaml deleted file mode 100644 index ea239c03e9..0000000000 --- a/schemas/v3.1/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/schemas/v3.1/schema.yaml b/schemas/v3.1/schema.yaml deleted file mode 100644 index 54c49a2f97..0000000000 --- a/schemas/v3.1/schema.yaml +++ /dev/null @@ -1,974 +0,0 @@ -$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 - -type: object -properties: - openapi: - type: string - pattern: '^3\.1\.\d+(-.+)?$' - info: - $ref: '#/$defs/info' - jsonSchemaDialect: - type: string - format: uri - default: 'https://spec.openapis.org/oas/3.1/dialect/WORK-IN-PROGRESS' - 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' - security: - type: array - items: - $ref: '#/$defs/security-requirement' - 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 - type: object - properties: - title: - type: string - summary: - type: string - description: - type: string - termsOfService: - type: string - format: uri - contact: - $ref: '#/$defs/contact' - license: - $ref: '#/$defs/license' - version: - type: string - required: - - title - - version - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - contact: - $comment: https://spec.openapis.org/oas/v3.1#contact-object - type: object - properties: - name: - type: string - url: - type: string - format: uri - email: - type: string - format: email - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - license: - $comment: https://spec.openapis.org/oas/v3.1#license-object - type: object - 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 - - server: - $comment: https://spec.openapis.org/oas/v3.1#server-object - type: object - properties: - url: - type: string - description: - type: string - variables: - type: object - additionalProperties: - $ref: '#/$defs/server-variable' - required: - - url - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - server-variable: - $comment: https://spec.openapis.org/oas/v3.1#server-variable-object - type: object - properties: - enum: - type: array - items: - type: string - minItems: 1 - default: - type: string - description: - type: string - required: - - default - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - components: - $comment: https://spec.openapis.org/oas/v3.1#components-object - type: object - properties: - schemas: - type: object - additionalProperties: - $dynamicRef: '#meta' - responses: - type: object - additionalProperties: - $ref: '#/$defs/response-or-reference' - parameters: - type: object - additionalProperties: - $ref: '#/$defs/parameter-or-reference' - examples: - type: object - additionalProperties: - $ref: '#/$defs/example-or-reference' - requestBodies: - type: object - additionalProperties: - $ref: '#/$defs/request-body-or-reference' - headers: - type: object - additionalProperties: - $ref: '#/$defs/header-or-reference' - securitySchemes: - type: object - additionalProperties: - $ref: '#/$defs/security-scheme-or-reference' - links: - type: object - additionalProperties: - $ref: '#/$defs/link-or-reference' - callbacks: - type: object - additionalProperties: - $ref: '#/$defs/callbacks-or-reference' - pathItems: - type: object - additionalProperties: - $ref: '#/$defs/path-item' - 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 - - paths: - $comment: https://spec.openapis.org/oas/v3.1#paths-object - type: object - patternProperties: - '^/': - $ref: '#/$defs/path-item' - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - path-item: - $comment: https://spec.openapis.org/oas/v3.1#path-item-object - 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' - put: - $ref: '#/$defs/operation' - post: - $ref: '#/$defs/operation' - delete: - $ref: '#/$defs/operation' - options: - $ref: '#/$defs/operation' - head: - $ref: '#/$defs/operation' - patch: - $ref: '#/$defs/operation' - trace: - $ref: '#/$defs/operation' - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - operation: - $comment: https://spec.openapis.org/oas/v3.1#operation-object - type: object - properties: - tags: - type: array - items: - type: string - summary: - type: string - description: - type: string - externalDocs: - $ref: '#/$defs/external-documentation' - operationId: - type: string - parameters: - type: array - items: - $ref: '#/$defs/parameter-or-reference' - requestBody: - $ref: '#/$defs/request-body-or-reference' - responses: - $ref: '#/$defs/responses' - callbacks: - type: object - additionalProperties: - $ref: '#/$defs/callbacks-or-reference' - deprecated: - default: false - type: boolean - security: - type: array - items: - $ref: '#/$defs/security-requirement' - servers: - type: array - items: - $ref: '#/$defs/server' - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - external-documentation: - $comment: https://spec.openapis.org/oas/v3.1#external-documentation-object - type: object - properties: - description: - type: string - url: - type: string - format: uri - required: - - url - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - parameter: - $comment: https://spec.openapis.org/oas/v3.1#parameter-object - type: object - properties: - name: - type: string - in: - enum: - - query - - header - - path - - cookie - description: - type: string - required: - default: false - type: boolean - deprecated: - default: false - type: boolean - schema: - $dynamicRef: '#meta' - content: - $ref: '#/$defs/content' - minProperties: 1 - maxProperties: 1 - required: - - name - - in - 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' - - 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 - required: - - content - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - request-body-or-reference: - if: - type: object - required: - - $ref - then: - $ref: '#/$defs/reference' - else: - $ref: '#/$defs/request-body' - - 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 - properties: - schema: - $dynamicRef: '#meta' - encoding: - type: object - additionalProperties: - $ref: '#/$defs/encoding' - allOf: - - $ref: '#/$defs/specification-extensions' - - $ref: '#/$defs/examples' - unevaluatedProperties: false - - encoding: - $comment: https://spec.openapis.org/oas/v3.1#encoding-object - type: object - properties: - contentType: - type: string - format: media-range - headers: - type: object - additionalProperties: - $ref: '#/$defs/header-or-reference' - 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 - - responses: - $comment: https://spec.openapis.org/oas/v3.1#responses-object - type: object - 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] - - response: - $comment: https://spec.openapis.org/oas/v3.1#response-object - type: object - 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 - 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' - - callbacks-or-reference: - if: - type: object - required: - - $ref - then: - $ref: '#/$defs/reference' - else: - $ref: '#/$defs/callbacks' - - example: - $comment: https://spec.openapis.org/oas/v3.1#example-object - type: object - properties: - summary: - type: string - description: - type: string - value: true - externalValue: - 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' - - link: - $comment: https://spec.openapis.org/oas/v3.1#link-object - type: object - properties: - operationRef: - type: string - format: uri-reference - operationId: - 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: string - required: - default: false - type: boolean - deprecated: - default: false - type: boolean - schema: - $dynamicRef: '#meta' - content: - $ref: '#/$defs/content' - minProperties: 1 - maxProperties: 1 - oneOf: - - required: - - schema - - required: - - content - dependentSchemas: - schema: - 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' - - 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 - - reference: - $comment: https://spec.openapis.org/oas/v3.1#reference-object - type: object - properties: - $ref: - type: string - format: uri-reference - summary: - type: string - description: - type: string - - 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 - type: object - properties: - type: - enum: - - apiKey - - http - - mutualTLS - - oauth2 - - openIdConnect - 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' - - oauth-flows: - type: object - properties: - implicit: - $ref: '#/$defs/oauth-flows/$defs/implicit' - password: - $ref: '#/$defs/oauth-flows/$defs/password' - clientCredentials: - $ref: '#/$defs/oauth-flows/$defs/client-credentials' - authorizationCode: - $ref: '#/$defs/oauth-flows/$defs/authorization-code' - $ref: '#/$defs/specification-extensions' - unevaluatedProperties: false - - $defs: - implicit: - 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 - - 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 - type: object - additionalProperties: - type: array - items: - type: string - - specification-extensions: - $comment: https://spec.openapis.org/oas/v3.1#specification-extensions - patternProperties: - '^x-': true - - examples: - properties: - example: true - examples: - type: object - additionalProperties: - $ref: '#/$defs/example-or-reference' - - map-of-strings: - type: object - additionalProperties: - type: string - - styles-for-form: - if: - properties: - style: - const: form - required: - - style - then: - properties: - explode: - default: true - else: - properties: - explode: - default: false diff --git a/scripts/schema-test-coverage.sh b/scripts/schema-test-coverage.sh index 0e4ed3883e..cdd746f06e 100755 --- a/scripts/schema-test-coverage.sh +++ b/scripts/schema-test-coverage.sh @@ -4,15 +4,10 @@ # Run this script from the root of the repo +[[ ! -e src/schemas ]] && exit 0 + echo echo "Schema Test Coverage" echo -for schemaDir in schemas/v3* ; do - version=$(basename "$schemaDir") - echo $version - - node scripts/schema-test-coverage.mjs $schemaDir/schema.yaml tests/$version/pass - - echo -done \ No newline at end of file +node scripts/schema-test-coverage.mjs src/schemas/validation/schema.yaml tests/schema/pass diff --git a/tests/v3.1/fail/invalid_schema_types.yaml b/tests/v3.1/fail/invalid_schema_types.yaml deleted file mode 100644 index d295b1f0ed..0000000000 --- a/tests/v3.1/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/v3.1/fail/no_containers.yaml b/tests/v3.1/fail/no_containers.yaml deleted file mode 100644 index c158bcb2b6..0000000000 --- a/tests/v3.1/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/v3.1/fail/server_enum_empty.yaml b/tests/v3.1/fail/server_enum_empty.yaml deleted file mode 100644 index cd6d30eb3e..0000000000 --- a/tests/v3.1/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/v3.1/fail/servers.yaml b/tests/v3.1/fail/servers.yaml deleted file mode 100644 index 1470fe1ec8..0000000000 --- a/tests/v3.1/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/v3.1/fail/unknown_container.yaml b/tests/v3.1/fail/unknown_container.yaml deleted file mode 100644 index 7f31e86053..0000000000 --- a/tests/v3.1/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/tests/v3.1/pass/comp_pathitems.yaml b/tests/v3.1/pass/comp_pathitems.yaml deleted file mode 100644 index 502ca1fca2..0000000000 --- a/tests/v3.1/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/v3.1/pass/info_summary.yaml b/tests/v3.1/pass/info_summary.yaml deleted file mode 100644 index 30d224afc2..0000000000 --- a/tests/v3.1/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/v3.1/pass/license_identifier.yaml b/tests/v3.1/pass/license_identifier.yaml deleted file mode 100644 index fbdba5efbe..0000000000 --- a/tests/v3.1/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/tests/v3.1/pass/mega.yaml b/tests/v3.1/pass/mega.yaml deleted file mode 100644 index 8838c03a6d..0000000000 --- a/tests/v3.1/pass/mega.yaml +++ /dev/null @@ -1,49 +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 -jsonSchemaDialect: https://spec.openapis.org/oas/3.1/dialect/base -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/v3.1/pass/minimal_comp.yaml b/tests/v3.1/pass/minimal_comp.yaml deleted file mode 100644 index 4553689ab4..0000000000 --- a/tests/v3.1/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/v3.1/pass/minimal_hooks.yaml b/tests/v3.1/pass/minimal_hooks.yaml deleted file mode 100644 index e67b2889de..0000000000 --- a/tests/v3.1/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/v3.1/pass/minimal_paths.yaml b/tests/v3.1/pass/minimal_paths.yaml deleted file mode 100644 index 016e86796f..0000000000 --- a/tests/v3.1/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/v3.1/pass/non-oauth-scopes.yaml b/tests/v3.1/pass/non-oauth-scopes.yaml deleted file mode 100644 index e757452f38..0000000000 --- a/tests/v3.1/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/v3.1/pass/path_no_response.yaml b/tests/v3.1/pass/path_no_response.yaml deleted file mode 100644 index 334608f111..0000000000 --- a/tests/v3.1/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/v3.1/pass/path_var_empty_pathitem.yaml b/tests/v3.1/pass/path_var_empty_pathitem.yaml deleted file mode 100644 index ba92742f10..0000000000 --- a/tests/v3.1/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/tests/v3.1/pass/schema.yaml b/tests/v3.1/pass/schema.yaml deleted file mode 100644 index e192529a68..0000000000 --- a/tests/v3.1/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/v3.1/pass/servers.yaml b/tests/v3.1/pass/servers.yaml deleted file mode 100644 index 77a20498da..0000000000 --- a/tests/v3.1/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/tests/v3.1/pass/valid_schema_types.yaml b/tests/v3.1/pass/valid_schema_types.yaml deleted file mode 100644 index 4431adcda5..0000000000 --- a/tests/v3.1/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/v3.1/pass/webhook-example.yaml b/tests/v3.1/pass/webhook-example.yaml deleted file mode 100644 index 2ac1cda985..0000000000 --- a/tests/v3.1/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/v3.1/schema.test.mjs b/tests/v3.1/schema.test.mjs deleted file mode 100644 index ab56bbb754..0000000000 --- a/tests/v3.1/schema.test.mjs +++ /dev/null @@ -1,55 +0,0 @@ -import { readdirSync, readFileSync } from "node:fs"; -import YAML from "yaml"; -import { validate, setMetaSchemaOutputFormat } from "@hyperjump/json-schema/openapi-3-1"; -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("./schemas/v3.1/schema.yaml"); - -describe("v3.1", () => { - describe("Pass", () => { - readdirSync(`./tests/v3.1/pass`, { withFileTypes: true }) - .filter((entry) => entry.isFile() && /\.yaml$/.test(entry.name)) - .forEach((entry) => { - test(entry.name, () => { - const instance = parseYamlFromFile(`./tests/v3.1/pass/${entry.name}`); - const output = validateOpenApi(instance, BASIC); - expect(output.valid).to.equal(true); - }); - }); - }); - - describe("Fail", () => { - readdirSync(`./tests/v3.1/fail`, { withFileTypes: true }) - .filter((entry) => entry.isFile() && /\.yaml$/.test(entry.name)) - .forEach((entry) => { - test(entry.name, () => { - const instance = parseYamlFromFile(`./tests/v3.1/fail/${entry.name}`); - const output = validateOpenApi(instance, BASIC); - expect(output.valid).to.equal(false); - }); - }); - }); -}); diff --git a/vitest.config.mjs b/vitest.config.mjs index b8c8dfb4c0..3d1b50025b 100644 --- a/vitest.config.mjs +++ b/vitest.config.mjs @@ -3,5 +3,6 @@ import { defineConfig } from 'vitest/config' export default defineConfig({ test: { forceRerunTriggers: ['**/scripts/**', '**/tests/**'], + include: ['**/tests/**/*.test.mjs'], }, }) \ No newline at end of file From 32ca940b99927b421690b815a532e2493412e994 Mon Sep 17 00:00:00 2001 From: Ralf Handl Date: Thu, 13 Mar 2025 21:46:23 +0100 Subject: [PATCH 2/4] Create README.md --- _archive_/README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 _archive_/README.md diff --git a/_archive_/README.md b/_archive_/README.md new file mode 100644 index 0000000000..b5e176213e --- /dev/null +++ b/_archive_/README.md @@ -0,0 +1,3 @@ +# Archive + +This folder contains files that are no longer actively maintained. From 9c9506e8bed095619f8daed1895ef8da2643b581 Mon Sep 17 00:00:00 2001 From: Ralf Handl Date: Tue, 18 Mar 2025 14:46:42 +0100 Subject: [PATCH 3/4] reactivate v3.0 schema tests This tests whether dependabot breaks vitest --- _archive_/schemas/v3.0/schema.test.mjs | 4 ++-- vitest.config.mjs | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/_archive_/schemas/v3.0/schema.test.mjs b/_archive_/schemas/v3.0/schema.test.mjs index edc1bf7c42..fd413ed0a5 100644 --- a/_archive_/schemas/v3.0/schema.test.mjs +++ b/_archive_/schemas/v3.0/schema.test.mjs @@ -26,8 +26,8 @@ const parseYamlFromFile = (filePath) => { setMetaSchemaOutputFormat(BASIC); -const validateOpenApi = await validate("./schemas/v3.0/schema.yaml"); -const folder = './tests/v3.0/pass/'; +const validateOpenApi = await validate("./_archive_/schemas/v3.0/schema.yaml"); +const folder = './_archive_/schemas/v3.0/pass/'; describe("pass", async () => { readdirSync(folder, { withFileTypes: true }) diff --git a/vitest.config.mjs b/vitest.config.mjs index 3d1b50025b..b8c8dfb4c0 100644 --- a/vitest.config.mjs +++ b/vitest.config.mjs @@ -3,6 +3,5 @@ import { defineConfig } from 'vitest/config' export default defineConfig({ test: { forceRerunTriggers: ['**/scripts/**', '**/tests/**'], - include: ['**/tests/**/*.test.mjs'], }, }) \ No newline at end of file From 73b9809b438500e04b86a931c90277e225df3b15 Mon Sep 17 00:00:00 2001 From: Ralf Handl Date: Wed, 19 Mar 2025 09:33:06 +0100 Subject: [PATCH 4/4] Remove now obsolete reference to schemas in main --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 4d622fbf73..5119a4e9bb 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,6 @@ This GitHub project is the starting point for OpenAPI. Here you will find the in This repository contains [the Markdown sources](versions) for [all published OpenAPI Specification versions](https://spec.openapis.org/). For release notes and release candidate versions, refer to the [releases page](releases). -Each folder in this repository, such as [schemas](schemas) and [tests](tests), should contain folders pertaining to the current and previous versions of the specification. - ## See It in Action If you just want to see it work, check out the [list of current examples](https://learn.openapis.org/examples/).