Minimal yaml:
openapi: 3.0.2
info:
title: test API
servers:
- url: 'https://api.server.com'
paths:
'/command':
get:
summary: command summary
requestBody:
content:
application/json:
schema:
oneOf:
- $ref: '#/components/schemas/CommandRequest1'
- $ref: '#/components/schemas/CommandRequest2'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CommandResponse'
components:
schemas:
CommandRequest1:
type: object
required:
- id
properties:
id:
type: string
CommandRequest2:
type: object
required:
- groupID
properties:
groupID:
type: string
CommandResponse:
type: object
required:
- command
properties:
command:
type: string
This is the generated go code:
package oapi
import (
"encoding/json"
)
// CommandRequest1 defines model for CommandRequest1.
type CommandRequest1 struct {
Id string `json:"id"`
}
// CommandRequest2 defines model for CommandRequest2.
type CommandRequest2 struct {
GroupID string `json:"groupID"`
}
// CommandResponse defines model for CommandResponse.
type CommandResponse struct {
Command string `json:"command"`
}
// GetCommandJSONBody defines parameters for GetCommand.
type GetCommandJSONBody struct {
union json.RawMessage
}
// GetCommandJSONRequestBody defines body for GetCommand for application/json ContentType.
type GetCommandJSONRequestBody GetCommandJSONBody
There is GetCommandJSONBody struct with union data but no functions to use it.
Minimal yaml:
This is the generated go code:
There is
GetCommandJSONBodystruct withuniondata but no functions to use it.