-
Notifications
You must be signed in to change notification settings - Fork 89
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
Schema example should not auto convert to examples #2076
Comments
@Azquelt do you have any thoughts on this request? I suppose it would be simple enough to keep FYI @michalvavrik. I remember you mentioned some impact to testing around the change from |
yes, this issue describes exactly what I meant, I didn't realize it was only deprecated; I need to be more careful next time |
Well, it is deprecated, but the scanner currently combines them all into the array, whether an example is in |
Yes exactly we think you should support both example and examples but don't combine them. |
The current behavior may be enforced by the MicroProfile OpenAPI 4.0.2 TCK test suite (I only glanced at it). If that's a case and it's agreed that it should be changed, this will need to be changed there first. |
Related issue in MicroProfile OpenAPI: eclipse/microprofile-open-api#674 |
There's not a 1:1 mapping between the annotation and the model. IMO where something is deprecated with a complete replacement, I think we should target generating the new thing. This allows users with an existing code base to generate a good OpenAPI 3.1 document without code changes. JSON Schema added the If someone really wants to put their examples under |
I'm not following your first point/reason. I think libraries should code for user's 'least surprise'. We were not expecting example in the annotations to be examples in the OpenAPI model. In OpenAPI model example and examples are both supported so users can use whichever they want and get the exact results they want. It does not help for the library to think the user wants something other than what they picked and switch to that something else. That being said, I have coded our app to apply filtering to keep example as example but I'd prefer to take that out if the library didn't make the switch we didn't want. Also note we can't go back to 3.0.x as we accidently set the version to 3.0.3 and lots of things did not work...so we have to stay with 3.1. |
If you're upgrading from MP OpenAPI 3.1 to 4.0, all your existing code will be using When you upgrade to MP OpenAPI 4.0, you expect to get your output in OpenAPI 3.1 format. I think it would be surprising if your output used the deprecated While I can see how if you're coming to it fresh, it looks like |
I see your points. We are not too interested in if the output is in 3.0.3 or 3.1 format, our users don't care about that (they don't even know what changed). And users certainly don't know or care if we are using MP OpenAPI 3.1 or 4.0, that is an internal detail.) Users just don't want our schema example wrapped in an array and moved to examples...as that will cause lots of confusion. If at some point, example is removed then we will have to explain why we now are using examples to our users, but we hope it's never removed. But I have a workaround for this in the filter so if you can't change it...its okay...as our workaround seems to work fine. So this is not a big issue for us. |
As mentioned in the MicroProfile issue, we can add a flag/property to disable the merging of |
Oh that would be ideal, thanks! |
In our upgrade from Swagger libraries to smallrye openapi it is converting all our 'example' to 'examples' in the OpenAPI schema.
This is not desirable as we need to be able provide an example that matches the data type. We use arrays extensively and even double arrays occasionally. With smallrye openapi wrapping the example in another array, will be very confusing for users.
I understand the microprofile-openapi-api has:
A free-form property to include an example of an instance for this schema.
Deprecated: use examples()
@Deprecated(since = "4.0") String example() default "";
But for now, example and examples are both valid per the OpenAPI spec.
https://github.com/oai/openapi-specification/blob/main/versions/3.1.0.md#schema-object
Deprecated: The example property has been deprecated in favor of the JSON Schema examples keyword. Use of example is discouraged, and later versions of this specification may remove it.
I would like to see smallrye openapi support example until it is actually removed which may never happen. And also support examples.
The text was updated successfully, but these errors were encountered: