Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3637

How to hide certain schemas from 'Schemas' section in Swagger UI (OpenAPI 3, Spring Boot)

$
0
0

I'm using Springdoc to document my REST API made in Spring Boot.I need to hide some models/schemas from Schemas section in Swagger UI which are used only internally in API, so there is no need to display them in Schemas section.

This is one of the models I'm trying to hide:

@Getter@Setter@EqualsAndHashCode(callSuper = true)@AllArgsConstructor@NoArgsConstructor@Entity@Tablepublic class EventRole extends AbstractEntity implements Serializable {    @Column(nullable = false, length = 25)    private String descriptor;}

Superclass of model shown above:

@Data@RequiredArgsConstructor@SuperBuilder@MappedSuperclasspublic abstract class AbstractEntity {    @Id    @GeneratedValue(strategy = GenerationType.IDENTITY)    private Long id;    @CreationTimestamp    @Column(nullable = false, updatable = false)    private LocalDateTime creationDate;    @UpdateTimestamp    @Column(nullable = false)    private LocalDateTime modificationDate;}

Most of annotations in these examples are from JPA or Lombok.To be clear: AbstractEntity is not visible in Schemas section – I included it here just in case.

I've tried so far:

  • using @Hidden annotation on classes I want to hide
  • using @Schema(hidden = true) on these classes
  • adding SpringDocUtils.getConfig().addAnnotationsToIgnore(EventRole.class, AbstractEntity.class); to my OpenAPI bean configuration

Also I've tested @Hidden on controller methods and it works fine. @Schema(hidden = true) hides properly model properties. Unfortunately, none of them hide whole model. Am I using wrong annotations or there might be other reason why this doesn't work? I'm new to OpenAPI 3.x and Springdoc and it is very likely that I misunderstood something.


Viewing all articles
Browse latest Browse all 3637

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>