Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,8 @@ How the specification maps onto Go:
like. A query parameter of the format is sent and read the same way.
- **Ignored header parameters** — a header parameter named `Accept`,
`Content-Type` or `Authorization` is ignored, as OpenAPI 3.1 says: the client
sends the request body's media type and the credential of the security scheme.
- **Accept** — each request sends the media types its operation's responses
declare, each once, such as `application/json`, or none where no response has
a body.
sends the request body's media type and the credential of the security scheme,
and no Accept, as Go's HTTP client does not.
- **Unknown formats** — a format the generator does not know, which OpenAPI 3.1
allows, gives the plain type: an `int`, a `float64` or a `string`.
- **Empty dates** — an empty string, which an API may send for a date or
Expand Down
6 changes: 2 additions & 4 deletions README/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,8 @@ How the specification maps onto Go:
like. A query parameter of the format is sent and read the same way.
- **Ignored header parameters** — a header parameter named `Accept`,
`Content-Type` or `Authorization` is ignored, as OpenAPI 3.1 says: the client
sends the request body's media type and the credential of the security scheme.
- **Accept** — each request sends the media types its operation's responses
declare, each once, such as `application/json`, or none where no response has
a body.
sends the request body's media type and the credential of the security scheme,
and no Accept, as Go's HTTP client does not.
- **Unknown formats** — a format the generator does not know, which OpenAPI 3.1
allows, gives the plain type: an `int`, a `float64` or a `string`.
- **Empty dates** — an empty string, which an API may send for a date or
Expand Down
14 changes: 0 additions & 14 deletions ir/ir.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,20 +666,6 @@ type Response struct {
BodyDescription string `json:"bodyDescription,omitzero"`
}

// Accept is the Accept header the operation sends: the media types its responses declare, in their order, or "" where
// none has a body.
func (op Operation) Accept() string {
var types []string

for _, r := range op.Responses {
if r.ContentType != "" && !slices.Contains(types, r.ContentType) {
types = append(types, r.ContentType)
}
}

return strings.Join(types, ", ")
}

// SuccessDescription is what the specification says beside the reference to the schema of the body the operation
// returns, if anything.
func (op Operation) SuccessDescription() string {
Expand Down
17 changes: 0 additions & 17 deletions ir/ir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,3 @@ func TestZeroVal(t *testing.T) {
}
}
}

// An operation accepts the media types its responses declare, each once, in their order; one without a body adds none.
func TestOperation_Accept(t *testing.T) {
op := Operation{Responses: Responses{
{StatusCode: "200", ContentType: "application/json"},
{StatusCode: "204"},
{StatusCode: "400", ContentType: "application/problem+json"},
{StatusCode: "500", ContentType: "application/json"},
}}
if got, want := op.Accept(), "application/json, application/problem+json"; got != want {
t.Errorf("Accept() = %q, want %q", got, want)
}

if got := (Operation{Responses: Responses{{StatusCode: "204"}}}).Accept(); got != "" {
t.Errorf("no body: Accept() = %q, want none", got)
}
}
3 changes: 0 additions & 3 deletions render/templates/client.gen.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,6 @@ func (c *Client) {{.Name}}(ctx context.Context{{range .PathParams}}, {{.GoName}}
{{ range .FixedHeaders -}}
"{{ .JSONName }}": []string{ {{- .Value -}} },
{{ end -}}
{{ with .Accept -}}
"Accept": []string{ {{- printf "%q" . -}} },
{{ end -}}
"User-Agent": []string{c.userAgent},
{{ if and .RequestBody .RequestBody.Required -}}
"Content-Type": []string{ {{printf "%q" .RequestBody.ContentType}} },
Expand Down
1 change: 0 additions & 1 deletion testdata/apikey/pkg/apikey/client.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions testdata/auth/pkg/auth/client.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions testdata/debug/pkg/debug/client.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions testdata/golden/pkg/golden/client.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading