Can't generate client for spec with refs in allOf
coandco opened this issue · 1 comments
Describe the bug
I'm attempting to use openapi-python-client to generate a client for the new XPipe API, but it's failing with "Cannot take allOf a non-object". I've boiled it down to the following minimal reproducer. I think what the original spec is trying to describe is an auth type that always has the key "type", and then either has one key or the other based on what type it is.
OpenAPI Spec File
openapi: 3.0.1
info:
title: Example
version: "1.0"
paths:
/ping:
get:
responses:
'200':
description: OK
components:
schemas:
AuthMethod:
type: object
discriminator:
propertyName: type
properties:
type:
type: string
required:
- type
oneOf:
- $ref: '#/components/schemas/FirstType'
- $ref: '#/components/schemas/SecondType'
FirstType:
type: object
allOf:
- $ref: '#/components/schemas/AuthMethod'
- type: object
properties:
key_one:
type: string
description: KeyOne
required:
- key_one
SecondType:
type: object
allOf:
- $ref: '#/components/schemas/AuthMethod'
- type: object
properties:
key_two:
type: string
description: KeyTwo
required:
- key_twoDesktop (please complete the following information):
- OS: I've tested it both on Windows and Linux
- Python Version: Tested on 3.12 (Windows) and 3.10 (Linux)
- openapi-python-client version: 0.21.0
Additional context
I'm fairly new to openapi specs, so it's entirely possible I'm misreading the file or that the original spec is doing something hinky that I don't understand. What am I missing here?
There are a few peculiar things about this document, none of which we’re likely to have an easy solution to:
- using both top-level schema and
oneOf. I’d need to read some of the jsonschema spec to see if that’s even allowed, and if so how to resolve it. - Reference cycles between all of the types. AuthMethod might be a FirstType which includes all of AuthMethod which might be a SecondType which…
- Using a discriminator and not defining the values to discriminate on. We don’t actually support discriminators yet, but if we did that’d be an error.
So no obvious way to support this schema in this project. Maybe take a look at the openapitools generator and see what they do with it?
Gonna close this since I don’t think it’s a bug.