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

@response(204, ... ) will not create the same type of response as schema definition. #4841

Closed
AlexDM0 opened this issue Mar 10, 2020 · 6 comments

Comments

@AlexDM0
Copy link

AlexDM0 commented Mar 10, 2020

Steps to reproduce

Current Behavior

If I want to use decorators for response, I cannot seem to get a correct 204 in the explorer.

If I use the schema definition:

  @post('/example', {responses: {204: { description: "Hello world"}}})
  example(
    @param.query.number("test") test : number,
  ) : void {
    // do something
  }

I get a clean 204 in the explorer:

Code | Description | Links
-- | -- | --
204 | Hello world

If I use the decorator however:

 @post('/example')
  @response(204, {description:"Hello world"})
  example(
    @param.query.number("test") test : number,
  ) : void {
    // do something
  }

I get the typeselector for the response:

Code | Description | Links
204 | No ContentMedia typeapplication/jsonControls Accept header.Example ValueSchema(no example available)

Since I cannot stack the @response decorators once I use the schema as described above, I can't easily compose my responses if the default return type is 204.

Finally, if I define no schema and no response decorator, the default return code is 200 which should be success with data instead of 204, which would make more sense if no data return type has been specified.

Expected Behavior

Link to reproduction sandbox

This works with the simple lb4 app empty project and a controller with that endpoint. Look at the explorer to see the difference.

Additional information

None required.

Related Issues

I searched for 204 but I could not find anything similar.

@AlexDM0 AlexDM0 added the bug label Mar 10, 2020
@dougal83
Copy link
Contributor

Hey @mschnee, Could you please take a look?

@achrinza
Copy link
Member

achrinza commented Mar 12, 2020

It seems that the oas.response() convenience wrapper ignores description.

Link to reproduction sandbox

https://github.com/achrinzatest/loopback4-sandbox-4841

Additional information

$ node -e 'console.log(process.platform, process.arch, process.versions.node)' && npm ls --prod --depth 0 | grep loopback
win32 x64 12.16.0
[email protected] C:\Users\rifaa\Documents\loopback4-sandbox-4841
+-- @loopback/[email protected]
+-- @loopback/[email protected]
+-- UNMET PEER DEPENDENCY @loopback/[email protected]
npm+-- @loopback/[email protected]
ERR!+-- UNMET PEER DEPENDENCY @loopback/[email protected]
 peer dep missing: @loopback/core@^1.12.0, required by @loopback/[email protected]
+-- @loopback/[email protected]
npm+-- @loopback/[email protected]
ERR!+-- @loopback/[email protected]
 peer dep missing: @loopback/repository@^1.16.0, required by @loopback/[email protected]
npm ERR! peer dep missing: @loopback/core@^1.12.0, required by @loopback/[email protected]
npm ERR! peer dep missing: @loopback/repository@^1.16.0, required by @loopback/[email protected]
npm ERR! peer dep missing: @loopback/core@^1.12.0, required by @loopback/[email protected]
npm ERR! peer dep missing: @loopback/repository@^1.16.0, required by @loopback/[email protected]
npm ERR! peer dep missing: @loopback/core@^1.12.0, required by @loopback/[email protected]
npm ERR! peer dep missing: @loopback/core@^1.12.0, required by @loopback/[email protected]
npm ERR! peer dep missing: @loopback/core@^1.12.0, required by @loopback/[email protected]

@AlexDM0
Copy link
Author

AlexDM0 commented Mar 12, 2020

I see you have indeed reproduced it in your sandbox. Let me know if there's anything more I can do to help out!

@achrinza
Copy link
Member

achrinza commented Apr 3, 2020

I suspect the following may be causing the issue:

https://github.com/strongloop/loopback-next/blob/4cf24ea4b9befc6def6fb92d1785fdfd2715832d/packages/openapi-v3/src/decorators/response.decorator.ts#L48-L55

Will need to do some more digging...

I'd like to hear input from @mschnee as the author of #4550.

@stale
Copy link

stale bot commented Dec 25, 2020

This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository. This issue will be closed within 30 days of being stale.

@stale stale bot added the stale label Dec 25, 2020
@stale
Copy link

stale bot commented Jul 14, 2021

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

@stale stale bot closed this as completed Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants