kin-openapi icon indicating copy to clipboard operation
kin-openapi copied to clipboard

openapi2conv: ToV3Response Missing header conversion

Open sydiesel opened this issue 3 years ago • 1 comments

The current code is as follows,

func ToV3Response(response *entity.Response) (*openapi3.ResponseRef, error) {
	if ref := response.Ref; ref != "" {
		return &openapi3.ResponseRef{Ref: ToV3Ref(ref)}, nil
	}
	stripNonCustomExtensions(response.Extensions)
	result := &openapi3.Response{
		Description:    &response.Description,
		ExtensionProps: response.ExtensionProps,
	}
	if schemaRef := response.Schema; schemaRef != nil {
		result.WithJSONSchemaRef(ToV3SchemaRef(schemaRef))
	}
	return &openapi3.ResponseRef{Value: result}, nil
}

sydiesel avatar Jun 15 '21 03:06 sydiesel

Indeed headers (as well as examples) are not converted https://github.com/getkin/kin-openapi/blob/707e4ba1acb2ff3340c197dde6d4527b9e8bcbec/openapi2/openapi2.go#L216-L223

This snippet needs editing https://github.com/getkin/kin-openapi/blob/707e4ba1acb2ff3340c197dde6d4527b9e8bcbec/openapi2conv/openapi2_conv.go#L402-L415

cc https://github.com/getkin/kin-openapi/issues/366

PRs very welcomed :)

fenollp avatar Jun 16 '21 06:06 fenollp

I think this issue can be closed. The problem seems to be fixed thanks to https://github.com/getkin/kin-openapi/pull/483.

jspdown avatar Jul 27 '23 09:07 jspdown