-
Notifications
You must be signed in to change notification settings - Fork 230
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
How to generate example in OpenAPI3 #2939
Comments
Hi, we have an implementation issue that hasn't been implemented yet #2700 However it is a little bigger than just openapi3 examples. We are definitely open to PR and if you are intrested in implementing on the decorator and openapi3 part (without the versioning) I think that would be fair to split. |
That's nice to hear :) The linked PR (#2700) seems broader, as it tries to tackle both "object" examples and "per property" examples. I would rather focus on "per property" example first, as it would have no impact on versioning and be simpler to implement. Something like that: model Person
{
@example("Alice")
name: string;
@example(42)
@added(Versions.v2)
age: int32;
} |
@ouvreboite That is covered by #2700, although the 'simple' example is a bit buried in the details: model Foo {
type: "bar" | "baz"
@jsonExample("2023-03-01T19:00:00Z")
createdAt: utcDateTime;
} Which for your example would be: model Person
{
@jsonExample("Alice")
name: string;
@jsonExample(42)
@added(Versions.v2)
age: int32;
} |
Note that, even property examples potentially have versioning implications, as example values can become obsolete over time |
@ouvreboite Please let us know if this implementation will enable what you need, or if you have questions or concerns. |
@markcowl LGTM :) |
When can I use this or test it? |
This comment was marked as off-topic.
This comment was marked as off-topic.
We are adding some new capabilities to OpenAPI for representing value types: #2046 We are integrating this into the Sample design and should have an updated design this month, with implementation to follow next month. |
@markcowl Has there been any progress on this? I have been porting a large OpenAPI file to Typespec today, and almost everything we need is supported except Examples for properties, which has meant we need to put the conversion on hold until it is supported. |
we have agreed on the first version of the updated design and should be working on it soon, planning for this incoming sprint(releasing next month as we are just about to release today) |
great news! The first version of the updated design, is it the one you've outlined here ? Very keen to get my hands on this - Just been starting to use TypeSpec for a new service and found it great so far, but really am missing the possibility to add examples for OpenAPI. |
Yea that one except all the scoping was cut for now, just a single arg with the example |
Will actually close this issue in favor of the other one #2700, I have started working on it, PR #3572 if you have feedback |
I see that generating per-field example in OpenAPIv3 is not supported (cf typespec-for-openapi).
Is there a specific reason for that, or are you open for a PR to add this support?
The text was updated successfully, but these errors were encountered: