0

Good day to you all!

I have a DTO class that has the information of an entity. I am using spring-docs-openapi-ui 1.4.8 to document the project. I am using JsonViews in order to show specific attributes of my class given the type of operation, if the operation is a GET, I will use a Json ClassDetail view. If the operation is PUT, I will use a ClassUpdate view. The attributes marked in the BaseClass with either ClassDetailDTO view or ClassUpdateDTO view will be displayed in the response regarding the Operation. However, when I build and check the generated documentation, For these 2 operations, some attributes are marked with the type of view of the Operation. Is there a way to disable this?

Here's what it looks like.

EntityDTO_ClassUpdated | Field | Data Type| | -------- | -------------- | | id | string| | identifier | IdentifierDTO_ClassUpdated[] |

EntityDTO_Write | Field | Is Required| Data Type | | -------- | -------------- | ----- | | identifier | No | IdentifierDTO_Write[]

Just to clarify, is there a way to get rid of the suffix? _Write, _ClassUpdated, _ClassDetail?

Thanks in advance.

f.khantsis
  • 3,256
  • 5
  • 50
  • 67

1 Answers1

0

I think it's to late for you, but the answer could help people in the future, so I share it : you can add ignoreJsonView = true in the annotation @Operation. For example :

@Operation(summary = "Retrieve a todo by id", ignoreJsonView = true)

How I found it ? I downloaded the source code from the public repository and searched for @JsonView. In the code you can find a way to ignore the view :

if (apiOperation != null && apiOperation.ignoreJsonView()) {
    jsonViewAnnotation = null;
    jsonViewAnnotationForRequestBody = null;
}
fego
  • 309
  • 5
  • 20