Comments (4)
hi, Grant
lets start from, how do you want your metadata object to be described in json-schema terms?
can you give me an example?
from scala-jsonschema.
something like this?
{
"type": "object",
"additionalProperties": true
}
from scala-jsonschema.
I want to create a field in my schema named "metadata" that has a type of "object". I need the scala type of that field to be play.api.libs.json.JsObject
because that allows me to create a play-json Format
which will understand how to parse the field properly.
So:
case class Payload(id: String, name: String, metadata: JsObject)
implicit val payloadFmt = Json.format[Payload]
val personSchema: json.Schema[Person] = Json.schema[Person]
should compile and
println(JsonFormatter.format(AsValue.schema(personSchema))
Should print something like:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"payload": {
"type": "object"
}
}
}
from scala-jsonschema.
hey @gavares
please find this in 0.5.0
it won't happen automagically, though
some documentation you can find in here https://github.com/andyglow/scala-jsonschema#free-objects
please also take a look at
and
from scala-jsonschema.
Related Issues (20)
- Built-in instances for basic scala types
- Support for json schema draft 2020-12 HOT 4
- dependencies cause failure to compile (or start sbt) HOT 8
- Schema for play-json JsValue HOT 3
- Derived Schema doesn't work with empty case class and case objects HOT 4
- JsNull: there is no way to expose type: null
- {} type
- field level @title+@description annotations needed HOT 3
- Clearer error messages for detected usage of empty case classes and singleton types
- PureConfig Sealed Families HOT 8
- @discriminatorKey doesn't work on case objects in ADTs HOT 4
- `const` instead of a `single value enum` on the `descriminator`
- support empty schema
- Generic types in regular mode aren't deduplicated in schema definitions HOT 2
- Question: How to create json schema from a case class, and create custom schemas for specific types HOT 2
- Basic usages triggers compiler warnings when using -Xlint HOT 2
- Add support for `jsontypedef`
- Provide Json sample to Schema functionality
- Question: Get Json schema from case class HOT 2
- Java enum ACTIVE is not a class
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 scala-jsonschema.