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
add example to string parameter in request body #2064
Comments
@eric-lee-ltk it works for me. Go code package main
// swagger:route GET /foobar foobar-tag Service
// swagger:parameters Service
type Req struct {
// desc
// in: body
// required: true
// example: example
Body string
} generated json: {
"swagger": "2.0",
"paths": {
"/foobar": {
"get": {
"tags": [
"foobar-tag"
],
"operationId": "Service",
"parameters": [
{
"example": "example",
"description": "desc",
"name": "Body",
"in": "body",
"required": true,
"schema": {
"type": "string"
}
}
]
}
}
}
} What am I missing? |
@ilyakaznacheev I just copy and paste your generated json to swagger ui . There has a structural error: It seems that the |
@eric-lee-ltk were you able to successfully add an example to a request body field? I'm still facing the same issue where the "example" field is wrongly getting added under parameters instead of schema. Or is there another way to set an example field? |
Hi, @eric-lee-ltk maybe you can try this.
It's look good to me. |
Problem statement
When I generate spec from go code, the
example
anddefault
tag of string parameter in request body is missingSwagger specification
expected:
actual:
Steps to reproduce
original code:
Environment
swagger version: v0.20.1
go version: 1.12.7
OS: CentOS 6
The text was updated successfully, but these errors were encountered: