question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for kotlin.Deprecated

See original GitHub issue

Hi, using SpringFox in a Kotlin project.

When an endpoint is marked with java.lang.Deprecated, then SpringFox shows it as deprecated in the GUI (as expected).

For Kotlin projects, it would be good to have the same support for when the annotation kotlin.Deprecated is used. This would be particularly useful with IntelliJ, as java.lang.Deprecated is itself deprecated in Kotlin, and IntelliJ flags all of its usages (with warnings to rather replace it with kotlin.Deprecated)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
dilipkrishcommented, Aug 3, 2020

This can be easily implemented as a plugin. Perhaps the long term solution is to create a Kotlin module that configures the defaults for Kotlin. Please +1 this issue if you’d like to see a fix for this or would like to create a Kotlin module

1reaction
fzyzcjycommented, Jan 31, 2022

Here is a workaround:

/**
 * Support [kotlin.Deprecated], when the original Springfox only supports [java.lang.Deprecated]
 * modified from: https://github.com/springfox/springfox/blob/master/springfox-spring-web/src/main/java/springfox/documentation/spring/web/readers/operation/OperationDeprecatedReader.java
 * see more at https://github.com/springfox/springfox/issues/2551
 */
@Component
@Order(Ordered.HIGHEST_PRECEDENCE)
class SwaggerKotlinOperationDeprecatedReader : OperationBuilderPlugin {
    override fun apply(context: OperationContext) {
        val annotationOnMethod = context.findAnnotation(Deprecated::class.java)
        val annotationOnController = context.findControllerAnnotation(Deprecated::class.java)
        val deprecated = annotationOnMethod.isPresent || annotationOnController.isPresent
        context.operationBuilder().deprecated(if (deprecated) "true" else null)
    }

    override fun supports(delimiter: DocumentationType): Boolean = true
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Deprecated - Kotlin Programming Language
A deprecated API element is not recommended to use, typically because it's being phased out or a better alternative exists. To help removing...
Read more >
Deprecation in Kotlin | Baeldung on Kotlin
By default, the Kotlin compiler only prints a warning message if we use a deprecated method. This compiler action, however, can be configured ......
Read more >
Enhanced Deprecation in Kotlin - Todd Ginsberg
Kotlin's Deprecation annotation makes life a lot easier for everybody when deprecating code. In this post, I'll show you what @Deprecated ...
Read more >
Deprecated | Android Developers
A program element annotated @Deprecated is one that programmers are discouraged from using. An element may be deprecated for any of several reasons, ......
Read more >
Support for kotlin.Deprecated · Issue #414 - GitHub
This is about using OpenApi in a Kotlin project. When an endpoint is marked with java.lang.Deprecated, then SpringDoc shows it as deprecated in ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found