openapi-generators / openapi-generators/openapi-python-client
Schema processing fails when "allOf" references to nullable object
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2k
- Forks
- 293
- Avg merge
- 34m
- Merged PRs (30d)
- 1
Description
Describe the bug
When using a schema that contains an "allOf" reference to a nullable object, the generation fails with the message "Cannot take allOf a non-object".
OpenAPI Spec File
Document to recreate:
openapi: 3.0.1
info:
title: Title
description: Description
version: 1.0.0
servers:
- url: /api
paths:
/item:
get:
operationId: item
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Item'
components:
schemas:
RelatedItemSuper:
type: object
nullable: true
properties:
propertyA:
type: string
RelatedItem:
type: object
allOf:
- $ref: '#/components/schemas/RelatedItemSuper'
- type: object
properties:
propertyB:
type: string
Item:
type: object
nullable: false
properties:
key:
type: string
relatedItem:
$ref: '#/components/schemas/RelatedItem'
A real world example can be found here.
Desktop (please complete the following information):
- OS: Linux
- Python Version: 3.11.2
- openapi-python-client version: 0.21.1
Additional context
Changing "nullable" to "false" on "RelatedItem" in the above example works but does not seem to be a suitable solution as the construct used is legitimate, or is it not?
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 openapi-python-client 0.21.1 against the supplied OpenAPI 3.0.1 document and trace the schema-processing path that emits "Cannot take allOf a non-object." Use the nullable RelatedItemSuper and RelatedItem definitions as the regression case; done means client generation succeeds without requiring nullable to be changed to false.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, python
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100