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:
Is there a way to do this without adding any custom description or at least adding a description in a generic way?
adamw
May 16, 2024, 8:21pm
2
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,..
adamw
May 17, 2024, 6:18am
4
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:
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:
adamw
May 20, 2024, 8:54am
8
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
pme123
May 20, 2024, 12:04pm
9