Questions tagged [go-swagger]

Swagger 2.0 implementation for go

94 questions
1
vote
0 answers

Could I reference field of request in text summary of endpoint in a swagger spec? In therefore go-swagger?

I have the following swagger spec for the endpoint: records-by-time: post: operationId: idOfRecordsByTimeEndpoint parameters: - in: body name: Body schema: $ref: '#/definitions/RecordsByTimeRequest' …
1
vote
0 answers

Unable to pass jwt token in header in swagger UI in GO

Unable to pass the JWT token in the header in the Swagger UI.Have tried API, its working fine. Below is the code snippet for CORS handleCORS := cors.Default().Handler return handleCORS(handler) }``` Used the below codes for swagger in the…
1
vote
3 answers

Is it possible to use "go mod tidy" to clear unused dependencies except indirect ones?

I understand that it is the expected behavior of go mod tidy to prune dependencies tree by removing the unnecessary ones, but part of my CI uses go-swagger to generate swagger JSON files. So, in the end. go mod tidy will remove the go-swagger…
phramos07
  • 136
  • 1
  • 8
1
vote
3 answers

Correct media type for swagger spec for downloading zip file

I am creating an api which allows downloading a zip file, so for this I am looking for correct media type for sending this zip file as response in swagger "2.0" specification. My current api spec looks like this /config: get: produces: -…
aman
  • 278
  • 3
  • 11
1
vote
1 answer

Replace go-swagger with another version in Windows

I am using go1.14.1 and go-swagger version dev in my Windows 10. I installed go-swagger with Installing from source. I'd like to use go-swagger version 0.25 instead. What is the clean way of replacing dev with 0.25?
AEWRocks
  • 157
  • 1
  • 2
  • 10
1
vote
2 answers

CORS Issue in Golang while accessing API from go-swagger UI

I have implemented go-swagger for my API documentation which is running on a different port on my localhost and my application is running on the port 8888. I have implemented cors https://github.com/rs/cors my code for implementing cors is var…
Abhimanyu
  • 705
  • 7
  • 20
1
vote
0 answers

Swagger json, block "definitions" - different required fields in specific methods

I have a simple swagger.json file, Product rest api with 2 methods: post (add new product) and put (update) and I want to define "name", "price" fields of Product definition as required for POST method but not for a PUT method. How can i do that…
nekishdev
  • 11
  • 2
1
vote
1 answer

How to write response with searched data - go-swagger & gorm

I used go-swagger and gorm for MySQL queries and one of my handlers is (retreiving one record) api.UsersUserGetByIDHandler = users.UserGetByIDHandlerFunc(func(params users.UserGetByIDParams) middleware.Responder { db := dbConn() user :=…
Sasa Jovanovic
  • 324
  • 2
  • 14
1
vote
0 answers

Go-Swagger how to get JSON response with middleware

After successful creation of swagger API with go-swagger, I need to customise the app, in order to store data to the database and retrieve data out of the database. I see that only one of the generated files I can edit: /restapi/customize_users.go …
Sasa Jovanovic
  • 324
  • 2
  • 14
1
vote
0 answers

How to implement middleware with go-swagger?

I am using go-swagger to create API endpoint and the business logic is called inside the handler function directly , which is working fine . I need to implement "Middleware" , which can also ease in unit testing which I am doing using mockery and…
infiniteLearner
  • 3,555
  • 2
  • 23
  • 32
1
vote
0 answers

Problem generating Spec for JSON Response type of Array of Users

I've got a Go project, exposing REST CRUD APIs, for a Mongo collection. I'm using go-swagger to generate the swagger spec. However, I'm having trouble getting the JSON response to look like I want without breaking the go-swagger spec generator. I'm…
dbh
  • 1,607
  • 13
  • 18
1
vote
1 answer

OperationhandlerFunc second parameter becomes interface{} instead of *models.Model

I'm trying to add authentication to my api following the go-swagger tutorial: https://goswagger.io/tutorial/composed-auth/ But my generated code becomes: type GetAuthenticatedUserHandlerFunc func(GetAuthenticatedUserParams, interface{})…
Wuzi
  • 386
  • 7
  • 17
1
vote
0 answers

go-swagger injects digits into properties names

The models.yaml file I have is: baseStorePatch: title: Store type: object required: - scalePolicy properties: scalePolicy: $ref: "#/definitions/scalePolicy" StorePatch: allOf: - $ref:…
injoy
  • 3,993
  • 10
  • 40
  • 69
1
vote
2 answers

GoLang with go-swagger response headers

I am pretty new to golang and trying to set my response headers. I have two headers that I want to set. I think that I am misunderstanding something fundamental. I am also using go-swagger to generate my endpoints. My problem is that I can only…
mornindew
  • 1,993
  • 6
  • 32
  • 54
1
vote
0 answers

Golang and AngularJS project structure with go-swagger

I'm relatively new to Golang, having used Node.JS with AngularJS on a previous project, and am having trouble with Golang being very opinionated about project structure. Our Go code exists in a repository that also contains our HTML, CSS, and JS…
iamtheddrman
  • 623
  • 5
  • 16