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

feat(openapi-v3): add OAS3 visibility decorator #6414

Conversation

achrinza
Copy link
Member

closes #6392

Signed-off-by: Rifa Achrinza [email protected]

Checklist

  • DCO (Developer Certificate of Origin) signed in all commits
  • 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 👈

@@ -43,6 +43,8 @@ export interface TagsDecoratorMetadata {
tags: string[];
}

export type VisibilityDecoratorMetadata = 'documented' | 'undocumented';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum or union type, which one is better?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I am fine with the union type.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum may be useful for pure-JavaScript experiences, but I'm ok with either.

Copy link
Member Author

@achrinza achrinza Sep 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to enum to be in line with existing packages (e.g. repository, authorization, context`)

Will need to fix the errors. Errors fixed.

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome @achrinza! I like that you included detailed documentation, extensive test coverage and the code is closely following our coding style 👏🏻

I have few comments to consider, PTAL 👇🏻

BTW are there any places where we could replace explicit x-visibility: undocumented with @oas.visibility() decorator instead? It would be great to update https://loopback.io/doc/en/lb4/creating-components-rest-api.html#undocumented-endpoints to show the new approach.

docs/site/decorators/Decorators_openapi.md Show resolved Hide resolved
packages/openapi-v3/src/controller-spec.ts Outdated Show resolved Hide resolved
@@ -43,6 +43,8 @@ export interface TagsDecoratorMetadata {
tags: string[];
}

export type VisibilityDecoratorMetadata = 'documented' | 'undocumented';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I am fine with the union type.

packages/openapi-v3/src/types.ts Outdated Show resolved Hide resolved
packages/openapi-v3/src/types.ts Outdated Show resolved Hide resolved
@achrinza
Copy link
Member Author

achrinza commented Sep 26, 2020

I've modified the behaviour to explicitly keep the value of x-visibility: 'documented' when using @oas.visibility(OperationVisibility.DOCUMENTED) - the same behaviour when setting x-visibility directly.

If need be, this should be stripped away by RoutingTable instead.

Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good 👏🏻

I have two minor comments to consider 👇🏻

docs/site/extending/rest-api.md Outdated Show resolved Hide resolved
docs/site/extending/rest-api.md Outdated Show resolved Hide resolved
closes loopbackio#6392

Co-authored-by: Miroslav Bajtoš <[email protected]>
Signed-off-by: Rifa Achrinza <[email protected]>
@achrinza achrinza force-pushed the feat/adds-oas-visibility-decorator branch from abd55fb to aa0a15f Compare September 29, 2020 09:10
@achrinza achrinza requested a review from raymondfeng October 1, 2020 13:59
@raymondfeng raymondfeng merged commit c388cbf into loopbackio:master Oct 6, 2020
@achrinza achrinza deleted the feat/adds-oas-visibility-decorator branch October 6, 2020 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a new decorator @visibility('undocumented')
3 participants