Questions about how the quarkus framework integrates with knife4j #41168
Sparkel-wsl
started this conversation in
Community
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Recently I used the swagger-ui he started on the quarkus project and found the native swagger-ui very difficult to use, and I want to port knife4j pages to the quarkus project. So I read the knife4j source code and found that knife4j essentially uses springdoc-openapi. After entering the knife4j home page, I will call the /v3/api-docs/swagger-config interface. This interface is also provided by springdoc-openapi, which returns some project documentation information and the address to get interface information, such as {{{}}
"configUrl": "/v3/api-docs/swagger-config",
"oauth2RedirectUrl": "http://localhost:8085/swagger-ui/oauth2-redirect.html",
"operationsSorter": "alpha",
"tagsSorter": "alpha",
"urls": [
{
"url": "/v3/api-docs/default",
"name": "default"
}
].
"validatorUrl": ""
} The url field in the urls returns the address from which the project fetched interface information. After the /v3/api-docs/swagger-config interface returns, call /v3/api-docs/default to get the interface information. I have basically understood the knife4j process for obtaining interface data, and I plan to transplant it into my quarkus project. After introducing smallrye-openapi into my quarkus project, I can obtain interface information from /q/openapi. However, the /v3/api-docs/swagger-config interface was not provided, so I manually wrote this interface to return the relevant information needed inside. It can be used normally here, and it is considered a successful transplant. The catch is that if I were to use knife4j on other quarkus projects, I would have to repeat the above steps and write the interface separately. I decided that this was not perfect enough, so I planned to write a jar package that would allow quarkus projects to access knife4j pages and provide the /v3/api-docs/swagger-config interface required for knife4j pages. I tried to write such a jar package by myself, but I found that I couldn't do it, because to provide such an interface, I needed to create a quarkus project and introduce some dependencies such as Quarkus-resteasy -reactive, so whether there would be version problems, for example: The quarkus version in the jar package I wrote is 3.2, but the version of the project that introduced this jar package is 3.11 so that there will be different versions of the problem. How do I write this jar package? Can provide http interface with address /v3/api-docs/default without version conflict problem, and can be directly used by other quarkus projects?
Beta Was this translation helpful? Give feedback.
All reactions