Skip to content
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

In path parameter for an embedded struct is ignored and thus default to in query parameter #2701

Open
BhanuKiranChaluvadi opened this issue Jan 25, 2022 · 0 comments
Labels
generate spec Related to spec generation from code scanner

Comments

@BhanuKiranChaluvadi
Copy link

BhanuKiranChaluvadi commented Jan 25, 2022

Problem statement

In path parameter is ignored by go-swagger and thus defaulting to query parameter

Auto generated Swagger specification

/urcap/{vendorID}/{urcapID}/{version}:
    delete:
      consumes:
      - application/json
      operationId: deleteURCap
      parameters:
      - in: query
        name: vendorID
        type: string
        x-go-name: Vendor
      - in: query
        name: urcapID
        type: string
        x-go-name: ID
      - in: query
        name: version
        type: string
        x-go-name: Version
      produces:
      - application/json
      responses:
        "201":
          $ref: '#/responses/noContent'
      schemes:
      - http
      summary: Delete/Uninstall URCap if installed.
      tags:
      - URCap

Steps to reproduce

package types

type URCapID struct {
    Vendor  string `yaml:"vendorID" json:"vendorID" mapstructure:"vendorID"`
    ID      string `yaml:"urcapID" json:"urcapID" mapstructure:"urcapID"`
    Version string `yaml:"version" json:"version" mapstructure:"version"`
}

Handle Function

// swagger:parameters deleteURCap
type urcapIDParam struct {
    // The id of the urcap to uninstall/delete
    // in: path
    // required: true
    types.URCapID
}

// Uninstall and deletes urcap if installed
func Uninstall(w http.ResponseWriter, r *http.Request) {

    //  swagger:route DELETE /urcap/{vendorID}/{urcapID}/{version} URCap deleteURCap
    //
    //  Delete/Uninstall URCap if installed.
    //
    //      Consumes:
    //      - application/json
    //
    //      Produces:
    //      - application/json
    //
    //      Schemes: http
    //
    //      Responses:
    //          201: noContent

}

Environment

swagger version: 0.28.0
go version: 1.17.5
OS: Linux

@fredbi fredbi added scanner generate spec Related to spec generation from code labels Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generate spec Related to spec generation from code scanner
Projects
None yet
Development

No branches or pull requests

2 participants