Skip to content

fix: propagate JsonView context when resolving Page<T> schema#3226

Merged
bnasslahsen merged 1 commit intospringdoc:mainfrom
Akila-1329:fix/jsonview-page-schema
Feb 25, 2026
Merged

fix: propagate JsonView context when resolving Page<T> schema#3226
bnasslahsen merged 1 commit intospringdoc:mainfrom
Akila-1329:fix/jsonview-page-schema

Conversation

@Akila-1329
Copy link
Contributor

Problem

When a controller method is annotated with @JSONVIEW and returns Page,
the generated OpenAPI schema ignores the JsonView and exposes all fields
of T instead of only the fields marked with that view.

Root Cause

In PageOpenAPIConverter.resolvePagedModelType(), a new AnnotatedType is
created for PagedModel but only copies the type information, dropping
the ctxAnnotations which carry the @JSONVIEW context.

Fix

Pass the original AnnotatedType to resolvePagedModelType() and copy its
ctxAnnotations onto the new AnnotatedType, preserving the JsonView context.

Test

Added test app245 which verifies that @JSONVIEW(Hello.class) on a method
returning Page correctly generates HelloWorld_Hello schema
with only the hello field.

@bnasslahsen
Copy link
Collaborator

Thanks @Akila-1329 for your contribution to the project!

@bnasslahsen bnasslahsen merged commit da1d8b1 into springdoc:main Feb 25, 2026
bnasslahsen added a commit that referenced this pull request Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants