Executive summary
We use swagger to generate model and operation API for Docker Engine (aka Moby), and we believe that types and structures should be separated from the code. This is why we are using an option to disable generating Validate() methods.
Unfortunately, this option has disappeared, making us stick to a very old go-swagger codebase, which is becoming more and more problematic, e.g.
Details
Both swagger generate model and swagger generate operation used to have an option to disable generating Validate() methods. The option name was --skip-validator (what was in line with other options such as --skip-struct or --skip-responses), it was added:
- for
generate model: by commit 38dbdd8 ("move generator2 to generator package", Feb 16 2015, possibly earlier but there's no git history AFAICS)
- for
generate operation: by commit 0415806 ("Add a --skip-validator flag for generate operation", Oct 5 2016)
Unfortunately, this option was silently removed from both commands by commit d2aae81 ("Added an option in genOpts", Jan 4, 2018).
A similarly named (but with very different semantics) option, --skip-validation, was added by commit 78f848e ("validate spec prior to gen. client/server", Jan 8, 2017). As suggested in d2aae81#commitcomment-29777292, a possible user confusion between --skip-validation and --skip-validator was the reason for removal, although it's not very clear.
We can obviously work around that by forking go-swagger and applying fixes on top of the old code, but I believe there's a better way.
Proposed solution
Reinstate the removed functionality.
To the best of my understanding, the biggest problem here is to avoid user confusion between --skip-validation and --skip-validator. There are many ways to solve it; I propose to:
- add
--generate option, accepting a string:bool type, for example: --generate struct:false --generate validator:false.
- for backward compatibility, add the following hidden options
--skip-struct (equivalent of --generate struct:false)
--skip-handler
--skip-parameters
--skip-responses
--skip-url-builder
Executive summary
We use swagger to generate model and operation API for Docker Engine (aka Moby), and we believe that types and structures should be separated from the code. This is why we are using an option to disable generating
Validate()methods.Unfortunately, this option has disappeared, making us stick to a very old go-swagger codebase, which is becoming more and more problematic, e.g.
Details
Both
swagger generate modelandswagger generate operationused to have an option to disable generatingValidate()methods. The option name was--skip-validator(what was in line with other options such as--skip-structor--skip-responses), it was added:generate model: by commit 38dbdd8 ("move generator2 to generator package", Feb 16 2015, possibly earlier but there's no git history AFAICS)generate operation: by commit 0415806 ("Add a --skip-validator flag for generate operation", Oct 5 2016)Unfortunately, this option was silently removed from both commands by commit d2aae81 ("Added an option in genOpts", Jan 4, 2018).
A similarly named (but with very different semantics) option,
--skip-validation, was added by commit 78f848e ("validate spec prior to gen. client/server", Jan 8, 2017). As suggested in d2aae81#commitcomment-29777292, a possible user confusion between--skip-validationand--skip-validatorwas the reason for removal, although it's not very clear.We can obviously work around that by forking go-swagger and applying fixes on top of the old code, but I believe there's a better way.
Proposed solution
Reinstate the removed functionality.
To the best of my understanding, the biggest problem here is to avoid user confusion between
--skip-validationand--skip-validator. There are many ways to solve it; I propose to:--generateoption, accepting astring:booltype, for example:--generate struct:false --generate validator:false.--skip-struct(equivalent of--generate struct:false)--skip-handler--skip-parameters--skip-responses--skip-url-builder