Swagger ui is shows empty object in model - spring-boot

I am using springboot and added swagger 3.0.0 dependency
When I run swagger ui model class is showing empty on ui and documentation pages.
I am using annotation to define swagger

If you are referring to Example Value Schema, please check your required object if you have getters and setters implemented.

Related

How does the #ApiOperation annotation workd in spring?

I want to know hoew does the annotation from spring #ApiOperation(value = "", hidden = true) works to hide information on my swagger page.
What class is responsible to load the annotation
What does it do with that same values of the annotation.
Where can I find how the annotation works?
The springfox.documentation.spring.web.readers.operation.ApiOperationReader.read(RequestMappingContext) method orchestrates the scanning of methods annotated with #ApiOperation and takes into consideration the hidden flag when doing so, you can see it in the sourcecode over at GitHub.
The specific method that scans the annotated methods and populates the context with the information regarding whether such method should be hidden or not can be found here.
You can keep browsing the source code for more information regarding the implementation, and you can also get more information regarding the #ApiOperation annotation over at https://github.com/swagger-api/swagger-core/wiki/annotations#apioperation.

Remove ModelAndView from Swagger 3.0 UI

I have a Spring Boot application that uses springdoc-openapi-ui to document REST endpoint. Also, there is some simple UI with Spring MVC. For some reason, in Swagger UI I see not only schemas for REST but also the schema for ModelAndView class. Is there a way to remove it from there?
I've tried already some options like limiting packages to scan with springdoc.packagesToScan or springdoc.model-and-view-allowed but without any results?
You can hide a Controller or Schema classes with #Hidden annotation, like this:
import io.swagger.v3.oas.annotations.Hidden;
#RestController
#Hidden
public class ItemController
#Hidden annotation is part of springdoc-openapi-ui library.

How to validate the fields in spring rest controller for the model created by swagger code generator?

We are using swagger code generator tool to create model and that model is using as spring boot rest api input payload and how to validate that generated model class similar to #valid annotation
If auto generated swagger class doesn't have any validation logic/annotations, need to copy properties/values to entity class object that having validation annotations and create validation factory and call the validate() from validator interface.

Swagger codegen option to don't generate hashCode() and equals()

The following refers to the generation of the Spring boot server stubs with swagger codegen (-l spring).
Is there any option for Swagger codegen binary (current: v2.3.1) to generate the dto models without the hashCode() and equals() methods?
I did not found any options in the config-help. I want the generated dto models to extend an abstract class where the hashCode() and equals() methods are already declared and therefore shouldn't be overwritten in the generated model classes.
One way is to customize the mustache templates (by removing those lines related to hashCode(), equals()) and use the -t option when generating the spring boot server stubs.

spring mvc annotation #RequestAttribute similar to #RequestParam

I would like add an annotation similar to #RequestParam, though have it pull the values from the request attribute rather than the request param...
Is there an example or explanation how to create my own annotation for this and the handler / binder needed as well?
Thanks
The blog entry with the title "Extending Spring MVC's annotation controller" answers your question. Google it to find it since Stackoverflow won't let me create the direct link.
Basically you create an #RequestAttribute annotation and then a custom WebArgumentResolver.
The blog entry has examples for #RequestAttribute and #SessionAttribute.
The svn directory with the examples is here.
http://impala-extensions.googlecode.com/svn/trunk/impala-extension-mvc/src/org/impalaframework/extension/mvc/
Since Spring 4.3 #RequestAttribute annotation is a part of Spring MVC, so there is no need to create your own #RequestAttribute annotation

Resources