How to improve Open API documentation for Iron (Refined) Types

Hi
How can I improve the documentation of Iron Types in Tapir Open API documentation?
Here some examples:

type Percentage = Int :| (GreaterEqual[0] & LessEqual[100])
type SelectedPensionType = Int :| any.In[(
  11393215,
    36496024,
    36496021,
    122483321,
    110354423,
    110354433,
    110354454,
    122483323
  )]

This gives me:
image

Is there a way to do this without adding any custom description or at least adding a description in a generic way?

I’m not sure I understand, what would you like to improve? That is, what’s the current vs desired OpenAPI schema that is being generated?

At the moment it generates: Value: 100

Instead I think I expect something like this:
Constraint: GreaterEqual[0] & LessEqual[100]
or Constraint: One of 11393215, 36496024,..

Can you check what’s the underlying OpenAPI schema (in yaml/json)? Is this the description that is generated?

I can’t see any code that would generate that here: tapir/integrations/iron/src/main/scala/sttp/iron/codec/iron/TapirCodecIron.scala at e7e450ef62e9526f9667665f131f2e4423088819 · softwaremill/tapir · GitHub

This seems to be the problem:
image
Working with Tapir Constraints (@validate) it works as expected:

GreaterEqual / LessEqual
TapirCodecIron.scala:

There are 2 Problems with this:

  • Why is it exclusive, even in TSchemaToASchema.scala it is mapped to exclusive = false:
  • From where comes Value: 100

In
There is no validator for this type in TapirCodecIron.scala

As both types are OR compositions, (e.g. type GreaterEqual[V] = (Greater[V] | StrictEqual[V]) ..) I suspect OR compositions are not mapped correctly to Tapir Validations.

I could reproduce GreaterEqual case:

Interesting Greater & Less works.

For the In case, I am not sure if I did the test right, but the result looks not right:

Can you maybe submit your tests as a PR? It will be easier to see what you’re trying to do in code, than on screenshots :slight_smile:

here there is: Adding two test cases in TapirCodecIronTestScala3 to illustrate Probl… by pme123 · Pull Request #3774 · softwaremill/tapir · GitHub

Fixed in Fixes for iron derivation for GreaterEqual, LessEqual, In by kciesielski · Pull Request #3790 · softwaremill/tapir · GitHub

1 Like