Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

Kotlin data classes no longer generating required properties #186

Open
jonnii opened this issue Jun 8, 2020 · 3 comments
Open

Kotlin data classes no longer generating required properties #186

jonnii opened this issue Jun 8, 2020 · 3 comments

Comments

@jonnii
Copy link

jonnii commented Jun 8, 2020

Previously a class like the below:

    data class BusinessDaysModel(
        val code: String,
        val description: String,
        val fromDate: LocalDate,
        val fromDateIsBusinessDay: Boolean,
        val nextBusinessDays: List<LocalDate>
    )

would have generated a swagger with each of these properties being marked as required. I'm assuming this change is due to this PR #164 which correctly removes the originalRef stuff.

I'm not sure what the best way forward here, on the one hand I can fix this by annotating every class in my application with an @ApiModelProperty annotation (but this is awkward to keep in sync). Is there a way to hook into this perhaps using a model converter (i've never done this before...)? Or perhaps we can add kotlin support as a first class thing like scala?

@jonnii
Copy link
Author

jonnii commented Jun 18, 2020

@gigaSproule any suggestions on what to do here? If you can give me a little bit of direction I'm happy to go and try to bottom out a solution.

@gigaSproule
Copy link
Owner

gigaSproule commented Aug 15, 2020

Hey, Kotlin/Scala support is only really on a best case efforts (as this was originally a quick plugin for a Java application). There are equivalent tests for Kotlin and Scala (although Scala is proving to be problematic at the moment). Unfortunately, I just don't have any time at the moment to really keep on top of this at the moment.

I agree though, annotating would be stupid (that's why Kotlin has "nullable" types!). There is also a lack of a test for this at all, so no wonder it's slipped through the net (not that I'm exactly happy with the level of testing here, but no time, no fix :( ).

It's worth pointing out that this probably also isn't working for Scala's and Java's Option types.

And finally, this logic is really just using Swaggers own logic (take a look at AbstractReader#getParameters), so you may have better luck with using the more official Gradle plugin (https://github.com/swagger-api/swagger-core/tree/master/modules/swagger-gradle-plugin), but that obviously requires using the Swagger 2.X annotations.

Alternatively, if you are able to find a fix for this, I'm more than happy to accept a PR.

@proggler23
Copy link

I would still like to use this plugin. works great for our needs. Any chance that this issue will be resolved in the near future?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants