FasterXML / FasterXML/jackson-module-jsonSchema

How to specify the "id" URI?

Aperta
#72 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
387
Fork
136
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I have two classes: `Article` and `User` and their respective schemas are available at:
- http://localhost:8080/api/articles/$schema
- http://localhost:8080/api/users/$schema

Since `Article.author` is of type `User`, how can I have the correct `$ref` in the schema? Now I'm getting this:

``` json
{
"type":"object",
"properties":{
"id":{
"type":"integer"
},
"title":{
"type":"string"
},
"author":{
"type":"object",
"id":"urn:jsonschema:it:saiv:best:common:entity:User",
"properties":{
"id":{
"type":"integer"
},
"cn":{
"type":"string"
}
}
}
}
}
```

but I would expect something like:

``` json
{
"type":"object",
"properties":{
"id":{
"type":"integer"
},
"title":{
"type":"string"
},
"author":{
"$ref":"http://localhost:8080/api/users/$schema"
}
}
}
```

This is the code I'm using to generate the schema:

``` java
@GET
@Path("/$schema")
@Produces(MediaType.APPLICATION_JSON)
public String getSchema() throws IOException {
HyperSchemaFactoryWrapper visitor = new HyperSchemaFactoryWrapper();
ObjectMapper mapper = new ObjectMapper();
mapper.acceptJsonFormatVisitor(Article.class, visitor);
JsonSchema schema = visitor.finalSchema();
return mapper.writeValueAsString(schema);
}
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.