Skip to content

[JAVA] Definitions that are only a type generate references to them instead of the type #6379

Closed
@christarczon

Description

@christarczon
Description

Definitions that are simply a type aren't generated correctly in Maven and CLI generators. Works as expected when generated at editor.swagger.io. I'm trying to generate a Spring Boot client (not available in online editor) but it happens for Java too.

Swagger-codegen version

2.2.3, 2.3.0-SNAPSHOT

Swagger declaration file content or url
swagger: '2.0'
info:
  title: Test
  version: '1'
paths:
  '/list':
    get:
      responses:
        '200':
          description: ''
          schema:
            $ref: '#/definitions/MyList'
definitions:
  MyList:
    type: array
    items:
      $ref: '#/definitions/ListItem'
  ListItem:
    type: string
Command line used for generation

java -jar ./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -l java -i test.yaml -o test-gen

Steps to reproduce

Generate the above yaml using CLI or Maven. The generated code imports and refers to a model that isn't generated.

Expected:
public class MyList extends ArrayList<String> {

Actual:
public class MyList extends ArrayList<ListItem> {

Related issues/PRs
Suggest a fix/enhancement

I don't understand why this is different from the online editor. Besides the reference to the ListItem class that isn't generated, the files are identical.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions