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

Referencing files with OpenAPI #15428

Closed
igbluz opened this issue Jan 6, 2021 · 4 comments
Closed

Referencing files with OpenAPI #15428

igbluz opened this issue Jan 6, 2021 · 4 comments
Labels
bug This bug is not present in a released version of Open Liberty in:MicroProfile/OpenAPI Needs member attention

Comments

@igbluz
Copy link

igbluz commented Jan 6, 2021

I want to reference another openapi yaml file (problem.yaml) from my master yaml (openapi.yaml)

I use this construct in openapi.yaml:

        '400':
          description: Invalid request data
          content:
            'application/problem+json':
              schema:
                $ref: 'problem.yaml#/components/schemas/BadRequestProblem'

With the openapi generator tool I can generate my stubs correctly.
When I start OpenLiberty server with the command mvn liberty:dev I get these OpenApi Validation exception:

[INFO] [ERROR   ] CWWKO1650E: Validation of the OpenAPI document produced the following error(s): 
[INFO]                                                                                                                
[INFO]  - Message: The "problem.yaml#/components/schemas/BadRequestProblem" value is an invalid reference, Location: #/paths/~1inventory~1systems~1{hostname}/get/responses/400/content/application~1problem+json/schema

Reproduce the error
You can reproduce very easy. Just use the guide-microprofile-openapi sample and copy the problem.yaml to the wepapp/META-INF directory.

Replace the 400: response with this:

        400:
          description: Invalid request data
          content:
            'application/problem+json':
              schema:
                $ref: 'problem.yaml#/components/schemas/BadRequestProblem'

After `mvn clean liberty:dev you can see the error.

Expected behavior
The Server starts without error and shows the OpenAPI UI (http://localhost:9080/openapi/ui) without error.

Diagnostic information:

  • OpenLiberty Version: 20.0.0.12
  • Java Version:
 openjdk version "1.8.0_265"
OpenJDK Runtime Environment (build 1.8.0_265-b01)
OpenJDK 64-Bit Server VM (build 25.265-b01, mixed mode)
  • server.xml: unchanged from the sample

Additional context
I uploaded problem.yaml.txt, just rename it to problem.yaml and use it

problem.yaml.txt

@Emily-Jiang
Copy link
Member

@igbluz thanks for raising this issue! After the discussion with MicroProfile Open API group, this behaviour should be speced in the spec. Are you ok to close this as we will continue our discussion in eclipse/microprofile-open-api#463?

@bmarwell
Copy link
Contributor

bmarwell commented Nov 8, 2023

@Emily-Jiang I think this is now mandatory in OA 3.0: https://swagger.io/docs/specification/using-ref/
See the section "$ref Syntax" which clearly references other files. Today I stumbled upon this not being supported in OL.

Does this still need a discussion?

@igbluz igbluz closed this as completed Oct 29, 2024
@igbluz
Copy link
Author

igbluz commented Oct 29, 2024

Thank you for the responses.
We resolved the case in using the $ref for referencing other files in nexus.

responses:
   ‘200’:
        content:
              application/json:
                    schema:
                         type: array
                         items:
                              $ref: ‘http://myserver.mydomain.com/nexus/repository/openapi/responses/200response’

@bmarwell
Copy link
Contributor

@igbluz could you kindly elaborate what's the current status? Thanks. 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This bug is not present in a released version of Open Liberty in:MicroProfile/OpenAPI Needs member attention
Projects
None yet
Development

No branches or pull requests

5 participants