docs.nestjs.com icon indicating copy to clipboard operation
docs.nestjs.com copied to clipboard

docs(openapi): Add docs to throw different exceptions under the same …

Open AxelDavid45 opened this issue 2 years ago • 4 comments

…http code

PR Checklist

Please check if your PR fulfills the following requirements:

  • [ x] The commit message follows our guidelines: https://github.com/nestjs/docs.nestjs.com/blob/master/CONTRIBUTING.md

PR Type

What kind of change does this PR introduce?

  • [ ] Bugfix
  • [ ] Feature
  • [ ] Code style update (formatting, local variables)
  • [ ] Refactoring (no functional changes, no api changes)
  • [ ] Build related changes
  • [x] Docs
  • [ ] Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

I think it's worthy to add this part to the docs because the decorator @ApiExtraModels() doesn't have an concrete example of its implementation.

Does this PR introduce a breaking change?

  • [ ] Yes
  • [x] No

Other information

AxelDavid45 avatar Feb 04 '22 21:02 AxelDavid45

can you add a hint at the end to tell from where refs is imported? I didn't find any reference to this utility in the docs yet

Like this one

image

micalevisk avatar Feb 04 '22 23:02 micalevisk

@micalevisk Done, is it OK?

AxelDavid45 avatar Feb 05 '22 18:02 AxelDavid45

@Injectable()
export class CatController {
  @ApiExtraModels(BadAppCodeException, BadEmailException)
  @ApiBadRequestResponse({
    schema: {
      oneOf: refs(BadAppCodeException, BadEmailException),
    },
  })
  multipleErrorsResponse() { ... }
}

some indentation

micalevisk avatar Feb 05 '22 19:02 micalevisk

@micalevisk Added indentation

AxelDavid45 avatar Feb 05 '22 21:02 AxelDavid45