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

Use HTTPS. #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Use HTTPS. #8

wants to merge 1 commit into from

Conversation

andreif
Copy link

@andreif andreif commented Jul 4, 2023

Adds support of HTTPS ref in addition to the existing HTTP.

@andreif
Copy link
Author

andreif commented Jul 4, 2023

Tested by adding

    {
        "description": "remote ref, containing refs itself using HTTPS",
        "schema": {"$ref": "https://json-schema.org/draft-04/schema#"},
        "tests": [
            {
                "description": "remote ref valid",
                "data": {"minLength": 1},
                "valid": true
            },
            {
                "description": "remote ref invalid",
                "data": {"minLength": -1},
                "valid": false
            }
        ]
    },

to https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/main/tests/draft4/ref.json#L229

@andreif
Copy link
Author

andreif commented Jul 4, 2023

Workaround:

import Ajv from 'ajv-draft-04';
import { SchemaObject } from 'ajv';

const ajv = new Ajv();

const META_SCHEMA_ID = 'http://json-schema.org/draft-04/schema';

const httpsSchemaId = META_SCHEMA_ID.replace(/^http:/, 'https:');
const httpsSchema = ajv.getSchema(META_SCHEMA_ID)?.schema as SchemaObject;
httpsSchema.id = httpsSchema.$schema = httpsSchemaId + '#';

ajv.addMetaSchema(httpsSchema, httpsSchemaId, false);

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

Successfully merging this pull request may close these issues.

2 participants