New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Parameters section to swagger:route #1405
Conversation
scan/validators.go
Outdated
} | ||
|
||
const ( | ||
ParamDescriptionKey = "description" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported const ParamDescriptionKey should have comment (or a comment on this block) or be unexported
Codecov Report
@@ Coverage Diff @@
## master #1405 +/- ##
==========================================
+ Coverage 72.35% 72.83% +0.47%
==========================================
Files 36 37 +1
Lines 6718 6844 +126
==========================================
+ Hits 4861 4985 +124
- Misses 1404 1406 +2
Partials 453 453
Continue to review full report at Codecov.
|
I'll increase the coverage in a bit |
@@ -729,34 +729,34 @@ func AssetNames() []string { | |||
// _bindata is a table, holding each asset generator, mapped to its name. | |||
var _bindata = map[string]func() (*asset, error){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in this file are just the result of a gofmt -s -w -l .
, no changes in logic. If needed they could be rolled back before merging
have you seen swagger:operation it allows you to specify routes but with the full swagger yaml syntax. This PR somewhat duplicates this, but with bespoke syntax. I wonder where the type goes and some of the other validations etc that can be defined on parameters. |
O I hadn't seen your response on #1404 |
Hi @casualjim will do, I'll cover more validations, such as only allow the use of schemas when Were there any other use cases you had in mind? |
once you have the ability to specify types you probably also want the ability to specify the validations they have to pass. Things min length, pattern, min/max etc come to mind. |
the constraints, you're absolutely right, I completely forgot about them, I'll work on those as well |
scan/route_params.go
Outdated
} | ||
|
||
var current *spec.Parameter | ||
var extraData map[string]string = make(map[string]string) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should omit type map[string]string from declaration of var extraData; it will be inferred from the right-hand side
scan/route_params.go
Outdated
TypeInteger = "integer" | ||
// TypeBoolean is the identifier for a boolean type in swagger:route | ||
TypeBoolean = "boolean" | ||
// TypeBoolean is the identifier for a boolean type in swagger:route |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment on exported const TypeBool should be of the form "TypeBool ..."
@casualjim I added a section to parse the schema in parameters, covers Let me know if you have any observations. Thanks! |
Working on a company project, we have a custom version of the Swagger API which allow us to do calls to our microservices by reading the swagger documentation generated from our builds.
We use Gin for our API endpoints in our Go Microservices and unfortunately we were unable to tie the Request models to the router definitions.
I added a section in the
swagger:route
parser, soParameters
can be included with their properties, to easily allow adding a reference to aswagger:model
for body params. Multiple parameters can be added underParameters
by simply using the+
prefix when a new parameter starts. Example: