From a90e79657b046f1013ebf6c6b253100a9b9afc67 Mon Sep 17 00:00:00 2001 From: Nicholas Wallace Date: Tue, 20 Feb 2024 01:41:27 +0000 Subject: [PATCH] Created `collectionBase` schema --- build-docs/swagger-output.json | 78 ++++++++++++++-------------------- server/models/Collection.js | 54 +++++++++-------------- 2 files changed, 52 insertions(+), 80 deletions(-) diff --git a/build-docs/swagger-output.json b/build-docs/swagger-output.json index 15579dd9a..2cdec5ccc 100644 --- a/build-docs/swagger-output.json +++ b/build-docs/swagger-output.json @@ -331,9 +331,9 @@ }, "components": { "schemas": { - "collection": { + "collectionBase": { "type": "object", - "description": "A public collection of library items which can be ordered and has a description.", + "description": "A public collection of library items which can be ordered and has a description, base schema.", "properties": { "id": { "description": "The ID of the collection.", @@ -354,13 +354,6 @@ null ] }, - "books": { - "description": "The books that belong to the collection.", - "type": "array", - "items": { - "$ref": "#/components/schemas/libraryItem" - } - }, "lastUpdate": { "description": "The time (in ms since POSIX epoch) when the collection was last updated.", "type": "integer" @@ -371,48 +364,41 @@ } } }, + "collection": { + "type": "object", + "description": "A public collection of library items which can be ordered and has a description.", + "allOf": [ + { + "$ref": "#/components/schemas/collectionBase" + }, + { + "books": { + "description": "The books that belong to the collection.", + "type": "array", + "items": { + "$ref": "#/components/schemas/libraryItem" + } + } + } + ] + }, "collectionExpanded": { "type": "object", - "properties": { - "id": { - "description": "The ID of the collection.", - "type": "string" + "description": "A public collection of library items which can be ordered and has a description. Replaces `libraryItem` with `libraryItemExtended`.", + "allOf": [ + { + "$ref": "#/components/schemas/collectionBase" }, - "libraryId": { - "description": "The ID of the library the collection belongs to.", - "type": "string" - }, - "userId": { - "description": "The ID of the user that created the collection.", - "type": "string" - }, - "name": { - "description": "The name of the collection.", - "type": "string" - }, - "description": { - "description": "The name of the collection.", - "type": [ - "string", - "null" - ] - }, - "books": { - "description": "The books that belong to the collection.", - "type": "array", - "items": { - "$ref": "#/components/schemas/libraryItemExpanded" + { + "books": { + "description": "The books that belong to the collection.", + "type": "array", + "items": { + "$ref": "#/components/schemas/libraryItemExpanded" + } } - }, - "lastUpdate": { - "description": "The time (in ms since POSIX epoch) when the collection was last updated.", - "type": "integer" - }, - "createdAt": { - "description": "The time (in ms since POSIX epoch) when the collection was created.", - "type": "integer" } - } + ] }, "oldLibraryId": { "type": "string", diff --git a/server/models/Collection.js b/server/models/Collection.js index 1e72a4b95..8c97b143f 100644 --- a/server/models/Collection.js +++ b/server/models/Collection.js @@ -6,9 +6,9 @@ const oldCollection = require('../objects/Collection') * @openapi * components: * schemas: - * collection: + * collectionBase: * type: object - * description: A public collection of library items which can be ordered and has a description. + * description: A public collection of library items which can be ordered and has a description, base schema. * properties: * id: * description: The ID of the collection. @@ -22,46 +22,32 @@ const oldCollection = require('../objects/Collection') * description: * description: The description of the collection. * type: [string, null] - * books: - * description: The books that belong to the collection. - * type: array - * items: - * $ref: '#/components/schemas/libraryItem' * lastUpdate: * description: The time (in ms since POSIX epoch) when the collection was last updated. * type: integer * createdAt: * description: The time (in ms since POSIX epoch) when the collection was created. * type: integer + * collection: + * type: object + * description: A public collection of library items which can be ordered and has a description. + * allOf: + * - $ref: '#/components/schemas/collectionBase' + * - books: + * description: The books that belong to the collection. + * type: array + * items: + * $ref: '#/components/schemas/libraryItem' * collectionExpanded: * type: object - * properties: - * id: - * description: The ID of the collection. - * type: string - * libraryId: - * description: The ID of the library the collection belongs to. - * type: string - * userId: - * description: The ID of the user that created the collection. - * type: string - * name: - * description: The name of the collection. - * type: string - * description: - * description: The name of the collection. - * type: [string, 'null'] - * books: - * description: The books that belong to the collection. - * type: array - * items: - * $ref: '#/components/schemas/libraryItemExpanded' - * lastUpdate: - * description: The time (in ms since POSIX epoch) when the collection was last updated. - * type: integer - * createdAt: - * description: The time (in ms since POSIX epoch) when the collection was created. - * type: integer + * description: A public collection of library items which can be ordered and has a description. Replaces `libraryItem` with `libraryItemExtended`. + * allOf: + * - $ref: '#/components/schemas/collectionBase' + * - books: + * description: The books that belong to the collection. + * type: array + * items: + * $ref: '#/components/schemas/libraryItemExpanded' */ class Collection extends Model { constructor(values, options) {