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

Add decorator to allow specification of the schema type name #981

Closed
zroadhouse-rigup opened this issue Sep 30, 2020 · 9 comments
Closed

Comments

@zroadhouse-rigup
Copy link

I'm submitting a...


[ ] Regression 
[ ] Bug report
[X] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

The Open API schema type name is the same as the type name.

Expected behavior

Add a decorator to allow specification of a schema type name that is different from the type name.

For example:

@ApiSchema({ name: 'MyType' })
class MyTypeDto {
}

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Type names often have suffixes such as Entity or Dto that represent internal
implementation choices. Allowing explicit specification of the schema type name
would avoid leaking these choices into the public interface.

Environment


Nest swagger version: 4.5.12

 
For Tooling issues:
- Node version: 12.13  
- Platform: Mac 

Others:

@kamilmysliwiec
Copy link
Member

Would you like to create a PR for this?

@libertysoftware
Copy link

Would you like to create a PR for this?

May I try?

@zroadhouse-rigup
Copy link
Author

zroadhouse-rigup commented Oct 1, 2020

@libertysoftware - go for it! I likely won't have time to get to it in the near future.

@radacovsky
Copy link

See the PR here
#983

@zroadhouse-rigup
Copy link
Author

zroadhouse-rigup commented Oct 5, 2020

On review, I'm thinking name should actually be title to be consistent with both the OpenAPI and JSON schema specifications. EDIT: there are other places in the annotations such as enumName so perhaps name is fine?)

And as we're adding that, we should add the other properties that are tied to the schema object that can't be set via annotations on the properties:

  • description
  • externalDocs
  • deprecated

After creating this issue, I found that I really wanted at least description where now I can only provide documentation comments on the type.

@pbn4
Copy link

pbn4 commented Oct 30, 2020

Hello, what's the status of this issue?

@radacovsky
Copy link

The original feature is implemented in my fork but the additional requested features not. I think my PR is still not merged.

@zroadhouse-rigup
Copy link
Author

Removed my comment from #983 in case it was blocking getting your change merged @radacovsky . Makes sense that we could file separate tickets for the other requested features.

@kamilmysliwiec
Copy link
Member

Let's track this here #983

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants