Skip to content

feat: Support oneOf for requestBody Schemas in OpenAPI v3 - #2059

Merged
ubogdan merged 3 commits into
swaggo:v2from
codingcn:feature/requstBody-oneof
Aug 19, 2025
Merged

ubogdan merged 3 commits into
swaggo:v2from
codingcn:feature/requstBody-oneof

Conversation

@codingcn

Copy link
Copy Markdown

Describe the PR
Support oneOf for requestBody Schemas in OpenAPI v3

Relation issue
e.g. https://github.com/swaggo/swag/pull/118/files

Additional context

// ChatCompletions godoc
//
// @Summary		ChatCompletions
// @Description	ChatCompletions
// @Produce		json
// @Security		ApiKeyAuth
// @Param openai body model.GeneralOpenAIRequest false "OpenAI Body"
// @Param anthropic body model.AnthropicMessageRequest false "Anthropic Body"
// @Success		200				{object}	model.ChatCompletionsStreamResponse
// @Router		/v1/chat/completions [post]

to

/v1/chat/completions:
  post:
    description: ChatCompletions
    requestBody:
      content:
        application/json:
          schema:
            oneOf:
            - $ref: '#/components/schemas/model.GeneralOpenAIRequest'
              description: OpenAI Body
              summary: openai
            - $ref: '#/components/schemas/model.AnthropicMessageRequest'
              description: Anthropic Body
              summary: anthropic
      description: OpenAI Body | Anthropic Body

@ubogdan ubogdan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ubogdan ubogdan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before merging, update README.md to reflect his feature

@codingcn

Copy link
Copy Markdown
Author

Before merging, update README.md to reflect his feature
TBR

@ubogdan

ubogdan commented Aug 18, 2025

Copy link
Copy Markdown
Contributor

@codingcn Thanks for your contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址