OpenAPITools / OpenAPITools/openapi-generator
[BUG][dart-dio] Using oneOf together with allOf does not generate properties
Open
Nobody has claimed this yet.
Issue: Bug
- 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
dart-dio does not generate properties for models when using oneOf together with allOf. The schema posted below generates the following code:
// ...
/// Dog
///
/// Properties:
/// * [petType]
/// * [hunts]
/// * [age]
/// * [bark]
/// * [breed]
@BuiltValue()
abstract class Dog implements Pet, Built<Dog, DogBuilder> {
Dog._();
factory Dog([void updates(DogBuilder b)]) = _$Dog;
@BuiltValueHook(initializeBuilder: true)
static void _defaults(DogBuilder b) => b..petType=b.discriminatorValue;
@BuiltValueSerializer(custom: true)
static Serializer<Dog> get serializer => _$DogSerializer();
}
// ...
I'd expect that it generates all properties related to Dog (petType, bark and breed).
openapi-generator version
7.4.0
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: pet
version: 0.0.1
paths:
/pets:
patch:
requestBody:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'
discriminator:
propertyName: pet_type
responses:
'200':
description: Updated
components:
schemas:
Pet:
type: object
required:
- pet_type
properties:
pet_type:
type: string
discriminator:
propertyName: pet_type
oneOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'
Dog:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
properties:
bark:
type: boolean
breed:
type: string
enum: [Dingo, Husky, Retriever, Shepherd]
Cat:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
properties:
hunts:
type: boolean
age:
type: integer
Steps to reproduce
openapi-generator-cli generate -i pet.yaml -g dart-dio -o ./pet
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-generator-cli command with the pet.yaml schema and inspect the dart-dio model generation for Dog. Trace how oneOf and allOf are combined, then verify that the generated Dog model includes pet_type, bark, and breed rather than only inherited interfaces.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100