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

@name doesn't work #1909

Open
tonidy opened this issue Oct 21, 2024 · 8 comments
Open

@name doesn't work #1909

tonidy opened this issue Oct 21, 2024 · 8 comments
Labels

Comments

@tonidy
Copy link

tonidy commented Oct 21, 2024

Describe the bug
When I upgraded swag from 1.16.3 to 1.16.4, I noticed the renaming model to display (@name) didn't work in my struct:

type CardResponse struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
} // @name CardResponseV2

Expected behavior

@name should be working

Screenshots

N/A

Your swag version
swag version v1.16.4

Your go version
go version go1.23.2 darwin/arm64

Desktop (please complete the following information):

  • OS: [e.g. iOS] macOS
  • Browser: [e.g. chrome, safari]
  • Version: [e.g. 22]

Additional context
Add any other context about the problem here.

@njacob1001
Copy link

njacob1001 commented Oct 23, 2024

Same issue,

type UIElement struct {
	Id          string            `json:"id"`
	UIElement    []UIElement   `json:"UIElement"`
	Title       string            `json:"title"`
} // @name UIElement

the output is

{
"internal_form_infrastructure_web_dto.UIElement": {
            "type": "object",
            "properties": {
                "UIElement": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/internal_form_infrastructure_web_dto.UIElement"
                    }
                },
                "id": {
                    "type": "string"
                },
                "title": {
                    "type": "string"
                }
            }
        }
}

@ubogdan ubogdan added the bug label Oct 24, 2024
@YlanzinhoY
Copy link

What should the correct output look like?

@tonidy
Copy link
Author

tonidy commented Nov 19, 2024

@YlanzinhoY with this struct:

type UpdateGameConfigRequest struct {
	GameConfig model.GameConfig `json:"gameConfig" validate:"required"`
} // @name UpdateGameConfigRequest

Here is when I run my code with swag 1.6.4:

image

The correct output should be dto.UpdateGameConfigRequest

@temamagic
Copy link

In my case it will work when comment like // @name User, but after swag fmt // @name UpdateUser it doesn't works

@njacob1001
Copy link

This issue was introduced in the new version of swag@v2
https://github.com/swaggo/swag/releases/tag/v2.0.0-rc4

I was using the previous version v2.0.0-rc3, but after updating to v2.0.0-rc4, the issue reappeared.

@ubogdan
Copy link
Contributor

ubogdan commented Dec 17, 2024

Can someone take a look at it and write a PR?

@njacob1001
Copy link

I'm figuring out which commit is, I found this one #1866

from this point the command doesn't work due to invalid memory address or nil pointer dereference

I'm still working on this investigation

@njacob1001
Copy link

njacob1001 commented Dec 17, 2024

@ubogdan I've created this PR #1948 hope this helps to have more context about this issue, I know it is not a final solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants