-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Epic: ENUM type (ORM, OpenAPI, etc.) #3033
Comments
I'm currently looking for a way to validate properties on my model of a |
any update about this feature? |
Works if you put the enum in jsonSchema object
|
@zzhenryquezz Take care in using this though as it may not be validating input. See comment. Also please use the voting system and refrain from creating comments that add no value to conversation such as |
@dougal83 I check on my side with the enum defined at property level (decorator) and this works perfectly (validation at controller level at least and spec generated). Enum as to be specified in a specific way tho enum QueryLanguage {
JSON = 'json',
SQL = 'sql',
}
// ...
@property({
type: 'string',
required: true,
jsonSchema: {
enum: Object.values(QueryLanguage),
},
})
queryLanguage: QueryLanguage; |
Yep, this is how I use here too. If you pass a normal enum will not work, probably because the jsonSchema expects an array of string or number but the enum of Typescript is converted to an object. But this way works well for me. |
@agnes512 @nabdelgadir Let's document this. |
I have an issue with this approach. lb4 inlines this jsonSchema fragment into both |
|
This issue has been marked stale because it has not seen activity within six months. If you believe this to be in error, please contact one of the code owners, listed in the |
This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the |
Implement a new property type - enum (enumeration).
Example model definition:
This issue is a replacement for strongloop/loopback#1321 that's tracking ENUM feature request in LoopBack 3.x
Areas to cover:
string
andnumber
as a backing datatypecreate
andupdateAttributes
enum
constraint to the discovered definitions where applicableenum
and include the constraint in the schema produced@loopback/rest
should validate ENUM constraints for input parameters, see Complex OpenAPI Validations with@property
#1624The text was updated successfully, but these errors were encountered: