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

feat: support the other def keyword #45

Merged
merged 2 commits into from
Jan 19, 2025
Merged

Conversation

vetsin
Copy link
Contributor

@vetsin vetsin commented Dec 8, 2024

To address #42 -- it does not fully support the json pointer spec as it 'should' perhaps, but it works for the common $defs/definitions use case.

@jiro4989
Copy link
Owner

jiro4989 commented Jan 10, 2025

Sorry, I'm away for a few days so I'll check when I get back.

@jiro4989
Copy link
Owner

Hmm, I guess this is the only way to do it now. I couldn't implement #42 because of I couldn't support dynamic definition in Nim.

I think supporting only common terms is a practical solution.

@jiro4989
Copy link
Owner

OK

(*'-')! < % cat examples/json_schema_2.json
{
  "$id": "https://example.com/product.schema.json",
  "type": "object",
  "properties": {
    "product": { "$ref": "#/$defs/product" },
    "testproduct": { "$ref": "#/definitions/testproduct" }
  },
  "$defs": {
    "product": { "type": "string" }
  },
  "definitions": {
    "testproduct": { "type": "array", "items": { "type": "string" } }
  }
}
(*'-')! < % ./bin/nimjson -j ./examples/json_schema_2.json
type
  Object = ref object
    product: Option[Product]
    testproduct: Option[Testproduct]
  Product = string
  Testproduct = seq[string]

@jiro4989
Copy link
Owner

@vetsin Sorry I'm late.

LGTM 👍

LGTM

@jiro4989 jiro4989 merged commit 4fb51bf into jiro4989:master Jan 19, 2025
10 checks passed
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

Successfully merging this pull request may close these issues.

2 participants