Skip to content

[BUG] Swagger 2.0 unresolved schema references are not detected during client generation #24832

Description

@j-steuer

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • 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?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When generating a client from a Swagger 2.0 specification containing a $ref to a schema that is not defined, OpenAPI Generator completes successfully instead of reporting an unresolved reference.

The generated library contains references to the missing model, but no corresponding model file is generated.

openapi-generator version

v7.25.0

OpenAPI declaration file content or url
swagger: '2.0'
info:
  title: Undefined Schema Reproduction
  version: '1.0.0'

paths:
  /test:
    post:
      parameters:
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/DoesNotExist'
      responses:
        '200':
          description: OK
Generation Details

The issue appears to be language-independent

Steps to reproduce

Generate a client library using the above schema and inspect the results.

Related issues/PRs
Suggest a fix

When a schema definition is missing an error should be raised as is done for 3.0.x declarations

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions