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

jsonschema: model URI and IRI formats #3451

Open
mahdanoura opened this issue Sep 13, 2024 · 2 comments
Open

jsonschema: model URI and IRI formats #3451

mahdanoura opened this issue Sep 13, 2024 · 2 comments
Assignees
Labels
FeatureRequest New feature or request

Comments

@mahdanoura
Copy link

mahdanoura commented Sep 13, 2024

The JSON Schema specification allows for modeling resource identifiers, such as URIs and IRIs, using the format keyword to specify that a string is of a specific type (e.g., uri, iri, uuid).

For example, in JSON Schema, this can be defined as follows:

"properties": {
  "id": {
    "type": "string",
    "format": "uri"
  }
}

To the best of my understanding, CUE does not directly support the URI or IRI string formats as part of its standard types. What is the recommended approach or best practice in CUE for modeling such formats?

@mahdanoura mahdanoura added the Triage Requires triage/attention label Sep 13, 2024
@mvdan
Copy link
Member

mvdan commented Sep 16, 2024

cc @rogpeppe

@rogpeppe rogpeppe added FeatureRequest New feature or request and removed Triage Requires triage/attention labels Sep 16, 2024
@rogpeppe
Copy link
Member

Currently AFAIK best approach is to use a regular expression (the first one I came across is here) but that's not ideal, clearly, given the size of it.

We should add a validator for this format, perhaps in a new net/url package. Given that we will want to support JSONSchema formats directly when importing JSON Schema into CUE, we will probably have direct support for most or all of those formats in the near(ish) future. Watch this space!

@mvdan mvdan changed the title Model URI and IRI Formats from JSON Schema in CUE jsonschema: model URI and IRI formats Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants