1

I am looking for a solution to extract api request from swagger.json in curl,GO,Node.js in java!

pallavi
  • 23
  • 8
  • What exactly are you trying to achieve? In other words, what do you need the request data for? We'd need to understand your problem more clearly to suggest a workable solution. – Helen Nov 01 '21 at 22:43
  • I am trying to create codegens, like postman has but in java – pallavi Nov 16 '21 at 08:39
  • So something like https://github.com/Kong/httpsnippet but using OpenAPI instead of HAR as a source? – Helen Nov 16 '21 at 09:57
  • The [Swagger Inflector](https://github.com/swagger-api/swagger-inflector) library can [generate JSON payload examples](https://stackoverflow.com/q/41408768/113116) based on an OpenAPI schema. But that's just the request body. As for the full HTTP request, I suggest you review the code of existing codegen projects such as [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) and [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator) to see how they handle this. – Helen Nov 16 '21 at 10:00
  • 1
    You'll probably have to use [Swagger Parser](https://github.com/swagger-api/swagger-parser/) to parse the OpenAPI file and extract various info (endpoint paths, parameters, etc.) that could then be converted into curl options. – Helen Nov 16 '21 at 10:03

0 Answers0