springwolf-core icon indicating copy to clipboard operation
springwolf-core copied to clipboard

AsyncApi doc genearation without root tag

Open strelchm opened this issue 4 years ago • 3 comments

Now my generation document on http://localhost:8086/springwolf/docs is: { "myproject": { "asyncapi": "2.2.0" "info": { .... } ...... } } The root node's "myproject" name is from part of AsyncApiConfig:

    @Bean
    public AsyncApiDocket asyncApiDocket() {
        Info info = Info.builder()
                .version("1.0.0")
                .title("myproject")
                .build();

If I set title to null, NullPointerException hapens.

When i try to generate client schema by AsyncApi generator # ag http://localhost:8086/springwolf/docs @asyncapi/java-spring-template I get the error:

Something went wrong:
Error: The `asyncapi` field is missing.
    at parse (/usr/local/lib/node_modules/@asyncapi/generator/node_modules/@asyncapi/parser/lib/parser.js:72:13)
    at Generator.generateFromString (/usr/local/lib/node_modules/@asyncapi/generator/lib/generator.js:265:28)
    at Generator.generateFromURL (/usr/local/lib/node_modules/@asyncapi/generator/lib/generator.js:298:17)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at /usr/local/lib/node_modules/@asyncapi/generator/cli.js:156:9

In the code of parser.js exception happens if there is no field "asyncapi" in Json (at first level). How can I generate the asyncapi document without root project title tag?

strelchm avatar Jan 28 '22 14:01 strelchm

Thanks for reporting thus issue! This behavior is intentional, but I realize now that it may interrupt flows like yours. I think the more reasonable solution here will be to return the valid asyncapi doc directly from http://localhost:8086/springwolf/docs.

I make the change and then close this issue.

stavshamir avatar Jan 30 '22 07:01 stavshamir

Thanks much for response and project! I had mistake in my message (in asyncApiDocket method), i fixed it, the title now is "myproject"

strelchm avatar Jan 30 '22 07:01 strelchm

Resolved in https://github.com/springwolf/springwolf-core/pull/75

Crain-32 avatar Jun 19 '22 14:06 Crain-32

Finally fixed, will be available in the next release (will require ui update)

stavshamir avatar Oct 15 '22 16:10 stavshamir