-
Notifications
You must be signed in to change notification settings - Fork 205
Closed
Description
Hi! Thank you for this library.
I have a problem with describing a recursive schema, which looks something like this in the response JSON:
[
{
"name": "foo",
"children": [
{
"name": "bar",
"children": [
{
"name": "baz",
"children": []
}
]
}
]
}
]Basically it represents a tree of nodes of nodes of nodes...
I tried something like this (already figured it out that there's a need to use Reference instead of module itself to avoid compilation errors):
defmodule MyAppWeb.Schemas do
alias OpenApiSpex.Schema
alias OpenApiSpex.Reference
defmodule Node do
require OpenApiSpex
OpenApiSpex.schema(%{
type: :object,
properties: %{
name: %Schema{type: :string, description: "Node name"},
children: %Reference{"$ref": "#/components/schemas/Nodes"}
},
required: [:name, :children]
})
end
defmodule Nodes do
require OpenApiSpex
OpenApiSpex.schema(%{
type: :array,
items: Node,
minLength: 0
})
end
endThis produces an output in the Swagger UI where everything seems to be correct except Node.children is shown as an array of anonymous objects, but nothing about it being array of Node.
How should a relation like this be described so that Swagger UI would at least show the type of array elements for children property?
Metadata
Metadata
Assignees
Labels
No labels