Skip to content
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

SWC-6662 - OpenAPI Client Generation for Synapse REST API #689

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

nickgros
Copy link
Collaborator

@nickgros nickgros commented Feb 6, 2024

No description provided.

@nickgros nickgros force-pushed the SWC-6662 branch 3 times, most recently from 70d3e23 to ed2dcd8 Compare March 13, 2024 21:23
@@ -0,0 +1 @@
src/generated/
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't commit the generated models to git

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Integrated into synapse-react-client as an example -- needed to pick models/services that had a low code surface, because our hand-written models are incompatible with the generated models. The OAuth client services seemed to be ok for that

Comment on lines +104 to +106
client?.redirect_uris?.map((str: string) => ({ uri: str })) ?? [
{ uri: '' },
],
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that redirect_uris is NOT required in the spec, so we have to do additional null handling or assertions to work with the new model. This will be common, and is IMO the biggest downside and reason to not use the generated code right now.

Comment on lines +112 to +115
(client?.userinfo_signed_response_alg ??
defaultUserInfoSignedResponseAlgorithm) as
| 'JSON'
| OIDCSigningAlgorithm,
Copy link
Collaborator Author

@nickgros nickgros Mar 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug where the property userinfo_signed_response_alg has the wrong type. The bug is in the spec, see PLFM-8319

oAuthClient: oAuthClient,
})
.then(precheckResult => {
setWarnTrigger(precheckResult.reverificationRequired!)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverificationRequired is another property that is never null, but because the spec doesn't indicate it as required, we have to add the ! non-null assertion

setWarnTrigger(precheckResult.reverificationRequired)
})
synapseClient.openIDConnectServicesClient
.putAuthV1Oauth2ClientIdVerificationPrecheck({
Copy link
Collaborator Author

@nickgros nickgros Mar 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These auto-generated method names are not great. Should we create our own wrapper? Push for the ability to incrementally curate these in the backend?

@@ -50,6 +54,16 @@ export function SynapseContextProvider(props: SynapseContextProviderProps) {
[providedContext.accessToken],
)

const synapseApiClient = useMemo(() => {
const configuration = new Configuration({
fetchApi: fetchWithExponentialTimeout,
Copy link
Collaborator Author

@nickgros nickgros Mar 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super fortunate that our existing abstraction just plugs in here. We pass in our fetchWithExponentialTimeout and we maintain the same behavior that we already have with automatic retries and all errors converted to our custom SynapseClientError class.

It should probably the the default behavior for our synapse-client package, but that refactoring can wait (hence the TODO)

)
setTosUri(client?.tos_uri ?? '')
}, [isShowingModal, client])

useDebouncedEffect(
() => {
if (accessToken && oAuthClient.client_id) {
if (oAuthClient.client_id) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you can ever see this component without being logged in, so I'm not worried about the accessToken checks

@nickgros nickgros changed the title [WIP] SWC-6662 - openapi client gen with openapi-generator typescript-fetch SWC-6662 - OpenAPI Client Geration for Synapse REST API Mar 14, 2024
@nickgros
Copy link
Collaborator Author

Current approach will increase our IIFE bundle size from 3MB to 5MB - this is already very large, so need to rethink the approach

@nickgros nickgros changed the title SWC-6662 - OpenAPI Client Geration for Synapse REST API SWC-6662 - OpenAPI Client Generation for Synapse REST API Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant