Open
Description
Q&A (please complete the following information)
- OS: macOS
- Browser: safari
- Version: 17.5
- Swagger-Editor version: https://editor-next.swagger.io
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
Example Swagger/OpenAPI definition:
openapi: 3.1.0
info:
title: Complex API with Conditional Requirements
version: "1.0"
description: An example API demonstrating conditional requirements within a single schema.
servers:
- url: https://api.example.com/v1
paths:
/resources:
get:
summary: List all resources
operationId: listResources
tags:
- Resources
security:
- bearerAuth: []
responses:
'200':
description: An array of resources
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Resource'
post:
summary: Create a new resource
operationId: createResource
tags:
- Resources
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Resource'
responses:
'201':
description: Resource created
/resources/{resourceId}:
get:
summary: Get a specific resource
operationId: getResource
tags:
- Resources
security:
- bearerAuth: []
parameters:
- name: resourceId
in: path
required: true
schema:
type: string
responses:
'200':
description: Detailed information about the resource
content:
application/json:
schema:
$ref: '#/components/schemas/Resource'
put:
summary: Update a resource
operationId: updateResource
tags:
- Resources
security:
- bearerAuth: []
parameters:
- name: resourceId
in: path
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Resource'
responses:
'200':
description: Resource updated
patch:
summary: Partially update a resource
operationId: partiallyUpdateResource
tags:
- Resources
security:
- bearerAuth: []
parameters:
- name: resourceId
in: path
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/Resource'
responses:
'200':
description: Resource partially updated
delete:
summary: Delete a resource
operationId: deleteResource
tags:
- Resources
security:
- bearerAuth: []
parameters:
- name: resourceId
in: path
required: true
schema:
type: string
responses:
'204':
description: Resource deleted
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
schemas:
Address:
type: object
properties:
level1:
type: string
level2:
type: string
level3:
type: string
required: [level1, level2, level3]
Resource:
type: object
properties:
id:
type: string
format: uuid
type:
type: string
enum: [TypeA, TypeB]
commonField:
type: string
address:
$ref: '#/components/schemas/Address'
required: [id, type, commonField, address]
allOf:
- if:
properties:
type:
const: TypeA
then:
properties:
specificFieldA:
type: object
properties:
name:
type: string
age:
type: integer
address:
$ref: '#/components/schemas/Address'
required: [specificFieldA]
- if:
properties:
type:
const: TypeB
then:
properties:
specificFieldB:
type: number
required: [specificFieldB]
Describe the bug you're encountering
After pasting the yaml into editor. schema renders the wrong result at the first time.
If you change it in the editor, the schema becomes correct.
Metadata
Assignees
Labels
No labels