Created collectionBase schema

This commit is contained in:
Nicholas Wallace 2024-02-20 01:41:27 +00:00
parent 0d89076d42
commit a90e79657b
2 changed files with 52 additions and 80 deletions

View file

@ -331,9 +331,9 @@
}, },
"components": { "components": {
"schemas": { "schemas": {
"collection": { "collectionBase": {
"type": "object", "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": { "properties": {
"id": { "id": {
"description": "The ID of the collection.", "description": "The ID of the collection.",
@ -354,65 +354,51 @@
null null
] ]
}, },
"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": { "books": {
"description": "The books that belong to the collection.", "description": "The books that belong to the collection.",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/libraryItem" "$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"
} }
} }
]
}, },
"collectionExpanded": { "collectionExpanded": {
"type": "object", "type": "object",
"properties": { "description": "A public collection of library items which can be ordered and has a description. Replaces `libraryItem` with `libraryItemExtended`.",
"id": { "allOf": [
"description": "The ID of the collection.", {
"type": "string" "$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": { "books": {
"description": "The books that belong to the collection.", "description": "The books that belong to the collection.",
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/libraryItemExpanded" "$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": { "oldLibraryId": {
"type": "string", "type": "string",

View file

@ -6,9 +6,9 @@ const oldCollection = require('../objects/Collection')
* @openapi * @openapi
* components: * components:
* schemas: * schemas:
* collection: * collectionBase:
* type: object * 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: * properties:
* id: * id:
* description: The ID of the collection. * description: The ID of the collection.
@ -22,46 +22,32 @@ const oldCollection = require('../objects/Collection')
* description: * description:
* description: The description of the collection. * description: The description of the collection.
* type: [string, null] * type: [string, null]
* books: * 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. * description: The books that belong to the collection.
* type: array * type: array
* items: * items:
* $ref: '#/components/schemas/libraryItem' * $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
* collectionExpanded: * collectionExpanded:
* type: object * type: object
* properties: * description: A public collection of library items which can be ordered and has a description. Replaces `libraryItem` with `libraryItemExtended`.
* id: * allOf:
* description: The ID of the collection. * - $ref: '#/components/schemas/collectionBase'
* type: string * - books:
* 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. * description: The books that belong to the collection.
* type: array * type: array
* items: * items:
* $ref: '#/components/schemas/libraryItemExpanded' * $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
*/ */
class Collection extends Model { class Collection extends Model {
constructor(values, options) { constructor(values, options) {