-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Description / Steps to reproduce / Feature proposal
LoopBack's @requestBody decorator is supposed to be capable of validation complex OpenAPI Schemas such as:
{
type: string,
minLength: 10,
format: 'email'
}
This only works when this schema is passed to the spec via the @model decorator (top-down approach) ... vs. the more common route / CLI recommended path of using the @property decorator.
If you add validation properties such as minLength, format, etc. to a property using the @property decorator the validation properties don't even show up in /openapi.json and as such are never validated against the requestBody since those validations aren't a part of the schema.
Current Behavior
- Can't add validation properties using the
@propertydecorator.
Expected Behavior
- Should be able to add model validation properties to a property via the
@propertydecorator.
Acceptance Criteria
-
@property()decorator should accept additional validation properties as per the OpenAPI Spec and add them to the schema of the Model (should show in/openapi.json) - see Refactor metaToJsonProperty to accept AJV keywords #2685 - Incoming
@requestBody()should honour validation properties added via@propertydecorator. - Confirm
@model()also works in preserving the validation properties - Update any relevant docs (if needed)
- Tests
See Reporting Issues for more tips on writing good issues
David-Mulder, SamMalayek, psaunders and shadyanwar