swagger-editor icon indicating copy to clipboard operation
swagger-editor copied to clipboard

SwaggerEditor@next: use stable version of `@asyncapi/[email protected]`

Open char0n opened this issue 9 months ago • 1 comments

The goal of this issue is to use stable version of @asyncapi/[email protected]. Unfortunately this stable version started to use @asyncapi/[email protected] under the hood which now uses Spectral for validation and reference processing (let's call all these new versions AsyncAPI next gen). This introduced many issues documented below:

Issue 1

It's complicated to bundle Spectral. But, we've already did some work to be able to support it in our building infra: https://github.com/swagger-api/swagger-editor-cra/commit/e7ebbcae834d9fe3574c510a6761a10b40e31e09

The POC of integrating next gen AsyncAPI tooling with Spectral is here: https://github.com/swagger-api/swagger-editor/pull/4446

Issue 2

Due to the fact that @asyncapi/[email protected] now uses Spectral, our bundle size have increased significantly. The parser also does the validation before parsing. We'll have to adapt to that and propagate validation errors to editor markers properly.

More info in https://github.com/asyncapi/parser-js/issues/857

Issue 3

@asyncapi/[email protected] serialization and deserialization it broken when used with @asyncapi/[email protected]. This is essential for us to store parsed AsyncAPI documents in redux. It can be worked around as demonstrated in POC https://github.com/swagger-api/swagger-editor/pull/4446.

More info in: https://github.com/asyncapi/asyncapi-react/issues/769

Issue 4

There is a breaking change in how @asyncapi/[email protected] handles references.

In Parser v1 we use @apidevtools/json-schema-ref-parser and now I see that v2 uses @stoplight/json-ref-resolver which is marked as deprecated and points to @apidevtools/json-schema-ref-parser 😄

We do provide override for AsyncAPI definition parsing which allows to plugin custom logic of URL resolution - https://github.com/swagger-api/swagger-editor/blob/718b04d756d0becc8bada052fbdcd960b7d8d51c/src/plugins/editor-preview-asyncapi/actions.js#L56-L55. It's critical that it functions equivalently.

It seems that the goal of AsyncAPI team is to return back to @apidevtools/json-schema-ref-parser, so it doesn't make sense for us to change own custom resolution mechanism, just to change it back again when the underlying library is switched.

More info in: https://github.com/asyncapi/parser-js/issues/761


For now, we'll stick with last working version of @asyncapi/[email protected] with @asyncapi/[email protected].

char0n avatar Nov 16 '23 10:11 char0n

For now we, we'll stick with last working version of @asyncapi/[email protected] with @asyncapi/[email protected].

This has been addressed in https://github.com/swagger-api/swagger-editor/pull/4586

char0n avatar Nov 16 '23 12:11 char0n

All issues have been addressed in https://github.com/swagger-api/swagger-editor/pull/4446

Issue 1

swagger-editor-cra has been compensated to support Spectral and SwaggerEditor@5 provides instructions for webpack how to overcome Spectral bundling issues.

Issue 2

There is nothing we can do about this. As mentioned in various in AsyncAPI issues, this is the status quo that will stay with AsyncAPI tooling for some time.

Issue 3

Workaround has been utilized.

Issue 4

It's a breaking change. We'll document migration of parser option in release notes.

char0n avatar Mar 28 '24 07:03 char0n