OpenAPITools / OpenAPITools/openapi-generator
[BUG] Swagger 2.0 unresolved schema references are not detected during client generation
Nobody has claimed this yet.
- 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?
- 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce client generation with the provided Swagger 2.0 YAML and inspect how unresolved schema references are handled for Swagger 2.0 versus 3.0 declarations. Trace the generator's reference-resolution and validation entry points, then add coverage showing that a missing definition raises an error instead of producing a client with a missing model.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100