softwaremill / softwaremill/tapir

[FEATURE] Support customizing the generated OpenAPI JSON schema

Open
#2,953 1 comment 1 reaction 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

After a discussion on softwaremill.community (https://softwaremill.community/t/differentiating-between-undefined-and-null/154/8), @adamw suggested opening an issue.

In short, this is a feature request for some way to customize what the generated OpenAPI JSON schema will be for a type.

In my particular use case, I needed the option to set "nullable" to true for a specific type, not for all optional types (that is already supported).

It is possible to manually, eg. with quicklens, modify the OpenAPI returned from OpenAPIDocsInterpreter(). toOpenAPI(...), but it's not very elegant.

Adam's suggestion from the discussion:

As for a more user-friendly fix, I think we should have an option to customise the final, generated JSON Schema (which is part of the OpenAPI object). We could set an attribute on the tapir-schema, with a function which would be called by the OpenAPI interpreter.

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 with OpenAPIDocsInterpreter().toOpenAPI(...) and the tapir-schema customization point described in the issue. Review how the interpreter produces the JSON Schema within the OpenAPI object and determine the API needed for per-type customization. Done means a specific type can customize its generated schema, including nullable=true, without changing all optional types.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.