@eropple/fastify-openapi3
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -13,3 +13,3 @@ import { TypeGuard } from "@sinclair/typebox/guard"; | ||
// but it does add time to plugin startup. | ||
if (isFalsy(s.type)) { | ||
if (isFalsy(s.type) && !s.allOf && !s.anyOf && !s.oneOf) { | ||
throw new Error(`Schema object has no type: ${JSON.stringify(s)}`); | ||
@@ -16,0 +16,0 @@ } |
{ | ||
"name": "@eropple/fastify-openapi3", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"author": "Ed Ropple", | ||
@@ -5,0 +5,0 @@ "license": "LGPL-3.0", |
@@ -34,3 +34,3 @@ import { | ||
// but it does add time to plugin startup. | ||
if (isFalsy(s.type)) { | ||
if (isFalsy(s.type) && !s.allOf && !s.anyOf && !s.oneOf) { | ||
throw new Error(`Schema object has no type: ${JSON.stringify(s)}`); | ||
@@ -37,0 +37,0 @@ } |
@@ -10,2 +10,3 @@ import { OpenAPIObject, OperationObject, SchemaObject } from 'openapi3-ts'; | ||
import { APPLICATION_JSON, SCHEMA_NAME_PROPERTY } from '../src/constants.js'; | ||
import { UnionOneOf } from './typebox-ext.js'; | ||
@@ -27,2 +28,6 @@ const typeA = schemaType('MyTypeA', Type.Object({})); | ||
const oneOfType = schemaType('OneOfType', UnionOneOf([ | ||
Type.Literal('a'), | ||
Type.Literal('b'), | ||
])); | ||
@@ -152,3 +157,3 @@ const baseOas: OpenAPIObject = { | ||
test('finds nested tagged schema', () => { | ||
test('finds nested tagged schema in objects', () => { | ||
const oas: OpenAPIObject = { | ||
@@ -169,3 +174,3 @@ ...baseOas, | ||
test('finds tagged schema in arrays', () => { | ||
test('finds nested tagged schema in arrays', () => { | ||
const oas: OpenAPIObject = { | ||
@@ -186,2 +191,18 @@ ...baseOas, | ||
test('correctly finds oneOf/anyOf schemas (despite not having types)', () => { | ||
const oas: OpenAPIObject = { | ||
...baseOas, | ||
components: { | ||
schemas: { | ||
'OneOfType': oneOfType, | ||
} | ||
} | ||
}; | ||
const schemaKeys = [ | ||
...new Set([...findTaggedSchemas(oas).map(s => s[SCHEMA_NAME_PROPERTY])]), | ||
]; | ||
expect(schemaKeys).toHaveLength(1); | ||
}); | ||
// TODO: test for callback | ||
@@ -188,0 +209,0 @@ // I'm confident it works (as it duplicates request body syntax), but we should have |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
163186
64
2300