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

Helper converting Model definitions to Swagger/OpenAPI schemas #700

Closed
3 tasks
bajtos opened this issue Nov 3, 2017 · 5 comments
Closed
3 tasks

Helper converting Model definitions to Swagger/OpenAPI schemas #700

bajtos opened this issue Nov 3, 2017 · 5 comments
Assignees
Labels

Comments

@bajtos
Copy link
Member

bajtos commented Nov 3, 2017

In our Todo model example, we are duplicating information about model properties - first time in Model definition, second time in Swagger (OpenAPI) Schema.

We should have a helper function that can create Swagger/OpenAPI Schema from the Model data.

Acceptance criteria

  • A blog post explaining how to use this new helper, maybe how is it built internally?
  • The implementation (including tests, etc.)
  • Documentation (including API docs)
@bajtos
Copy link
Member Author

bajtos commented Nov 3, 2017

A thing to figure out: which version to support - Swagger (v2) or OpenAPI (v3) or both? This is related to #182

@bajtos bajtos added p1 labels Nov 3, 2017
@M-jerez
Copy link

M-jerez commented Nov 3, 2017

Hi,

This probably has been discussed before, but I would go the other way around, I would define the models using the Swagger/OpenAPI schema, and generate TS interface/class to extend/implement.
This would allow for much better tooling for models creation/edition without coding requirements (thinking on CRM-CMS) and still

Please ignore this message if this has been already discussed.

@jannyHou jannyHou self-assigned this Nov 7, 2017
@jannyHou
Copy link
Contributor

jannyHou commented Nov 8, 2017

I kind of agree with @M-jerez, I would expect this helper tool give developers the flexibility to convert a Swagger style schema to any format of Model definition: either the official ModelDef style in LoopBack 4(which may change in the future) or any ModelDef flavour the users like.

But IMO one of our goals is relieving users from writing Swagger schema: they define LB style model and the Swagger schema will be auto-generated accordingly and be consumed by controller(@api, or apiDef annotations).

So I propose make the tool be able to convert from both directions:
SwaggerSchema <---> ModelDef

writing more about details, will update later...

And another thing to consider: LB4 should be able to plugin other ORM

@bajtos
Copy link
Member Author

bajtos commented Dec 8, 2017

Hello @M-jerez, thank you for your comment, your request make a lot of sense to me! It's out of scope of this particular issue, but I believe we have it already covered by #725. I'll cross-post your comment there for posterity.

@bajtos
Copy link
Member Author

bajtos commented Dec 12, 2017

Closing in favor of #786

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

No branches or pull requests

3 participants