Open Kinjalrk2k opened 1 year ago
I was looking into the requestBody
and found that the data returned is:
{
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"example": {
"id": "100",
"createdAt": "2021-06-04T15:50:38.568Z",
"name": "Carol",
"avatar": "https://cdn.fakercloud.com/avatars/nelsonjoyce_128.jpg"
}
}
}
}
}
}
Shouldn't the requestBody
be:
{
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object"
},
"example": {
"id": "100",
"createdAt": "2021-06-04T15:50:38.568Z",
"name": "Carol",
"avatar": "https://cdn.fakercloud.com/avatars/nelsonjoyce_128.jpg"
}
}
}
}
}
What I want to point out is wont the schema
and example
fields be on the same level?
Reference: https://swagger.io/docs/specification/describing-request-body/
Please guide me to the right direction if I'm wrong!
please check and merge this PR @joolfe
@Kinjalrk2k I need some time to review but I'm taking it into consideration, thanks so much for the PR.
This repo lacks an important feature and the MR at least enables basic support for that. However, the repo from @Kinjalrk2k seems outdated and not maintained as well as fails npm audit
.
I would really appreciate a solution here and I think other would do too. Maybe the perfection in #246 can be a long term goal, but with intermediate steps (e.g. this MR)?
Thanks for everyones effort. This generators saves a lot of work!!!
@joolfe Are you able to review this PR?
I created a package that provides a function to create the missing schema types for request bodies and responses based on the examples. I will deprecate the package if the PR is merged but this repository seems pretty dead.
https://github.com/soerenuhrbach/openapi-schema-types-from-examples#use-with-postman-to-openapi
Few notable points:
application/json
responses will have a schema.Referencing important issues:
22