Implement character and scenario management features in the API
- Add create, update, and delete functionality for characters and scenarios in CharacterService and ScenarioService. - Introduce CreateCharacterRequest and CreateScenarioRequest models for handling character and scenario creation requests. - Update CharactersResource and ScenariosResource to expose new endpoints for character and scenario management. - Enhance OpenAPI specification to document new API endpoints and request/response schemas. - Implement frontend components for managing characters and scenarios, including listing, creating, editing, and deleting. - Add unit tests for CharacterService to ensure correct behavior of character creation and updates.
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
quarkus:
|
||||
application:
|
||||
name: roleplay
|
||||
resteasy-reactive:
|
||||
scan:
|
||||
paths: de.neitzel.roleplay.fascade,de.neitzel.roleplay.business,de.neitzel.roleplay.common,de.neitzel.roleplay.data
|
||||
http:
|
||||
root-path: /
|
||||
datasource:
|
||||
@@ -12,9 +9,6 @@ quarkus:
|
||||
url: jdbc:h2:mem:roleplay;DB_CLOSE_DELAY=-1
|
||||
username: sa
|
||||
password: ""
|
||||
hibernate-orm:
|
||||
database:
|
||||
generation: none
|
||||
liquibase:
|
||||
change-log: db/migration/changelog.xml
|
||||
migrate-at-start: true
|
||||
|
||||
@@ -61,6 +61,31 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ScenarioListResponse'
|
||||
post:
|
||||
operationId: createScenario
|
||||
summary: Create a scenario
|
||||
description: Creates a new scenario with optional character slots. Server generates UUID.
|
||||
tags:
|
||||
- scenarios
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CreateScenarioRequest'
|
||||
responses:
|
||||
"201":
|
||||
description: Scenario created.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ScenarioSummary'
|
||||
"400":
|
||||
description: Invalid request body or referenced character not found.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
|
||||
/scenarios/{scenarioId}:
|
||||
get:
|
||||
@@ -84,6 +109,56 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
put:
|
||||
operationId: updateScenario
|
||||
summary: Update a scenario
|
||||
description: Full replace. Replaces all character slots.
|
||||
tags:
|
||||
- scenarios
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/ScenarioId'
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CreateScenarioRequest'
|
||||
responses:
|
||||
"200":
|
||||
description: Scenario updated.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ScenarioSummary'
|
||||
"400":
|
||||
description: Invalid request body or referenced character not found.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
"404":
|
||||
description: Scenario not found.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
delete:
|
||||
operationId: deleteScenario
|
||||
summary: Delete a scenario
|
||||
description: Removes the scenario template.
|
||||
tags:
|
||||
- scenarios
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/ScenarioId'
|
||||
responses:
|
||||
"204":
|
||||
description: Scenario deleted.
|
||||
"404":
|
||||
description: Scenario not found.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
|
||||
/characters:
|
||||
get:
|
||||
@@ -99,6 +174,31 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CharacterListResponse'
|
||||
post:
|
||||
operationId: createCharacter
|
||||
summary: Create a character
|
||||
description: Creates a new character template. Server generates UUID if id is omitted.
|
||||
tags:
|
||||
- characters
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CreateCharacterRequest'
|
||||
responses:
|
||||
"201":
|
||||
description: Character created.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CharacterDefinition'
|
||||
"400":
|
||||
description: Invalid request body.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
|
||||
/characters/{characterId}:
|
||||
get:
|
||||
@@ -122,6 +222,56 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
put:
|
||||
operationId: updateCharacter
|
||||
summary: Update a character
|
||||
description: Full replace of the character. All fields required except optional ones.
|
||||
tags:
|
||||
- characters
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/CharacterId'
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CreateCharacterRequest'
|
||||
responses:
|
||||
"200":
|
||||
description: Character updated.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/CharacterDefinition'
|
||||
"400":
|
||||
description: Invalid request body.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
"404":
|
||||
description: Character not found.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
delete:
|
||||
operationId: deleteCharacter
|
||||
summary: Delete a character
|
||||
description: Removes the character template. Scenarios referencing it may need updating.
|
||||
tags:
|
||||
- characters
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/CharacterId'
|
||||
responses:
|
||||
"204":
|
||||
description: Character deleted.
|
||||
"404":
|
||||
description: Character not found.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ErrorResponse'
|
||||
|
||||
/sessions:
|
||||
post:
|
||||
@@ -401,6 +551,80 @@ components:
|
||||
required:
|
||||
- characters
|
||||
|
||||
CreateCharacterRequest:
|
||||
type: object
|
||||
description: Request body for creating or updating a character. id optional on create (server generates UUID).
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
format: uuid
|
||||
description: Optional on create; server generates if omitted.
|
||||
name:
|
||||
type: string
|
||||
description: Display name.
|
||||
role:
|
||||
type: string
|
||||
description: Narrative role.
|
||||
backstory:
|
||||
type: string
|
||||
description: Character background.
|
||||
speakingStyle:
|
||||
type: string
|
||||
description: How the character speaks.
|
||||
personalityTraits:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
description: List of personality traits.
|
||||
goals:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
description: Character goals.
|
||||
required:
|
||||
- name
|
||||
- role
|
||||
|
||||
ScenarioCharacterSlot:
|
||||
type: object
|
||||
description: Assignment of a character to a scenario slot (user or AI, with position).
|
||||
properties:
|
||||
characterId:
|
||||
type: string
|
||||
format: uuid
|
||||
description: Reference to a saved character.
|
||||
isUserCharacter:
|
||||
type: boolean
|
||||
description: True if this slot is the player character.
|
||||
position:
|
||||
type: integer
|
||||
description: Order of the character (0 for user, 1+ for AI).
|
||||
required:
|
||||
- characterId
|
||||
- isUserCharacter
|
||||
- position
|
||||
|
||||
CreateScenarioRequest:
|
||||
type: object
|
||||
description: Request body for creating or updating a scenario.
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: Human-readable scenario name.
|
||||
setting:
|
||||
type: string
|
||||
description: Place, time, and atmosphere.
|
||||
initialConflict:
|
||||
type: string
|
||||
description: The hook or starting conflict.
|
||||
characterSlots:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/ScenarioCharacterSlot'
|
||||
description: Assigned characters (one user, ordered AI).
|
||||
required:
|
||||
- name
|
||||
|
||||
ScenarioSetup:
|
||||
type: object
|
||||
description: |
|
||||
|
||||
Reference in New Issue
Block a user