Comments (7)
Was just about to submit a ticket for this. This is really relevant. We can probably come up with a different key
discriminant than the type name here:
Lines 225 to 227 in 5268080
Perhaps a Hash
of std::any::TypeId
?
from schemars.
Commenting here to mention that I have also run into this problem. Would love to see a fix for this, Should be fairly straightforward I imagine.
from schemars.
Hi @ewoolsey, #178 is a potential fix. Although, as highlighted in there, I believe a different approach should be considered. An approach that, in-turn, won't be a simple fix.
from schemars.
Hi @ewoolsey, #178 is a potential fix. Although, as highlighted in there, I believe a different approach should be considered. An approach that, in-turn, won't be a simple fix.
Haha things are never as straightforward as they first seem. @miraclx any Idea when we can expect either of these solutions to be implemented? I'm working on an interactive parser built on top of schemers and serde to generate complex types from user input. Using it to build some cool development tools. Should I proceed with a workaround or wait it out?
from schemars.
@ewoolsey, depending on your use case, #178 should suffice for schema generation.
For schema consumption, however, clients have to read the title
field for type names. Which, unless you're writing your own jsonschema consumer, probably won't use.
But if you are, it should work perfectly.
One last thing to note is that PR aids exhaustive schema generation.
But you should be careful about espousing reductionism when consuming it.
Effectively, you need to be careful not to remap it to {TypeName: TypeSchema}
.
Avoiding these classes of errors both when generating and consuming the schema will require a different approach for encoding information in the jsonschema that helps clients further disambiguate types. Module paths might be an option. But that's tricky to extract from macros.
from schemars.
Unfortunately because I'm dealing with a large library that implements JsonSchema on all its types, I'll have to wait for a new release on crates.io :/ Really appreciate the info though! And good luck finding a more robust solution!
from schemars.
I encountered the same issue with structs having the same name in different mods.
from schemars.
Related Issues (20)
- 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
- FEEDBACK WANTED - API proposal - supporting multiple JSON schema versions, breaking changes to `Schema` definition HOT 2
- Impl JsonSchema for for rocket_validation::Validated
- Generating definition types for enums with serde tag HOT 3
- Huge LLVM line count, quadratic compile time for derive(JsonSchema) HOT 7
- default member missing in schema for generic type that implements Default HOT 2
- Support for no_std
- Just can't enable smol_str feature
- Kubernetes extensions
- Schemars omit serde(flatten) BTreeMap HOT 3
- Override Serde for schema generation only
- Switch to indexmap2 for aarch64
- Consider updating `schemars_derive` to use `syn` v2 HOT 1
- Allow #[schemars(with = "Type")] on struct HOT 1
- Support Avro schema generation?
- Example for JsonSchema without definition references HOT 1
- Maintenance status HOT 1
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.