|
| 1 | +Swagger Code Generator for OpenAPI 3.0 implemented in Perl |
| 2 | + |
| 3 | +usage: swaggercodegenv2.pl [-dhlmsuvx] [-c <classnames>] [-o <configoptions>] -b <output path> -p <basepackage> [-e <endpoint>] [-i <json|yaml>] -|<infile1>[ <infile2> ...] |
| 4 | + |
| 5 | +generate model, controller and service classes and sample client instantiation code for all requests from an api's swagger file. |
| 6 | + |
| 7 | +Options: |
| 8 | + |
| 9 | +-d dump the contents of the swaggerfile and exit |
| 10 | +-h print this help screen |
| 11 | +-l list endpoints and request bodies only. don't generate any code. |
| 12 | +-m don't abort when samenamed types from different input files mismatch. |
| 13 | +-r dump the definitions from the swaggerfile interleaved with the derived classes |
| 14 | +-s dump the symboltable after the inputfile is parsed. |
| 15 | +-u read/write files utf-8 encoded |
| 16 | +-v increase verbosity |
| 17 | +-x append path-derived suffixes to output path and basepackage |
| 18 | +-z plain dump of the swagger file, without any parsing |
| 19 | + |
| 20 | +Arguments: |
| 21 | + |
| 22 | +-b base directory for generated output files. '-' for stdout. |
| 23 | +-c relative package and class names for model, controller and service classes : |
| 24 | + [model=controller.dto]|controller=[rest.controller.]EchoController|service=[rest.client.]EchoService |
| 25 | + CAVEAT: to define a relative model package add a '.', e.g. model=.dto |
| 26 | +-e generate interface classes for a single endpoint |
| 27 | +-i specify the input format when piping a swagger file to stdin |
| 28 | +-p base package to generate the classes in (defaults to: default) |
| 29 | + the base package will be converted to a relative path and added to the base directory |
| 30 | +-o configuration options delimited by '|' characters. supported options are : |
| 31 | + |
| 32 | + ignoreMismatches : don't abort when samenamed types from different input files mismatch. equivalent to -m |
| 33 | + skipAuthorization : suppress 'Authorization' parameters carrying OAuth2 tokens |
| 34 | + extendBaseType : extend the base type instead of adding new attributes for polymorph declarations |
| 35 | + attribCardinality : add a mandatory/optional comment after a class attribute |
| 36 | + jsonCardinality : add a (required=[true|false]) annotation to a @JsonProperty annotation |
| 37 | + jsonIncludeNonNull : suppress serialization of empty/null class attributes |
| 38 | + clusterByTag : cluster the endpoints into controller classes by the 'tag' attribute |
| 39 | + this overrides any class names specified in the -c option |
| 40 | + generateController : generate a controller class exposing the REST endpoints |
| 41 | + generateControllerAdvice : generate controller advice classes |
| 42 | + generateService : generate a service class that implements the operations |
| 43 | + generateClient : generate code for creating request bodies for POST requests |
| 44 | + sharedModelPackage : generate model classes in a single package. write new model class version on collision. |
| 45 | + dedicatedPackage : append path-derived suffixes to output path and basepackage. equivalent to -x |
| 46 | + this will prevent collisions between different implementations of like-named client classes |
| 47 | + useErrorResponse : use a generic class 'ErrorResponse' instead of generated specific classes for all responses not 1xx or 2xx |
| 48 | + useArrayResponseType : use a synthetic array class in a response instead of the (default) 'responseContainer = List' annotation |
| 49 | + |
| 50 | + openapi 3.0 introduced new response layouts 'links' and 'content'. |
| 51 | + code generation is designed for either one with 'content' the default. |
| 52 | + enforceLinksResolution : enforce resolution of the 'link' component of a response |
| 53 | + |
| 54 | +The generator resolves '$ref' references to external files in the format <file>#/<reference> where <file> is |
| 55 | +a filename relative to the directory of the primary input file and '#/<reference' is a regular local reference. |
| 56 | +The definitions from the external file should come in one of the predefined sections (definitions, components, |
| 57 | +links, parameters). If the section is omitted, it defaults to 'definitions'. |
| 58 | +If the external file holds only a single definition, the <reference> in the '$ref' clause can be omitted. |
| 59 | +It defaults to the definition from the file. If the external file holds multiple definitions and the reference |
| 60 | +is omitted from the '$ref' clause, the processing run will fail with an error message. |
| 61 | + |
| 62 | +Example for generating classes from a downloaded swaggerfile and writing them to stdout : |
| 63 | + |
| 64 | +curl -s -X GET http://openshift-echoservice-dk0429-a.router.default.svc.cluster.local:80/v2/api-docs |\ |
| 65 | +swaggercodegen.pl -sb -b ./src/main/java -o 'jsonCardinality|jsonIncludeNonNull|useErrorResponse|generateController|generateControllerAdvice\ |
| 66 | + |generateService|generateClient|extendBaseType|clusterByTag' |
| 67 | + -c 'model=controller.model|controller=rest.controller.EchoController|service=rest.client.EchoService' |
| 68 | + -p com.db.payment.service.directive.adapter.scgc -i json - |
0 commit comments