Skip to content

Commit

Permalink
Merge 0b555f8 into eeb8216
Browse files Browse the repository at this point in the history
  • Loading branch information
kylef committed Jan 18, 2019
2 parents eeb8216 + 0b555f8 commit 2e4cd08
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/parse.js
Expand Up @@ -2,6 +2,7 @@ const fury = require('fury');

fury.use(require('fury-adapter-apib-parser'));
fury.use(require('fury-adapter-swagger'));
fury.use(require('fury-adapter-oas3-parser'));

function createWarning(message) {
const annotationElement = new fury.minim.elements.Annotation(message);
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -28,6 +28,7 @@
"dependencies": {
"fury": "3.0.0-beta.8",
"fury-adapter-apib-parser": "0.12.0",
"fury-adapter-oas3-parser": "0.3.0",
"fury-adapter-swagger": "0.23.1",
"uri-template": "1.0.1"
},
Expand Down
7 changes: 7 additions & 0 deletions test/fixtures/index.js
Expand Up @@ -15,6 +15,7 @@ const fromFile = filename => fs.readFileSync(path.join(__dirname, filename)).toS
const FORMAT_NAMES = {
apib: 'API Blueprint',
openapi2: 'OpenAPI 2',
openapi3: 'OpenAPI 3',
};

// Fixture factory. Makes sure the fixtures are available both as an iterable
Expand Down Expand Up @@ -62,6 +63,7 @@ const fixtures = {
empty: fixture({
apib: '',
openapi2: '',
openapi3: '',
}),
ordinary: fixture({
apib: fromFile('./apib/ordinary.apib'),
Expand Down Expand Up @@ -194,6 +196,11 @@ const fixtures = {
defaultResponse: fixture({
openapi2: fromFile('./openapi2/default-response.yml'),
}),

// Specific to OpenAPI 3
proofOfConcept: fixture({
openapi3: fromFile('./openapi3/proof-of-concept.yml'),
}),
};

module.exports = fixtures;
109 changes: 109 additions & 0 deletions test/fixtures/openapi3/proof-of-concept.yml
@@ -0,0 +1,109 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int32
responses:
'200':
description: A paged array of pets
headers:
x-next:
description: A link to the next page of responses
schema:
type: string
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
'201':
description: Null response
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
/pets/{petId}:
parameters:
- name: petId
in: path
required: true
description: The id of the pet to retrieve
schema:
type: string
get:
summary: Info for a specific pet
operationId: showPetById
tags:
- pets
responses:
'200':
description: Expected response to a valid request
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
24 changes: 24 additions & 0 deletions test/integration/compile-openapi3-test.js
@@ -0,0 +1,24 @@
const createCompilationResultSchema = require('../schemas/compilation-result');
const fixtures = require('../fixtures');

const { assert, compileFixture } = require('../utils');

describe('compile() · OpenAPI 3', () => {
describe('ordinary, valid API description', () => {
let compilationResult;

before((done) => {
compileFixture(fixtures.proofOfConcept.openapi3, (err, result) => {
compilationResult = result;
done(err);
});
});

it('produces some annotation and some transactions', () => {
assert.jsonSchema(compilationResult, createCompilationResultSchema({
annotations: [1],
transactions: [1],
}));
});
});
});

0 comments on commit 2e4cd08

Please sign in to comment.