swagger-api / swagger-api/swagger-codegen

[spring] Extenal schema file interpreted incorrectly

Open
#6,355 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

        <dependency>
		    <groupId>io.swagger</groupId>
		    <artifactId>swagger-codegen-maven-plugin</artifactId>
		    <version>2.3.0</version>
        </dependency>

In the following config I have an external schema file defined - $ref: 'file-event.yaml'

	paths:
	  /files:
		post:
		  operationId: addFile
		  consumes:
		  - application/json
		  parameters:
		  - in: body
			name: body
			required: true
			schema:
			  $ref: 'file-event.yaml'
		  responses:
			'200':
			  description: successful operation

This is interpreted incorrectly by the plugin which is expecting the schema to be the part of the "definitions" within the same file.

"jsonSchema" : "{\r\n "in" : "body",\r\n "name" : "body",\r\n "description" : "File event to add to the TaskManager",\r\n "required" : true,\r\n "schema" : {\r\n "$ref" : "#/definitions/file-event.yaml"\r\n }\r\n}",

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

Start with the swagger-codegen-maven-plugin handling of the external file-event.yaml $ref shown in the issue, and compare it with how local definitions are resolved. Done means the external schema remains an external reference rather than being rewritten as #/definitions/file-event.yaml; no repository test or source file is named in the report.

Written by the indexing model from the issue text.

Assessment

Tech stack
spring
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.