Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

add patch /work_package/week_days

Christophe Bliardf6e34431cd27
diff --git a/docs/api/apiv3/components/schemas/week_day_collection_model.yml b/docs/api/apiv3/components/schemas/week_day_collection_model.yml
index 21adcef9f79..da09ffcb73a 100644
--- a/docs/api/apiv3/components/schemas/week_day_collection_model.yml
+++ b/docs/api/apiv3/components/schemas/week_day_collection_model.yml
@@ -28,6 +28,8 @@ allOf:
type: array
description: |-
The array of week days.
+ minItems: 7
+ maxItems: 7
items:
$ref: './week_day_model.yml'
diff --git a/docs/api/apiv3/components/schemas/week_day_collection_write_model.yml b/docs/api/apiv3/components/schemas/week_day_collection_write_model.yml
new file mode 100644
index 00000000000..a65c2e81fd9
--- /dev/null
+++ b/docs/api/apiv3/components/schemas/week_day_collection_write_model.yml
@@ -0,0 +1,50 @@
+# Schema: WeekDayCollectionWriteModel
+---
+type: object
+required:
+ - _type
+ - _embedded
+properties:
+ _type:
+ type: string
+ enum:
+ - Collection
+ _embedded:
+ type: object
+ required:
+ - elements
+ properties:
+ elements:
+ type: array
+ description: |-
+ The array of week days.
+ minItems: 7
+ maxItems: 7
+ items:
+ $ref: './week_day_write_model.yml'
+
+example:
+ _type: Collection
+ _embedded:
+ elements:
+ - _type: WeekDay
+ day: 1
+ working: true
+ - _type: WeekDay
+ day: 2
+ working: true
+ - _type: WeekDay
+ day: 3
+ working: true
+ - _type: WeekDay
+ day: 4
+ working: true
+ - _type: WeekDay
+ day: 5
+ working: true
+ - _type: WeekDay
+ day: 6
+ working: false
+ - _type: WeekDay
+ day: 7
+ working: false
diff --git a/docs/api/apiv3/components/schemas/week_day_write_model.yml b/docs/api/apiv3/components/schemas/week_day_write_model.yml
new file mode 100644
index 00000000000..d53b23c3707
--- /dev/null
+++ b/docs/api/apiv3/components/schemas/week_day_write_model.yml
@@ -0,0 +1,29 @@
+# Schema: WeekDayWriteModel
+---
+type: object
+description: |-
+ Describes a week day as a working day or a non working day (weekend).
+required:
+ - _type
+ - day
+ - working
+properties:
+ _type:
+ type: string
+ enum:
+ - WeekDay
+ day:
+ type: integer
+ description: |-
+ The week day from 1 to 7. 1 is Monday. 7 is Sunday.
+ readOnly: true
+ minimum: 1
+ maximum: 7
+ working:
+ type: boolean
+ description: |-
+ `true` for a working day. `false` for a weekend day.
+example:
+ _type: WeekDay
+ day: 5
+ working: false
diff --git a/docs/api/apiv3/openapi-spec.yml b/docs/api/apiv3/openapi-spec.yml
index d3a235d0dac..fe4ef9d5d29 100644
--- a/docs/api/apiv3/openapi-spec.yml
+++ b/docs/api/apiv3/openapi-spec.yml
@@ -424,7 +424,6 @@ paths:
"/api/v3/work_packages/{id}/watchers/{user_id}":
"$ref": "./paths/work_package_watcher.yml"
"/api/v3/work_schedule/week_days":
- # TODO: patch
"$ref": "./paths/work_schedule_week_days.yml"
"/api/v3/work_schedule/week_days/{day}":
"$ref": "./paths/work_schedule_week_day.yml"
@@ -778,8 +777,12 @@ components:
"$ref": "./components/schemas/watchers_model.yml"
WeekDayCollectionModel:
"$ref": "./components/schemas/week_day_collection_model.yml"
+ WeekDayCollectionWriteModel:
+ "$ref": "./components/schemas/week_day_collection_write_model.yml"
WeekDayModel:
"$ref": "./components/schemas/week_day_model.yml"
+ WeekDayWriteModel:
+ "$ref": "./components/schemas/week_day_write_model.yml"
Wiki_PageModel:
"$ref": "./components/schemas/wiki_page_model.yml"
Work_PackageModel:
diff --git a/docs/api/apiv3/paths/work_schedule_week_days.yml b/docs/api/apiv3/paths/work_schedule_week_days.yml
index b54bb24b684..b56658096df 100644
--- a/docs/api/apiv3/paths/work_schedule_week_days.yml
+++ b/docs/api/apiv3/paths/work_schedule_week_days.yml
@@ -25,3 +25,75 @@ get:
_type: Error
errorIdentifier: urn:openproject-org:api:v3:errors:InvalidRequestBody
message: The request body was not a single JSON object.
+
+patch:
+ summary: Update week days
+ operationId: update_week_days
+ tags:
+ - Work Schedule
+ - Non working days
+ - Week days
+ description: |-
+ Update all week days with work schedule information.
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: ../components/schemas/week_day_collection_write_model.yml
+ example:
+ _type: Collection
+ _embedded:
+ elements:
+ - _type: WeekDay
+ day: 1
+ working: true
+ - _type: WeekDay
+ day: 2
+ working: true
+ - _type: WeekDay
+ day: 3
+ working: true
+ - _type: WeekDay
+ day: 4
+ working: true
+ - _type: WeekDay
+ day: 5
+ working: true
+ - _type: WeekDay
+ day: 6
+ working: false
+ - _type: WeekDay
+ day: 7
+ working: false
+
+ responses:
+ '200':
+ description: OK
+ content:
+ application/hal+json:
+ schema:
+ $ref: '../components/schemas/week_day_collection_model.yml'
+ '400':
+ description: Returned if the client sends invalid request parameters
+ content:
+ application/hal+json:
+ schema:
+ $ref: '../components/schemas/error_response.yml'
+ example:
+ _type: Error
+ errorIdentifier: urn:openproject-org:api:v3:errors:InvalidRequestBody
+ message: The request body was not a single JSON object.
+ '422':
+ description: |-
+ Occurs if the request body was correctly formatted, but some properties lead to errors in the validation
+ process. This happens for example if not every days were sent.
+ content:
+ application/hal+json:
+ schema:
+ $ref: "../components/schemas/error_response.yml"
+ examples:
+ response:
+ value:
+ _type: Error
+ errorIdentifier: urn:openproject-org:api:v3:errors:PropertyConstraintViolation
+ message: The request was invalid. Must send all days of the week.