-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] refs not resolved with a lot of indirection/nesting #152
Comments
Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request. |
Up to now, I even transformed all JSONs to YAMLs, removed all suspicious characters, and placed them all in one directory, but they are not dereferenced anyway. |
Hello @aeworxet Thanks for your quick response. Please let me know if you need any more info/debugging from my side. |
side-note: if anyone else stumbles upon this issue and needs an urgent fix/workaround: https://www.npmjs.com/package/api-ref-bundler (version 0.4.0) seems to work be able to bundle these files correctly |
I ran [
{
code: 'invalid-ref',
path: [
'components',
'schemas',
'task.v1',
'properties',
'customerOids',
'items',
'$ref'
],
message: "'#/definitions/customerOidType' does not exist",
severity: 0,
range: { start: [Object], end: [Object] }
}
] Changed {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"definitions": {
"customerOidType": {
"type": "string",
"minLength": 1,
"maxLength": 128
},
"customerOidArrayType": {
"type": "array",
"items": {
"type": "string",
"minLength": 1,
"maxLength": 128
}
}
}
} and got asyncapi: 2.6.0
info:
version: 1.4.2
title: demo
defaultContentType: application/json
channels:
task.v1:
publish:
operationId: publishTaskEvent
message:
$ref: '#/components/messages/task.v1'
components:
messages:
task.v1:
name: task.v1
contentType: application/cloudevents+json; charset=utf-8
payload:
$ref: '#/components/schemas/event-task.v1'
schemas:
event-task.v1:
properties:
data:
$ref: '#/components/schemas/task.v1'
task.v1:
$schema: http://json-schema.org/draft-07/schema#
type: object
properties:
customerOids:
description: A list of customer Oids
type: array
items:
type: string
minLength: 1
maxLength: 128 (differs from the expected result)
|
@deiferni, please check if the issue still exists in v0.5.0. |
@aeworxet, yes as far as I can see the issue still persists. I did update my example files in https://github.com/deiferni/asyncapibundlerbrokenexample. After running:
I'm still getting the error:
The file it produces looks like this: https://github.com/deiferni/asyncapibundlerbrokenexample/blob/8d9e933141d57903877cfa3f76b52493e461aff2/bundled.yaml |
In
So all const { writeFileSync } = require('fs');
const bundle = require('@asyncapi/bundler');
async function main() {
const bundledDocument = await bundle('main.yml')
writeFileSync('bundled.yaml', bundledDocument.yml());
}
main().catch((e) => console.error(e)); CLI, however, still uses |
CLI version |
Hey @aeworxet as far as i could see the files are now bundled without error with both the CLI and the bundler package. Thanks! (And sorry for the late reply) Updated files in https://github.com/deiferni/asyncapibundlerbrokenexample/ |
@deiferni |
Describe the bug.
When referenced documents have a lot of indirection some of the $refs are not resolved as I'm expecting. I might be missing something or not using the tooling correctly ... but as far as I could tell this might be a bug.
when i bundle the following files a
$ref
incommonTypes.json
is not resolved correctly. The input files look like this:main.yml
:schema/v1/task.json
:schema/v1/commonTypes.json
:I bundle and validate the files as follows in
bundle.js
:The output file looks like this
bundled.yml
:The issue is in the final line, the
$ref
#/definitions/customerOidType
is not resolved and thus invalid. The validation outputs:I put the failing example in a repo at https://github.com/deiferni/asyncapibundlerbrokenexample for your convenience.
Expected behavior
I would expect the schema to be included in
components.schemas
and be referenced correctly in the bundled file, something like this:Screenshots
IMO a screenshot is not very useful :)
How to Reproduce
node bundle.js
bundled.yaml
🥦 Browser
None
👀 Have you checked for similar open issues?
#151 might be related, but it explicitly mentions v3. We are using an older version.
#141 might also be related, but I'm not completely sure either.
🏢 Have you read the Contributing Guidelines?
Are you willing to work on this issue ?
No, someone else can work on it
The text was updated successfully, but these errors were encountered: