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.

Springfox 3.0.0 generates 3 classes instead of 1 (Class, ClassReq, ClassRes) and ClassReq is missing required fields

See original GitHub issue
  • What version of the library are you using? 3.0.0

For a single class 3.0.0 generates 3 classes: the original class, one with the Req and one with the Res postfix. Req seems to be used if @RequestBody is being used. Res I suppose when @ResponseBody is in use (do not use it, class is still generated). The original Class name is used when the class is present on another object.

This makes it impossible to pass a response object to a request API in Java and other other languages that rely on nominal typing because they are completely separate classes.

Even worse: it seems that the ParsedBusinessScheduleReq object does not properly generate the required fields. Below is the used class. Take a look at the required field which is absent for the ParsedBusinessScheduleReq object.

@ApiModel(value = "ParsedBusinessSchedule")
data class OpeningHours(
    val daysInWeek: List<WeeklyOpeningHours> = emptyList(),
    val daysInYear: List<YearlyOpeningHours> = emptyList(),
    val winterSeason: WinterSeason? = null,
    val closedOnHoliday: Boolean = true
)
{
  "ParsedBusinessSchedule": {
    "type": "object",
    "required": [
      "closedOnHoliday",
      "daysInWeek",
      "daysInYear"
    ],
    "properties": {
      "closedOnHoliday": {
        "type": "boolean"
      },
      "daysInWeek": {
        "type": "array",
        "items": {
          "$ref": "#/definitions/WeeklyOpeningHours"
        }
      },
      "daysInYear": {
        "type": "array",
        "items": {
          "$ref": "#/definitions/YearlyOpeningHours"
        }
      },
      "winterSeason": {
        "$ref": "#/definitions/WinterSeason"
      }
    }
  },
  "ParsedBusinessScheduleReq": {
    "type": "object",
    "properties": {
      "closedOnHoliday": {
        "type": "boolean"
      },
      "daysInWeek": {
        "type": "array",
        "items": {
          "$ref": "#/definitions/WeeklyOpeningHoursReq"
        }
      },
      "daysInYear": {
        "type": "array",
        "items": {
          "$ref": "#/definitions/YearlyOpeningHoursReq"
        }
      },
      "winterSeason": {
        "$ref": "#/definitions/WinterSeasonReq"
      }
    }
  },
  "ParsedBusinessScheduleRes": {
    "type": "object",
    "required": [
      "closedOnHoliday",
      "daysInWeek",
      "daysInYear"
    ],
    "properties": {
      "closedOnHoliday": {
        "type": "boolean"
      },
      "daysInWeek": {
        "type": "array",
        "items": {
          "$ref": "#/definitions/WeeklyOpeningHoursRes"
        }
      },
      "daysInYear": {
        "type": "array",
        "items": {
          "$ref": "#/definitions/YearlyOpeningHoursRes"
        }
      },
      "winterSeason": {
        "$ref": "#/definitions/WinterSeasonRes"
      }
    }
  }
}
  • Question. Is this a question about how to do a certain thing? Not sure if this is a bug or feature, couldn’t find any docs on that.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:30 (2 by maintainers)

github_iconTop GitHub Comments

19reactions
BernhardPosseltcommented, Mar 12, 2021

This is still an issue.

6reactions
krisgerhardcommented, Jun 10, 2021

It’s causing a lot of discomfort for us still. Could someone address this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Springfox 3.0.0 is not working with Spring Boot 2.6.0 [duplicate]
Only adding @EnableWebMvc in main class resolved the problem: @EnableWebMvc @SpringBootApplication public class MyApp { public static void ...
Read more >
Bountysource
Springfox 3.0.0 generates 3 classes instead of 1 (Class, ClassReq, ClassRes) and ClassReq is missing required fields.
Read more >
Springfox Reference Documentation - GitHub Pages
Springfox works by examining an application, once, at runtime to infer API semantics based on spring configurations, class structure and ...
Read more >
API Documentation with Springfox 3 - Microflash
The code written for this post uses: Java 14; Spring Boot 2.3.3; Springfox Boot Starter 3.0.0; Postgres 13 running in a Docker container;...
Read more >
I can't run any version of swagger-fox. Spring Boot 2.4.2 + JDK 8.
IllegalArgumentException: Unresolvable class definition for class [springfox.documentation.spring.web.OnServletBasedWebApplication]
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