Skip to content

Commit cfb55fb

Browse files
authored
fix: allow custom schema formats without validation error
The parser now accepts any string schema format as valid, aligning with the AsyncAPI spec which states custom formats are allowed with optional implementation. Unknown formats are passed through without modification instead of throwing an error.
1 parent 8710f53 commit cfb55fb

File tree

1 file changed

+12
-1
lines changed
  • packages/parser/src/schema-parser

1 file changed

+12
-1
lines changed

packages/parser/src/schema-parser/index.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,21 @@ export async function validateSchema(parser: Parser, input: ValidateSchemaInput)
4646
}
4747

4848
export async function parseSchema(parser: Parser, input: ParseSchemaInput) {
49+
// First validate that format is a string
50+
if (typeof input.schemaFormat !== 'string') {
51+
throw new Error('Schema format must be a string');
52+
}
53+
4954
const schemaParser = parser.parserRegistry.get(input.schemaFormat);
55+
5056
if (schemaParser === undefined) {
51-
throw new Error('Unknown schema format');
57+
// Simply return the schema as-is for unknown formats
58+
return {
59+
parsed: input.data, // Assuming you meant to return input.data instead of input.schema
60+
format: input.schemaFormat
61+
};
5262
}
63+
5364
return schemaParser.parse(input);
5465
}
5566

0 commit comments

Comments
 (0)