The OpenAPI 3 spec specifies a field to flag a property as deprecated. oapi-codegen does not process this field, even though there is a standard way of marking fields (and other things) as deprecated in Go: https://github.com/golang/go/wiki/Deprecated
It should also be possible to add an extension comment to explain why something is deprecated and what to use instead.
Example YAML:
components:
schemas:
DeprecatedProperty:
type: object
required:
- newProp
- oldProp
properties:
newProp:
type: string
description: Use this now!
oldProp1:
type: string
deprecated: true
# description: No description on this one to test generation in that case
oldProp2:
type: string
deprecated: true
description: It used to do this and that
oldProp3:
type: string
deprecated: true
x-deprecated-reason: Use NewProp instead!
oldProp4:
type: string
deprecated: true
x-deprecated-reason: Use NewProp instead!
description: It used to do this and that
Expected Go code:
// DeprecatedProperty defines model for DeprecatedProperty.
type DeprecatedProperty struct {
// NewProp Use this now!
NewProp string `json:"newProp"`
// Deprecated:
OldProp1 *string `json:"oldProp1,omitempty"`
// OldProp2 It used to do this and that
// Deprecated:
OldProp2 *string `json:"oldProp2,omitempty"`
// Deprecated: Use NewProp instead!
OldProp3 *string `json:"oldProp3,omitempty"`
// OldProp4 It used to do this and that
// Deprecated: Use NewProp instead!
OldProp4 *string `json:"oldProp4,omitempty"`
}
The OpenAPI 3 spec specifies a field to flag a property as deprecated. oapi-codegen does not process this field, even though there is a standard way of marking fields (and other things) as deprecated in Go: https://github.com/golang/go/wiki/Deprecated
It should also be possible to add an extension comment to explain why something is deprecated and what to use instead.
Example YAML:
Expected Go code: