Class PagedModelScanUtils
- java.lang.Object
-
- org.openapitools.codegen.languages.PagedModelScanUtils
-
public final class PagedModelScanUtils extends Object
Language-agnostic utility for detecting OpenAPI schemas that represent paginated responses (SpringPagedModel-like DTOs) and should be substituted withorg.springframework.data.web.PagedModel<T>during code generation.Two structural patterns are recognised:
- Flat-object form — a plain
type: objectwith acontentarray property and a separate property whose$refpoints to a pagination-metadata schema (e.g.PageMetadata). - allOf form — a schema composed via
allOfwhere one entry is a$refto the pagination-metadata schema and another is an inline object with acontentarray property.
Detection heuristics deliberately avoid name-based matching and only trigger when structural conditions are all met, to minimise false positives.
Used by both
SpringCodegenandKotlinSpringServerCodegen. - Flat-object form — a plain
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPagedModelScanUtils.DetectedPagedModelCarries the result of a single detected paged-model schema.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisPaginationSchema(io.swagger.v3.oas.models.media.Schema<?> schema)Returnstrueif the given schema looks like a pagination-metadata schema.static Map<String,PagedModelScanUtils.DetectedPagedModel>scanPagedModels(io.swagger.v3.oas.models.OpenAPI openAPI)Scans all named schemas inopenAPI.components.schemasand returns those that match the paged-model pattern.
-
-
-
Method Detail
-
scanPagedModels
public static Map<String,PagedModelScanUtils.DetectedPagedModel> scanPagedModels(io.swagger.v3.oas.models.OpenAPI openAPI)
Scans all named schemas inopenAPI.components.schemasand returns those that match the paged-model pattern.- Parameters:
openAPI- the parsed OpenAPI document- Returns:
- map from schema name to
PagedModelScanUtils.DetectedPagedModel; empty if none found or ifcomponents/schemasis absent
-
isPaginationSchema
public static boolean isPaginationSchema(io.swagger.v3.oas.models.media.Schema<?> schema)
Returnstrueif the given schema looks like a pagination-metadata schema.The heuristic checks that at least 2 of the well-known field names (
size,number,page,totalElements,totalPages) are present as direct properties.
-
-