Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

How to specify the "id" URI?

Open
#72 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java

Research direction

Start with the getSchema entry point and trace how HyperSchemaFactoryWrapper and ObjectMapper handle the Article.author User relationship. Compare the generated schema with the expected $ref to determine whether URI configuration is supported; done means the author property references the User schema at the specified URI.

Written by the indexing model from the issue text.

Description

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:

{
   "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:

{
   "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:

    @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);
    }
Dominant language
Java
Stars
387
Forks
138
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from FasterXML/jackson-module-jsonSchema

All issues in FasterXML/jackson-module-jsonSchema

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.