Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions test/specs/xquik/xquik-openapi.yaml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions test/specs/xquik/xquik.spec.js
Original file line number Diff line number Diff line change
@@ -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");
});
});