2

I just generated code using Swagger.io with the OpenApi 3.0 spec. The code it produces doesn't compile. Once class has this seemingly crucial import:

import springfox.documentation.oas.annotations.EnableOpenApi;

But I get this error: package springfox.documentation.oas.annotations does not exist

I can't figure out what I need to add to my pom.xml file to make the import work. The maven repo at https://mvnrepository.com/ doesn't let me search for a specific class, which makes no sense.

Helen
  • 87,344
  • 17
  • 243
  • 314
MiguelMunoz
  • 4,548
  • 3
  • 34
  • 51
  • Usually one looks for jar files on findjar.com , and then when one found on mvnrepository for proper maven coordinates. Project istelf is here: https://springfox.github.io/springfox/ – Konstantin Pribluda Jan 05 '21 at 07:22
  • Thank you. That helped with other missing classes, like io.swagger.v3.oas.models.OpenAPI, but didn't help with springfox.documentation.oas.annotations.EnableOpenApi. – MiguelMunoz Jan 05 '21 at 07:36
  • 1
    Well, look into project on github. There must be information somewhere about distribution repository. mvnrepository does not serach everywhere, and spring uses own repositories – Konstantin Pribluda Jan 05 '21 at 07:50
  • Take a look at http://springfox.github.io/springfox/docs/snapshot/#maven – Amir M Jan 05 '21 at 07:59

1 Answers1

1

I hope you have missed swagger oas dependency so you are getting package not exist error. Swagger oas available in the below maven repository.

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-oas</artifactId>
    <version>3.0.0</version>
</dependency>
Sathiamoorthy
  • 8,831
  • 9
  • 65
  • 77
  • That helped with most of the problems with the package. I still can't build, because I'm getting an error on a call to a method called apiInfo(), with a signature that's presumably `public springfox.documentation.service.ApiInfo apiInfo()` – MiguelMunoz Jan 05 '21 at 15:37
  • @MiguelMunoz, Swagger is old version, you should use openapi. Follow this link to integrate swagger in your application. https://stackoverflow.com/questions/65557795/springboot-security-swagger-springfox-boot-starter/65558262#65558262 – Sathiamoorthy Jan 05 '21 at 17:28
  • When I last used openApi, I found some options that I wanted to use were missing. I also didn't like the quality of the code they generated, although I had (smaller) problems with Swagger's generated code. – MiguelMunoz Jan 05 '21 at 20:10
  • 1
    Add this maven dependecies and try ` io.springfox springfox-boot-starter 3.0.0 ` – Sathiamoorthy Jan 06 '21 at 04:38
  • Although following @Sathia s suggestion I still can't build using openapi-generator-maven-plugin because internally deprecated class RelativePathProvider (current: BasePathProvider) is used during code generation. How can I solve this? – du-it Mar 09 '21 at 14:32
  • @du-it, I didn't understand. Can you post your question separately with more detail? – Sathiamoorthy Mar 09 '21 at 14:49
  • 1
    Please look at https://stackoverflow.com/questions/66550300/how-to-resolve-that-openapi-generator-maven-plugin-uses-deprecated-class – du-it Mar 09 '21 at 15:55
  • @du-it, solution added and voted for your question. – Sathiamoorthy Mar 09 '21 at 16:46