-
Notifications
You must be signed in to change notification settings - Fork 27
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
Make Optional API Fields Optional in Typescript Client #42
Comments
Does it force the |
I will test with an empty string to see if that behaves the way I need, and worst case scenario I will generate a UUID client side in the short term. But still probably should be changed at some point. |
Agreed, this appears to be a bug. |
Not sure the best way to fix this. The current method signatures is:
It should be (I think):
But we can't have a required parameter follow an optional, so would need to re-order these parameters to use the Is there a better way to do this in TS w/out re-ordering the parameters? Maybe we default the parameter to
|
If we use
Do we need a way to mark UUID as optional (when building the client lib, not at runtime)? If so, I don't think we have one, but we need such an attribute for openAPI (see https://github.com/FusionAuth/fusionauth-client-builder/blob/openapi-poc/src/main/api/createUserAction.json where I added |
We do have some "optional" capability. I think we currently parse for "Optional". We could make it more official in our DSL. |
Having a separate field in the DSL might be a little more ... robust ... than parsing a comment for the word 'Optional'. :) |
You need to turn on 'strict' in the tsconfig.json, otherwise a whole bunch of useful checks are skipped and you get inconsistencies like this. If the issue is browser vs node client, then splitting into seperate types, and sharing commong code is best option. So ServerOptions, BrowserOptions both extend Options, etc. I just fought this same mess with the Okta client. |
Totally agree. This shouldn't be too hard to add. |
Thanks for the feedback @DanielJoyce - I apologize we are bit weak on TypeScript over here. In your experience, do clients built with OpenAPI / Swagger work pretty well? We have been reviewing options if we want to keep building our own template for these and battle with not knowing every language as well as we'd like, or if we can use something like OpenAPI to build a idiomatic client if we just build the correct DSL. Thoughts? |
Initially I'd stick to best practices for each use case. For SPA, ocid using pkce. Redirect to service hosted form or hosted iframe, support authorization code and refresh token. Document needs around third party cookies, configuring custom domains to handle cors issues, etc. This would apply to authfusion and okta along with others as well. You can support your own service explicitly and ask for community help to document the others. Make the JS lib not depend on any frameworks. For server side I think implicit flow may be the reccomended solution. I'd have to check. Try to design these systems as the bare necessity core. Then you can base other things on top. Once you have a JS lib you can use it for react and vue or whatever support. Once you have a python lib, layer on flask or whatever. Same for java, etc. If the core abstraction is good then it can be used wherever it is needed. The community could easily provide it. |
@robotdan any updates on this? fusionauth-typescript-client/src/FusionAuthClient.ts Lines 2256 to 2267 in 4106f56
|
I think this problem is widespread across the library? For example : I am wondering if I have missed something or this miss is just as basic as it looks?
|
This seems like something that should be fixed fairly urgently, as it forces typescript users to pass invalid data to essentially all methods. Is this project being maintained? |
Thanks @slifty. The project is being maintained :) . We had an internal discussion but don't have a timeline for you for this issue. |
Checking on this, still an issue four years later. What is the suggested workaround while we must deal with a broken library? For registration should I just pass an empty string? Or do I need to force the library to accept a |
fusionauth-typescript-client/src/FusionAuthClient.ts
Line 401 in 1d54de7
userId
I think should be an optional field here. The API and the docs say it is optional, but the Typescript client is forcing me to put one in.There are other instances in this file where optional parameters are required.
The text was updated successfully, but these errors were encountered: