You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Seems like examples rely on an internal 'id' field to identify them within the express-openapi-validator lib. If you have multiple examples, and they share the same ID - requests to your API error out.
Error: reference "1234" resolves to more than one schema
To Reproduce
git clone git@github.com:HairyMike/bug-express-openapi-validator.git
cd bug-express-openapi-validator.git & npm i & node index.js &
curl http://localhost:3000/v1/test
Actual behavior
I get the following message:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Error: reference "1234" resolves to more than one schema<br> at ambiguos (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/ajv/dist/compile/resolve.js:151:16)<br> at Ajv.addRef (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/ajv/dist/compile/resolve.js:118:23)<br> at /Users/michael.eller/nodejs/bug-open-api-validator/node_modules/ajv/dist/compile/resolve.js:109:29<br> at _traverse (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/json-schema-traverse/index.js:69:5)<br> at _traverse (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/json-schema-traverse/index.js:83:9)<br> at _traverse (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/json-schema-traverse/index.js:83:9)<br> at _traverse (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/json-schema-traverse/index.js:83:9)<br> at _traverse (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/json-schema-traverse/index.js:83:9)<br> at _traverse (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/json-schema-traverse/index.js:83:9)<br> at module.exports (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/json-schema-traverse/index.js:14:3)</pre>
</body>
</html>
Error: reference "1234" resolves to more than one schema
at ambiguos (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/ajv/dist/compile/resolve.js:151:16)
at Ajv.addRef (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/ajv/dist/compile/resolve.js:118:23)
at /Users/michael.eller/nodejs/bug-open-api-validator/node_modules/ajv/dist/compile/resolve.js:109:29
at _traverse (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/json-schema-traverse/index.js:69:5)
at _traverse (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/json-schema-traverse/index.js:83:9)
at _traverse (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/json-schema-traverse/index.js:83:9)
at _traverse (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/json-schema-traverse/index.js:83:9)
at _traverse (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/json-schema-traverse/index.js:83:9)
at _traverse (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/json-schema-traverse/index.js:83:9)
at module.exports (/Users/michael.eller/nodejs/bug-open-api-validator/node_modules/json-schema-traverse/index.js:14:3)
Expected behavior
Should see:
hello world
Examples and context
This is the open-api snippet that is causing the issue. Note the identical IDs:
components:
schemas:
ExampleResponse:
type: object
examples:
FirstExample:
value:
title: Bug Example
description: Error example (same ID as other example), but valid open-api document
content:
id: '1234'
SecondExample:
value:
title: Bug Example
description: Error example (same ID as other example), but valid open-api document
content:
id: '1234'
The text was updated successfully, but these errors were encountered:
Describe the bug
Seems like examples rely on an internal 'id' field to identify them within the
express-openapi-validator
lib. If you have multiple examples, and they share the same ID - requests to your API error out.Example open-api doc here: https://github.com/HairyMike/bug-express-openapi-validator/blob/master/openapi.yaml
You will get a response like this:
To Reproduce
Actual behavior
I get the following message:
Expected behavior
Should see:
Examples and context
This is the open-api snippet that is causing the issue. Note the identical IDs:
The text was updated successfully, but these errors were encountered: