-
-
Notifications
You must be signed in to change notification settings - Fork 1k
strict fiber server returns nothing when using schema with oneOf #1872
Copy link
Copy link
Open
Description
oapi-codegen --version: v2.4.1
go 1.23.4
Generating code with the following config:
package: main
generate:
fiber-server: true
strict-server: true
models: true
and a openapi.yaml with a oneof:
openapi: 3.0.0
paths:
/test:
get:
responses:
'200':
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/Test'
components:
schemas:
Test:
oneOf:
- $ref: '#/components/schemas/Test1'
- $ref: '#/components/schemas/Test2'
Test1:
type: object
properties:
test1:
type: string
required:
- test1
Test2:
type: object
properties:
test2:
type: string
required:
- test2
generates code:
type Test struct {
union json.RawMessage
}
type GetTest200JSONResponse Test
func (response GetTest200JSONResponse) VisitGetTestResponse(ctx *fiber.Ctx) error {
ctx.Response().Header.Set("Content-Type", "application/json")
ctx.Status(200)
return ctx.JSON(&response)
}
since union starts with a lower case letter the endpoint won't return anything.
I would expect it to return my Test struct.
changing the generated code to return ctx.JSON(&response.union) fixed the issue
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels