github.com/go-swagger/go-swagger@v0.31.0/docs/generate/model.md (about) 1 --- 2 title: Generating models 3 date: 2023-01-01T01:01:01-08:00 4 draft: true 5 weight: 40 6 --- 7 # Generate models from a swagger spec 8 9 10 ``` 11 Usage: 12 swagger [OPTIONS] generate model [model-OPTIONS] 13 14 generate one or more models from the swagger spec 15 16 Application Options: 17 -q, --quiet silence logs 18 --log-output=LOG-FILE redirect logs to file 19 20 Help Options: 21 -h, --help Show this help message 22 23 [model command options] 24 -n, --name= the model to generate, repeat for multiple (defaults to all). Same as --models 25 --accept-definitions-only accepts a partial swagger spec wih only the definitions key 26 27 Options common to all code generation commands: 28 -f, --spec= the spec file to use (default swagger.{json,yml,yaml}) 29 -t, --target= the base directory for generating the files (default: ./) 30 --template=[stratoscale] load contributed templates 31 -T, --template-dir= alternative template override directory 32 -C, --config-file= configuration file to use for overriding template options 33 -r, --copyright-file= copyright file used to add copyright header 34 --additional-initialism= consecutive capitals that should be considered intialisms 35 --allow-template-override allows overriding protected templates 36 --skip-validation skips validation of spec prior to generation 37 --dump-data when present dumps the json for the template generator instead of generating files 38 --strict-responders Use strict type for the handler return value 39 --with-expand expands all $ref's in spec prior to generation (shorthand to --with-flatten=expand) 40 --with-flatten=[minimal|full|expand|verbose|noverbose|remove-unused] flattens all $ref's in spec prior to generation (default: minimal, verbose) 41 42 Options for model generation: 43 -m, --model-package= the package to save the models (default: models) 44 -M, --model= specify a model to include in generation, repeat for multiple (defaults to all) 45 --existing-models= use pre-generated models e.g. github.com/foobar/model 46 --strict-additional-properties disallow extra properties when additionalProperties is set to false 47 --keep-spec-order keep schema properties order identical to spec file 48 --struct-tags= the struct tags to generate, repeat for multiple (defaults to json) 49 --rooted-error-path extends validation errors with the type name instead of an empty path, in the case of arrays and maps 50 ``` 51 52 Schema generation rules are detailed [here](../reference/models/schemas.md).