postman-to-openapi
postman-to-openapi copied to clipboard
Response schemas
We need to have a way to define response schemas so docs are more complete
Postman allows you to save example responses maybe the schema can be derived from those ?
Yes probably this is the direction to follow but there are lot of questions as a response don't have description etc... Just a name and a value in the fields
I do not think that it is possible to generate the necessary data from the response. Maybe the information could be generated in a similar way as with the status code. At example by evaluating the schema of the following function.
pm.expect(tv4.validate(pm.response.json(), schema)).to.be.true;
However, I am not sure how often such tests are implemented for the response
In version 1.3.0
now is possible to add example responses in the request, is still not a schema solution but can be work for lot of people meanwhile.
Perhaps the best interim solution is to just have a scheme with a name and a type for now. Not having a scheme with types is a deal-breaker for me to use this library. Another service reads the swagger doc to determine the data types of incoming data. If having a description is essential then the markdown solution might be the only option @joolfe
Just dropped a project working towards this! https://github.com/Kinjalrk2k/postman-to-openapi-json-extended
What I've done is:
- Used this library to parse the Postman collection and extract the paths in which schemas might be useful.
- Use the examples for building the schemas using: https://github.com/Nijikokun/generate-schema
- Write all these down on a JSON file for the ~user~ developer to edit the schemas as they wish
- Again use this library to build the OpenAPI spec file whilst adding the extracted schemas
My use-case was JSON specific, hence favoured JSON on the OpenAPI side ;)
@kyriakos cool approach the use of external json files is not a bad ideaat all
Best Regards.
Just dropped a project working towards this! https://github.com/Kinjalrk2k/postman-to-openapi-json-extended
What I've done is:
- Used this library to parse the Postman collection and extract the paths in which schemas might be useful.
- Use the examples for building the schemas using: https://github.com/Nijikokun/generate-schema
- Write all these down on a JSON file for the ~user~ developer to edit the schemas as they wish
- Again use this library to build the OpenAPI spec file whilst adding the extracted schemas
My use-case was JSON specific, hence favoured JSON on the OpenAPI side ;)
I think that was cool if you create a PR to this repo, however, please create a PR about generate schema from examples.
Hi there, great tool first of all!
I think. this way already discussed in some of the closed issues, but not sure if it's solved. Is it possible to somehow create request body properties in the output openapi file? Currently, I'm adding the properties manually to the output according to my example responses, but it would be great if it's automatically supported.
Best regards.
Why can't the schema be inferred from the example response(s)? The name and literal types are there.
Using $ref
to reference files generated/manually created elsewhere doesn't solve this problem, but makes it easier to workaround. This tool automates much of the work I need to perform. I have no problem manually creating request/response schemas. Will you consider reopening https://github.com/joolfe/postman-to-openapi/issues/243?