swaggo / swag

Automatically generate RESTful API documentation with Swagger 2.0 for Go.
MIT License
10.49k stars 1.19k forks source link

how to set generate example filed name use json tag #1708

Open ttktatakai opened 9 months ago

ttktatakai commented 9 months ago

for example I have a struct as input parameter

type Account struct {
  AccountType int `json:"account_type"`
}

Then I start swagger by using https://github.com/swaggo/gin-swagger. The paramters example value shows as

{
  "accountType": "string"
}

I expected the field name is used json tag like

{
  "account_type": "string"
}

Is there anyway to config this? Thanks in advance.

rickywei commented 9 months ago

You could use option -p snakecase

--propertyStrategy value, -p value Property Naming Strategy like snakecase,camelcase,pascalcase (default: "camelcase")