Code Monkey home page Code Monkey logo

jasyncapi-idea-plugin's People

Contributors

pakisan avatar philcryoport avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jasyncapi-idea-plugin's Issues

[1.2.0-RC] WebSocket renderer doesn't work

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:

"Error: The `asyncapi` field is missing." when trying preview of sample schema

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.

  1. Right-Click in project folder. New ->AsyncAPI Schema
  2. Name the file test.json or test.yaml (tried both)
  3. open the file and push one of the preview buttons (Edge or Built-In)
  4. Preview-Window or browser shows the error "Error: The 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.

Suggestions is not working

IntelliJ IDEA 2021.3.3

Just installed AsyncAPI 1.5.0+idea2021

and suggestions is not working totally for me

Could you please advise on how to fix this? Or trace exact problem

image

Thanks!

Validate referenced objects

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:

  • Validate referenced object by their type

Different behaviour of _ij_reload in 2021.1 and 2021.2

Research why _ij_reload=RELOAD_ON_SAVE has different behaviour in 2021.1, 2021.2 IDEA

Differences:

  • 2021.1 ignores RELOAD_ON_SAVE which causes reloading while editing
  • 2021.2 respects RELOAD_ON_SAVE and reloads on after saving

I think that 2021.1 has different parameter name or knows nothing about it.

References:

Implement reload on save for AsyncAPI schema preview

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]

Does not work with windows

            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`

Resolution of relative path Avro schema files doesn't work properly

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

Plugin is available only from 2021.2

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.*")
 }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.