I updated my project's Springboot version from 1.5.10 to 2.2.2. As per the documentation, I did all the necessary changes to resolve HATEOS related compilation errors. But now the HTTP response is not coming as expected. Now, I'm getting "links" instead of "_links". Also, I'm not getting "_embedded" attribute in response anymore.
I did below changes:
Replaced ResourceSupport with RepresentationModel<T>
Replaced Resource with EntityModel
Replaced Resources with CollectionModel
Please help me out in resolving this issue.
It seems like hateoas and swagger do not work together after springboot 2.x.x. I ended up replacing swagger with springdoc-openapi-ui for documentation.
Related
I have a Spring-Boot Application, generating swagger JSON at /contextPath/v2/api-docs.
Due to security concerns I have installed Swagger-UI from webJars version: 4.1.3.
Swagger-UI no longer allows ?url as a query parameter.
I have tried placing swagger-config.yaml and swagger-config.json in /resources/static/ and /resources/META-INF/resources/
I have also tried adding a new rest controller for a GET endpoint of
webpack://SwaggerUIBundle/swagger-config.yaml
So far nothing has worked.
When I manually paste the endpoint into "Explore" the Docs load.
So I know the problem isn't with my generated swagger JSON.
So How do I get Swagger-UI to load my Swagger JSON when the page loads?
After migration of Spring Boot to version 3.1 and springdoc-openapi libraries to 1.4.1:
springdoc-openapi-ui
springdoc-openapi-security
springdoc-openapi-data-rest
I faced issue ClassNotFoundException: org.springframework.data.rest.webmvc.support.DefaultedPageable
Also now on Swagger UI page controllers and schemas for #Entity are generated, however earlier there were only endpoints from #RestController, request and response DTOs. Are there any way to disable it?
From your description, you don't need to load springdoc-openapi-data-rest. (You will load unecessary beans related to spring-data-rest)
If you just need to enable the support of Pageable, you can just add the following line:
SpringDocUtils.getConfig().replaceWithClass(org.springframework.data.domain.Pageable.class, Pageable.class);
This is explained here: https://springdoc.org/
Section [Spring Data Rest support]
Or, if you want to depend on spring-boot-starter-data-rest, then add the dependency.
I have a springboot application with springfox swagger 2.9.2, for one of my microservice the swagger base url generated in the swagger docs is appending "/v2/api-docs" at the end, for seemingly no apparent reason.
Here is what my application properties file looks like
spring.profiles.active=dev
server.contextPath=/xxxxxxxxxxxx-enterprise/v2/sas
server.port=8070
I have a feeling I am missing something silly.
Because this is the swagger service descriptions default path
From Springfox documentation: https://springfox.github.io/springfox/docs/snapshot/#customizing-the-swagger-endpoints
This can be customized by overriding "springfox.documentation.swagger.v2.path" property
From looking at the thymeleaf documentation, I've tried to access web context objects with thymeleaf in my Spring boot project in this manner:
<p th:text="${#request.getRequestURL()}">lol</p>
which results in the following exception:
org.springframework.expression.spel.SpelEvaluationException: EL1011E: Method call:
Attempted to call method getRequestURL() on null context object
From this error it seems that I might be missing a dependency? I've seen a similar question, where the solution was to add an extras thymeleaf package as a dependency.
However, it is stated in the thymeleaf documentation that these objects and variable maps are always available to be invoked so I guess that shouldn't be the case here.
I'm using the release 1.5.1 of spring-boot-starter-thymeleaf as well as a number of other spring-boot-starter packages like web and security.
I got it to work with thymeleaf-spring4:3.0.0.RELEASE and thymeleaf-layout-dialect 2.0.0, so seems like these are the minimum versions required.
The spring-boot-starter-thymeleaf:1.5.1.RELEASE only provides thymeleaf-spring4:2.1.5.RELEASE and thymeleaf-layout-dialect 1.4.0.
I am currently working on a project involving spring-boot and swagger. I have upgraded my maven spring boot project to the latest Swagger using the link Upgrade to version2.
I am currently using the Swagger-UI which I have configured from the link Swagger-UI with Spring Boot
I try to access the url : localhost:8080/swagger/index.html after deploying the app successfully on my tomcat server. Unfortunately, it does not work and I am unable to view the swagger-ui in my browser. How do I go on about it further?
I think you're mixing the documentation of 2 versions of the library. The second link points to an older version of the springfox library. Please follow the instructions in the latest snapshot of the documentation. If you've configured everything correctly you should see the swagger-ui at http://localhost:8080[/CONTEXT-PATH]/swagger-ui.html. Depending on how you've set your springboot app the context path is optional.