Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openapi2conv: ToV3Response Missing header conversion #370

Closed
sydiesel opened this issue Jun 15, 2021 · 2 comments
Closed

openapi2conv: ToV3Response Missing header conversion #370

sydiesel opened this issue Jun 15, 2021 · 2 comments

Comments

@sydiesel
Copy link

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
}
@fenollp
Copy link
Collaborator

fenollp commented Jun 16, 2021

Indeed headers (as well as examples) are not converted

type Response struct {
openapi3.ExtensionProps
Ref string `json:"$ref,omitempty"`
Description string `json:"description,omitempty"`
Schema *openapi3.SchemaRef `json:"schema,omitempty"`
Headers map[string]*Header `json:"headers,omitempty"`
Examples map[string]interface{} `json:"examples,omitempty"`
}

This snippet needs editing

func ToV3Response(response *openapi2.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
}

cc #366

PRs very welcomed :)

@jspdown
Copy link

jspdown commented Jul 27, 2023

I think this issue can be closed. The problem seems to be fixed thanks to #483.

@fenollp fenollp closed this as completed Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants