pakisan / jasyncapi-idea-plugin Goto Github PK
View Code? Open in Web Editor NEW/jay-sync-api/-idea-plugin is a IDEA plugin for AsyncAPI specification
Home Page: https://plugins.jetbrains.com/plugin/15673-asyncapi
License: Apache License 2.0
/jay-sync-api/-idea-plugin is a IDEA plugin for AsyncAPI specification
Home Page: https://plugins.jetbrains.com/plugin/15673-asyncapi
License: Apache License 2.0
I use WebServerPageConnectionService#fileRequested for reload preview on specification changes. After creation of 1.2.0
release I decided to check it on new versions, not only on 2021.2.
Error occurred when I open preview on 2021.2.2 because of changing of method signature.
java.lang.NoSuchMethodError: 'java.lang.CharSequence org.jetbrains.builtInWebServer.liveReload.WebServerPageConnectionService.fileRequested(io.netty.handler.codec.http.FullHttpRequest, java.util.function.Supplier)'
at com.asyncapi.plugin.idea._core.AsyncAPISchemaHtmlRenderer.render(AsyncAPISchemaHtmlRenderer.kt:54)
at com.asyncapi.plugin.idea.extensions.web.StaticServer$process$resourceHandler$1.handle(StaticServer.kt:47)
at com.asyncapi.plugin.idea.extensions.web.StaticServer.handleRequest(StaticServer.kt:88)
at com.asyncapi.plugin.idea.extensions.web.StaticServer.process(StaticServer.kt:74)
In 2021.1 - 2021.2.1 is:
fun fileRequested(request: FullHttpRequest, fileSupplier: Supplier<out VirtualFile?>): CharSequence?
In 2021.2.2 - 2021.2.3 is:
fun fileRequested(request: FullHttpRequest, onlyIfHtmlFile: Boolean, fileSupplier: Supplier<out VirtualFile?>): CharSequence?
Signature was changed in 2021.2.2 (build 212.5284)
WebServerPageConnectionService.fileRequested's signature was changed in 2021.2.2 (build 212.5284)
Use reflection for calling for proper method. com.intellij.openapi.application.ApplicationInfo#getFullVersion
helps to know which IDEA is using plugin.
I chose it because signature won't be changed in future, and it easier than maintain two releases
Is current signature final variant in 2021.2.3 and will not change in next releases like 2021.3, 2022.*? If so I will left It on a place.
Yes, it won't be changed, at least backward compatibility won't be broken, so please feel free to use it.
References:
Update gradle-intellij-plugin from 1.1.4
to 1.2.1
Hi there,
It would be really useful to display the stated AsyncAPI version in the preview. Please add this? Thank you!
Add AsyncAPI 2.4.0
When I try to preview the file with "Built-In Preview" of intellij or "Edge-Preview" there is only a page showing the error "Error: The asyncapi
field is missing.".
Instead I would expect to see the generated API-Doc.
Steps to reproduce.
asyncapi
field is missing."Used System:
IntelliJ IDEA 2022.1 (Ultimate Edition)
Build #IU-221.5080.210, built on April 12, 2022
Runtime version: 11.0.14.1+1-b2043.25 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 8
Non-Bundled Plugins:
...
com.asyncapi.plugin.idea (1.5.0+idea2021)
...
The same procedure works on my colleague's macbook without errors, so I guess it's a problem with my operating system.
Nothing complicated. Just add support for new AsyncAPI schema versions.
New versions to support:
2.1.0
2.2.0
2.3.0
Update intellij-plugin-verifier from 1.266
to 1.268
First step:
Collect all objects which can be referenced in the 2.1.0
schema
Collect all objects which can be referenced in the 2.2.0
schema
Check that this references for 2.0.0
schema are correct
val possibleReferencesLocation = mapOf(
AsyncAPISchemaIndex.channels to setOf("\$.channels.*.\$ref"),
AsyncAPISchemaIndex.parameters to setOf(
"\$.channels.*.parameters.*.\$ref",
"\$.components.parameters.*.\$ref"
),
AsyncAPISchemaIndex.traits to setOf(
"\$.channels.*.subscribe.traits.*.\$ref",
"\$.channels.*.publish.traits.*.\$ref",
"\$.components.messages.*.traits.*.\$ref"
),
AsyncAPISchemaIndex.messages to setOf(
"\$.channels.*.subscribe.message.\$ref",
"\$.channels.*.publish.message.\$ref",
"\$.components.messages.*.\$ref"
),
AsyncAPISchemaIndex.schemas to setOf("\$.components.schemas.*.\$ref"),
AsyncAPISchemaIndex.securitySchemes to setOf("\$.components.securitySchemes.*.\$ref"),
AsyncAPISchemaIndex.correlationIds to setOf(
"\$.components.messages.*.correlationId.\$ref",
"\$.components.messages.*.traits.*.correlationId.\$ref"
),
AsyncAPISchemaIndex.headers to setOf(
"\$.components.messages.*.headers.\$ref",
"\$.components.messages.*.traits.*.headers.\$ref"
)
)
Second step:
Generate JsonSchema per object which can be referenced in the 2.0.0
specification
Generate JsonSchema per object which can be referenced in the 2.1.0
specification
Generate JsonSchema per object which can be referenced in the 2.2.0
specification
Third step:
Check that plugin collects referenced objects correctly for 2.0.0
Collect referenced objects for 2.1.0
Collect referenced objects for 2.2.0
Fourth step:
Research why _ij_reload=RELOAD_ON_SAVE
has different behaviour in 2021.1
, 2021.2
IDEA
Differences:
RELOAD_ON_SAVE
which causes reloading while editingRELOAD_ON_SAVE
and reloads on after savingI think that 2021.1 has different parameter name or knows nothing about it.
References:
IDEA provides WebSocket for updating preview of document when one of events happens: save, change.
We can obtain embedable code for WebSocket from WebServerPageConnectionService
val ws = WebServerPageConnectionService.instance.fileRequested(request, Supplier<VirtualFile?> { schemaVirtualFile })
Use provided WebSocket for updating of html page in preview of AsyncAPI schema as html in built-in/external browser [#3]
AsyncApiStandalone.render({
schema: {
url: 'http://localhost:63342/asyncapi/resources?schemaUrl=C:\Users\uisee\AppData\Local\Temp\jasyncapi-idea-plugin-1652714434031.yaml',
options: { method: "GET", mode: "cors" },
},
config: {
show: {
sidebar: true,
}
},
}, document.getElementById('asyncapi'));
</script>
`Uncaught SyntaxError: Invalid Unicode escape sequence`
Hello Pavel,
I have a strange issue with local path resolution of locally stored *.avsc files. And actually only with these files.
In the AsyncAPI definition file (*.yml) I have multiple interface channels where I'm using local files references for examples and schema payloads. The definition looks like this:
asyncapi: 2.3.0
channels:
kafka-topic-name:
publish:
message:
name: message_name
description: interface description
schemaFormat: 'application/vnd.apache.avro;version=1.9.0'
examples:
- name: message_example_name
summary: message example summary
payload:
$ref: "./example-folder/filename.json"
payload:
$ref: './schema-folder/LocationUpdated.avsc'
When I'm starting browser preview I see following error message: "Error: Error downloading http://localhost:63342/asyncapi/resources?referenceUrl=/absolute/path/to/the/avro/schema/file/filename.avsc HTTP ERROR 404"
When I'm putting the Avro schema definition directly into the AsyncAPI definition file it works again. The resolution of the example JSON file works in every case.
So I'm not 100-% sure if it's a plugin or AsyncAPI avro parser bug.
When I'm for example running the asyncapi generator (html template) it works without any problem and the external *.avsc files will be properly resolved from the relative path and also properly parsed.
Could you please take a look at that?
Thank you,
Dmitriy
When try to using Intelllij Idea extansion I see that:
Also, when I check inspection profile for AsyncAPI the link in description are broken.
The link is: https://raw.githubusercontent.com/asyncapi/asyncapi/master/versions/2.0.0/schema.json and it 404
Plugin is available only from 2021.2. It's wrong cause supporting range is 2021.1
- 2021.2
. New version 2021.3
is not included because it's in beta state.
Replace this:
tasks.getByName<org.jetbrains.intellij.tasks.PatchPluginXmlTask>("patchPluginXml") {
sinceBuild.set("211.*")
untilBuild.set("212.*")
}
with this:
tasks.getByName<org.jetbrains.intellij.tasks.PatchPluginXmlTask>("patchPluginXml") {
sinceBuild.set("211")
untilBuild.set("212.*")
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.