When using allOf that one of the options contains $ref with enum, the pydantic model is generated without the ref
Example schema:
components:
schemas:
AdminUser:
type: object
properties:
userType:
type: string
enum:
- admin
username:
type: string
details:
type: object
required:
- phoneNumber
properties:
phoneNumber:
type: string
minLength: 9
maxLength: 15
pattern: '^\+[0-9]{9,15}$'
required:
- userType
- username
- details
RegularUser:
type: object
properties:
userType:
type: string
enum:
- regular
username:
type: string
details:
type: object
required:
- address
properties:
address:
type: string
required:
- userType
- username
- details
User:
oneOf:
- $ref: '#/components/schemas/AdminUser'
- $ref: '#/components/schemas/RegularUser'
discriminator:
propertyName: userType
paths:
/user:
post:
summary: Add user
requestBody:
content:
application/json:
schema:
allOf:
- type: object
properties:
userId:
type: string
required:
- userId
- $ref: '#/components/schemas/User'
responses:
'200':
description: OK
Output:
class UserPostRequest(BaseModel):
userId: str
Version:
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too