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

Generator cannot (?) handle wrapped data from API #14

Closed
lorenzulrich opened this issue Feb 15, 2023 · 5 comments
Closed

Generator cannot (?) handle wrapped data from API #14

lorenzulrich opened this issue Feb 15, 2023 · 5 comments

Comments

@lorenzulrich
Copy link

Sometimes, API data is wrapped in an object, e.g. data, because errors and meta information would be on the same level. The Open API schema could look like this:

  '/user/profile-information':
    get:
      tags:
        - user
      summary: Returns information about the current authentication status and user
      operationId: userProfileInformation
      responses:
        '200':
          description: 'Success'
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/AuthenticationData'

And the AuthenticationData schema could look like this:

    AuthenticationData:
      type: object
      properties:
        csrfToken:
          type: string
        user:
          $ref: '#/components/schemas/User'
        ssoUrl:
          type: string
        impersonationDetails:
          $ref: '#/components/schemas/ImpersonationDetails'
      required:
        - csrfToken
        - user
        - ssoUrl
        - impersonationDetails

(etc.)

This is valid OpenAPI configuration, however the generator cannot handle this and will fail to generate the interfaces.

How could this be implemented in the package?

@teobler
Copy link
Owner

teobler commented Feb 16, 2023

Hi @lorenzulrich seems this is a bug, I will fix this

@teobler
Copy link
Owner

teobler commented Feb 16, 2023

Fixed now, will update npm version later.

@teobler
Copy link
Owner

teobler commented Feb 21, 2023

1.2.1 released

@teobler teobler closed this as completed Feb 21, 2023
@lorenzulrich
Copy link
Author

@teobler Thanks a lot, I will test this soon!

@lorenzulrich
Copy link
Author

I could verify that this fix works as expected. Many 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