-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Steps to reproduce
define a nested array model property like the following
import {Model, property} from '@loopback/repository';
class testModel extends Model {
@property.array(Array)
nestedArr: Array<Array<string>>;
}
Current Behavior
The app crashes with the error Cannot start the application. Error: "items" property must be present if "type" is an array
Expected Behavior
The nested array property should be defined without problems. Would be nice to also allow defining the type of the nested array for example @property.array(Array<string>).
Link to reproduction sandbox
Additional information
darwin x64 10.19.0
├── @loopback/authentication@3.3.1
├── @loopback/authorization@0.4.9
├── @loopback/boot@1.7.2
├── @loopback/context@2.0.0
├── @loopback/core@1.12.2
├── @loopback/openapi-v3@1.12.0
├── @loopback/rest@1.26.0
└── @loopback/rest-explorer@1.4.8
Related Issues
See Reporting Issues for more tips on writing good issues
Acceptance Criteria
- Update documentation to clarify that @property.array() decorator does not support nested arrays in model properties ( add reasons why, Ts type issues)
- Fix validation code in https://github.com/strongloop/loopback-next/blob/master/packages/repository-json-schema/src/build-schema.ts#L221 to return appropriate error when seeing a nested array.
- Add example to achieve nested arrays with json schema directly using @param() decorator