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

Wrong schema generated

Open
#158 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start with the CarDto and TireDto examples and the test using JsonSchemaGenerator.generateSchema(CarDto.class). Inspect how the generator represents the first TireDto property versus later references, then compare that behavior with the expected repeated schema structure. Done means the behavior is corrected or the required configuration is clearly identified and covered by the reproduction test.

Written by the indexing model from the issue text.

Description

Hello, I want to generate schema for carDto, which contains as attributes also four tireDto's. Here is exmaple of such dto's:

@Getter
@Setter
public class CarDto
{
  private String licencePlate;
  private String vin;
  private String brand;
  private String model;
  private TireDto tireFrontLeft;
  private TireDto tireFrontRight;
  private TireDto tireBackLeft;
  private TireDto tireBackRight;
}
@Getter
@Setter
public class TireDto
{
  private String tireBrand;
  private String tireModel;
  private String dimension;
  private String season;
}

Here is the test how I want to generate schema:

  @Test
  void shouldGenerateValidSchema() throws IOException {
    SimpleModule module = new SimpleModule();
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.registerModule(module);

    ObjectSchema dtoSchema = (ObjectSchema) new JsonSchemaGenerator(objectMapper).generateSchema(CarDto.class);

    System.out.println(dtoSchema.getProperties());
  }

I would expect that all attributes of class TireDto (tireFrontLeft, tireFrontRight, tireBackLeft and tireBackRight) will be instances of the same schema. But it is not like that. First attribute tireFrontLeft is instance of ObjectSchema and all others (tireFrontRight, tireBackLeft and tireBackRight) are instances of ReferenceSchema. Besides that, only tireFrontLeft contains also properties of TireDto.

Here I'm also attaching screenshot from debugging.
image

So is it a bug, or I'm missing some configuration?

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.