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

docs: changes Model.md to reflect known issue #3871

Merged
merged 1 commit into from
Oct 7, 2019

Conversation

taicho
Copy link
Contributor

@taicho taicho commented Oct 4, 2019

Changes Model.md to reflect a known issue with property reflection when dealing with type aliases and extracted types. See #3863. No code changes.

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 👈

@@ -465,6 +465,10 @@ The property decorator leverages LoopBack's
[metadata package](https://github.com/strongloop/loopback-next/tree/master/packages/metadata)
to determine the type of a particular property.

{% include note.html content="
Currently, property types must be specified explicitly either on the property itself or via the `type` option of the property decorator. Aliased types or types that extracted from a class or interface (e.g. `public name: OtherClass['otherProperty']`) will not work properly and will result in the property type being resolved as an empty object rather than the intended type in the generated OpenAPI specifcation. This is due to a limitation and flaw in the way TypeScript currently generates the metadata that is used to generate the OpenAPI specification for the application. (see [Issue #3863](https://github.com/strongloop/loopback-next/issues/3863))
" %}
Copy link
Contributor

@raymondfeng raymondfeng Oct 4, 2019

Choose a reason for hiding this comment

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

Can you provide a code snippet that the design:type is not emitted by TypeScript to make it clear? For example:

@model()
class MyModel {
  @property()
  p1: string[]; // => design:type: Array
  p2: MyType<string>; // => design:type Object
  p3: OtherClass['otherProperty']; // => design:type: Object
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@raymondfeng Thanks - I've added a snippet to the note in an amended commit.

Changes Model.md to reflect a known issue with property reflection when dealing with type aliases and extracted types. Edit - adds example suggested by @raymondfeng.  See loopbackio#3863. No code changes.
@raymondfeng raymondfeng merged commit 09bafe1 into loopbackio:master Oct 7, 2019
@raymondfeng
Copy link
Contributor

@taicho PR landed. Thank you for the contribution! 👍

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.

3 participants