Closed SerVB closed 4 years ago
Hi, Generics classes are unsupported. Reflection is used during initialization, and generic types are erased. See JVM type erasure. This is one of the biggest caveats of JVM languages... One way around it is to wrap your generic types like this:
class NotGeneric: GenericClass<Generic>()
This should allow the reflection to find the appropriate types.
As for the nulls, the library currently relies on ktor to serialize the model into json. The mapper.setSerializationInclusion(Include.NON_NULL)
should be activated for Jackson.
Although thinking about it, the KType information seems to have the generic information... Maybe there is a way to handle it.
Also, there is a hook in the configuration that allows you to properly rename the classes to be digestible by the standard.
@SerVB I changed the model acquisition system in the new release. Please verify if your issue persists or not.
https://github.com/papsign/Ktor-OpenAPI-Generator/releases/tag/0.1-beta.1
Fixed. Marking as closed.
@Wicpar, thank you! I see many changes, for example, T
and kotlin.collections.List
have disappeared.
However, there are things that I still don't understand:
3) minimum: null/maximum: null
for string
and boolean
seem redundant.
If I do mapper.setSerializationInclusion(Include.NON_NULL)
, these redundant lines disappear but it's not a solution, because also my server stops sending fields with null values. I want it to continue sending objects like {"data": null}
.
4) minimum: -2147483648
for id: int32
isn't appropriate, I want it to start with 0
.
So is there a way to annotate it?
these are separate issues... Currently the model is made with data classes and serialised from it. I'll have to change the whole model system to make it work like that. This can be quick fixed with a separate object mapper that serialises it to string in the openapi.json endpoint. Also, currently there are no @min @max annotations. Though it can be added quite rapidly iirc.
Hi! Is there an opportunity to change the "Models" section?
Currently, I have the following one (on this commit):
I'm not an experienced Swagger user but I think the issues are:
T
model should not be presented.minimum: null/maximum: null
forstring
andboolean
seem redundant.minimum: -2147483648
forid: int32
isn't appropriate, I want it to start with0
.kotlin.collections.List
is strange, it's a simple JSON array...io.github.servb.eShop.util.OptionalResult<io.github.servb.eShop.route.product.v1.ProductUsable>
has thedata: T
field, butdata: io.github.servb.eShop.route.product.v1.ProductUsable
is more logical here.I've briefly checked the annotations but haven't found suitable ones.