Overview
Generates native Groovy schema code from attributes for the specified object class. This endpoint automatically loads attributes from the session and uses AI to generate the appropriate schema structure.
Path Parameters
The unique identifier of the session
The name of the object class (e.g., “account”, “user”, “group”)
Query Parameters
Whether to use previous session data for generation. Set to false to force regeneration from scratch.
Request
No request body is required. The endpoint automatically loads attributes from the session data.
Response
The unique identifier for the created code generation job
Example Response
{
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
Prerequisites
Before calling this endpoint, you must:
- Create a session using
POST /api/v1/session
- Generate attributes for the object class using
POST /api/v1/session/{session_id}/classes/{object_class}/attributes
If attributes are not found in the session, the endpoint returns a 404 error.
Status Codes
Session not found or attributes not available for the object class
Example Request
curl -X POST "https://api.example.com/api/v1/session/123e4567-e89b-12d3-a456-426614174000/classes/account/native-schema?usePreviousSessionData=true" \
-H "Content-Type: application/json"
Checking Job Status
After creating the job, use the GET endpoint to check the generation status:
curl "https://api.example.com/api/v1/session/123e4567-e89b-12d3-a456-426614174000/classes/account/native-schema?jobId=a1b2c3d4-e5f6-7890-abcd-ef1234567890"
Status Response
{
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "finished",
"createdAt": "2026-03-10T12:00:00Z",
"startedAt": "2026-03-10T12:00:01Z",
"updatedAt": "2026-03-10T12:00:45Z",
"progress": {
"stage": "finished",
"message": "Native schema generated successfully"
},
"result": {
"code": "// Generated Groovy schema code\n..."
}
}
Manually Override Schema
You can manually override the generated schema using the PUT endpoint:
curl -X PUT "https://api.example.com/api/v1/session/123e4567-e89b-12d3-a456-426614174000/classes/account/native-schema" \
-H "Content-Type: application/json" \
-d '{
"code": "// Custom Groovy schema code\n..."
}'
Override Response
{
"message": "Native schema for account overridden successfully",
"sessionId": "123e4567-e89b-12d3-a456-426614174000",
"objectClass": "account"
}
Generated Code Structure
The generated native schema typically includes:
- Object class definition in Groovy
- Attribute declarations with proper types
- Schema builder pattern implementation
- Field mappings and transformations
Example generated schema:
objectClass {
type ObjectClass.ACCOUNT_NAME
attributes {
uid required: true
name()
email multivalued: false
active type: boolean
groups multivalued: true
}
}
Error Responses
404 Not Found - Session Not Found
{
"detail": "Session with ID 123e4567-e89b-12d3-a456-426614174000 not found"
}
404 Not Found - Attributes Not Available
{
"detail": "No attributes found for account in session 123e4567-e89b-12d3-a456-426614174000. Please run /classes/account/attributes endpoint first."
}