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

Add support for $ref to all types that allow reference objects #9

Closed
dalewking opened this issue Dec 6, 2018 · 5 comments
Closed
Labels
0.2.0 Release 0.2.0 enhancement New feature or request

Comments

@dalewking
Copy link

dalewking commented Dec 6, 2018

Currently reference objects (i.e. $ref) are only supported for schema. It needs to be supported for all types that support reference objects. For the types that swagger-brake cares about that means:

  • ApiResponse
  • Parameter
  • RequestBody

Here is a file that causes an NPE due to ref for the request body:

openapi: 3.0.0
info:
  title: EXAMPLE
  version: '1'
paths:
  /actuator/info:
    get:
      tags:
        - operation-handler
      summary: handle
      operationId: handleUsingGET_1
      responses:
        '200':
          description: OK
          responseSchema:
            type: object
          content:
            application/json:
              schema:
                type: object
            application/vnd.spring-boot.actuator.v2+json:
              schema:
                type: object
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
        '404':
          description: Not Found
      deprecated: false
      requestBody:
        $ref: '#/components/requestBodies/handleUsingGETBody'
components:
  requestBodies:
    handleUsingGETBody:
      content:
        application/json:
          schema:
            type: object
            additionalProperties:
              type: string
      description: body

@dalewking
Copy link
Author

dalewking commented Dec 6, 2018

Looks like Path Item needs to add support for it as well, but the spec is kind of unclear. It says you can do it, but there is no support for it in components. Perhaps that is only for referencing another file.

@dalewking
Copy link
Author

Actually, the easiest fix is probably change the parsing to set resolve fully:

        ParseOptions options = new ParseOptions();
        options.setResolveFully(true);
        OpenAPI loadedApi = new OpenAPIV3Parser().read(path, null, options);

@galovics galovics added enhancement New feature or request 0.2.0 Release 0.2.0 labels Dec 7, 2018
galovics added a commit that referenced this issue Dec 9, 2018
…solution for reader is set + one bugfix included which deals with the situation when the response does not define any schemas
@galovics
Copy link
Member

galovics commented Dec 9, 2018

Fixed. Thanks for the hint @dalewking. Full resolution is set now. :-)

@galovics galovics closed this as completed Dec 9, 2018
@dalewking
Copy link
Author

Now that my issues are fixed, just need a new release, soon

@galovics
Copy link
Member

galovics commented Dec 9, 2018

Most probably I'll do one on the next week. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.2.0 Release 0.2.0 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants