Skip to content

Conversation

@taba2424
Copy link

@taba2424 taba2424 commented Jan 10, 2026

Describe the PR

  • Fix OpenAPI v3 requestBody schema generation so the default schema created by @Accept does not get merged via oneOf with the actual body schema.
  • Replace the placeholder type: object with the real body schema when @Param ... body is parsed after @Accept.
  • Add a regression test covering @Accept json + body parameter.

Relation issue

N/A (no related issue)

Additional context

Example setup:

// @Accept json
// @Param request body types.CreateRequest true "作成リクエスト"

Command (example):

Generated specs using swag init with OpenAPI v3.1 output and YAML format.
Before, the generated requestBody schema included:

oneOf:
  - type: object
  - $ref: '#/components/schemas/CreateRequest'

This PR ensures the placeholder type: object from @accept is replaced by the actual body schema, resulting in only the $ref entry.

@taba2424 taba2424 marked this pull request as ready for review January 10, 2026 20:51
@taba2424 taba2424 changed the title fix(v3): avoid oneOf when @Accept adds default schema fix: avoid oneOf when @Accept adds default schema Jan 10, 2026
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.

1 participant