Swagger 2.0 implementation for go
Questions tagged [go-swagger]
94 questions
1
vote
1 answer
Add example for go-swagger ref array and map model
I am trying to use go-swagger to generate my service swagger spec
I have a response struct like
type MyResponse struct {
// example: ["This", "Is", "A", "Test"]
MyTestArray MyArray `json:"MyTestArray"`
}
type MyArray []string
So,…

user1722361
- 377
- 1
- 4
- 14
1
vote
0 answers
go-openapi CSVProducer returns a "data type must be byte array" error
I've made an swagger 2.0 specification endpoint to produce a response in CSV format:
/query/csv:
post:
summary: Execute query and return response in CSV format
description: Executes query and returns response in CSV format
…

Artem Orlov
- 11
- 1
1
vote
1 answer
Swagger OpenAPI 2: Cannot remove package from definition model name
I am generating an OpenAPI 2 Spec for my GoLang Web API via swagger. My generated models all have the package name prefixed before the the model name, which is not the behavior I want.
When I annotate my API as:
// @Summary Get Account
//…

Blue
- 51
- 3
1
vote
1 answer
Go-Swagger not generating properties in yaml file
I am trying to use go-swagger for generating docs but the generated swagger.yaml file doesn't have properties of a response object.
Project Structure:
cmd
-api
-main.go
-movies.go
internal
-data
…

Tahir Ali
- 155
- 1
- 2
- 10
1
vote
0 answers
go-swagger use a model for query parameters
According to the docs if we want to define query params as a struct we need to list every single operation that uses them after the struct.
This will prove exhausting for an API with hundreds of endpoints that all use the same query params that…

sc-atompower
- 11
- 1
1
vote
0 answers
Go-Swagger: Failed to load API definition 405
I'm trying to generate a swagger docs in golang with go-swagger mod. Basically i'm generating the specs by source
swagger generate spec -o ./gen/swagger-local.yaml --scan-models
On localhost it's ok, the docs was generated and I can visualize on…

Juny
- 191
- 1
- 1
- 15
1
vote
1 answer
Integrate new relic with go swagger
In golang we have used go swagger to generate a bunch of APIs, now we trying to integrate new relic with our application, trying to wrap around the API to get the metrics, can it be done through yaml file or any other way? Because refactoring every…

Vishal reddy 11
- 11
- 1
1
vote
0 answers
What is the reason of request body not matching the schema?
I'm using swagger to describe a simple endpoint to upload file with date(int64). There is request body:
put:
tags:
- files
description: Add an associated file to a project
operationId: addFile
parameters:
- name: projectId
in:…

Howkee
- 37
- 4
1
vote
1 answer
Why Swagger with Golang is not working in Vercel production?
I have a Golang project, deployed in vercel environment. Everything is working fine but swagger. Swagger implementation is working fine in dev environment but in the production same route doesn't work. I have used gin-swagger, swag, gin-gonic,…

Md Riadul Islam
- 1,273
- 11
- 25
1
vote
0 answers
goswagger setting a reference for the field
i have a hypothetical code
// swagger:model Type
// enum:none,offshore,international
type Type int
//swagger:model VatExemption
type Model struct {
// The Model UUID.
// Example - j290f1ee-6c54-4b01-90e6-d701748f0851
// swagger:strfmt…

mikr
- 43
- 1
- 6
1
vote
1 answer
unsupported type "invalid type" when using jwk.Key as swagger response type
I have the following endpoint
package token
import (
"crypto/rsa"
"github.com/dhis2-sre/im-user/pkg/config"
"github.com/dhis2-sre/im-user/pkg/token/helper"
"github.com/gin-gonic/gin"
"log"
"net/http"
)
func…

user672009
- 4,379
- 8
- 44
- 77
1
vote
1 answer
How to specify type for a swagger:parameters struct
My struct is defined as the following
// swagger:parameters instanceLogs
type SelectorParameter struct {
// selector
// in: query
// required: false
// type: string
Selector uint `json:"selector"`
}
However the type show in my…

user672009
- 4,379
- 8
- 44
- 77
1
vote
1 answer
When to use swagger route vs swagger operator
I am trying to auto-generate swagger.yaml file using go-swagger in my golang project. I understood difference between path and operation. And here are links for individual documentation for swagger:router and swagger:operator. As I see the syntax…

BhanuKiran
- 2,631
- 3
- 20
- 36
1
vote
1 answer
Uncaught SyntaxError: Invalid regular expression: missing / when using go-swagger
I'm trying to implement go-swagger but this error keep flashing. I'm using windows machine. I appreciate any help.
My implementation:
opts := middleware.RedocOpts{RedocURL: "/swagger.yaml"}
sh := middleware.Redoc(opts,…

BlackLotus
- 318
- 4
- 12
1
vote
1 answer
How to implement unit test with a code generated by go swagger
I have two questions on this go swagger generated codes, firstly I made my first api with go swagger but my employer asked me to implement the unit (go test) but trying to perform the usual http test does not work,
here is my test code bellow
//…

Anachunam Michael
- 23
- 5