OpenAPITools / OpenAPITools/openapi-generator

[BUG] RELATIVE refs could not be loaded

Open
#9,991 5 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description

After the latest version of the OpenAPI Generator was released: 5.2.0, a new bug was introduced regarding relative $refs: during generation the following error occurs:

[main] WARN  io.swagger.v3.parser.OpenAPIV3Parser - Exception while resolving:
java.lang.RuntimeException: Unable to load RELATIVE ref: ./specs/my_spec.yaml path: /specs/spec_path

This behaviour is only seen in the latest released version, previously it was working correctly. I've looked through the CHANGELOG document but couldn't find an entry that could have introduced this problem.

openapi-generator version

5.2.0

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: MyExampleSpec
  description: >-
paths: {}
components:
  schemas:
    MyExampleSchema:
      description: >-
      properties:
        id:
          description: The id of MyExampleSchema.
          type: string
        message:
          description: The message of MyExampleSchema.
          $ref: ../specs/MySchemas.yaml#/components/schemas/Message
Generation Details
Steps to reproduce
  1. Build the OpenAPI Generator.
  2. Run one of the generators ( I've tested it with PowerShell and Python) with the provided yaml using the following command:
java openapi-generator-cli-5.2.0.jar generate -g powershell -i "myOpenAPISpec.yaml" --global-property
  1. Observe the errors that occur which should match the mentioned error message above.
Related issues/PRs

none

Suggest a fix

Currently no fix suggestion can be provided. I'll try to find the root cause of the issue and then think about what kind of fix can be added.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Build OpenAPI Generator and run the CLI generate command with the supplied YAML and the PowerShell or Python generator. Compare version 5.2.0 with the previously working version and trace the relative $ref loading error; done means the example resolves without the reported exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, powershell, python
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.