openapi-enforcer
Advanced tools
Comparing version 1.12.8 to 1.13.0
@@ -7,2 +7,8 @@ # Change Log | ||
## 1.13.0 | ||
- **Add getBundledDefinition** | ||
The ref parser already has a bundler function, but now when creating an OpenAPI or Swagger component using the [Enforcer function](https://byu-oit.github.io/openapi-enforcer/api/openapi-enforcer#enforcer) an additional property will be added to get the bundled definition. | ||
## 1.12.8 | ||
@@ -14,3 +20,3 @@ | ||
The operation response function now checks that write only properties are not being sent to the client. | ||
The operation response function now checks that write only properties are not being sent to the client. | ||
@@ -23,3 +29,3 @@ ## 1.12.7 | ||
Although readOnly and writeOnly errors were being caught correctly, the messaging was negative. For example, it would say "Cannot write to read only" when it meant "Cannot read from write only" and vice versa. | ||
Although readOnly and writeOnly errors were being caught correctly, the messaging was negative. For example, it would say "Cannot write to read only" when it meant "Cannot read from write only" and vice versa. | ||
@@ -32,3 +38,3 @@ ## 1.12.6 | ||
The library was incorrectly not accounting for readOnly and writeOnly when using schema validation. This functionality has been added. | ||
The library was incorrectly not accounting for readOnly and writeOnly when using schema validation. This functionality has been added. | ||
@@ -35,0 +41,0 @@ ## 1.12.5 |
@@ -14,2 +14,4 @@ --- | ||
The OpenAPI or Swagger component that is returned will have one additional property, `getBundledDefinition()`, that can be called to get back a JSON object that has the `$refs` resolved to only use a single file. This object can be converted to a string using `JSON.stringify()` to get the bundled definition. | ||
**Parameters:** | ||
@@ -16,0 +18,0 @@ |
@@ -0,0 +0,0 @@ ;(function () { |
11
index.js
@@ -85,2 +85,13 @@ /** | ||
if (exception && exception.hasException) throw Error(exception.toString()); | ||
openapi.getBundledDefinition = async function () { | ||
if (useNewRefParser) { | ||
const result = await refParser.bundle() | ||
if (result.error) throw Error(result.error) | ||
return result.value | ||
} else { | ||
return await refParser.bundle(definition) | ||
} | ||
} | ||
return openapi; | ||
@@ -87,0 +98,0 @@ } |
{ | ||
"name": "openapi-enforcer", | ||
"version": "1.12.8", | ||
"version": "1.13.0", | ||
"description": "Library for validating, parsing, and formatting data against open api schemas.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -88,3 +88,3 @@ const expect = require('chai').expect; | ||
const parser = new RefParser(path.resolve(resourcesDir, 'Value.yaml')); | ||
const [ result ] = await parser.dereference(); | ||
const [ result, err ] = await parser.dereference(); | ||
expect(result.Value['x-key']).to.equal('Value'); | ||
@@ -94,3 +94,3 @@ expect(result.Value.properties.value.type).to.equal('integer'); | ||
it('can handle circular references in same document', async () => { | ||
it('can handle circular references in same object', async () => { | ||
const obj = { | ||
@@ -207,3 +207,3 @@ A: { | ||
it('can identify node source for child http resource', async () => { | ||
const source = parser.getSourcePath(result.People.items.property); | ||
const source = parser.getSourcePath(result.People.items.properties); | ||
expect(source).to.equal('http://localhost:18088/People.yml'); | ||
@@ -274,3 +274,3 @@ }); | ||
const [ value ] = await parser.dereference(); | ||
const source = parser.getSourceNode(value.People.items.property); | ||
const source = parser.getSourceNode(value.People.items.properties); | ||
expect(source).to.haveOwnProperty('Person'); | ||
@@ -381,3 +381,12 @@ expect(source.Person['x-key']).to.equal('Person'); | ||
x: { | ||
type: 'string' | ||
type: 'object', | ||
'x-foo': 'foo', | ||
properties: { | ||
x: { | ||
$ref: '#/schemas/x' | ||
}, | ||
y: { | ||
type: 'number' | ||
} | ||
} | ||
} | ||
@@ -389,3 +398,4 @@ } | ||
const [ bundled ] = await parser.bundle(); | ||
expect(bundled.components.schemas.x).to.deep.equal({ type: 'string' }) | ||
expect(bundled.components.schemas.x['x-foo']).to.equal('foo') | ||
expect(bundled.schemas.x).to.haveOwnProperty('$ref') | ||
}); | ||
@@ -392,0 +402,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
1500492
181
20359