OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.35k stars 6.46k forks source link

Kotlin delegate pattern should declare delegate parameter as nullable #6857

Open rainoko opened 4 years ago

rainoko commented 4 years ago

https://github.com/OpenAPITools/openapi-generator/blob/21e285cea9a876a2ae30f5b22153e160dbcaca9f/modules/openapi-generator/src/main/resources/kotlin-spring/apiController.mustache#L14

Constructor declares autowired as required=false but parameter itself is not nullable, as I understand it should be nullable otherwise exception is rised when there is no implementation yet for delegate.

pstorch commented 2 months ago

Looks like this is fixed in the meantime: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/kotlin-spring/apiController.mustache#L16

On the other hand the lateinit modifier of the field is flagged as unnecessary by the IDE and the Optional.ofNullable in the init{} block is not ideomatic Kotlin. Maybe worth a different issue.