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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helpers for building JSON/OpenAPI schema referencing shared definitions #2971

Merged
merged 1 commit into from May 30, 2019

Conversation

Projects
None yet
3 participants
@bajtos
Copy link
Member

commented May 27, 2019

Introduce the following helpers:

  • getModelSchemaRef returning OpenAPI spec
  • getJsonSchemaRef returning JSON Schema

Example usage in controllers:

class MyController {
  @get('/my', {
    responses: {
      '200': {
        description: 'Array of MyModel model instances',
        content: {
          'application/json': {
            schema: getModelSchemaRef(MyModel),
          },
        },
      },
    },
  })
  async find(): Promise<MyModel[]> {
    // etc.
  }
}

Resolve #2631.

See also #1352, #2652 and #2653.

Checklist

馃憠 Read and sign the CLA (Contributor License Agreement) 馃憟

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

馃憠 Check out how to submit a PR 馃憟

@bajtos bajtos added this to the May 2019 milestone milestone May 27, 2019

@bajtos bajtos requested review from raymondfeng, jannyHou and nabdelgadir May 27, 2019

@bajtos bajtos self-assigned this May 27, 2019

@bajtos bajtos force-pushed the feat/getModelSchemaRef branch from f10a806 to 6a41e9e May 27, 2019

@nabdelgadir
Copy link
Contributor

left a comment

馃憤

* ```
*
* @param modelCtor The model constructor (e.g. `Product`)
* @param options Additional options

This comment has been minimized.

Copy link
@raymondfeng

raymondfeng May 28, 2019

Member

Please use @param modelCtor - The model ... and @param options - Additional options

This comment has been minimized.

Copy link
@bajtos

bajtos May 30, 2019

Author Member

Will do.

It's annoying that VSCode is generating tsdoc comments in a format that's not recognized by api-extractor :(

This comment has been minimized.

Copy link
@bajtos

bajtos May 30, 2019

Author Member

@raymondfeng How can we automate this part of review process, so that npm test fails when there are any tsdoc comments violating api-extractor requirements?

feat: helpers for building JSON/OpenAPI schema referencing shared def鈥
鈥nitions

Introduce the following helpers:

- `getModelSchemaRef` returning OpenAPI spec
- `getJsonSchemaRef` returning JSON Schema

Signed-off-by: Miroslav Bajto拧 <mbajtoss@gmail.com>

@bajtos bajtos force-pushed the feat/getModelSchemaRef branch from 6a41e9e to 808da4f May 30, 2019

@bajtos bajtos merged commit bf07ff9 into master May 30, 2019

4 checks passed

clahub All contributors have signed the Contributor License Agreement.
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.001%) to 91.893%
Details

@bajtos bajtos deleted the feat/getModelSchemaRef branch May 30, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.