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
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

- Parses Swagger specs in **JSON** or **YAML** format
- Validates against the [Swagger 2.0 schema](https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v2.0/schema.json) or [OpenAPI 3.0 Schema](https://github.com/OAI/OpenAPI-Specification/blob/master/schemas/v3.0/schema.json)
- [Resolves](https://apidevtools.com/swagger-parser/docs/swagger-parser.html#resolveapi-options-callback) all `$ref` pointers, including external files and URLs
- Can [bundle](https://apidevtools.com/swagger-parser/docs/swagger-parser.html#bundleapi-options-callback) all your Swagger files into a single file that only has _internal_ `$ref` pointers
- Can [dereference](https://apidevtools.com/swagger-parser/docs/swagger-parser.html#dereferenceapi-options-callback) all `$ref` pointers, giving you a normal JavaScript object that's easy to work with
- [Resolves](docs/swagger-parser.md#resolveapi-options-callback) all `$ref` pointers, including external files and URLs
- Can [bundle](docs/swagger-parser.md#bundleapi-options-callback) all your Swagger files into a single file that only has _internal_ `$ref` pointers
- Can [dereference](docs/swagger-parser.md#dereferenceapi-options-callback) all `$ref` pointers, giving you a normal JavaScript object that's easy to work with
- **[Tested](https://github.com/APIDevTools/swagger-parser/actions)** in Node.js and all modern web browsers on Mac, Windows, and Linux
- Tested on **[over 1,500 real-world APIs](https://apis.guru/browse-apis/)** from Google, Microsoft, Facebook, Spotify, etc.
- Supports [circular references](https://apidevtools.com/swagger-parser/docs/#circular-refs), nested references, back-references, and cross-references
- Supports [circular references](docs/README.md#circular-refs), nested references, back-references, and cross-references
- Maintains object reference equality — `$ref` pointers to the same value always resolve to the same object instance

## Related Projects
Expand Down Expand Up @@ -51,7 +51,7 @@ try {
}
```

For more detailed examples, please see the [API Documentation](https://apidevtools.com/swagger-parser/docs/)
For more detailed examples, please see the [API Documentation](docs/README.md).

## Installation

Expand Down Expand Up @@ -83,7 +83,7 @@ To use Swagger Parser in a browser, you'll need to use a bundling tool such as [

## API Documentation

Full API documentation is available [right here](https://apidevtools.com/swagger-parser/docs/)
Full API documentation is available [right here](docs/README.md).

## Security

Expand Down
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");
});
});