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

Ref with anyOf not working as it should #202

Closed
davidgayoso opened this issue Apr 17, 2023 · 3 comments
Closed

Ref with anyOf not working as it should #202

davidgayoso opened this issue Apr 17, 2023 · 3 comments
Assignees

Comments

@davidgayoso
Copy link
Contributor

davidgayoso commented Apr 17, 2023

Captura de pantalla 2023-04-17 a las 12 29 35

In the above case, I have a component with two refs to another component which contains an anyOf specification. The next photo shows the component with the anyOf:

Captura de pantalla 2023-04-17 a las 12 31 53

When the multiapi tries to generate all the needed files based on the OpenAPI specification, it returns a NullPointerException. However, if you substitute the first ref from the first image with the component itself like in the next image, it generates the corresponding elements but not properly:
Captura de pantalla 2023-04-17 a las 12 34 31

I think that the problem resides in how it works with the anyOf specification.

Here you have a zip containing the files with the OpenAPI specification:
specification.zip

@github-actions
Copy link

Thank you for collaborating with the project by giving us feedback! Cheers!

@5uso-sng
Copy link
Contributor

5uso-sng commented May 9, 2023

Looking into this I managed to reproduce the NullPointerException with this reduced specification:
api-test.yml

openapi: 3.0.2
info:
  title: Schema Management
  version: 2.0.0
servers:
- url: https://localhost/v1
paths:
  /schema:
    get:
      tags:
      - schema
      operationId: getSchema
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: "assets/components.yml#/components/schemas/schema"

assets/components.yml

components:
  schemas:
    schema:
      type: object
      properties:
        thing:
          $ref: "#/components/schemas/typeArray"
    typeArray:
      type: array
      items:
        oneOf:
        - $ref: "#/components/schemas/stringField"
    stringField:
      type: string

This crashes inside the MapperContentUtil class. If schema is instead defined as...

schema:
  $ref: "#/components/schemas/typeArray"

...the crash then happens inside the MapperPathUtil class.

Do note that separating the components into a different file is required for the issue to occur. This seems to be caused by the OpenAPI library returning an incomplete list of schemas when calling openAPI.getComponents().getSchemas() only when the files are separate.

@AdrianLagartera AdrianLagartera self-assigned this May 23, 2023
@AdrianLagartera
Copy link
Member

Resolved in the #160

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

When branches are created from issues, their pull requests are automatically linked.

3 participants