Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
627 changes: 626 additions & 1 deletion CLAUDE.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ describe('DotContentTypesEditComponent', () => {
contentTypeForm = de.query(By.css('dot-content-types-form'));
});

it('should udpate content type', () => {
it('should update content type', () => {
const responseContentType = Object.assign({}, fakeContentType, {
fields: [{ hello: 'world' }]
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.dotcms.contenttype.model.field;

import com.dotcms.rest.ResponseEntityView;
import java.util.List;
import java.util.Map;

/**
* Entity View for field type collection responses.
* Contains list of field type configurations.
*
* @author Steve Bolton
*/
public class ResponseEntityFieldTypeListView extends ResponseEntityView<List<Map<String, Object>>> {
public ResponseEntityFieldTypeListView(final List<Map<String, Object>> entity) {
super(entity);
}
}
59 changes: 59 additions & 0 deletions dotCMS/src/main/java/com/dotcms/rest/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# dotCMS REST API Guide for Claude AI

## πŸ“‹ Essential Reference

**πŸ‘‰ REQUIRED: Read [README.md](./README.md) for comprehensive REST API development guidelines**

This file contains **AI-specific instructions only**. You MUST follow all patterns, standards, and checklists in README.md.

---

## πŸ€– AI-Specific @Schema Rules

### Quick Decision Matrix

| Method Returns | Use @Schema |
|---------------|-------------|
| `ResponseEntity<UserView>` | `implementation = ResponseEntityUserView.class` |
| `ResponseEntity<List<T>>` | `implementation = ResponseEntityListView.class` |
| `List<MyEntity>` | `implementation = MyEntityListView.class` ΒΉ |
| `Map<String, MyType>` | `implementation = MapStringMyTypeView.class` ΒΉ |
| `Map<String, Object>` | `type = "object", description = "..."` |
| `JSONObject` / AI APIs | `type = "object", description = "...", example = "..."` |

ΒΉ *Create if doesn't exist: `class MyEntityListView extends ArrayList<MyEntity>`*

### 🚨 FORBIDDEN for AI

```java
❌ @Schema(implementation = Object.class) // Use type = "object" instead
❌ @Schema(implementation = Map.class) // Use specific view class
❌ @Schema(implementation = HashMap.class) // Use specific view class
❌ Missing descriptions on type = "object" // Always add description
```

### βœ… AI Description Requirements

For `@Schema(type = "object")`:
- **Analyze the method's business logic** to understand what data is returned
- **Be specific**: "AI search results with contentlets and fragments" not "JSON object"
- **Add examples** for complex AI/external API responses
- **Pattern**: "[Service] [operation] response containing [specific data] and [metadata]"

---

## 🎯 AI Workflow

1. **READ** [README.md](./README.md) patterns and requirements
2. **ANALYZE** method return statement - wrapped vs unwrapped?
3. **CHECK** if specific view class exists for the return type
4. **APPLY** correct @Schema from decision matrix above
5. **VERIFY** against [README.md checklist](./README.md#summary-checklist)

### Critical AI Verification
- βœ… Schema matches actual return type (not generic Object.class)
- βœ… All `type = "object"` have meaningful descriptions
- βœ… Descriptions explain actual data structure
- βœ… No deprecated Object.class/Map.class patterns remain

**Goal**: Create precise API documentation that helps developers understand exactly what each endpoint returns.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public Response getErrorResponse(final Response.Status status,
try {

return Response.status(status).entity
(new ResponseEntityView
(new ResponseEntityView<>
(Arrays.asList(new ErrorEntity(messageKey,
LanguageUtil.get(locale,
messageKey, arguments))))).build();
Expand Down
20 changes: 20 additions & 0 deletions dotCMS/src/main/java/com/dotcms/rest/ListMapView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.dotcms.rest;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
* Generic response entity view for List&lt;Map&lt;String, Object&gt;&gt; responses.
* Used for endpoints that return collections of map data structures.
* Whereas Map<String,Object> and this can be represented by type = "object" as just json
* This class explicitly defines an array of json objects.
*
* @author Claude Code
*/
public class ListMapView extends ArrayList<Map<String, Object>> {

public ListMapView(List<Map<String, Object>> detailedAssets) {
addAll(detailedAssets);
}
}
Loading