Questions tagged [go-swagger]

Swagger 2.0 implementation for go

94 questions
23
votes
1 answer

What't the means about var () in golang

I go though the code generated by go-swagger, found follow code: // NewReceiveLearningLabActsParams creates a new ReceiveLearningLabActsParams object // with the default values initialized. func NewReceiveLearningLabActsParams()…
fisafoer
  • 273
  • 1
  • 2
  • 6
8
votes
6 answers

Setting up go-swagger for first time

I am new to go-lang and so to go-swagger. I am following a blog and have installed go-swagger with command : go get -u github.com/go-swagger/go-swagger/cmd/swagger I can see that the go-swagger folder is created in…
Samuel
  • 1,128
  • 4
  • 14
  • 34
7
votes
3 answers

How to access JWT claims from API handler functions in go-swagger?

I'm using go-swagger with BearerAuth using JWT tokens. Along with the actual token I'm receiving claims which include such data as username. How can I access claims in api.ItemsCreateItemHandler function below? package restapi func…
Maklaus
  • 538
  • 2
  • 16
  • 37
6
votes
1 answer

How to expose swagger.json with go-swagger server?

I'm using go-swagger to generate the API server. I noticed that the json generated from swagger.yml is being kept in restapi/embedded_spec.go. What's the best way to expose that JSON spec so my ReactJS client can access it? So far I've had to use…
Maklaus
  • 538
  • 2
  • 16
  • 37
5
votes
0 answers

how to use go-swagger with sentry performance monitoring?

i am using go-swagger . Sentry added perormance monitoring i am looking for best pratice to add this feature in my project. I know, go-swagger uses "net/http" but it is still a liitle bit controversial about correct way to adding. I added init…
FunDogg
  • 51
  • 1
4
votes
2 answers

GO: import a struct and rename it in json

I have built a database in go with gorm. For this I created a struct and with this struct I created a table. So far so good. In the backend everything works, but in the frontend the problem is that the JSON which is called always returns the ID in…
mattia_m
  • 119
  • 1
  • 13
4
votes
1 answer

Install go-swagger on Linux Ubuntu

I want to install go-swagger on LInux Ubuntu 22.04 but i have blocker. This is my code to install go-swagger. sudo apt install -y apt-transport-https gnupg curl curl -1sLf…
Sutrisno
  • 91
  • 5
4
votes
0 answers

Swagger doesnt detect in command from makefile ubuntu 22

i have install swagger in my computer, and i try to run my swagger command using makefile to validate my go project in linux 22 but the swagger doesn't detect if i try to run the swagger direcly from terminal its work for information my make…
ishak
  • 131
  • 5
4
votes
2 answers

Empty Swagger specification is created in Go API

I am trying to use generate swagger spec from my API handler. I have installed the go-swagger from go get: go get -u github.com/go-swagger/go-swagger/cmd/swagger See the project structure below: main.go uses handler definitions in products.go.…
Ayman Arif
  • 1,456
  • 3
  • 16
  • 40
4
votes
1 answer

go-swagger TLS Config

I generated a golang server with go-swagger. I set the scheme to https (and only https). When I startup my server I get a TLS error. the required flags `--tls-certificate` and `--tls-key` were not specified It is clear that I haven't properly…
mornindew
  • 1,993
  • 6
  • 32
  • 54
4
votes
1 answer

How to setup go-swagger to generate spec from annotation

I am following the instructions for generating swagger spec here https://goswagger.io/generate/spec.html. I have an existing project that needs a UI for the API. I want to use go swagger but I am completely confused…
Sakib
  • 1,503
  • 4
  • 26
  • 39
3
votes
0 answers

in path parameter is ignored by go-swagger

I am typing to generate in path parameters using go-swagger. But after running swagger generate spec -o ./swagger.yaml --scan-models I see the generated swagger has in:query rather than in:path package types package types type URCapID struct { …
BhanuKiran
  • 2,631
  • 3
  • 20
  • 36
3
votes
1 answer

Golang Swagger annotation for enum input parameter

I am not sure how to specify annotation for an input string parameter for a rest call. Where input parameter can take one of three possible string values. If I have to assume there will be a drop down menu with these three value…
BhanuKiran
  • 2,631
  • 3
  • 20
  • 36
3
votes
1 answer

swagger:parameters keep showing as query string param

I have the following handler // Create database // swagger:route POST /databases createDatabase // // Create database // // Security: // oauth2: // // responses: // 202: Database // 401: Error // ... func (h Handler) Create(c *gin.Context) { …
user672009
  • 4,379
  • 8
  • 44
  • 77
3
votes
1 answer

go-swagger: no spec available to unmarshal

I am trying to define a swagger operation for my REST endpoint written in Golang. I need to specify the POST request body and responses. // swagger:operation POST /user user createUser // // Creates user // // produces: // - application/json //…
Arjun K S
  • 51
  • 4
1
2 3 4 5 6 7