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

Support for HTTP references #102

Closed
yannh opened this issue Jan 22, 2023 · 3 comments
Closed

Support for HTTP references #102

yannh opened this issue Jan 22, 2023 · 3 comments
Labels

Comments

@yannh
Copy link

yannh commented Jan 22, 2023

Hello! I maintain a repository of JSON Schemas for Kubernetes, forked from an older project - which for better (or worse) contains HTTP references, like here: /~https://github.com/yannh/kubernetes-json-schema/blob/ded4ffd7cdc4f5564af13a684620cd7e962bd560/v1.26.0/deployment.json#L22

Am I looking at the right place, to assume that this is not supported by this library yet?

"file": loadFileURL,

It is currently throwing the following error:
error: jsonschema https://kubernetesjsonschema.dev/master/replicationcontroller-v1.json compilation failed: no Loader found for https://kubernetesjsonschema.dev/master/_definitions.json

Is this something you would consider adding support for? I am interested in this to keep full backward compatibility for Kubeconform (WIP PR yannh/kubeconform#168) - even though by default it uses files without those HTTP references and I am not sure if people actually do use the files with references.

Many thanks!

@santhosh-tekuri
Copy link
Owner

http references are supported. it is mentioned in README. below code shows how to do it:

package main

import (
	"fmt"

	"github.com/santhosh-tekuri/jsonschema/v5"
	_ "github.com/santhosh-tekuri/jsonschema/v5/httploader"
)

func main() {
	u := "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/ded4ffd7cdc4f5564af13a684620cd7e962bd560/v1.26.0/deployment.json"
	_, err := jsonschema.Compile(u)
	fmt.Println("error: ", err)
}

@santhosh-tekuri
Copy link
Owner

you need to add following import:

import _ "github.com/santhosh-tekuri/jsonschema/v5/httploader"

@yannh
Copy link
Author

yannh commented Jan 23, 2023

Thanks a lot for the support! This worked ❤️

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

No branches or pull requests

2 participants