diff --git a/bun.lockb b/bun.lockb index 1310ff25..9a00e35c 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 4df339fe..e1ff3cb6 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "An open source Plex Media Server API Specification", "main": "src/pms-spec.yaml", "scripts": { - "dev": "redocly preview --product=redoc -d=./src", + "dev": "redocly preview -d=./src", "stats": "redocly stats ./src/pms-spec.yaml", "build": "swagger-cli bundle --dereference ./src/pms-spec.yaml -t yaml -o ./output/plex-media-server-spec-dereferenced.yaml", "build-redocly": "redocly bundle ./src/pms-spec.yaml --ext yaml -o ./output/plex-media-server-spec-dereferenced.yaml", @@ -18,7 +18,8 @@ "license": "ISC", "devDependencies": { "@modyfi/vite-plugin-yaml": "^1.1.0", - "@redocly/cli": "^1.22.0", + "@redocly/cli": "latest", + "@scalar/cli": "^0.2.190", "@types/node": "^22.5.0", "swagger-cli": "^4.0.4", "typescript": "^5.5.4", diff --git a/src/models/common/PlexMediaType.yaml b/src/models/common/PlexMediaType.yaml new file mode 100644 index 00000000..132524fc --- /dev/null +++ b/src/models/common/PlexMediaType.yaml @@ -0,0 +1,16 @@ +type: integer +enum: + - 0 + - 1 + - 2 + - 3 + - 4 +example: 2 +default: 0 +description: | + The type of media to retrieve. + 1 = movie + 2 = show + 3 = season + 4 = episode + E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries diff --git a/src/parameters/accept-application-json.yaml b/src/parameters/accept-application-json.yaml new file mode 100644 index 00000000..2b5db9d5 --- /dev/null +++ b/src/parameters/accept-application-json.yaml @@ -0,0 +1,9 @@ +name: Accept +in: header +required: false +schema: + type: string + enum: + - application/json + - application/xml + example: application/json diff --git a/src/parameters/container-size.yaml b/src/parameters/container-size.yaml index 44d09f0f..98e82b1d 100644 --- a/src/parameters/container-size.yaml +++ b/src/parameters/container-size.yaml @@ -5,5 +5,6 @@ description: | By default this is 50 schema: type: integer -example: 0 + default: 50 + example: 50 required: false diff --git a/src/parameters/container-start.yaml b/src/parameters/container-start.yaml index 3d2c77f6..a1f667f4 100644 --- a/src/parameters/container-start.yaml +++ b/src/parameters/container-start.yaml @@ -5,5 +5,6 @@ description: | By default this is 0 schema: type: integer -example: 0 + default: 0 + example: 0 required: false diff --git a/src/parameters/plex-token.yaml b/src/parameters/plex-token.yaml new file mode 100644 index 00000000..ce9d9ee8 --- /dev/null +++ b/src/parameters/plex-token.yaml @@ -0,0 +1,7 @@ +name: X-Plex-Token +in: query +description: Plex Authentication Token +schema: + type: string +example: CV5xoxjTpFKUzBTShsaf +required: true diff --git a/src/parameters/type.yaml b/src/parameters/type.yaml new file mode 100644 index 00000000..76cab8ec --- /dev/null +++ b/src/parameters/type.yaml @@ -0,0 +1,21 @@ +#name: type +#in: query +#description: | +# Filter the type of media to retrieve +#required: false +#schema: +# $ref: '../models/common/PlexMediaType.yaml' +# +# +name: type +in: query +description: Plex content type to search for +schema: + type: integer + enum: + - 1 + - 2 + - 3 + - 4 +example: 2 +required: true diff --git a/src/paths/library/[sectionId]/get-library-items.yaml b/src/paths/library/[sectionId]/get-library-items.yaml index f40945d5..262bf378 100644 --- a/src/paths/library/[sectionId]/get-library-items.yaml +++ b/src/paths/library/[sectionId]/get-library-items.yaml @@ -79,27 +79,10 @@ get: - 1 example: 1 required: false - - name: type - in: query - description: | - Filter the type of media to retrieve - 1 is movie - 2 is tv shows - 3 is seasons - 4 is episodes - E.g. A movie library will not return anything with type 3 as there are no seasons for movie libraries - schema: - type: integer - enum: - - 0 - - 1 - - 2 - - 3 - - 4 - example: 2 - required: false + - $ref: "../../../parameters/type.yaml" - $ref: "../../../parameters/container-start.yaml" - $ref: "../../../parameters/container-size.yaml" + - $ref: "../../../parameters/accept-application-json.yaml" responses: "200": description: The contents of the library by section and tag diff --git a/src/paths/library/content-search.yaml b/src/paths/library/content-search.yaml index 167c45d1..969430c7 100644 --- a/src/paths/library/content-search.yaml +++ b/src/paths/library/content-search.yaml @@ -29,17 +29,8 @@ get: description: the Id of the library to query schema: type: integer - - name: type - description: Plex content type to search for - in: query - schema: - type: integer - enum: - - 1 - - 2 - - 3 - - 4 - required: true + - $ref: "../../parameters/accept-application-json.yaml" + - $ref: "../../parameters/type.yaml" responses: "200": description: The contents of the library by section and type diff --git a/src/paths/library/recentlyadded.yaml b/src/paths/library/get-recently-added.yaml similarity index 98% rename from src/paths/library/recentlyadded.yaml rename to src/paths/library/get-recently-added.yaml index cfada46e..f53d2ced 100644 --- a/src/paths/library/recentlyadded.yaml +++ b/src/paths/library/get-recently-added.yaml @@ -5,6 +5,10 @@ get: description: | This endpoint will return the recently added content. operationId: getRecentlyAdded + parameters: + - $ref: "../../parameters/accept-application-json.yaml" + - $ref: "../../parameters/container-start.yaml" + - $ref: "../../parameters/container-size.yaml" responses: "200": description: The recently added content diff --git a/src/paths/user/user.yaml b/src/paths/user/user.yaml index 7724c550..296f6518 100644 --- a/src/paths/user/user.yaml +++ b/src/paths/user/user.yaml @@ -2,10 +2,12 @@ get: servers: - url: 'https://plex.tv/api/v2' tags: - - Plex + - User summary: Get UserData By Token description: Get the User data from the provided X-Plex-Token operationId: getUserDetails + parameters: + - $ref: '../../parameters/plex-token.yaml' responses: '200': description: Logged in user details diff --git a/src/pms-spec.yaml b/src/pms-spec.yaml index cd2a3429..9bf3a174 100644 --- a/src/pms-spec.yaml +++ b/src/pms-spec.yaml @@ -41,6 +41,15 @@ components: name: X-Plex-Token paths: + parameters: + - name: Accept + in: header + required: true + schema: + type: string + enum: [application/json] + description: Specifies that the client expects a JSON response. + # Plex Media Server endpoints # Colon Endpoints @@ -116,7 +125,7 @@ paths: /library/hashes: $ref: "./paths/library/hashes.yaml" /library/recentlyAdded: - $ref: "./paths/library/recentlyadded.yaml" + $ref: "./paths/library/get-recently-added.yaml" /library/sections: $ref: "./paths/library/get-all-libraries.yaml" /library/sections/{sectionId}: