fastify / fastify-swagger

Swagger documentation generator for Fastify
MIT License
915 stars 201 forks source link

fix `examples` in json schema #702

Closed trim21 closed 1 year ago

trim21 commented 1 year ago

Checklist

fix https://github.com/fastify/fastify-swagger/issues/625

mcollina commented 1 year ago

I think we still need to support OpenAPI 3.0 too.

trim21 commented 1 year ago

I think we still need to support OpenAPI 3.0 too.

I don't think this will break openapi 3.0, it just stop replacing examples property in json schema object

Did I miss something?

trim21 commented 1 year ago

I would move the examples mutation to the proper place that should happen.

For example, resolveResponse. It can ensure, we are properly mutate the top-level only.

transformDefsToComponents is called on path, params, response and query, this will require to write it multiple times

trim21 commented 1 year ago

I guess you want to move examples transform in schemaToMedia?

climba03003 commented 1 year ago

Actually, cookie, query, path, header already doing it's own transform for the properties.examples. There are no need to mutate the examples for them.

For body, it reuse the same logic inside schemaToMedia which does require some mutation.

For response, it is the only one need to do more things.

trim21 commented 1 year ago

I think this is what you are expecting?

trim21 commented 1 year ago

any releasing plan? I'm currently encountering a openapi rendering issue will be fixed by this PR.

Eomm commented 1 year ago

Done in 8.2.1