-
Couldn't load subscription status.
- Fork 2.3k
Closed as duplicate of#9540
Description
Paste the yaml below into the editor on https://editor-next.swagger.io/ and look at the request body schema. It'll look like this:
Now modify the schema to use OAS 3.1.0 and look at the request body schema again: it'll have lost all the 'type' names and everything has become objects:
openapi: 3.0.0
info:
title: Simple API
version: 1.0.0
description: A simple API with a PATCH endpoint using anyOf payload
paths:
/users/{id}:
patch:
summary: Update user
description: Update a user with either basic info or profile data
parameters:
- name: id
in: path
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserUpdate'
responses:
'200':
description: User updated successfully
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: User updated successfully
'400':
description: Bad request
'404':
description: User not found
components:
schemas:
UserUpdate:
anyOf:
- $ref: '#/components/schemas/BasicInfo'
- $ref: '#/components/schemas/ProfileData'
BasicInfo:
type: object
properties:
name:
type: string
example: John Doe
email:
type: string
format: email
example: john.doe@example.com
required:
- name
ProfileData:
type: object
properties:
bio:
type: string
example: Software developer with 5 years of experience
location:
type: string
example: New York, NY
website:
type: string
format: uri
example: https://johndoe.dev
required:
- bio