swagger-api / swagger-api/swagger-core

[Bug]: JsonSchema fails with JSON round-trip

Open Beginner friendly
#5,264 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backlog Bug
Dominant language
Java
Stars
7.5k
Forks
2.3k
Avg merge
18h 1m
Merged PRs (30d)
10

Description

Description of the problem/issue

JsonSchema type field is asymmetric since there is a custom serializer that does not have a matching deserializer. This leads to a JSON round-trip failing when a single type is set.

Affected Version

2.2.53

Steps to Reproduce

  1. Create an instance of JsonSchema where there is a single type defined
  2. Serialize it
  3. Deserialize it, and see that it fails with reading type: X into types

Expected Behavior

Deserialization should work.

Actual Behavior

Deserialization does not work.

Logs / Stack Traces

Additional Context

Checklist

  • I have searched the existing issues and this is not a duplicate.
  • I have provided sufficient information for maintainers to reproduce the issue.

Contributor guide

Open the contributing guide

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.

Research direction

Start with JsonSchema and the custom serializer in modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/mixin/Schema31Mixin.java around line 65. Reproduce the single-type serialize/deserialize round trip and inspect the deserialization path; done means a JsonSchema with one type serializes and deserializes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.