Closed
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
Generating using the Rust client (reqwest-trait) does not compile if there is a oneOf
with multiple $ref
s that point to the same schema.
Error:
error[E0428]: the name `Foo` is defined multiple times
--> src/models/_v1_foo_patch_200_response.rs:18:5
|
17 | Foo(Box<models::Foo>),
| --------------------- previous definition of the type `Foo` here
18 | Foo(Box<models::Foo>),
| ^^^^^^^^^^^^^^^^^^^^^ `Foo` redefined here
|
= note: `Foo` must be defined only once in the type namespace of this enum
openapi-generator version
7.13.0
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: client gen error
description: ''
version: 1.0.0
servers: []
paths:
/v1/foo:
patch:
summary: "foo summary"
description: foo
responses:
'200':
description: foo
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Foo'
- $ref: '#/components/schemas/Foo'
components:
schemas:
Foo:
type: object
properties:
bar:
type: string
Generation Details
generatorName: rust
library: reqwest-trait
additionalProperties:
supportMiddleware: true
preferUnsignedInt: true
topLevelApiClient: true
useBonBuilder: true
mockall: true
enumUnknownDefaultCase: true
Steps to reproduce
- Copy the spec above
- Generate the Rust client with the config above
- Run
cargo build
and get a compiler error
Related issues/PRs
Suggest a fix
- Option 1: De-duplicate these
$ref
s - Option 2: Make these schemas fail in
openapi-generator validate