-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Labels
Description
For instance, given:
openapi: "3.0.0"
info:
version: 1.0.0
title: Generate models
paths:
/client:
put:
operationId: updateClient
requestBody:
required: false
content:
application/json:
schema:
type: object
properties:
foo:
type: string
oapi-codegen v2.5.0 will generate:
package client
// ...
type UpdateClientJSONBody struct {
Foo *string `json:"foo,omitempty"`
}
// NOTE that this is not optional
type UpdateClientJSONRequestBody UpdateClientJSONBody
type ClientInterface interface {
// NOTE that this is not an optional body
UpdateClientWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
// NOTE that this is not an optional body
UpdateClient(ctx context.Context, body UpdateClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
}It would be better if we detected required: false and instead i.e.
type UpdateClientJSONRequestBody *UpdateClientJSONBody
type ClientInterface interface {
// A body can be set from raw data
UpdateClientWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
// A body can be set as its struct
UpdateClient(ctx context.Context, body *UpdateClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
}As a breaking change to currently generated code, this would be via an output-options.
Reactions are currently unavailable