Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# yaml-language-server: $schema=../../../../../configuration-schema.json
package: wholefileunion
output: union.gen.go
generate:
models: true
7 changes: 7 additions & 0 deletions internal/test/references/external/whole_file_union/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Package wholefileunion exercises oneOf/anyOf branches that $ref a whole file
// (issue #2639): a response body, an anyOf mixing a whole-file branch with an
// inline one, an object property, and a component schema. Such a branch names
// no Go type, so it is generated like an inline branch, named after its path.
package wholefileunion

//go:generate go run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=config.yaml spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# From issue-2639: a whole file used as a union branch.
type: object
properties:
id:
type: integer
69 changes: 69 additions & 0 deletions internal/test/references/external/whole_file_union/spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# From issue-2639: oneOf/anyOf branches that $ref a whole file (no # fragment)
# generated accessors named after the branch's inline struct, which didn't parse.
openapi: 3.0.3
info:
title: references/external/whole_file_union
version: "1"
paths:
/items:
get:
responses:
"200":
description: A response body union of two whole-file refs.
content:
application/json:
schema:
oneOf:
- $ref: ./user.yaml
- $ref: ./group.yaml
/mixed:
get:
responses:
"200":
description: An anyOf with one whole-file branch and one inline branch.
content:
application/json:
schema:
anyOf:
- $ref: ./user.yaml
- type: object
properties:
label:
type: string
/items/{id}:
get:
parameters:
- name: id
in: path
required: true
schema:
type: string
responses:
"200":
description: A component schema union of two whole-file refs.
content:
application/json:
schema:
$ref: "#/components/schemas/Item"
/holder:
get:
responses:
"200":
description: An object property union of two whole-file refs.
content:
application/json:
schema:
$ref: "#/components/schemas/Holder"
components:
schemas:
Item:
oneOf:
- $ref: ./user.yaml
- $ref: ./group.yaml
Holder:
type: object
properties:
member:
oneOf:
- $ref: ./user.yaml
- $ref: ./group.yaml
Loading
Loading