softwaremill / softwaremill/tapir

Can we add `SchemaType.Intersection` for `SProduct`s?

Open
#3,767 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
1.5k
Forks
468
Avg merge
5h 37m
Merged PRs (30d)
34

Description

So let me describe a use case I'm fairly sure is familiar.

I have bunch of data types. Some product types appear both in a sum type and alone. I prefer to use discriminators in sum types.

The way this typically works out is that you get two unrelated types in JSON Schema, where one has a 1 suffix, one of the two have the discriminator field, and they share the entire structure otherwise.

I'd like for this to be rendered as two types in JSON Schema:

  • Foo (without discriminator)
  • FooDisc (with discriminator)

Where FooDisc would be expressed using allOf in JSON Schema. This way the relationship would be clear, there would be less duplication.

I can try a PR myself, just wanted to check if it looks worthwhile first

Contributor guide

No contributing guide indexed for this repository

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 by tracing the existing SchemaType and SProduct handling for JSON Schema generation. Confirm how the requested Foo and FooDisc relationship should be represented with allOf, then verify that the generated schemas avoid duplicated structure while preserving the discriminator behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.