Swagger Jersey project, openapi.json is missing "maximum" and "minimum" etc - jersey

Jersey project using following Swagger Core:
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-jaxrs2</artifactId>
<version>2.0.2</version>
</dependency>
open and compare "path/openapi.json" and "path/swagger.json", openapi.json is missing information like "maximum" and "minimum". for some reason I have to use openapi.json instead of swagger.json. Please refer to the image below.

Related

Spring Boot 3 JSP Issue

I've been having issues with JSP since moving to Java 17 and Spring Boot 3. I know that we need to use jakarta.* instead of javax.*, but is there something I'm missing? I am using Spring Tools 4 and just running a basic web app using JSP. When using the following dependencies
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
</dependency>
The project runs, but I get the following error
The superclass "javax.servlet.http.HttpServlet", determined from the Dynamic Web Module facet version (2.5), was not found on the Java Build Path
I can get rid of it by adding the javax servlet dependency
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
But that goes against using javax.* dependencies with Spring Boot 3.
I have read these articles and tried adding the jakarta.servlet.jsp dependency with no luck.
https://debugah.com/solved-tomcat10-error-jakarta-servlet-servletexception-class-com-kuang-servlet-helloservlet-is-not-a-servlet-22749/
https://howtodoinjava.com/java/exception-handling/solved-the-superclass-javax-servlet-http-httpservlet-was-not-found-on-the-java-build-path-in-eclipse/
Solved!
All I had to do was go into Project Properties and under Project Faces, change my Dynamic Web Module from 2.5 to 5.0
The JSTL warning can be suppressed under Properties->Web->JSP Files->Validation->Custom actions->Other problems with TagExtraInfo class (Just change from 'Warning' to 'Ignore')

Micronaut Swagger multimodule

I am trying to visualize the API definitions from a Multimodule project. First I want to start from simple, and I want to visualize the yaml from the parent module. Then I will add other APIs in my Swagger Controller to call the specific url as is done in the example https://github.com/frehov/micronaut-swagger-server
I have my Swagger Controller and my SwaggerConfiguration with my index.hbs inside resource > views.swagger I took the example from the repo https://github.com/frehov/micronaut-swagger-server
This is my Result:
Instead of something like:
When I compared the two project, somehow my view.swagger package from my target folder gets generated into a different way, compared with the example:
What I am missing?
Could you please look at my repo:
https://github.com/amhg/swagger
Thank you
The folder containing the swagger-ui-wrapper (index.hbs) in your project is called 'views.swagger', while the sample has defined 'views/swagger' (so swagger is a folder inside of views). Change that and you get the views/swagger result in your target.
You also need to enable the micronaut handlebars-views (i.e. serving the .hbs files from a controller); add these to the pom.xml of startup (not at the root-pom!):
<dependency>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-views</artifactId>
</dependency>
<dependency>
<groupId>com.github.jknack</groupId>
<artifactId>handlebars</artifactId>
<version>4.1.0</version>
<scope>runtime</scope>
</dependency>
These will perform the magic of rendering the configuration you return from the controller into an html-page.
Depending on where you're going to put the swagger-annotated controllers, you might also want to add
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger.version}</version>
<scope>compile</scope>
</dependency>

OpenAPI 3 Casting Exception fails to show Api-Docs on localhost

I am converting our current Swagger configuration from spring fox (Swagger2) to OpenAPI 3.0 (Swagger3), however when I run the SpringBoot project locally and attempt to hit localhost:8080/v3/api-docs I get a casting exception:
{"errors":[{""errorCode":"INTERNAL_SERVER_ERROR", "errorDescription":"Internal server error. Unable to process your request", "stackTrace": "java.lang.ClassCastException: java.lang.String cannot be cast to com.package.ObjectInQuestion}]}
Swagger2 used to work fine but once I introduced the OpenAPI dependencies below, and take out all Swagger2 references, it breaks.
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-open-ui</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-open-webmvc-core</artifactId>
<version>1.5.5</version>
</dependency>
I even added the webmvc-core alongside to see if that fixed the issue but to no avail. Updated all the tags to the appropriate OpenAPI tags to our API's. Tried with Docket(Swagger2) and OpenAPI(Swagger3) #Beans.
The ObjectInQuestion is not even used in the project, its included as a class model in our common jars so I suspect the issue is with the Swagger3 configuration.
I used the following link to configure OpenAPI, springdoc.org/#migrating-from-springfox

Open API code generator Maven plugin uses old Swagger 2 annotations instead of Swagger 3 annotations

I'm using Open API code generator Maven plugin to generate Open API 3.0 from a file. I'm using this plugin in in my pom.xml:
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.3.0</version>
The plugin generates the API without any issues but instead of using Swagger v3 annotations it uses old Swagger annotations. For example parameters are annotated using #ApiParam, instead #Parameter annotation should be used from io.swagger.v3.oas.annotations package:
default ResponseEntity<Fault> getFault(#ApiParam(value = "",required=true) #PathVariable("jobId") String jobId) {
Because of it the latest Swagger UI isn't showing the documentation correctly. When I create an endpoint using swagger.v3 annotations then Swagger UI is working properly.
According to the official website https://openapi-generator.tech/docs/plugins/ , I should include this dependency:
<dependency>
<groupId>io.swagger.parser.v3</groupId>
<artifactId>swagger-parser</artifactId>
</dependency>
But even with this dependency the plugin still generates sources with the old annotations.
How can I force Open API code generator to use Swagger v3 annotations?
V3 annotations are not supported at this moment.
You need to override mustache templates.
Check these PRs:
https://github.com/OpenAPITools/openapi-generator/pull/4779
https://github.com/OpenAPITools/openapi-generator/pull/6306
more info:
https://github.com/OpenAPITools/openapi-generator/issues/6108
https://github.com/OpenAPITools/openapi-generator/issues/5803
You can use upgraded templates from PRs above or wait when merged.
Now that version 5.3.1 of the plugin is released, I used the information from https://github.com/OpenAPITools/openapi-generator/pull/9775 and https://github.com/OpenAPITools/openapi-generator/issues/6108 to make it work for me.
I added the three configOptions in the pom.xml:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.3.1</version>
<configuration>
<!-- other config omitted -->
<configOptions>
<oas3>true</oas3>
<useSpringController>true</useSpringController>
<useSpringfox>false</useSpringfox>
</configOptions>
</configuration>
</plugin>
After that, it may be necessary to add another dependency as a workaround, because the plugin adds unused imports into the generated code.
<dependency>
<!-- try to remove this dependency when a new version (5.3.1+) of the openapi-generator plugin is available -->
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.3</version>
</dependency>
I am using the springdoc-openapi-ui dependency.
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.3</version>
</dependency>

Cannot find SerialAddress class in Apache Mina 2.0.2

I added the below dependencies in my project POM file and the SerialAddress class is no where to be found from the downloaded mina-core.2.0.2.jar.
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
<version>2.0.2</version>
</dependency>
the package org.apache.mina.transport.serial doesnt even exist. Please advice me on the correct Dependency.
It looks like this class is not part of mina-core. Some exploration lead to the existence of Apache Mina Serial Communication Support.
So I guess you would want to add the dependency for mina-transport-serial.
<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-transport-serial</artifactId>
<version>2.0.2</version>
</dependency>

Resources