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

error parsing a ref based schema #38

Open
croconut opened this issue Mar 6, 2024 · 2 comments
Open

error parsing a ref based schema #38

croconut opened this issue Mar 6, 2024 · 2 comments

Comments

@croconut
Copy link

croconut commented Mar 6, 2024

Library version:

1.7.1

JSON schema version: draft-04

The current behavior

Fails to parse with Unsupported schema.

The expected behavior

Parsing correctly. What I would really like is a separate typebox definition for each defined schema, but getting the top level schema is good, since i can pull it apart when I use it.

Why does it happen? What/How to fix the issue?

Probably the top level ref -> definitions usage. It is valid tho afaik, was working with my other tools. Hard to say since this is the only thing I've attempted to use this cli for.

Content of minimal json schema file which causes the problem

Click to expand/collapse
{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "$ref": "#/definitions/S3Event",
    "definitions": {
        "S3Bucket": {
            "required": [
                "name",
                "ownerIdentity",
                "arn"
            ],
            "properties": {
                "arn": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                },
                "ownerIdentity": {
                    "$ref": "#/definitions/S3UserIdentity"
                }
            },
            "additionalProperties": false,
            "type": "object"
        },
        "S3Entity": {
            "required": [
                "s3SchemaVersion",
                "configurationId",
                "bucket",
                "object"
            ],
            "properties": {
                "bucket": {
                    "$schema": "http://json-schema.org/draft-04/schema#",
                    "$ref": "#/definitions/S3Bucket"
                },
                "configurationId": {
                    "type": "string"
                },
                "object": {
                    "$schema": "http://json-schema.org/draft-04/schema#",
                    "$ref": "#/definitions/S3Object"
                },
                "s3SchemaVersion": {
                    "type": "string"
                }
            },
            "additionalProperties": false,
            "type": "object"
        },
        "S3Event": {
            "required": [
                "Records"
            ],
            "properties": {
                "Records": {
                    "items": {
                        "$schema": "http://json-schema.org/draft-04/schema#",
                        "$ref": "#/definitions/S3EventRecord"
                    },
                    "type": "array"
                }
            },
            "additionalProperties": false,
            "type": "object"
        },
        "S3EventRecord": {
            "required": [
                "eventVersion",
                "eventSource",
                "awsRegion",
                "eventTime",
                "eventName",
                "userIdentity",
                "requestParameters",
                "responseElements",
                "s3"
            ],
            "properties": {
                "awsRegion": {
                    "type": "string"
                },
                "eventName": {
                    "type": "string"
                },
                "eventSource": {
                    "type": "string"
                },
                "eventTime": {
                    "type": "string",
                    "format": "date-time"
                },
                "eventVersion": {
                    "type": "string"
                },
                "requestParameters": {
                    "$schema": "http://json-schema.org/draft-04/schema#",
                    "$ref": "#/definitions/S3RequestParameters"
                },
                "responseElements": {
                    "patternProperties": {
                        ".*": {
                            "type": "string"
                        }
                    },
                    "type": "object"
                },
                "s3": {
                    "$schema": "http://json-schema.org/draft-04/schema#",
                    "$ref": "#/definitions/S3Entity"
                },
                "userIdentity": {
                    "$schema": "http://json-schema.org/draft-04/schema#",
                    "$ref": "#/definitions/S3UserIdentity"
                }
            },
            "additionalProperties": false,
            "type": "object"
        },
        "S3Object": {
            "required": [
                "key",
                "size",
                "urlDecodedKey",
                "versionId",
                "eTag",
                "sequencer"
            ],
            "properties": {
                "eTag": {
                    "type": "string"
                },
                "key": {
                    "type": "string"
                },
                "sequencer": {
                    "type": "string"
                },
                "size": {
                    "type": "integer"
                },
                "urlDecodedKey": {
                    "type": "string"
                },
                "versionId": {
                    "type": "string"
                }
            },
            "additionalProperties": false,
            "type": "object"
        },
        "S3RequestParameters": {
            "required": [
                "sourceIPAddress"
            ],
            "properties": {
                "sourceIPAddress": {
                    "type": "string"
                }
            },
            "additionalProperties": false,
            "type": "object"
        },
        "S3UserIdentity": {
            "required": [
                "principalId"
            ],
            "properties": {
                "principalId": {
                    "type": "string"
                }
            },
            "additionalProperties": false,
            "type": "object"
        }
    }
}
@croconut
Copy link
Author

croconut commented Mar 6, 2024

I'll inline the top level object and see how that works

@croconut
Copy link
Author

croconut commented Mar 6, 2024

It worked once I did that. Looks like it was that it didnt expect the top level to be using a reference. Guess I'll do a minor rewrite for these schemas

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