expect-digital / go-request

MIT License
1 stars 0 forks source link

Use single field tag name #26

Open janishorsts opened 1 month ago

janishorsts commented 1 month ago

Currently, the field tag has multiple names that increase the risk of conflicts with other field tags from other packages. Breaking change.

Currently

type Req struct {
  B int `path:"b"`
  C int `query:"c"`
  D int `body:"json"`

  E []int `query:"e,implode,pipeDelimited"`
}

Next

Use single field tag "oas" (OpenAPI Specification). All settings are comma-separated as before. Additionally, a new origin setting is added:

type Req struct {
  B int `oas:"b,path"`
  C int `oas:"c,query"`
  D int `oas:",body,json"` // if name is provided, it is ignored

  E []int `oas:"e,query,implode,pipeDelimited"`
}
mvilks commented 1 month ago

I'd rewrite

  D int `oas:"d,body,json"`

I.e. [name][where][options]

janishorsts commented 1 month ago

I don't want to enforce the sequence, it makes it harder to use. The setting names do not conflict, they can be used in any order.

mvilks commented 1 month ago

If you rename the tag to "OpenAPI Request Specification" you can use this for logo: 🚣 ;)

janishorsts commented 1 month ago

In principle, the syntax is <name>,<settings> where <settings> is a comma-separated list of settings.