Package: inducoapi
InducOapiA simple python module to generate OpenAPI Description Documents by supplying request/response bodies.Contributions for new features, fixes or improvements are welcome. Feel free to send a pull request.MotivationSometimes you have a fully functioning HTTP service without OpenAPI documentation. At some point in time, others may
need to use your service. Writing the documentation by hand is a pain and can feel like an overwhelming job for complex
services.inducoapihelps you generate your OpenAPI Description Documents by taking as input request/response examples plus some
other information.The generated OpenAPI documentation is validated
withopenapi-spec-validator.Warning: This program also generates theexamplefields in OpenAPI schemas by default. If you have sensitive data in
your request/response files, disable this feature with--no-example.InstallationWithpippipinstallinducoapiWithpoetrygitclonegit@github.com:TheWall89/inducoapi.gitcdinducoapi
poetryinstallTo run unit-tests:poetryrunpytestUsageFrom CLIinducoapiprovides its own command. You can simply execute it withinducoapiIf you get acommand not founderror, try to activate your virtualenv or runpoetry shellfirst.You can also runinducoapiin the classic way:python-minducoapiHelpinducoapiprovides its own help. Check it out with:python-minducoapi-hExamplesLet's consider a simple case: you have an HTTP service managing employees. We want to generate the OpenAPI Description
Document for a GET on all the employees, returning a 200 status code:python-minducoapiGET/employees200outputopenapi:3.0.0info:title:Generated by InducOapiversion:v1paths:/employees:get:responses:200:description:''Now, a GET request with an empty response is not quite useful. Let's add an argument with a JSON file containing a
response example. Input examples can be found inexamples.python-minducoapiGET/employees200--responseexamples/employees.jsonoutputopenapi:3.0.0info:title:Generated by InducOapiversion:v1paths:/employees:get:responses:200:description:''content:application/json:schema:type:arrayitems:type:objectproperties:id:type:integerexample:1name:type:stringexample:Dwight Schruterole:type:stringexample:salesmanLet's add a parameter to filter the employees by name.python-minducoapiGET/employees200--responseexamples/employees.json--parametername,queryoutputopenapi:3.0.0info:title:Generated by InducOapiversion:v1paths:/employees:get:responses:'200':description:''content:application/json:schema:type:arrayitems:type:objectproperties:id:type:integerexample:1name:type:stringexample:Dwight Schruterole:type:stringexample:salesmanparameters:-name:namein:queryrequired:falsedescription:''schema:{}Finally, let's try a POST request with both request and response examples.python-minducoapiPOST/employees201--requestexamples/new_employee_req.json--responseexamples/new_employee_resp.jsonoutputopenapi:3.0.0info:title:Generated by InducOapiversion:v1paths:/employees:post:requestBody:content:application/json:schema:type:objectproperties:name:type:stringexample:Michael Scottrole:type:stringexample:managerresponses:201:description:''content:application/json:schema:type:objectproperties:id:type:integerexample:4name:type:stringexample:Michael Scottrole:type:stringexample:managerIf you want to directly write the generated OpenAPI Description Documents to a YAML file, just
add--output openapi.yamlFrom pythontest_inducoapi.pyprovides usage examples of the module from python.TODO listAdd support for request/response files in YAMLAdd support forapplication/yamlcontentCustomize title and version in infoPackage moduleSupport for$refin response schemasAdd support forparametersAdd support forlinks(I don't think it is very useful)Add support forformat(hard to infer)