swagger-api / swagger-api/swagger-codegen

[Spring] Wrong class path for DeferredResult

Open
#6,451 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Generated code for Spring is using wrong class path for DeferredResult. Currently, it is used org.springframework.web.context.request.DeferredResult, when actual class path is org.springframework.web.context.request.async.DeferredResult. See here.

Fix should be simple, I will provide PR soon.

Swagger-codegen version

2.2.3. This bug is present since corresponding feature is introduced.

Swagger declaration file content or url
Command line used for generation

I am using swagger-codegen-maven-plugin. Here is the configuration

<configuration>
    <inputSpec>${project.basedir}/src/main/spec/api.yaml</inputSpec>
    <language>spring</language>
    <apiPackage>...removed..</apiPackage>
    <modelPackage>...removed...</modelPackage>
    <configOptions>
        <sourceFolder>java</sourceFolder>
        <dateLibrary>java8</dateLibrary>
        <interfaceOnly>true</interfaceOnly>
        <java8>true</java8>
        <responseWrapper>DeferredResult</responseWrapper>
    </configOptions>
    <library>spring-mvc</library>
    <output>${project.build.directory}/generated-sources/server</output>
</configuration>
Steps to reproduce
Related issues/PRs
Suggest a fix/enhancement

I will provide PR.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Spring generator path used by swagger-codegen-maven-plugin, focusing on the spring-mvc library and the responseWrapper=DeferredResult option. Reproduce generation with the shown configuration and verify that the generated import uses the async DeferredResult class path.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
api, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.