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

Feat: add example to schema definition #421

Merged
merged 3 commits into from
May 1, 2022

Conversation

rlebran
Copy link
Contributor

@rlebran rlebran commented Apr 23, 2022

Add example for schema and fields through openapi attribute.

This produce valid openapi specification. I changed the example type from String to serde_json::Value because the specification describe example as

A free-form property to include an example of an instance for this schema.

and examples show a json like example value.

This is link to #417

Copy link
Collaborator

@tiagolobocastro tiagolobocastro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rlebran!
Btw, what do you think about using the Default trait as another way of specifying examples automatically?
Maybe something like #[openapi(default_examples)].

@tiagolobocastro tiagolobocastro merged commit 2c5042e into paperclip-rs:master May 1, 2022
@rlebran rlebran deleted the feat-schema-example branch May 2, 2022 06:03
@rlebran
Copy link
Contributor Author

rlebran commented May 2, 2022

That's a good idea but should it be opt-in or if a Default implementation exists we can use it automatically ?

tiagolobocastro added a commit that referenced this pull request Jul 27, 2022
- Add support for `PATCH` methods. [PR#422](#422)
- Add support for header parameters through the newly introduced `Apiv2Header` derive macro. [PR#413](#413)
- Add support for [RapiDoc UI](https://mrin9.github.io/RapiDoc/index.html). [PR#420](#420)
- Add example support for derived `Apiv2Schema`. [PR#421](#421)
- Add ability to not generate documentation for some operations through the skip attribute on api_v2_schema macro. [PR#423](#423)
- Add support for deprecated operations. [PR#424](#424)

- Fix missing slash between url parts [PR#416](#416)
- Properly support non-BoxBody response payload types [PR#414](#414)
- Fix required fields definition when using serde flatten [PR#412](#412)
- Fix reference urls not being RFC3986-compliant [PR#411](#411)
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

Successfully merging this pull request may close these issues.

2 participants