@sebspark/openapi-e2e
Advanced tools
+10
-0
| # @sebspark/openapi-e2e | ||
| ## 2.0.2 | ||
| ### Patch Changes | ||
| - 06948d0: Updated dependencies | ||
| - Updated dependencies [06948d0] | ||
| - @sebspark/openapi-express@2.0.3 | ||
| - @sebspark/openapi-client@2.2.3 | ||
| - @sebspark/openapi-core@2.2.1 | ||
| ## 2.0.1 | ||
@@ -4,0 +14,0 @@ |
+5
-4
| { | ||
| "name": "@sebspark/openapi-e2e", | ||
| "version": "2.0.1", | ||
| "version": "2.0.2", | ||
| "license": "Apache-2.0", | ||
@@ -16,9 +16,10 @@ "scripts": { | ||
| "@sebspark/openapi-express": "*", | ||
| "express": "5.0.1" | ||
| "express": "5.1.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@sebspark/openapi-typegen": "*", | ||
| "@types/express": "5.0.0", | ||
| "tsconfig": "*" | ||
| "@types/express": "5.0.1", | ||
| "tsconfig": "*", | ||
| "vitest": "3.1.2" | ||
| } | ||
| } |
+57
-1
| import type { Server } from 'node:http' | ||
| import { TypedClient } from '@sebspark/openapi-client' | ||
| import type { Serialized } from '@sebspark/openapi-core' | ||
| import { afterAll, beforeAll, describe, expect, it } from 'vitest' | ||
| import { | ||
| type Mock, | ||
| afterAll, | ||
| beforeAll, | ||
| describe, | ||
| expect, | ||
| it, | ||
| vi, | ||
| } from 'vitest' | ||
| import type { | ||
@@ -15,2 +23,3 @@ InstrumentEntityResponse, | ||
| let client: MarketdataClient | ||
| beforeAll(async () => { | ||
@@ -22,2 +31,3 @@ await new Promise<void>((resolve) => { | ||
| }) | ||
| afterAll( | ||
@@ -32,2 +42,3 @@ () => | ||
| ) | ||
| it('returns markets', async () => { | ||
@@ -37,2 +48,3 @@ const result = await client.get('/markets') | ||
| }) | ||
| it('works for multiple parameter urls', async () => { | ||
@@ -57,2 +69,3 @@ const result = await client.get( | ||
| }) | ||
| it('sends headers', async () => { | ||
@@ -64,2 +77,45 @@ const result = await client.get('/secured', { | ||
| }) | ||
| describe('authorizationTokenGenerators are unique per instance', () => { | ||
| let clientOne: MarketdataClient | ||
| let clientTwo: MarketdataClient | ||
| let authorizationTokenGeneratorOne: Mock< | ||
| (url: string) => Promise<Record<string, string>> | undefined | ||
| > | ||
| let authorizationTokenGeneratorTwo: Mock< | ||
| (url: string) => Promise<Record<string, string>> | undefined | ||
| > | ||
| beforeAll(async () => { | ||
| authorizationTokenGeneratorOne = vi.fn().mockResolvedValue({ | ||
| 'x-test-value': 'one', | ||
| }) | ||
| authorizationTokenGeneratorTwo = vi.fn().mockResolvedValue({ | ||
| 'x-test-value': 'two', | ||
| }) | ||
| clientOne = TypedClient<MarketdataClient>(`http://localhost:${PORT}`, { | ||
| authorizationTokenGenerator: authorizationTokenGeneratorOne, | ||
| }) | ||
| clientTwo = TypedClient<MarketdataClient>(`http://localhost:${PORT}`, { | ||
| authorizationTokenGenerator: authorizationTokenGeneratorTwo, | ||
| }) | ||
| }) | ||
| it('calls the server with the correct authorization token', async () => { | ||
| const resultOne = await clientOne.get('/header/extract') | ||
| expect(resultOne.data).toEqual('one') | ||
| expect(authorizationTokenGeneratorOne).toHaveBeenCalledWith( | ||
| `http://localhost:${PORT}/header/extract` | ||
| ) | ||
| const resultTwo = await clientTwo.get('/header/extract') | ||
| expect(resultTwo.data).toEqual('two') | ||
| expect(authorizationTokenGeneratorTwo).toHaveBeenCalledWith( | ||
| `http://localhost:${PORT}/header/extract` | ||
| ) | ||
| }) | ||
| }) | ||
| }) |
+174
-45
@@ -21,3 +21,7 @@ { | ||
| ], | ||
| "security": [{ "ApiKey": [] }], | ||
| "security": [ | ||
| { | ||
| "ApiKey": [] | ||
| } | ||
| ], | ||
| "responses": { | ||
@@ -34,7 +38,41 @@ "200": { | ||
| }, | ||
| "403": { "$ref": "#/components/responses/Forbidden" }, | ||
| "500": { "$ref": "#/components/responses/InternalServerError" } | ||
| "403": { | ||
| "$ref": "#/components/responses/Forbidden" | ||
| }, | ||
| "500": { | ||
| "$ref": "#/components/responses/InternalServerError" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "/header/extract": { | ||
| "get": { | ||
| "summary": "Get the value of the x-test-value header", | ||
| "parameters": [ | ||
| { | ||
| "name": "X-Test-Value", | ||
| "in": "header", | ||
| "required": true, | ||
| "schema": { | ||
| "type": "string" | ||
| } | ||
| } | ||
| ], | ||
| "responses": { | ||
| "200": { | ||
| "description": "Successful response", | ||
| "content": { | ||
| "application/json": { | ||
| "schema": { | ||
| "type": "string" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "500": { | ||
| "$ref": "#/components/responses/InternalServerError" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "/markets": { | ||
@@ -72,6 +110,14 @@ "get": { | ||
| }, | ||
| "401": { "$ref": "#/components/responses/Unauthorized" }, | ||
| "403": { "$ref": "#/components/responses/Forbidden" }, | ||
| "404": { "$ref": "#/components/responses/NotFound" }, | ||
| "500": { "$ref": "#/components/responses/InternalServerError" } | ||
| "401": { | ||
| "$ref": "#/components/responses/Unauthorized" | ||
| }, | ||
| "403": { | ||
| "$ref": "#/components/responses/Forbidden" | ||
| }, | ||
| "404": { | ||
| "$ref": "#/components/responses/NotFound" | ||
| }, | ||
| "500": { | ||
| "$ref": "#/components/responses/InternalServerError" | ||
| } | ||
| } | ||
@@ -104,6 +150,14 @@ } | ||
| }, | ||
| "401": { "$ref": "#/components/responses/Unauthorized" }, | ||
| "403": { "$ref": "#/components/responses/Forbidden" }, | ||
| "404": { "$ref": "#/components/responses/NotFound" }, | ||
| "500": { "$ref": "#/components/responses/InternalServerError" } | ||
| "401": { | ||
| "$ref": "#/components/responses/Unauthorized" | ||
| }, | ||
| "403": { | ||
| "$ref": "#/components/responses/Forbidden" | ||
| }, | ||
| "404": { | ||
| "$ref": "#/components/responses/NotFound" | ||
| }, | ||
| "500": { | ||
| "$ref": "#/components/responses/InternalServerError" | ||
| } | ||
| } | ||
@@ -132,3 +186,7 @@ } | ||
| "type": "string", | ||
| "enum": ["INDICIES", "STOCKS", "FUNDS"] | ||
| "enum": [ | ||
| "INDICIES", | ||
| "STOCKS", | ||
| "FUNDS" | ||
| ] | ||
| } | ||
@@ -149,6 +207,14 @@ } | ||
| }, | ||
| "401": { "$ref": "#/components/responses/Unauthorized" }, | ||
| "403": { "$ref": "#/components/responses/Forbidden" }, | ||
| "404": { "$ref": "#/components/responses/NotFound" }, | ||
| "500": { "$ref": "#/components/responses/InternalServerError" } | ||
| "401": { | ||
| "$ref": "#/components/responses/Unauthorized" | ||
| }, | ||
| "403": { | ||
| "$ref": "#/components/responses/Forbidden" | ||
| }, | ||
| "404": { | ||
| "$ref": "#/components/responses/NotFound" | ||
| }, | ||
| "500": { | ||
| "$ref": "#/components/responses/InternalServerError" | ||
| } | ||
| } | ||
@@ -197,6 +263,14 @@ } | ||
| }, | ||
| "401": { "$ref": "#/components/responses/Unauthorized" }, | ||
| "403": { "$ref": "#/components/responses/Forbidden" }, | ||
| "404": { "$ref": "#/components/responses/NotFound" }, | ||
| "500": { "$ref": "#/components/responses/InternalServerError" } | ||
| "401": { | ||
| "$ref": "#/components/responses/Unauthorized" | ||
| }, | ||
| "403": { | ||
| "$ref": "#/components/responses/Forbidden" | ||
| }, | ||
| "404": { | ||
| "$ref": "#/components/responses/NotFound" | ||
| }, | ||
| "500": { | ||
| "$ref": "#/components/responses/InternalServerError" | ||
| } | ||
| } | ||
@@ -229,6 +303,14 @@ } | ||
| }, | ||
| "401": { "$ref": "#/components/responses/Unauthorized" }, | ||
| "403": { "$ref": "#/components/responses/Forbidden" }, | ||
| "404": { "$ref": "#/components/responses/NotFound" }, | ||
| "500": { "$ref": "#/components/responses/InternalServerError" } | ||
| "401": { | ||
| "$ref": "#/components/responses/Unauthorized" | ||
| }, | ||
| "403": { | ||
| "$ref": "#/components/responses/Forbidden" | ||
| }, | ||
| "404": { | ||
| "$ref": "#/components/responses/NotFound" | ||
| }, | ||
| "500": { | ||
| "$ref": "#/components/responses/InternalServerError" | ||
| } | ||
| } | ||
@@ -244,3 +326,5 @@ } | ||
| "application/json": { | ||
| "schema": { "$ref": "#/components/schemas/Error" } | ||
| "schema": { | ||
| "$ref": "#/components/schemas/Error" | ||
| } | ||
| } | ||
@@ -253,3 +337,5 @@ } | ||
| "application/json": { | ||
| "schema": { "$ref": "#/components/schemas/Error" } | ||
| "schema": { | ||
| "$ref": "#/components/schemas/Error" | ||
| } | ||
| } | ||
@@ -262,3 +348,5 @@ } | ||
| "application/json": { | ||
| "schema": { "$ref": "#/components/schemas/Error" } | ||
| "schema": { | ||
| "$ref": "#/components/schemas/Error" | ||
| } | ||
| } | ||
@@ -271,3 +359,5 @@ } | ||
| "application/json": { | ||
| "schema": { "$ref": "#/components/schemas/Error" } | ||
| "schema": { | ||
| "$ref": "#/components/schemas/Error" | ||
| } | ||
| } | ||
@@ -288,8 +378,13 @@ } | ||
| }, | ||
| "required": ["id", "name"] | ||
| "required": [ | ||
| "id", | ||
| "name" | ||
| ] | ||
| }, | ||
| "Market": { | ||
| "allOf": [ | ||
| { "$ref": "#/components/schemas/MarketListItem" }, | ||
| { | ||
| "$ref": "#/components/schemas/MarketListItem" | ||
| }, | ||
| { | ||
| "type": "object", | ||
@@ -350,4 +445,8 @@ "properties": { | ||
| "properties": { | ||
| "data": { "$ref": "#/components/schemas/MarketListItem" }, | ||
| "links": { "$ref": "#/components/schemas/SelfLink" } | ||
| "data": { | ||
| "$ref": "#/components/schemas/MarketListItem" | ||
| }, | ||
| "links": { | ||
| "$ref": "#/components/schemas/SelfLink" | ||
| } | ||
| } | ||
@@ -363,3 +462,6 @@ } | ||
| }, | ||
| "required": ["data", "links"] | ||
| "required": [ | ||
| "data", | ||
| "links" | ||
| ] | ||
| }, | ||
@@ -372,5 +474,10 @@ "MarketEntityResponse": { | ||
| }, | ||
| "links": { "$ref": "#/components/schemas/SelfLink" } | ||
| "links": { | ||
| "$ref": "#/components/schemas/SelfLink" | ||
| } | ||
| }, | ||
| "required": ["data", "links"] | ||
| "required": [ | ||
| "data", | ||
| "links" | ||
| ] | ||
| }, | ||
@@ -431,4 +538,6 @@ "InstrumentListItem": { | ||
| "allOf": [ | ||
| { "$ref": "#/components/schemas/InstrumentListItem" }, | ||
| { | ||
| "$ref": "#/components/schemas/InstrumentListItem" | ||
| }, | ||
| { | ||
| "type": "object", | ||
@@ -445,3 +554,6 @@ "properties": { | ||
| }, | ||
| "required": ["lastValidDate", "lastValidDateTime"] | ||
| "required": [ | ||
| "lastValidDate", | ||
| "lastValidDateTime" | ||
| ] | ||
| } | ||
@@ -458,4 +570,8 @@ ] | ||
| "properties": { | ||
| "data": { "$ref": "#/components/schemas/InstrumentListItem" }, | ||
| "links": { "$ref": "#/components/schemas/SelfLink" } | ||
| "data": { | ||
| "$ref": "#/components/schemas/InstrumentListItem" | ||
| }, | ||
| "links": { | ||
| "$ref": "#/components/schemas/SelfLink" | ||
| } | ||
| } | ||
@@ -471,3 +587,6 @@ } | ||
| }, | ||
| "required": ["data", "links"] | ||
| "required": [ | ||
| "data", | ||
| "links" | ||
| ] | ||
| }, | ||
@@ -484,3 +603,6 @@ "InstrumentEntityResponse": { | ||
| }, | ||
| "required": ["data", "links"] | ||
| "required": [ | ||
| "data", | ||
| "links" | ||
| ] | ||
| }, | ||
@@ -494,3 +616,5 @@ "SelfLink": { | ||
| }, | ||
| "required": ["self"] | ||
| "required": [ | ||
| "self" | ||
| ] | ||
| }, | ||
@@ -516,3 +640,5 @@ "PaginationLinks": { | ||
| }, | ||
| "required": ["self"] | ||
| "required": [ | ||
| "self" | ||
| ] | ||
| }, | ||
@@ -546,3 +672,6 @@ "PaginationMeta": { | ||
| }, | ||
| "required": ["code", "message"] | ||
| "required": [ | ||
| "code", | ||
| "message" | ||
| ] | ||
| } | ||
@@ -558,2 +687,2 @@ }, | ||
| } | ||
| } | ||
| } |
+9
-0
| import { | ||
| ForbiddenError, | ||
| InternalServerError, | ||
| NotImplementedError, | ||
@@ -37,2 +38,10 @@ type PartiallySerialized, | ||
| }, | ||
| '/header/extract': { | ||
| get: { | ||
| handler: async ({ headers }) => { | ||
| if (!headers['x-test-value']) throw new InternalServerError() | ||
| return [200, { data: headers['x-test-value'] }] | ||
| }, | ||
| }, | ||
| }, | ||
| '/instruments/:isin': { | ||
@@ -39,0 +48,0 @@ get: { |
35009
12.52%864
26.5%4
33.33%+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated