Comments (1)
I have experienced the same issue, but with types that have an indirect reference cycle instead (e.g. A references to B, which references to C, which references to A again), so using self references in the generated schema would not be enough in that case.
Maybe an expected output that also takes into account indirect reference cycles would be the following:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Test",
"$ref": "#/definitions/Test", // <------------------------- reference to the definition
"definitions": {
"Test": {
"oneOf": [
{
"type": ["object", "string"],
"required": ["function"],
"properties": {
"function": {
"type": "string",
"enum": ["randomVariantA"]
}
}
},
{
"type": ["object", "integer"],
"format": "int32",
"required": ["function"],
"properties": {
"function": {
"type": "string",
"enum": ["randomVariantB"]
}
}
},
{
"type": ["object", "array"],
"items": {
"$ref": "#/definitions/Test"
},
"required": ["function"],
"properties": {
"function": {
"type": "string",
"enum": ["recursiveTests"]
}
}
}
]
}
}
}
from schemars.
Related Issues (20)
- `#[doc = include_str!("../xx.md")]` or `#[schemars(description = include_str!("xx.md"))]` not work yet
- There are no such thing as null type in OpenAPI
- Non-compliant generated "format" values
- serde default value from function
- Support for Serde into and try_from container attributes
- Controlling referenceability in derived schemas
- failed to deserialize json from payload
- How to incorporate additional schema ?
- JsonSchema is not implemented for std::time::Instant
- Please add support for time::OffsetDateTime and perhaps other types from time crate HOT 1
- Traversal of the Schema tree
- Variant-level #[serde(untagged)] is not yet supported HOT 3
- Compiler error when using serde_with::with_prefix! HOT 2
- Is this crate unmaintained? HOT 4
- Incompatibility with serde_json feature "arbitrary_precision" HOT 1
- Missing "$id" field on root schema HOT 1
- Incorrect Schema Generated for Response with Tuple HOT 2
- Toggle ability to ignore Example code in documentation
- Add support for garde crate as alternative to validator HOT 1
- Map schemas do not specify the key type
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from schemars.