Swagger 2.0 implementation for go
Questions tagged [go-swagger]
94 questions
1
vote
1 answer
Goswagger not creating appropriate json spec file
I am trying to create a spec file for the go implementation of petstore example . I tried a go generate in the directory which had doc.go but it did nothing. On further reading, I realised that there should be
//go:generate swagger generate spec -o…

Krash
- 2,085
- 3
- 13
- 36
1
vote
1 answer
go-swagger response payloads not model types
I'm running go-swagger head of master https://github.com/go-swagger/go-swagger/commit/3981236c3f6bd9eabb26f14e9d31b853d340405f
Not sure if this is an issue or just a lack of understanding on my part. I have a healthcheck method that returns a…

Myles McDonnell
- 12,943
- 17
- 66
- 116
0
votes
0 answers
go-swagger - set additionalProperties as false using generate specs
I am generating swagger.json using go-swagger with command swagger generate spec -o swagger.json
I need to set additionalProperties as false in the swagger doc to make sure user can't supply additional properties other than defined in…

codingenious
- 8,385
- 12
- 60
- 90
0
votes
0 answers
go-swagger: How to use custom validators
I would like to be able to define custom validators that can be used in the spec in the same way as strfmt.UUID and strfmt.ObjectId "github.com/go-openapi/strfmt"
For example, I could write in the swagger spec something like this
login:
type:…

fpawel
- 309
- 1
- 3
- 14
0
votes
0 answers
Go Lang- How to configure Swagger UI(http://localhost:4545/docs) and local host(http://localhost:4545) running at the same time on the same host/port
I'm trying to implement go-swagger for Go-lang project. How to configure both Swagger UI(http://localhost:4545/docs) and local host(http://localhost:4545) running at the same on port 4545. I can get response only on one interface(either swagger UI…

Sri
- 45
- 2
0
votes
0 answers
Generate swagger Open 'file': permission denied
I tried to generate swagger using this command
swagger generate spec -o ./swagger.yaml --scan-models
but I got error like this :
open ./swagger.yaml: permission denied
I have installed (go-swagger) using docker with version :
version:…

noqriz
- 11
- 1
0
votes
0 answers
go-swagger: `swagger generate server` "import cycles not allowed"
First: I have read through and attempted to apply what I found in related posts, but nothing seems to be working. Related posts would be:
Error "import cycle not allowed" in go-swagger auto generated code
The spec in its most simple form…

Matthew Hoggan
- 7,402
- 16
- 75
- 140
0
votes
1 answer
What is the reason of parse error in go-swagger redoc URL?
I was working on documentation for APIs. I've used Go-Swagger for the same. It's working for regular Docs but not for Redoc.
Here are my implementation details:
router.StaticFile("/swagger", "./api/swagger.yaml")
opts :=…

shantanu sharma
- 55
- 2
- 11
0
votes
1 answer
Docker build failed: lstat /root/go: no such file or directory
I am dockerizing my app that runs in a custom base image with alpine:golang and goswagger installed. Currently, I'm trying to reduce the image size by implementing a multistage build. But when I run
swagger generate
it always showing error…

amerw
- 357
- 2
- 12
0
votes
1 answer
go-swagger - array of objects in request body
I'm using go-swagger for generating swagger file for our APIs
I've been trying to add comments for an API that gets an array of objects in request but the go-swagger seems like is not recognizing it
my request looks like this in JSON format:
{
[
…

Amirreza KN
- 21
- 1
- 6
0
votes
1 answer
Can perform POST call from browser using go-swagger and gorilla mux
I am using gorilla/mux and go-swagger to serve REST endpoints. Since I am running goswagger and calling REST endpoints from browser, the POST call is making http.MethodOptions first and then http.MethodPut later. Because of which I had a lot of…

BhanuKiran
- 2,631
- 3
- 20
- 36
0
votes
1 answer
How to change the order of values in body
I am using go-swagger. Is there any way to make attribute in generated swagger have the same order as defined. In generated swagger it is sorted in alphabetical order.
This is my definition
This is generated swagger

BlackLotus
- 318
- 4
- 12
0
votes
1 answer
How do I write a swagger endpoint using go-swagger where I can delay the consumption of the body in its parameters?
I need to define a swagger endpoint that needs to take in media types text and zip. Instead of having the generated package consume it and reassign it into separate types such as string, can I get the io.Readcloser passed through directly?

Sammy Eang
- 21
- 4
0
votes
1 answer
accessing index array from gotmpl
I have this list of an array and want to print something if index = 0, but print something else after that.
I've looked at this docs but seems not successful... all of them is printing something else instead.
{{ range $i, $v := .Lists }}
{{ if…

rulisastra
- 311
- 1
- 2
- 14
0
votes
1 answer
How to respond with code 401 or 404 instead of 500 in go-swagger for invalid bearer token
I have created a REST API server using go-swagger and added bearer token security to a few endpoints. As per docs, the token verification method should have a signature like func(string) (interface{}, error).
The token verification method returns an…

KIRAN KUMAR B
- 404
- 4
- 8