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

v2: x-name is a tab too far for API Operation #1913

Open
mtuska opened this issue Oct 23, 2024 · 1 comment
Open

v2: x-name is a tab too far for API Operation #1913

mtuska opened this issue Oct 23, 2024 · 1 comment
Labels
bug v2 Used for all v2 related issues

Comments

@mtuska
Copy link

mtuska commented Oct 23, 2024

Describe the bug
In the v2 branch with the --v3.1 option, the x-name parsing is placing the extended attributes within "responses" of a path, rather than inside the path object itself. Using the swagger v2 parser works as expected, with no additional indentation, but v3.1 is failing. I am correcting this locally with a quick sed on the yaml(Lazy-man's bug fix).

To Reproduce

// PostAction	godoc
// @Summary		Execute a specified action
// @Description	This endpoint allows the execution of a specified action
// @ID			postAction
// @Tags		action
// @Param		action	path	string	true	"The action to be performed"
// @Success	200 {object}	Action_Result	"Successful execution of the action"
// @Router		/action/{action} [post]
// @Security	ApiKeyAuth
//
// @x-openai-isConsequential	true
func PostAction(c *gin.Context) {
}

Then with the other boiler plate, create the 3.1 spec.
swag-v2 init --v3.1

The above results in the following for me:

  /action/{action}:
    post:
      description: This endpoint allows the execution of a specified action
      operationId: postAction
      parameters:
      - description: The action to be performed
        in: path
        name: action
        required: true
        schema:
          type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/action.Action_Result'
          description: Successful execution of the action
        x-openai-isConsequential: true
      security:
      - ApiKeyAuth: []
      summary: Execute a specified action on a CPE
      tags:
      - action

Expected behavior
Simply expect the extended attribute to be indented 1 set less.

  /action/{action}:
    post:
      description: This endpoint allows the execution of a specified action
      operationId: postAction
      parameters:
      - description: The action to be performed
        in: path
        name: action
        required: true
        schema:
          type: string
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/action.Action_Result'
          description: Successful execution of the action
      x-openai-isConsequential: true
      security:
      - ApiKeyAuth: []
      summary: Execute a specified action on a CPE
      tags:
      - action

Your swag version
v2.0.0-rc3

Your go version
go version go1.23.1 linux/amd64

Desktop (please complete the following information):

  • OS: fedora 42
  • Browser: brave
  • Version: Version 1.71.114 Chromium: 130.0.6723.58 (Official Build) (64-bit)
@ubogdan ubogdan added bug v2 Used for all v2 related issues labels Oct 23, 2024
@ubogdan
Copy link
Contributor

ubogdan commented Oct 23, 2024

OAS 3 has a different code for parsing since the spec is different. Not a surprise.
if you need this feature in v2 (OAS 3) please feel free to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug v2 Used for all v2 related issues
Projects
None yet
Development

No branches or pull requests

2 participants