You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One huge TypeScript problem (though it's ignorable) is that the response body properties are all optional.
Problem
sw2dts generates optional types by default unless the user sets the required tag in the property of a component.
Point:
type: objectproperties:
x:
type: numbery:
type: numberrequired: # <-- This
- x
- y
=>
exportinterfacePoint{x: numbery: number}
Without the required tags, we end up with
exportinterfacePoint{x?: numbery?: number}
The auto-generated JSON that we read from (http://www.mingweisamuel.com/riotapi-schema/openapi-3.0.0.yml) does not have the required property. However, I do not believe that is the problem of the JSON we read from. required (based on what I know) is based on parameters (path & query) for an endpoint, and not for the response classes themselves.
Manual Workaround
Workaround 1
constname: string=summoner.name// BREAKS. string != string | undefinedconstname: string=summoner.name!// probably the best way (non-null assertion operator)constname=summoner.nameasstring// force it to work if you know it's not undefined
Workaround 2
Manual file-editing, which is not fun.
If I forget about this and you're having issues due to bad code and run-time errors hit me up
Will revert the typings as it is unsafe and I don't want to go through every response to determine what fields are missing in which situation until I have a lot of free time. Body param DTOs will gain their optional params, which is nice (requires casting though), while response DTOs will still use optional fields.
Activity
[-]TypeScript Optional Response Parameteres[/-][+]TypeScript Optional Response Parameters[/+]cnguy commentedon Feb 4, 2019
League API responses seem to not have optional member fields (there is no Static API anymore). It might be worth considering a pull request.
fix (Typings): Remove optional member fields #42 TADA
fix (Typings): Remove optional member fields #42 TADA
cnguy commentedon Mar 8, 2019
MingweiSamuel/riotapi-schema#7
Will revert the typings as it is unsafe and I don't want to go through every response to determine what fields are missing in which situation until I have a lot of free time. Body param DTOs will gain their optional params, which is nice (requires casting though), while response DTOs will still use optional fields.
Revert "fix (Typings): Remove optional member fields #42 TADA"