-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
Description
I'm want to store any type on a property, for example:
@model()
class MyModel extends Entity{
@property({id: true})
id: number;
@property({
type: 'I DONT KNOW WHT TO PUT HERE TO ALLOW ANY VALUE'
})
value: any;
}
The idea, is that, when I POST to that entity I can send the following examples, and all work the same
POST /mymodels
{
"id": 1,
"value": 1
}
---
POST /mymodels
{
"id": 2,
"value": "1"
}
---
POST /mymodels
{
"id": 3,
"value": true
}
---
POST /mymodels
{
"id": 4,
"value": null
}
---
POST /mymodels
{
"id": 5,
"value": {"a":"b" }
}
Note: Database is a mongo db, so it shouldn't be a problem.
Acceptance Criteria
- Specify type
anyinlb4 modelcli should not result in "Unsupported type" error. - Add test to make sure the type can be converted to OpenAPI spec correctly
References:
- Code that gives out the "unsupported type" error: https://github.com/strongloop/loopback-next/blob/master/packages/repository-json-schema/src/build-schema.ts#L167
- Supported types: https://loopback.io/doc/en/lb3/LoopBack-types.html. This is a LB3 docs, I assume it would be the same for LB4 (?).