blob: 69b3e10bfd91be9f731913f616bb7a2b2edf9728 [file] [log] [blame]
cue def foo.cue -o openapi+cue:out.cue
cmp out.cue expect-out.cue
cue def openapi+cue: expect-cue-out -o -
cue def foo.cue -o openapi:-
cmp stdout expect-json-out
cue def foo.cue -o openapi+cue:-
cmp stdout expect-cue-out
cue def foo.cue -o openapi+yaml:-
cmp stdout expect-yaml-out
cue def -p foo openapi: openapi.json
cmp stdout expect-cue
# auto mode
cue def -p foo openapi.json
cmp stdout expect-cue
# cue to openapi
cue def openapi+cue: expect-cue-out -o -
cmp stdout expect-cue2
# combine
cue def -p foo openapi.json openapi2.json
cmp stdout expect-cue3
-- foo.cue --
// Some clever title.
$version: "v1"
#Foo: {
a: int
b: uint & <10
}
#Bar: {
foo: #Foo
}
-- openapi.json --
{
"openapi": "3.0.0",
"info": {
"title": "My OpenAPI",
"version": "v1alpha1"
},
"paths": {},
"components": {
"schemas": {
"Bar": {
"type": "object",
"required": [
"foo"
],
"properties": {
"foo": {
"$ref": "#/components/schemas/Foo"
}
}
},
"Foo": {
"type": "object",
"required": [
"a",
"b"
],
"properties": {
"a": {
"type": "integer"
},
"b": {
"type": "integer",
"minimum": 0,
"exclusiveMaximum": 10
}
}
}
}
}
}
-- openapi2.json --
{
"openapi": "3.0.0",
"info": {
"title": "My OpenAPI2",
"version": "v1alpha1"
},
"paths": {},
"components": {
"schemas": {
"Baz": {
"type": "object",
"required": [
"a",
"b"
],
"properties": {
"a": {
"type": "integer"
},
"b": {
"type": "integer",
"minimum": 0,
"exclusiveMaximum": 10
}
}
}
}
}
}
-- expect-json-out --
{
"openapi": "3.0.0",
"info": {
"title": "Some clever title.",
"version": "v1"
},
"paths": {},
"components": {
"schemas": {
"Bar": {
"type": "object",
"required": [
"foo"
],
"properties": {
"foo": {
"$ref": "#/components/schemas/Foo"
}
}
},
"Foo": {
"type": "object",
"required": [
"a",
"b"
],
"properties": {
"a": {
"type": "integer"
},
"b": {
"type": "integer",
"minimum": 0,
"maximum": 10,
"exclusiveMaximum": true
}
}
}
}
}
}
-- expect-yaml-out --
openapi: 3.0.0
info:
title: Some clever title.
version: v1
paths: {}
components:
schemas:
Bar:
type: object
required:
- foo
properties:
foo:
$ref: '#/components/schemas/Foo'
Foo:
type: object
required:
- a
- b
properties:
a:
type: integer
b:
type: integer
minimum: 0
maximum: 10
exclusiveMaximum: true
-- expect-cue-out --
openapi: "3.0.0"
info: {
title: "Some clever title."
version: "v1"
}
paths: {}
components: schemas: {
Bar: {
type: "object"
required: ["foo"]
properties: foo: $ref: "#/components/schemas/Foo"
}
Foo: {
type: "object"
required: ["a", "b"]
properties: {
a: type: "integer"
b: {
type: "integer"
minimum: 0
maximum: 10
exclusiveMaximum: true
}
}
}
}
-- expect-cue --
// My OpenAPI
package foo
info: {
title: *"My OpenAPI" | string
version: *"v1alpha1" | string
}
#Bar: {
foo: #Foo
...
}
#Foo: {
a: int
b: uint & <10
...
}
-- expect-cue2 --
info: {
title: *"Some clever title." | string
version: *"v1" | string
}
#Bar: {
foo: #Foo
...
}
#Foo: {
a: int
b: uint & <10
...
}
-- expect-cue2 --
info: {
title: *"Some clever title." | string
version: *"v1" | string
}
#Bar: {
foo: #Foo
...
}
#Foo: {
a: int
b: uint & <10
...
}
-- expect-cue3 --
// My OpenAPI
// My OpenAPI2
package foo
info: {
title: (*"My OpenAPI" | string) & (*"My OpenAPI2" | string)
version: (*"v1alpha1" | string) & (*"v1alpha1" | string)
}
#Bar: {
foo: #Foo
...
}
#Foo: {
a: int
b: uint & <10
...
}
#Baz: {
a: int
b: uint & <10
...
}
-- expect-out.cue --
openapi: "3.0.0"
info: {
title: "Some clever title."
version: "v1"
}
paths: {}
components: schemas: {
Bar: {
type: "object"
required: ["foo"]
properties: foo: $ref: "#/components/schemas/Foo"
}
Foo: {
type: "object"
required: ["a", "b"]
properties: {
a: type: "integer"
b: {
type: "integer"
minimum: 0
maximum: 10
exclusiveMaximum: true
}
}
}
}