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

Update TypeGenerator to create valid files that use relative property object references ($ref) #616

Closed
Gytaco opened this issue Jul 6, 2021 · 1 comment

Comments

@Gytaco
Copy link
Contributor

Gytaco commented Jul 6, 2021

Is your feature request related to a problem? Please describe.
I am unable to TypeGenerator on json files that reference local json files and therefore I need to put my json files on the web with a public facing http endpoint just to generate types that reference other custom element types.

For example I would like to be able to use 2 json files in a folder and be able to compile them. Refer to the following types I would like to see working.

So this Vector2 file compiles fine.

{
"$id": "Vector2.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Vector2",
"x-namespace": "Elements.Geometry",
"x-struct": true,
"description": "A 2D vector.",
"type": [
"object",
"null"
],
"required": [
"X",
"Y"
],
"properties": {
"X": {
"type": "number",
"description": "The X component of the vector."
},
"Y": {
"type": "number",
"description": "The Y component of the vector."
}
},
"additionalProperties": false
}

However I get the following error when I try and generate cs from this I get an issue.

{
"$id": "BoundingRectangle.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "BoundingRectangle",
"x-namespace": "Elements.Geometry",
"type": [ "object", "null" ],
"discriminator": "discriminator",
"description": "The base segment class.",
"required": [ "discriminator" ],
"properties": {
"Min": {
"description": "The min point.",
"$ref": "#Vector2"
},
"Max": {
"description": "The max point.",
"$ref": "#Vector2"
}
},
"additionalProperties": false
}

The error is as follows: "Could not resolve the JSON path 'Vector2.json' because no document path is available.

Describe the solution you'd like
I would like to be to reference local files or even use json arrays similar to the schema where you can call a single json file and use the prefix # to reference the object, you can find more about this here.
https://redoc.ly/docs/resources/ref-guide/

Describe alternatives you've considered
I can just put this on http end points I make publicly to get around this for the moment.

Additional context
image

@andrewheumann
Copy link
Member

This is believed fixed.

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

2 participants