0

i have a response model entity ResponseEntity:

RespDTO:

@Getter
@Setter
public class RespDTO implements Serializable{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    
    @Schema(nullable = true)
    private Long id;
    @Schema(nullable = true)
    private String otherId;
     @NotNull
    private String cod;
     @NotNull
    private String description;
     
    @Schema(nullable = true)
    private OtherDTO object;

     @NotNull
    private String idTransaction;
    
}

My problem, in OpenApi doc, is the representation of OtherDTO because:

RespDTO:
      required:
        - cod
        - description
        - idTransaction
      type: object
      properties:
        id:
          type: integer
          format: int64
          nullable: true
        otherId:
          type: string
          nullable: true
        cod:
          type: string
        description:
          type: string
       object:
          $ref: '#/components/schemas/OtherDTO'
        idTransaction:
          type: string 

I want to show, in openApi doc, the "nullable" to

object: $ref: '#/components/schemas/OtherDTO'

My wrong test:

  1. Annotation @Schema with nullable true
  2. Annotation @Nullable
  3. i have manipulated the io.swagger.v3.oas.models.OpenAPI with automatic required false when the property name is object

Every test is wrong.

Please help me :)

Thank to all

Alex
  • 111
  • 1
  • 13

1 Answers1

0

Problem

This question was asked previously, but no accepted answer and no follow-up, so I'll answer here.

This appears to be a known bug with springdoc. You can see the issue on their github. What's interesting is that the springdoc developers directed the person who originaly posted the bug to raise the issue up with swagger-core (which he did), and then closed the ticket. However, the swagger-core devs claimed the issue isn't related to their code, stating:

Looking at the linked issue, it looks like you're using springdoc, and they sent you here because they claim to be using our processor (which they might). However, officially, we don't support Spring MVC/Boot as they use a different annotatiions to describe operations.

We're very grateful for the sample project, however, in order to isolate that the issue really is in swagger-core and not springdoc, we'd need a sample that's based on JAX-RS and not spring boot to reproduce it.

The OP never responded with the requested example, and the ticket has laid dormant for three years.

Solution

I'd recommend revisiting the issue on the swagger page or opening a new issue. Hopefully it will get resolved eventually.

tbatch
  • 1,398
  • 10
  • 21