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

TypeSpec integration with JSON Schema #2464

Open
mikekistler opened this issue Sep 21, 2023 · 11 comments
Open

TypeSpec integration with JSON Schema #2464

mikekistler opened this issue Sep 21, 2023 · 11 comments
Assignees
Labels
design:needed A design request has been raised that needs a proposal triaged:core
Milestone

Comments

@mikekistler
Copy link
Member

mikekistler commented Sep 21, 2023

Services that conform to industry standard data formats, e.g Health Insights and the FHIR standard, would benefit from TypeSpec support to directly import JSON Schema definitions.

An example of where this support would be really useful is the Health Insights service, which works with data that conforms to the FIHR industry standards, which have published JSON schemas, e.g.

observation.schema.json.html

@allenjzhang allenjzhang added the design:needed A design request has been raised that needs a proposal label Sep 25, 2023
@allenjzhang
Copy link
Member

allenjzhang commented Sep 25, 2023

From the issue, there could be different requirements:

  • @useref for emitter to generate correct output which we currently support

  • true import of JSON schema into TypeSpec models for in-depth application

#1 We do support it already. @mikekistler to check with Health Insight team.

#2 Keeping this open on backlog for future design discussions.

@asaflevi-ms
Copy link

@mikekistler, @allenjzhang
We need to be able to reference FHIR objects as external models.
As for clients, FHIR as its own serializers, so it will be great if emitters can give the option to set (by decoration, custom configuration) specific serializers.

@asaflevi-ms
Copy link

BTW - "@useref for emitter to generate correct output which we currently support"
I tried to use it and got "unknown decorator"

@bterlson
Copy link
Member

bterlson commented Oct 9, 2023

I assume we are talking about Json Schema not OpenAPI here, and yeah useRef is not implemented there but should be. I'm not clear if this meets the "directly import" criteria in the OP though.

@bterlson
Copy link
Member

bterlson commented Oct 9, 2023

it will be great if emitters can give the option to set (by decoration, custom configuration) specific serializers.

Can you give more detail here? I'm not sure I understand the scenario yet.

@mikekistler
Copy link
Member Author

BTW - "@useref for emitter to generate correct output which we currently support"
I tried to use it and got "unknown decorator"

You must import the @typespec/openapi3 package to use the @useRef decorator.

See this link for more information and a Playground example of using the @useRef decorator to get an external reference.

@asaflevi-ms
Copy link

@mikekistler
Is it possible to import openapi3 and generate OpenAPI version 2 json spec ?

@mikekistler
Copy link
Member Author

Yes ... for OpenAPI v2 you need to use the @azure-tools/typespec-autorest package.

Here's a playground example

@asaflevi-ms
Copy link

asaflevi-ms commented Oct 11, 2023

@mikekistler

image
OpenApi generated with an error

@mikekistler
Copy link
Member Author

What extension/tooling is generating this error?

I think it is likely that whatever it is assumes that the $ref value is a "URL" -- that will actual resolve in an HTTP request.

I tried this same thing but using a true "URL" and I'm not getting an error:

image

@markcowl markcowl added the epic label Oct 11, 2023
@markcowl markcowl added this to the Backlog milestone Nov 6, 2023
@allenjzhang allenjzhang removed the epic label Jan 23, 2024
@allenjzhang
Copy link
Member

While this has been an epic to start with, it is now a design discussion on a feature request. Removing Epic label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design:needed A design request has been raised that needs a proposal triaged:core
Projects
None yet
Development

No branches or pull requests

5 participants