Package: py-swagger-generator
Python Swagger Generator v.1.1.0This is a package for python to automatically create swagger documentation yaml files using templates.InstallationInstall this package using pip :pip install py-swagger-generatorUsageAfter installing this package you can execute the tool in the terminal by typingpy-swagger-generatorThis command currently has 2 arguments :--verbose : Outputs some more debug information--build   : Builds everything inside the swagger_generator folder.Config FoldersA config folder is a folder inside theswagger_generatorfolder that contains aconfig.yamlfile and atemplatesfolder (This is where you place your template files).There can be more than one config folder inside the swagger_generator folder.The structure of the config.yaml is as follows :data:routes:-[Name of template without .yaml and containing data for the Route]components:responses:-[Name of template without .yaml and containing data for the Response]schemas:-[Name of template without .yaml and containing data for the Schema]build:output:[Path to Where the finished result will be stored at]If you put any data that dose not fall under the keys named above under thedatakey, then this data will not be modified, but will be placed inside the output file.TemplatesA Template is in our case just a normal yaml file with some modifications.These modifications start whenever the program sees two{characters and ends when it sees two}characters.These modifications will be replaced with what the user has inputted in that specific field in the config.yaml file.Every modification has some arguments some are required some are not.
Arguments are separated using commas.
Its important that the arguments are in a specific order since the meaning of the data inside a argument changes based on its order.The argument order is as follows :Argument IndexArgument NameRequiredDefault ValueFormatArgument Description0Key Nameyes-At least one character. All uppercase and_This argument will be used to identify the argument and is also the name that will be displayed when the program is asking the user for a value in a template.1Input Typeyes-STRING,INTEGER,SCHEMA,OBJECTCHOOSE_ONE< Insert data type here >( Choices separated by the pipe character )CHOOSE_ANY Then same as choose oneCHOOSE_ANY_LIST Then same as choose oneThe type of the value you want to ask the user for. If set toCHOOSE_ONEthe user can choose from a list of values that you provide in the template inside the parentheses right after the choice data type, which will then be converted to the type you specify in the angle brackets. If set toCHOOSE_ANYits the same asCHOSE_ONE, but you can select more then one item. Setting it toCHOOSE_ANY_LISTdose the same asCHOSE_ANY, but the generated is inserted as a list.2Is Requiredonly if input type is set toOBJECTREQUIREDREQUIRED,OPTIONALIndicates if the user has to provide the value or not.3Multiple Typeonly if input type is set toOBJECTSINGLESINGLE,ONE_OR_MORE,ONE_OR_MORE_LISTIndicates how many times the user can enter the value. It can only be set toONE_OR_MOREorONE_OR_MORE_LISTif the input type is set toOBJECT. If set toONE_OR_MOREthe user will need to enter all the values in the reference object.ONE_OR_MORE_LISThas the same functionality asONE_OR_MORE, however the object will be inserted as a list in the generated yaml.4Reference Pathonly if input type is set toOBJECT-Any characters followed by .yamlThis argument contains the path to another template. This argument can only be set if the input type is set toOBJECT. If the program encounters this value it will interpret the argument as a path and interpret the file at that path as template. The user will have to provide all values that the referenced template includes and the program will then insert the filled yaml of the referenced template at that point.ExampleHere is a example for a really simple route template which could be stored underswagger_generator/test_config/templates/route.yaml:/{{ROUTE_PATH, STRING, REQUIRED}}:{{HTML_REQUEST_TYPE,STRING,REQUIRED}}:tags:-{{CATORGY,STRING,REQUIRED}}summary:{{SUMMARY,STRING,REQUIRED}}operationId:{{OPERATION_ID,STRING,REQUIRED}}requestBody:content:application/json:schema:{{SCHEMA,SCHEMA,REQUIRED}}responses:{{RESPONSE,OBJECT,REQUIRED,ONE_OR_MORE,response.yaml}}You can see that this templates references toswagger_generator/test_config/templates/response.yamlwhich content could be seen here :'{{STATUS_CODE,INTEGER,REQUIRED}}':description:{{DESCRIPTION,STRING,REQUIRED}}Now we only need to create aconfig.yamlfile for our test_config which could be stored here :swagger_generator/test_config/config.yamldata:openapi:3.0.1info:title:Testversion:v1-url:http://localhost:80tags:-name:testdescription:Testroutes:-route:ROUTE_PATH:testHTML_REQUEST_TYPE:postCATORGY:testSUMMARY:Dose some stuff and things.OPERATION_ID:testSCHEMA:name:type:stringdata:type:stringRESPONSE:-STATUS_CODE:200DESCRIPTION:Okbuild:output:test.yamlNow just callpy-swagger-generator --build.
This will generate a test.yaml file containing all the specified data.