OpenAPITools / OpenAPITools/openapi-generator
[BUG][csharp] oneOf with arrays is generating duplicated 'GetList'
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- 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?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When generating a model with a oneOf of arrays, the generated model contains two GetList which result in the following error when building:
error CS0111: Type 'OneOfArrayRequest' already defines a member called 'GetList' with the same parameter types
openapi-generator version
7.12.0 (latest master)
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: Oneof array test
version: 1.0.0
servers:
- url: /
paths:
/one-of-array:
post:
description: Oneof array test
operationId: oneOfArray
requestBody:
content:
application/json:
schema:
oneOf:
- items:
type: string
type: array
- items:
$ref: '#/components/schemas/TestObject'
type: array
responses:
"204":
description: Successful operation
components:
schemas:
TestObject:
properties:
name:
type: string
type: object
Generation Details
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -i ./oneOfArray.yaml -g csharp -o test
Steps to reproduce
Generate using the command above and try to build the generated code
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
Start by running the provided OpenAPI declaration with the shown openapi-generator CLI command and inspect the generated C# model for duplicate GetList methods. Trace how the oneOf array schemas are rendered, then confirm the generated project builds without CS0111 and cover the case with a regression test if the existing test structure supports it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, openapi
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100