cloudflare / cloudflare/chanfana
oneOf support
- Dominant language
- TypeScript
- Stars
- 766
- Forks
- 70
- Avg merge
- 25m
- Merged PRs (30d)
- 4
Description
Is there a way to use the oneOf attribute on the response specification?
Like this:
```
export class PreviewLink extends OpenAPIRoute {
static schema: OpenAPIRouteSchema = {
tags: ["Link Preview"],
summary: "Previews the contents of a given link",
requestBody: {
description: "Preview request options",
required: true,
content: {
"application/json": {
schema: PreviewLinkRequestData,
},
"application/x-www-form-urlencoded": {
schema: PreviewLinkRequestData,
},
"multipart/form-data": {
schema: PreviewLinkRequestData,
},
},
},
responses: {
"200": {
description: "Returns the link preview",
schema: {
oneOf: [
ResponseDocLink,
ResponseXUserLink,
ResponseXPostLink,
ResponseYoutubeChannelLink,
ResponseYoutubeVideoLink,
ResponseHtmlLink,
ResponseImageLink,
ResponseVideoLink,
ResponseAudioLink,
ResponseInstagramUserLink,
ResponseInstagramPostLink,
],
},
},
},
};
```
Contributor guide
Research direction
Start with OpenAPIRouteSchema and trace how response schemas are converted into the generated OpenAPI document. Determine how the oneOf array in the example should be represented and validated, then confirm that a response containing these alternatives produces the expected OpenAPI schema.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100