-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Open
Labels
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
openapi: 3.0.0
info:
description: >-
Test to replicate duplicate os imports.
version: 1.0.0
title: Duplicate Imports
license:
name: Apache-2.0
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
paths:
/file1:
post:
tags:
- file1
summary: uploads an image
description: ''
operationId: postFile1
responses:
'200':
description: successful operation
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
additionalMetadata:
description: Additional data to pass to server
type: string
file:
description: file to upload
type: string
format: binary
/file2:
post:
tags:
- file2
summary: uploads an image
description: ''
operationId: postFile2
responses:
'200':
description: successful operation
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
additionalMetadata:
description: Additional data to pass to server
type: string
file:
description: file to upload
type: string
format: binary- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
Expected Output:
package openapi
import (
"context"
"net/http"
"os"
)Actual Output:
package openapi
import (
"context"
"net/http"
"os"
"os"
)- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
While trying to create a PR for a separate issue, I discovered that go-server (and potentially some of the other go generators have an issue with postProcessOperationsWithModels. This method can create duplicate import mappings in go-server's api.go if two separate tags try and create the same mapping.
openapi-generator version
Tried on 6.0.0-SNAPSHOT. It doesn't appear to be a regression.
OpenAPI declaration file content or url
Yaml posted above.
Generation Details
Steps to reproduce
./run-in-docker.sh java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate --input-spec test.yaml --generator-name go-server --output generated
Related issues/PRs
Suggest a fix
Trying to figure out a fix for this right now as I'm about to create a PR that makes the issue more obvious. I don't think postProcessOperationsWithModels is necessarily the problem but I'm not sure where else the imports could be added.
Reactions are currently unavailable