OpenAPITools / OpenAPITools/openapi-generator

[BUG] common folder is checked twice when reference to external common component

Open
#2,860 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Bug Report Checklist
  • [ x] Have you provided a full/minimal spec to reproduce the issue?
  • [ x] Have you validated the input using an OpenAPI validator (example)?
  • [ x] What's the version of OpenAPI Generator used? --> latest (nightlybuild 09052019)
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

use remote reference in common folder does not wok

In principal specifications, i added a reference to common specification schema:
$ref: './components/errors.yaml#/components/responses/400'
error message
[main] WARN o.o.codegen.utils.ModelUtils - Failed to get the schema name: ./components/components/errors.yaml#/components/schemas/Error
=>common folder is checked twice

openapi-generator version

latest SNAPSHOT version : nightly build 09052019

OpenAPI declaration file content or url

#principal specifications: /some-api.yaml
openapi: 3.0.0
info:
title: Test
version: 1.0.0

paths:
/value:
get:
operationId: getValues
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ComponentA'
"400":
$ref: './components/errors.yaml#/components/responses/400'

components:
schemas:
ComponentA:
type: object
properties:
someAtt:
description: some attribute
type: string

common specifications /components/errors.yaml

components:
schemas:
Error:
type: object
title: SomeError
description: Error details
properties:
name:
type: string
description: Human readable, unique name of the error.
responses:
"400":
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/Error'

Command line used for generation

java -jar ./openapi-generator-cli.jar generate -g spring -i some-api.yaml -c some-api-java.json -o ./generated/some-api

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

Reproduce the issue with some-api.yaml, components/errors.yaml, and the Java CLI command using the spring generator. Start at the ModelUtils warning about the duplicated components path and trace external $ref resolution. Done means the external response resolves its Error schema without checking the common folder twice.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring
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.