swagger-api / swagger-api/swagger-codegen
Spring codegen handles incorrectly definition named "Resource"
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Codegen doesn't generate "Resource" model class. It uses org.springframework.core.io.Resource instead.
Swagger-codegen version
2.3.0
Swagger declaration file content or url
swagger: '2.0'
info:
version: 1.0.0
title: Simple API
paths:
/resource:
get:
responses:
200:
description: search results matching criteria
schema:
$ref: '#/definitions/Resource'
definitions:
Resource:
type: object
properties:
id:
type: string
Steps to reproduce
- Save the definition to a file (e.g. C:\swagger.yaml).
- Generate spring code using codegen v.2.3.0
Sample command line:
java -jar swagger-codegen-cli.jar generate -l spring -i C:\swagger.yaml -o C:\spring - Examine the generated ResourceApiController.java file.
Expected:
A "Resource" model class is generated and used in it.
Actual:
org.springframework.core.io.Resource class is used

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
Run the documented swagger-codegen-cli generate command with the supplied Swagger definition and inspect the generated ResourceApiController.java. Trace the Spring generator's model and import handling for the definition named Resource; done means a Resource model is generated and used instead of org.springframework.core.io.Resource.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100