hyperledger / identus-cloud-agent

Identus Cloud Agent
https://docs.atalaprism.io/
Apache License 2.0
72 stars 18 forks source link

Fix the encoding of examples in generated OpenAPI file #1137

Open FabioPinheiro opened 1 month ago

FabioPinheiro commented 1 month ago

Is this a regression?

No

Description

In several places in the OpenAPI the examples are broken. The examples are shown as the output of the method .toString instead of proper JSON as is expected by the API

To fix these people use a hammer like @encodedExample(JsonEncoder[... See https://github.com/hyperledger/identus-cloud-agent/pull/1130

I suspect the problem comes from for the marco Schema.derived and the case class Annotation[E](description: String, example: E, validator: Validator[E] = Validator.pass[E])

This E is of type Any and without requiring anything. I also don't see any value for Schema[Annotation] So where is the Schema[Annotation[_]] ? I bet the macro Schema.derived is calling the method Object#toString in that case. IMO my opinion the macro should fill in that case.

We could require E to have json encoder and adding some glue to make it work on a more generic case

Please provide the exception or error you saw

Instead of

2024-06-03-11_59_51

we want

2024-06-03-16_35_34

Please provide the environment you discovered this bug in

No response

Anything else?

No response

FabioPinheiro commented 2 weeks ago

This was not as simple as I expected See feat/PoC-for-1137-Annotation-OpenApi

We need to remove the Annotation class and make in another way. But is not worth the effort for now