Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Schema vocabulary for Singer schemas #2783

Open
edgarrmondragon opened this issue Nov 29, 2024 · 1 comment
Open

JSON Schema vocabulary for Singer schemas #2783

edgarrmondragon opened this issue Nov 29, 2024 · 1 comment

Comments

@edgarrmondragon
Copy link
Collaborator

edgarrmondragon commented Nov 29, 2024

Stub.


For example OpenAPI defines its own vocabulary on top of Draft 2020-12

  1. Custom data types and formats: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#data-types

  2. Examples: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schema-object-examples

  3. https://spec.openapis.org/oas/3.1/dialect/base

{
    "$id": "https://spec.openapis.org/oas/3.1/dialect/base",
    "$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 documents",

    "$vocabulary": {
        "https://json-schema.org/draft/2020-12/vocab/core": true,
        "https://json-schema.org/draft/2020-12/vocab/applicator": true,
        "https://json-schema.org/draft/2020-12/vocab/unevaluated": true,
        "https://json-schema.org/draft/2020-12/vocab/validation": true,
        "https://json-schema.org/draft/2020-12/vocab/meta-data": true,
        "https://json-schema.org/draft/2020-12/vocab/format-annotation": true,
        "https://json-schema.org/draft/2020-12/vocab/content": true,
        "https://spec.openapis.org/oas/3.1/vocab/base": false
    },

    "$dynamicAnchor": "meta",

    "allOf": [
        { "$ref": "https://json-schema.org/draft/2020-12/schema" },
        { "$ref": "https://spec.openapis.org/oas/3.1/meta/base" }
    ]
}
  1. https://spec.openapis.org/oas/3.1/meta/base
{
    "$id": "https://spec.openapis.org/oas/3.1/meta/base",
    "$schema": "https://json-schema.org/draft/2020-12/schema",

    "title": "OAS Base vocabulary",
    "description": "A JSON Schema Vocabulary used in the OpenAPI Schema Dialect",

    "$vocabulary": {
        "https://spec.openapis.org/oas/3.1/vocab/base": true
    },

    "$dynamicAnchor": "meta",

    "type": ["object", "boolean"],
    "properties": {
        "example": true,
        "discriminator": { "$ref": "#/$defs/discriminator" },
        "externalDocs": { "$ref": "#/$defs/external-docs" },
        "xml": { "$ref": "#/$defs/xml" }
    },

    "$defs": {
        "extensible": {
            "patternProperties": {
                "^x-": true
            }
        },

        "discriminator": {
            "$ref": "#/$defs/extensible",
            "type": "object",
            "properties": {
                "propertyName": {
                    "type": "string"
                },
                "mapping": {
                    "type": "object",
                    "additionalProperties": {
                        "type": "string"
                    }
                }
            },
            "required": ["propertyName"],
            "unevaluatedProperties": false
        },

        "external-docs": {
            "$ref": "#/$defs/extensible",
            "type": "object",
            "properties": {
                "url": {
                    "type": "string",
                    "format": "uri-reference"
                },
                "description": {
                    "type": "string"
                }
            },
            "required": ["url"],
            "unevaluatedProperties": false
        },

        "xml": {
            "$ref": "#/$defs/extensible",
            "type": "object",
            "properties": {
                "name": {
                    "type": "string"
                },
                "namespace": {
                    "type": "string",
                    "format": "uri"
                },
                "prefix": {
                    "type": "string"
                },
                "attribute": {
                    "type": "boolean"
                },
                "wrapped": {
                    "type": "boolean"
                }
            },
            "unevaluatedProperties": false
        }
    }
}

Related:

@edgarrmondragon
Copy link
Collaborator Author

https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#section-7.2.3

Vocabularies do not support specifically declaring different value sets for keywords. Due to this limitation, and the historically uneven implementation of this keyword, it is RECOMMENDED to define additional keywords in a custom vocabulary rather than additional format attributes if interoperability is desired.

This means we probably should not use custom format values, but rather define custom keywords (e.g. dbtype).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant