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

Distinguish between single / array response #8

Open
ColinFrick opened this issue Sep 3, 2024 · 1 comment
Open

Distinguish between single / array response #8

ColinFrick opened this issue Sep 3, 2024 · 1 comment

Comments

@ColinFrick
Copy link

For example the response for retrieveRefreshTokenById and retrieveRefreshTokens both return the RefreshTokenResponse.

Currently the RefreshTokenResponse is defined as:

    RefreshTokenResponse:
      description: API response for retrieving Refresh Tokens
      type: object
      properties:
        refreshToken:
          "$ref": "#/components/schemas/RefreshToken"
        refreshTokens:
          type: array
          items:
            "$ref": "#/components/schemas/RefreshToken"

This makes it harder to use the API clients. F.e. when using the typescript client:

const response = await this._fusionClient.retrieveRefreshTokens(userId);
typeof response.response.refreshTokens; // RefreshToken[] | undefined
typeof response.response.refreshToken; // RefreshToken | undefined

const refreshToken = await this._fusionClient.retrieveRefreshTokenById(ctx.params.id);
typeof refreshToken.response.refreshTokens; // RefreshToken[] | undefined
typeof refreshToken.response.refreshToken; // RefreshToken | undefined

It would be better if the OpenAPI specifies which property is included:

const response = await this._fusionClient.retrieveRefreshTokens(userId);
typeof response.response.refreshTokens; // RefreshToken[]
typeof response.response.refreshToken; // Property refreshToken does not exist on type RefreshTokenResponse.

const refreshToken = await this._fusionClient.retrieveRefreshTokenById(ctx.params.id);
typeof refreshToken.response.refreshTokens; // Property refreshTokens does not exist on type RefreshTokenResponse.
typeof refreshToken.response.refreshToken; // RefreshToken

This applies to other API calls like:

  • ApplicationResponse
  • ConnectorResponse
  • ConsentResponse
  • EmailTemplateResponse
  • EntityGrantResponse
  • FamilyResponse
  • FormResponse
  • FormFieldResponse
  • GroupResponse
  • IdentityProviderLinkResponse
  • IdentityProviderResponse
  • KeyResponse
  • LambdaResponse
  • MessengerResponse
  • TenantResponse
  • ThemeResponse
  • UserActionReasonResponse
  • UserActionResponse
  • UserConsentResponse
  • UserCommentResponse
  • WebAuthnCredentialResponse
  • WebhookResponse

The list is probably not complete.

@ColinFrick ColinFrick changed the title Distinquish between single / array response Distinguish between single / array response Sep 3, 2024
@mooreds
Copy link
Contributor

mooreds commented Sep 3, 2024

This is really interesting feedback.

Thanks!

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

No branches or pull requests

2 participants