swagger-api / swagger-api/swagger-codegen

Spring codegen handles incorrectly definition named "Resource"

Open
#7,381 1 comment 1 reaction 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

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
  1. Save the definition to a file (e.g. C:\swagger.yaml).
  2. 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
  3. 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
image

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.