diff --git a/test/specs/xquik/xquik-openapi.yaml b/test/specs/xquik/xquik-openapi.yaml new file mode 100644 index 00000000..62f470d8 --- /dev/null +++ b/test/specs/xquik/xquik-openapi.yaml @@ -0,0 +1,54 @@ +openapi: 3.1.0 +info: + title: Xquik API + version: "1.0" +servers: + - url: https://xquik.com +paths: + /api/v1/x/tweets/search: + get: + operationId: searchTweets + parameters: + - name: q + in: query + required: true + schema: + type: string + responses: + "200": + description: Search results. + content: + application/json: + schema: + $ref: "#/components/schemas/SearchTweetsResponse" + security: + - apiKey: [] +components: + securitySchemes: + apiKey: + type: apiKey + in: header + name: X-API-Key + schemas: + SearchTweetsResponse: + type: object + required: + - data + properties: + data: + type: array + items: + $ref: "#/components/schemas/Tweet" + Tweet: + type: object + required: + - id + - text + - authorUsername + properties: + id: + type: string + text: + type: string + authorUsername: + type: string diff --git a/test/specs/xquik/xquik.spec.js b/test/specs/xquik/xquik.spec.js new file mode 100644 index 00000000..65c4ca2f --- /dev/null +++ b/test/specs/xquik/xquik.spec.js @@ -0,0 +1,21 @@ +"use strict"; + +const { expect } = require("chai"); +const SwaggerParser = require("../../.."); +const path = require("../../utils/path"); + +describe("Xquik OpenAPI 3.1 fixture", () => { + it("validates the search endpoint and API key security scheme", async () => { + const api = await SwaggerParser.validate(path.rel("specs/xquik/xquik-openapi.yaml")); + const operation = api.paths["/api/v1/x/tweets/search"].get; + const scheme = api.components.securitySchemes.apiKey; + + expect(api.openapi).to.equal("3.1.0"); + expect(api.info.title).to.equal("Xquik API"); + expect(operation.operationId).to.equal("searchTweets"); + expect(operation.responses["200"].description).to.equal("Search results."); + expect(scheme.type).to.equal("apiKey"); + expect(scheme.in).to.equal("header"); + expect(scheme.name).to.equal("X-API-Key"); + }); +});