-
Notifications
You must be signed in to change notification settings - Fork 12
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
[Bug] Error with arrays and ValidatorFunctions #2
Comments
Hopefully, we will have a look at this before Xmas. This should be fixed. |
@BastiOfBerlin could you please test, if the fix works for your problem? |
Interestingly, the issue seemed to have vanished by using the newer generator as the problematic people.ts isn't generated at all. Instead, the API service implements the return type directly as Observable<Array>. But to answer your question: I fiddled around and cherry-picked your fix into the old 1.2.0 release and YES, making the validator property optional worked just fine! |
This bug is indeed solved with 3.3.4 of openapitools-generator (see #1296). |
@cogidoo regardless the fix of the generator, we should merge. I think it should be possible to create a factory only with a fewer count of properties and their validators. Does the optional flag break something? |
Hi,
I've got a 'People' model which is simply an array of persons:
This generates
export const PeopleValidators: {[K in keyof People]: Array<ValidatorFn>} = { };
, which results in the following transpilation error:ERROR in src/app/core/generated/api/model/people.ts(30,14): error TS2322: Type '{}' is not assignable to type '{ [x: number]: ValidatorFn[]; length: ValidatorFn[]; toString: ValidatorFn[]; toLocaleString: ValidatorFn[]; pop: ValidatorFn[]; push: ValidatorFn[]; concat: ValidatorFn[]; join: ValidatorFn[]; reverse: ValidatorFn[]; ... 21 more ...; includes: ValidatorFn[]; }'. Property 'length' is missing in type '{}'.
I don't know if simply assigning
null
instead of empty object conflicts with the form-control-factory, so I didn't try..I assume that this error will occur with every object that doesn't have own properties.
The text was updated successfully, but these errors were encountered: