springfox-swagger : model with SnakeCaseStrategy support - spring-boot

I'm currently using Springfox Swagger to document my spring boot application with a Java config.
When I add
#JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
on my model class, and execute the application from swagger ui, its giving me null pointer exception.
But code runs if you try to run from postman or some java client.
I want all my model attributes in snake case. Looks like swagger is not able to serialize/deserialize the object. Please let me know if there is any workaround

Related

Why springdoc swagger-ui returns page with empty array []?

When I run locally my Spring Boot application with added dependencies springdoc-openapi-ui, I expect to get generated swagger api form for rest methods at url
http://localhost:55555/swagger-ui/index.html, but instead I get response with empty array []. But if I open http://localhost:55555/v3/api-docs, it shows openapi specification for rest methods.
There is no warnings in application log. How can I troubleshoot this library?
P.S. Swagger api form was working shortly before this moment. When problem had been occured, I removed any related configuration properties and beans, but the problem remained

Custom swagger documentation/ Where is my swagger setup?

I have a jhipster based Spring project, which uses yarn/angular on the front end, and Spring on the back. I am with trying to figure out how to customize the swagger page. Currently it auto-populates new API's using swagger-ui, which is great, but I needed to add more custom info to those API's, hence my problem.
But I'm confused on what's running swagger. It looks like there's a node package called swagger-ui-dist and I also see a src/main/webapp folder with a swagger-ui folder, containing an index.html page.
I think what I pretty much want is to replace the current swagger-ui auto setup, with swagger that reads a file that I can create online using Swagger editor.
Apologies, for what I hope are simple questions. I'm brand new at swagger and npm/yarn.
Thanks
So after a bit more research, I found you could create your own OpenAPI doc, but an easier method in Spring is to annotate the endpoint methods with the #APIOperation annotation. There are other swagger specific annotations as well.
In the parameters, you can give value="", notes="" and a number of other customized values that will clarify what your API does in Swagger. Then swagger auto fills it in when bringing up your swagger page.
I hope that helps anyone with the same issue I had.

Spring boot pre api action annotation

I'm new using Spring boot , but i come from a Play! framework background.
In Play there was something called action "Action Composition"
https://www.playframework.com/documentation/2.6.x/JavaActionsComposition
It is used to do some code logic before going through the api method , so it could be used for creating a custom security for example or whatever logic we want to add before accessing an api method.
Then we simply annotate whatever api with this Action.
Is there something similar to do in Spring boot ?
I have googled for actions/ validators , but i did not find results similar to Play framework's action composition behavior.
What you are looking for is called an interceptor. Its purpose is to allow some action to be taken before an actual API endpoint is reached.
This documentation should help.

Swagger shows wrong id field using Spring Data Rest

I'm using Spring Boot + Spring DATA REST and Swagger (Springfox 2.7.0). Spring DATA REST follows HATEOAS principles, so id field should never be present in return resources.
In GET methods this works fine but in POST methods the form show an id parameter I don't understand where it comes from.
This is the screenshot of the Swagger ui. Like you see, the form contains an id parameter of type path that is not present in the model definition.
I'm sure it is not needed, in fact doing a request via Postman, it works without set id param.
Also in swagger everything works fine, filling id param with a random value.
Is it an incompatibility between Spring DATA REST and Swagger or I should set something more?
I followed instructions here:http://springfox.github.io/springfox/docs/current/#support-for-spring-data-rest
=================== UPDATE ==============================
This issue is resolved in SpringFox version > 2.7.0.
Here the link to the bug: https://github.com/springfox/springfox/issues/1839

Register Jackson with wink using spring integration

I have developed a small RESTful web service using apache wink. I am using the spring integration module and define my rest services there. I am trying to add JSON support and have run into a small bug. When I try to return a java list with only 1 element in it, wink returns just the object instead of an array with 1 object in it. It seems this is a bug with the default JSON providers that come with wink.
So I have attempted to use Jackson as the wink JSON provider. I have found documentation of how to define a WinkApplication and set Jackson as the provider. This never gets used in my app and I believe it's because the winkCoreContext-server.xml file defines a Registrar instead of using the Application I defined.
Can anyone point me to some documentation or an example of how to use Jackson together with the spring integration module of Apache Wink?
I finally found a post that answered my question:
http://agoodexample.tumblr.com/
I needed to extend the wink-spring-integration Registrar class and add a setter for singletons then load my jackson provider through a reference.

Resources