Skip to content

Allow custom schema examples in OpenAPI format - #616

Merged
mcollina merged 10 commits into
fastify:masterfrom
mxck:feature/custom-examples
Jun 19, 2022
Merged

Allow custom schema examples in OpenAPI format#616
mcollina merged 10 commits into
fastify:masterfrom
mxck:feature/custom-examples

Conversation

@mxck

@mxck mxck commented Jun 11, 2022

Copy link
Copy Markdown
Contributor

Hi!
I added the ability to pass examples directly through the "x-examples" field (check this #535 (comment)) and added documentation about examples in general.

Checklist

@mxck

mxck commented Jun 11, 2022

Copy link
Copy Markdown
Contributor Author

Started to check the validity of the scheme through swagger editor and realized that it needs some fine-tuning. I'll reopen the PR later.

UPD:
It turns out that only media objects have examples field. In all other cases you have to use example field.
Now in the master fields are generated incorrectly. I can fix this with a separate PR.

@mxck mxck closed this Jun 11, 2022
@mxck mxck reopened this Jun 11, 2022
@mcollina
mcollina requested review from Eomm and climba03003 June 11, 2022 15:41

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@mxck

mxck commented Jun 11, 2022

Copy link
Copy Markdown
Contributor Author

I found a error in example.
And I need to add support for response and parameters objects.

Comment thread README.md Outdated
Comment thread README.md Outdated
Co-authored-by: Manuel Spigolon <behemoth89@gmail.com>
@mxck
mxck requested review from Eomm and mcollina June 12, 2022 08:08
@mxck

mxck commented Jun 12, 2022

Copy link
Copy Markdown
Contributor Author

Please look again. I added support of examples to params, response and body.

Comment thread README.md
minItems: 1,
}
},
"x-examples": {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you make this example complete? I think we need a custom Ajv config, i.e. ajv.addKeyword() to make this work.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm

@mcollina

Copy link
Copy Markdown
Member

@climba03003 @Eomm could you take a look?

@climba03003 climba03003 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

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.

4 participants