docs: add OpenAPI annotations to 18 MCP-priority REST resources#34778
docs: add OpenAPI annotations to 18 MCP-priority REST resources#34778
Conversation
Add @operation, @ApiResponses, @parameter, and @RequestBody annotations to ~100 previously undocumented endpoints across 14 REST resource files, raising MCP-priority documentation coverage from 41% to near 100%. Key fixes: - ES search GET endpoints marked @hidden, POST documented as primary - cachettl/sortOrder/SYSTEM_FOLDER restrictions documented in page endpoints - FormDataMultiPart schemas replaced with descriptive object schemas - Contentlet field structure documented in workflow fire endpoints - siteId/hostId/host aliasing noted in site endpoint descriptions - theme/themeId aliasing noted in template/theme descriptions - v1 TagResource methods marked deprecated, referencing v2 API - Explicit operationIds added to all new annotations - Class-level @tag added/improved on all resources Metrics: summaries 244->341, auto-gen operationIds 130->113, 4 critical bugs fixed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
❌ Issue Linking RequiredThis PR could not be linked to an issue. All PRs must be linked to an issue for tracking purposes. How to fix this:Option 1: Add keyword to PR body (Recommended - auto-removes this comment)
Why is this required?Issue linking ensures proper tracking, documentation, and helps maintain project history. It connects your code changes to the problem they solve.--- This comment was automatically generated by the issue linking workflow |
dotCMS/src/main/java/com/dotcms/rest/api/v1/categories/CategoriesResource.java
Outdated
Show resolved
Hide resolved
dotCMS/src/main/java/com/dotcms/rest/api/v1/categories/CategoriesResource.java
Outdated
Show resolved
Hide resolved
dotCMS/src/main/java/com/dotcms/rest/api/v1/categories/CategoriesResource.java
Outdated
Show resolved
Hide resolved
dotCMS/src/main/java/com/dotcms/rest/api/v1/categories/CategoriesResource.java
Outdated
Show resolved
Hide resolved
dotCMS/src/main/java/com/dotcms/rest/api/v1/container/ContainerResource.java
Outdated
Show resolved
Hide resolved
dotCMS/src/main/java/com/dotcms/rest/api/v1/container/ContainerResource.java
Outdated
Show resolved
Hide resolved
dotCMS/src/main/java/com/dotcms/rest/api/v1/container/ContainerResource.java
Outdated
Show resolved
Hide resolved
dotCMS/src/main/java/com/dotcms/rest/api/v1/folder/FolderResource.java
Outdated
Show resolved
Hide resolved
Replace generic ResponseEntityView.class and Object.class with specific typed view classes for better API documentation: - CategoriesResource: ResponseEntityCategoryView, ResponseEntityCategoryWithChildCountView, ResponseEntityBulkResultView; Tag name fixed to "Categories" - ContainerResource: ResponseEntityContainerObjectMapView, ResponseEntityContainerView, ResponseEntityContainerWithContentTypesView, ResponseEntityBulkResultView, ResponseEntityStringView (all 16 Object.class refs replaced) - FolderResource: ResponseEntityFolderView, ResponseEntityFolderWithSubfoldersView, ResponseEntityFolderSearchResultView, ResponseEntityListView Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Restored original business logic that was accidentally modified. Re-applied only OpenAPI annotations (@operation, @ApiResponses, @parameter) with specific view classes (ResponseEntityCategoryView, ResponseEntityCategoryWithChildCountView, ResponseEntityBulkResultView). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Semgrep found 1
Detected user input controlling a file path. An attacker could control the location of this file, to include going backwards in the directory with '../'. To address this, ensure that user-controlled variables in file paths are sanitized. You may also consider using a utility method such as org.apache.commons.io.FilenameUtils.getName(...) to only retrieve the file name from the path. View Dataflow Graphflowchart LR
classDef invis fill:white, stroke: none
classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none
subgraph File0["<b>dotCMS/src/main/java/com/dotcms/rest/ContentResource.java</b>"]
direction LR
%% Source
subgraph Source
direction LR
v0["<a href=https://github.com/dotCMS/core/blob/b1e8a1a7375a407ae4b8ff3647881ddac3100ed1/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1794 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1794] multipart</a>"]
end
%% Intermediate
subgraph Traces0[Traces]
direction TB
v2["<a href=https://github.com/dotCMS/core/blob/b1e8a1a7375a407ae4b8ff3647881ddac3100ed1/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1794 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1794] multipart</a>"]
v3["<a href=https://github.com/dotCMS/core/blob/b1e8a1a7375a407ae4b8ff3647881ddac3100ed1/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1799 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1799] multipartPUTandPOST</a>"]
v4["<a href=https://github.com/dotCMS/core/blob/b1e8a1a7375a407ae4b8ff3647881ddac3100ed1/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1856 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1856] multipart</a>"]
v5["<a href=https://github.com/dotCMS/core/blob/b1e8a1a7375a407ae4b8ff3647881ddac3100ed1/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1871 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1871] part</a>"]
v6["<a href=https://github.com/dotCMS/core/blob/b1e8a1a7375a407ae4b8ff3647881ddac3100ed1/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1871 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1871] part</a>"]
v7["<a href=https://github.com/dotCMS/core/blob/b1e8a1a7375a407ae4b8ff3647881ddac3100ed1/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1951 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1951] processFile</a>"]
v8["<a href=https://github.com/dotCMS/core/blob/b1e8a1a7375a407ae4b8ff3647881ddac3100ed1/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1983 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1983] part</a>"]
v9["<a href=https://github.com/dotCMS/core/blob/b1e8a1a7375a407ae4b8ff3647881ddac3100ed1/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1986 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1986] badFileName</a>"]
v10["<a href=https://github.com/dotCMS/core/blob/b1e8a1a7375a407ae4b8ff3647881ddac3100ed1/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1987 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1987] filename</a>"]
end
v2 --> v3
v3 --> v4
v4 --> v5
v5 --> v6
v6 --> v7
v7 --> v8
v8 --> v9
v9 --> v10
%% Sink
subgraph Sink
direction LR
v1["<a href=https://github.com/dotCMS/core/blob/b1e8a1a7375a407ae4b8ff3647881ddac3100ed1/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L2001 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 2001] new File(<br> tmpFolder.getAbsolutePath() + File.separator + filename)</a>"]
end
end
%% Class Assignment
Source:::invis
Sink:::invis
Traces0:::invis
File0:::invis
%% Connections
Source --> Traces0
Traces0 --> Sink
If this is a critical or high severity finding, please also link this issue in the #security channel in Slack. |
Restored FolderResource.java from main and re-applied only OpenAPI annotations without modifying any business logic. Added @operation, @ApiResponses, and @Schema to all 7 endpoints. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Semgrep found 1 The application builds a file path from potentially untrusted data, which can lead to a path traversal vulnerability. An attacker can manipulate the path which the application uses to access files. If the application does not validate user input and sanitize file paths, sensitive files such as configuration or user data can be accessed, potentially creating or overwriting files. To prevent this vulnerability, validate and sanitize any input that is used to create references to file paths. Also, enforce strict file access controls. For example, choose privileges allowing public-facing applications to access only the required files. In Java, you may also consider using a utility method such as View Dataflow Graphflowchart LR
classDef invis fill:white, stroke: none
classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none
subgraph File0["<b>dotCMS/src/main/java/com/dotcms/rest/ContentResource.java</b>"]
direction LR
%% Source
subgraph Source
direction LR
v0["<a href=https://github.com/dotCMS/core/blob/66e70a909e64d1f2f33451a633872dc8288a697c/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1794 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1794] multipart</a>"]
end
%% Intermediate
subgraph Traces0[Traces]
direction TB
v2["<a href=https://github.com/dotCMS/core/blob/66e70a909e64d1f2f33451a633872dc8288a697c/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1794 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1794] multipart</a>"]
v3["<a href=https://github.com/dotCMS/core/blob/66e70a909e64d1f2f33451a633872dc8288a697c/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1799 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1799] multipartPUTandPOST</a>"]
v4["<a href=https://github.com/dotCMS/core/blob/66e70a909e64d1f2f33451a633872dc8288a697c/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1856 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1856] multipart</a>"]
v5["<a href=https://github.com/dotCMS/core/blob/66e70a909e64d1f2f33451a633872dc8288a697c/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1871 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1871] part</a>"]
v6["<a href=https://github.com/dotCMS/core/blob/66e70a909e64d1f2f33451a633872dc8288a697c/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1871 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1871] part</a>"]
v7["<a href=https://github.com/dotCMS/core/blob/66e70a909e64d1f2f33451a633872dc8288a697c/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1951 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1951] processFile</a>"]
v8["<a href=https://github.com/dotCMS/core/blob/66e70a909e64d1f2f33451a633872dc8288a697c/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1983 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1983] part</a>"]
v9["<a href=https://github.com/dotCMS/core/blob/66e70a909e64d1f2f33451a633872dc8288a697c/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1986 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1986] badFileName</a>"]
v10["<a href=https://github.com/dotCMS/core/blob/66e70a909e64d1f2f33451a633872dc8288a697c/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L1987 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 1987] filename</a>"]
end
v2 --> v3
v3 --> v4
v4 --> v5
v5 --> v6
v6 --> v7
v7 --> v8
v8 --> v9
v9 --> v10
%% Sink
subgraph Sink
direction LR
v1["<a href=https://github.com/dotCMS/core/blob/66e70a909e64d1f2f33451a633872dc8288a697c/dotCMS/src/main/java/com/dotcms/rest/ContentResource.java#L2002 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 2002] tmpFolder.getAbsolutePath() + File.separator + filename</a>"]
end
end
%% Class Assignment
Source:::invis
Sink:::invis
Traces0:::invis
File0:::invis
%% Connections
Source --> Traces0
Traces0 --> Sink
If this is a critical or high severity finding, please also link this issue in the #security channel in Slack. |
…iew classes Replaced all generic @Schema(implementation = ResponseEntityView.class) and @Schema(implementation = Object.class) with specific typed view classes across 9 MCP-priority REST resources: - PageResource: 10 schemas fixed (EmptyPageView, PageView, ContentletMapsView, TemplateView, PageLivePreviewVersionView, MulitreeView, etc.) - SiteResource: 6 schemas fixed (SiteView, ListMapView, SiteSwitchView, etc.) - WorkflowResource: 9 schemas fixed (MapStringObjectView for all fireAction methods) - TemplateResource: 2 schemas fixed (ListTemplateView, type="object" for image) - ContentResource: 1 schema fixed (SearchView) - LanguagesResource: 2 schemas fixed (type="object" for list, MapStringStringView) - ThemeResource: 2 schemas fixed (PaginatedArrayListMapView, MapStringObjectView) - TempFileResource: 2 schemas fixed (type="object" with descriptions) - TagResource: 1 schema fixed (type="object" for unwrapped map) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@claude code review this. |
|
Claude finished @fmontes's task —— View job Code Review: OpenAPI Annotations PRReview Progress:
🎯 Overall Assessment: Strong Implementation with Critical Security IssueThis PR significantly improves dotCMS's OpenAPI documentation coverage and follows most established patterns correctly. However, there's one critical security vulnerability that must be addressed before merge. 🚨 Critical Issue: Path Traversal VulnerabilityPRIORITY: MUST FIX BEFORE MERGE Location: final File tempFile = new File(
tmpFolder.getAbsolutePath() + File.separator + filename);Problem: While the code sanitizes the filename on line 1987 using Fix: Use final File tempFile = tmpFolder.toPath()
.resolve(Paths.get(filename).getFileName()) // Only use filename component
.toFile();This ensures only the filename portion is used, preventing any potential directory traversal. ✅ Strong Points1. Excellent Schema Pattern ComplianceThe PR correctly follows dotCMS's schema implementation rules:
2. Comprehensive Annotation Coverage
3. Consistent Patterns
🔧 Recommended Improvements1. Use More Specific View Classes (per @jdcmsd's feedback)Several instances could use more specific view classes that already exist: CategoriesResource.java:
ContainerResource.java:
FolderResource.java:
2. Minor Documentation EnhancementsParameter Descriptions: Some could be more specific: // Current
@Parameter(description = "Language ID for the page content")
// Better
@Parameter(description = "Language ID for the page content (e.g., 1 for English, 2 for Spanish)")3. Consistent Response DescriptionsSome methods use generic descriptions like "Success" - consider more specific descriptions like:
📋 Schema Pattern ValidationThe PR correctly implements dotCMS schema patterns: ✅ Pattern 1 - Wrapped Responses: Uses specific 🔗 Missing Issue LinkThe PR needs to be linked to a GitHub issue as flagged by the automation. Add one of these to the description:
📊 Impact Assessment
🎯 Action ItemsBefore Merge:
Post-Merge:
Verdict: Excellent OpenAPI implementation work that significantly improves documentation coverage, but requires security fix before merge. |
There was a problem hiding this comment.
It can probably merge as is, though the @consumes and @RequestBody stuff will need attention in a future adjustment. (See attached conversation)
dotCMS/src/main/java/com/dotcms/rest/api/v1/categories/CategoriesResource.java
Show resolved
Hide resolved
Restored ContainerResource, SiteResource, TemplateResource, WorkflowResource, ESContentResourcePortlet, ContentResource, and TagResource from main to remove accidental logic changes. Re-applied only OpenAPI annotations with specific view classes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@freddy I did already have updates to fix and also enforce through test that all the endpoints were correct and had everything we need. I went through and broke this up to 9 PRs but was not prioritised as I transitioned into platform after getting Batch 1 in the system. There is probably some duplication of work here and the changes may make it even more difficult to sync up merge conflicts. We should see if there is anything we can salvage from the work I have already done, and I think the work I have to have ongoing tests to prevent new changes to the rest endpoints from missing the correct annotations is still useful. We got held up on Batch 2 because it raised some questions on how we were handling file streaming consistently. I just did not have any cycles to go back in and support Jamie on this Do we throw away these PRs. Do we try to add the validation logic from this PR more focused on the important APIs but work with the changes here. |
Summary
@Operation,@ApiResponses,@Parameter, and@RequestBodyannotations to ~100 previously undocumented endpoints across 14 REST resource filesResponseEntityView.classandObject.classschemas with specific typed view classes across all MCP-priority resourcesKey Fixes
@RequestBodywith proper schema on POST; GET variants marked@Hidden@Schema(type="object")in workflow/temp endpointsResponseEntityView.classschemasResponseEntityPageView,ResponseEntitySiteView,ResponseEntityMapStringObjectView)Object.classschemastype="object"with meaningful descriptions for unwrapped returnsSchema Improvements (35 generic schemas replaced)
EmptyPageView,PageView,ContentView,ContentletMapsView,TemplateView,PageLivePreviewVersionView,MulitreeView,ListPersonalizationPersonaPageView,PaginatedDataView,LanguagesForPageViewSiteView,ListMapView,SiteSwitchView,SiteSetupProgressViewMapStringObjectView(all fireAction methods)ListTemplateView,type="object"with descriptionSearchViewtype="object"for unwrapped map,MapStringStringViewPaginatedArrayListMapView,MapStringObjectViewtype="object"with meaningful descriptionstype="object"for unwrapped mapMetrics
ResponseEntityView.classin MCP resourcesObject.classin MCP resourcesFiles Changed (16)
14 Java REST resources + 1 new view class + regenerated openapi.yaml
ESContentResourcePortlet.java— 4 methodsContentResource.java— 11 methods + 1 schema fixNavResource.java— 1 methodPageResource.java— 14 methods + 10 schema fixesSiteResource.java— 18 methods + 6 schema fixesTemplateResource.java— 14 methods + 2 schema fixesWorkflowResource.java— schema fixes on ~8 methods + 9 schema fixesCategoriesResource.java— 9 methodsFolderResource.java— 7 methodsContainerResource.java— 21 methodsTagResource.java(v1) — 10 methods (all deprecated) + 1 schema fixLanguagesResource.java— 2 methods + 2 schema fixesThemeResource.java— 2 methods + 2 schema fixesTempFileResource.java— 2 methods + 2 schema fixesResponseEntityHostView.java— new view classopenapi.yaml— regeneratedTest plan
./mvnw install -pl :dotcms-core -DskipTests)🤖 Generated with Claude Code