Swagger - s50600822/Notes GitHub Wiki

Online Editor

https://editor-next.swagger.io/

https://github.com/OpenAPITools/openapi-generator/blob/master/docs/qna.md

https://github.com/swagger-api/swagger-codegen

https://github.com/swagger-api/swagger-codegen/issues/11812

FUED

swagger-codegen-maven-plugin vs openapi-generator-maven-plugin https://openapi-generator.tech/docs/swagger-codegen-migration/

isssue:

JDK 8 and above

➜  swagger-codegen git:(master) cd samples/server/petstore/spring-mvc
➜  spring-mvc git:(master) mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------< io.swagger:swagger-spring-mvc-server >----------------
[INFO] Building swagger-spring-mvc-server 1.0.0
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- clean:3.2.0:clean (default-clean) @ swagger-spring-mvc-server ---
[INFO] Deleting /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc/target
[INFO]
[INFO] --- resources:3.3.0:resources (default-resources) @ swagger-spring-mvc-server ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- compiler:3.10.1:compile (default-compile) @ swagger-spring-mvc-server ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 60 source files to /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc/target/classes
[INFO] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java: Some input files use unchecked or unsafe operations.
[INFO] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/PetApiController.java: Recompile with -Xlint:unchecked for details.
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java:[3,33] package javax.xml.bind.annotation does not exist
[ERROR] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java:[6,27] package javax.xml.bind.annotation does not exist
[ERROR] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java:[45,6] cannot find symbol
  symbol:   class XmlTransient
  location: class io.swagger.api.ApiResponseMessage
[INFO] 3 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.423 s
[INFO] Finished at: 2023-05-02T03:19:01+10:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project swagger-spring-mvc-server: Compilation failure: Compilation failure:
[ERROR] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java:[3,33] package javax.xml.bind.annotation does not exist
[ERROR] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java:[6,27] package javax.xml.bind.annotation does not exist
[ERROR] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc/src/main/java/io/swagger/api/ApiResponseMessage.java:[45,6] cannot find symbol
[ERROR]   symbol:   class XmlTransient
[ERROR]   location: class io.swagger.api.ApiResponseMessage
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException


➜  spring-mvc-j8-async git:(master) ✗ mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] -----------< io.swagger:swagger-spring-mvc-server-j8-async >------------
[INFO] Building swagger-spring-mvc-server-j8-async 1.0.0
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- clean:3.2.0:clean (default-clean) @ swagger-spring-mvc-server-j8-async ---
[INFO] Deleting /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc-j8-async/target
[INFO]
[INFO] --- resources:3.3.0:resources (default-resources) @ swagger-spring-mvc-server-j8-async ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- compiler:3.10.1:compile (default-compile) @ swagger-spring-mvc-server-j8-async ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 59 source files to /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc-j8-async/target/classes
[INFO] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/configuration/RFC3339DateFormat.java: /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/configuration/RFC3339DateFormat.java uses or overrides a deprecated API.
[INFO] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/configuration/RFC3339DateFormat.java: Recompile with -Xlint:deprecation for details.
[INFO] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java: Some input files use unchecked or unsafe operations.
[INFO] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/PetApi.java: Recompile with -Xlint:unchecked for details.
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/ApiResponseMessage.java:[3,33] package javax.xml.bind.annotation does not exist
[ERROR] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/ApiResponseMessage.java:[6,27] package javax.xml.bind.annotation does not exist
[ERROR] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/ApiResponseMessage.java:[45,6] cannot find symbol
  symbol:   class XmlTransient
  location: class io.swagger.api.ApiResponseMessage
[INFO] 3 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  4.593 s
[INFO] Finished at: 2023-05-02T03:36:31+10:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project swagger-spring-mvc-server-j8-async: Compilation failure: Compilation failure:
[ERROR] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/ApiResponseMessage.java:[3,33] package javax.xml.bind.annotation does not exist
[ERROR] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/ApiResponseMessage.java:[6,27] package javax.xml.bind.annotation does not exist
[ERROR] /Users/hoaphan/dev/code/swagger-codegen/samples/server/petstore/spring-mvc-j8-async/src/main/java/io/swagger/api/ApiResponseMessage.java:[45,6] cannot find symbol
[ERROR]   symbol:   class XmlTransient
[ERROR]   location: class io.swagger.api.ApiResponseMessage
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

explain

javax.xml.bind.annotation was included in JDK 6 and JDK 7 as part of the Java API for XML Web Services (JAX-WS) and Java Architecture for XML Binding (JAXB) frameworks. However, starting from JDK 9, these APIs are no longer included in the JDK by default, and must be added as dependencies if needed.

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.1</version>
        </dependency>  
⚠️ **GitHub.com Fallback** ⚠️