swagger-api / swagger-api/swagger-codegen

swagger-codegen erroneously import java.io.File

Open
#8,134 3 comments 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

If you generate code for python-flask using a spec file that contains a definition for an object called "File", swagger-codegen never creates the corresponding model file module and imports java.io.File into the generated default_controller.py.

Swagger-codegen version

2.3.1

Swagger declaration file content or url

swagger: "2.0"

info:
version: 0.0.1
title: Blah API
description: An API for interacting with the blah system

paths:

/files:

get:
  description: Retrieves information on files that match the specified criteria

  produces:
  - "application/json"

  parameters:
    - name: tags
      type: array
      description: The tags for which matching files are to be returned
      in: query
      items:
        type: string

  responses:
    '200':
      description: Successful response
      schema:
        type: array
        items:
          $ref: "#/definitions/File"

definitions:
File:
type: object
properties:
file_id:
type: "string"
format: "uuid"
path:
type: "string"
tags:
type: array
items:
type: "string"

Command line used for generation

java -jar /home/sknick/Misc/swagger-codegen-cli-2.3.1.jar generate -l python-flask -o ./Source -i ./api.yaml

Steps to reproduce

(Shown above.)

Related issues/PRs

Not sure.

Suggest a fix/enhancement

No idea.

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 report with the provided Swagger declaration and the python-flask generation command using swagger-codegen 2.3.1. Start at the python-flask generator and its templates, then verify that the File model is generated and that default_controller.py no longer imports java.io.File.

Written by the indexing model from the issue text.

Assessment

Tech stack
flask, java, python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.