Skip to content

Commit

Permalink
Ensure response refs are also resolved (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
praneetloke authored May 17, 2024
1 parent 7268a52 commit 4c28e96
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,17 @@ func (o *OpenAPIContext) GatherResourcesFromAPI(csharpNamespaces map[string]stri
if statusCodeOkResp != nil {
jsonResp := statusCodeOkResp.Value.Content.Get(jsonMimeType)
if jsonResp != nil {
resourceResponseType = jsonResp.Schema.Value
// TODO: Looks like kin-openapi isn't automatically resolving
// the ref for response schemas unlike request schemas. Bug?
if jsonResp.Schema.Ref != "" {
v, err := o.Doc.Components.Schemas.JSONLookup(strings.TrimPrefix(jsonResp.Schema.Ref, componentsSchemaRefPrefix))
if err != nil {
return nil, o.Doc, err
}
resourceResponseType = v.(*openapi3.Schema)
} else {
resourceResponseType = jsonResp.Schema.Value
}
}
}

Expand Down

0 comments on commit 4c28e96

Please sign in to comment.