Anyway to get a Union type to work in a operation? #4460
-
I'm trying to accomplish the ability to pass a Union type in a operation. It seems to only take Essentially, in the API, there are two params that cannot be passed together, but work if passed individually. Due to a operation only allowing me to pass in a model, i'm only able to pass in one of these Types. I can create a type, and pass a property that takes in the union, but then I have a property that does not exist. Example can be found here I'm hoping to accomplish something similar to the spec below. I want the ability to declare a request body of a operation as a Union that can declare to use openapi: 3.0.0
info:
title: Test API
version: 0.0.0
tags: []
paths:
/test:
post:
operationId: SIPEndpoints_list
parameters: []
responses:
'204':
description: 'There is no content to send for this request, but the headers may be useful. '
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/TestUnion'
security:
- BasicAuth: []
components:
schemas:
TestA:
type: object
required:
- a
- b
properties:
a:
type: string
enum:
- a
b:
type: string
enum:
- b
TestB:
type: object
required:
- c
- d
properties:
c:
type: string
enum:
- c
d:
type: string
enum:
- d
TestUnion:
oneOf:
- $ref: '#/components/schemas/TestA'
- $ref: '#/components/schemas/TestB'
securitySchemes:
BasicAuth:
type: http
scheme: basic
servers:
- url: https://test/api/
description: Endpoint
variables: {} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @Devon-White, this looks pretty close, does it give you what you need? |
Beta Was this translation helpful? Give feedback.
-
You just want to add |
Beta Was this translation helpful? Give feedback.
You just want to add
@body
on the property to say the body is the content of that prop, then it can be anythingPlayground