You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I've got an API that uses the same response format repeatedly, so I opted for using a $ref to avoid the repetition in my spec.
It appears that when you do this, the generator does not seem to correctly pick up the response schema, resulting in it being left out. I've tested this in the go and javascript generators, so I have a suspicion it's a more widespread issue.
The workaround here is to just avoid $ref and repeat the response config each time it is needed.
I am doing this on macOS, so I've needed to use docker to work, but I suspect the equivalent CLI instructions should suffice. (there's no extra config to worry about)
Once you have the generated code, here's what I've noticed:
go
The Execute() methods typically return (Model, *http.Response, error), which is found in api_default.go:
// no $ref: works as expectedfunc (rApiNoRefGetRequest) Execute() (string, *http.Response, error) {
// uses $ref for response, but no $ref for content: missing modelfunc (rApiRefNoRefGetRequest) Execute() (*http.Response, error) {
// uses $ref for response and content: missing modelfunc (rApiRefRefGetRequest) Execute() (*http.Response, error) {
javascript
The returnType variables generated typically use the model model or null when the response content has no detected schema/model, which is found in src/api/DefaultApi.js
// no $ref: works as expectedletreturnType='String';// uses $ref for response, but no $ref for content: missing modelletreturnType=null;// uses $ref for response and content: missing modelletreturnType=null;
Related issues/PRs
I have not yet found a ticket that seems to reference this issue as well, as most of my search criteria result in hundreds of issues as they are unfortunately rather common terms.
Suggest a fix
n/a
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
I've got an API that uses the same response format repeatedly, so I opted for using a
$ref
to avoid the repetition in my spec.It appears that when you do this, the generator does not seem to correctly pick up the response schema, resulting in it being left out. I've tested this in the
go
andjavascript
generators, so I have a suspicion it's a more widespread issue.The workaround here is to just avoid
$ref
and repeat the response config each time it is needed.openapi-generator version
7.1.0-SNAPSHOT (latest docker image as of today)
OpenAPI declaration file content or url
Generation Details
I am doing this on macOS, so I've needed to use docker to work, but I suspect the equivalent CLI instructions should suffice. (there's no extra config to worry about)
Steps to reproduce
Once you have the generated code, here's what I've noticed:
go
The
Execute()
methods typically return(Model, *http.Response, error)
, which is found inapi_default.go
:javascript
The
returnType
variables generated typically use the model model ornull
when the response content has no detected schema/model, which is found insrc/api/DefaultApi.js
Related issues/PRs
I have not yet found a ticket that seems to reference this issue as well, as most of my search criteria result in hundreds of issues as they are unfortunately rather common terms.
Suggest a fix
n/a
The text was updated successfully, but these errors were encountered: