Quarkus rest-easy reactive AWS lamda application is not showing the swagger-ui page in qa env - quarkus-reactive

My Quarkus rest-easy reactive application shows good the OpenAPI swagger docs in local.
http://localhost:8080/q/swagger-ui
I used the below gradle dependnecy
io.quarkus:quarkus-smallrye-openapi
But not showing in the deployed env of QA AWS as a server less lamda application.
{myapplicationHost}/q/swagger-ui gives a blank page and I observed 502 status for below resources
http://{myapplicationHost}/q/swagger-ui/swagger-ui-standalone-preset.js
http://{myapplicationHost}/q/swagger-ui/swagger-ui-bundle.js
I have tried many Options
I had the property in my application.properties
Based on the quarkus docs I have tried with
quarkus.swagger-ui.always-include=true
quarkus.swagger-ui.enable=true
None of them solved the problem. Can you please suggest me if I miss any thing. Thanks.

Related

Open API (Swagger) non working in Spring Boot when adding context path

I have a Spring Boot application exposing REST services that are easily called on addresses like
http://localhost:8080/<controller_mapping>/<service_mapping>.
I've been asked to modify my settings in order to add a context path and have my services to respond on
http://localhost:8080//gesev-mensa/<controller_mapping>/<service_mapping>.
Thus I edited my application.properties adding
server.servlet.context-path=/gesev-mensa
Everything works but I can't call Swagger on old address
http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/
I get the error Failed to load remote configuration
As suggested, I tried to add property
springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html
but problem persists.
I guess Swagger should be reachable at
http://localhost:8080/gesev-mensa/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/
but that doesn't work.
Any hint?
Thanks for support.
Try removing
springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html
from your properties,
And your swagger will be available in
http://localhost:8080/gesev-mensa/swagger-ui/index.html
As per your current configuration with,
springdoc.swagger-ui.path=/gesev-mensa/swagger-ui/index.html
Swagger will be available in
http://localhost:8080/gesev-mensa/gesev-mensa/swagger-ui/index.html

springdoc-openapi generate openapi yaml on build without server

I have a Spring boot Gradle project and I want to get it's OpenAPI spec YAML file.
As I understand the official swagger-core does not support Spring boot projects, thus I found springdoc-openapi (https://github.com/springdoc/springdoc-openapi-gradle-plugin).
It seems that in order to get the YAML/JSON files, when running the generateOpenApiDocs task, the springdoc library sets up a server with some endpoints (/v3/api-docs) to download the files.
I'm using the default configuration, and for some reason I keep getting the following error:
Execution failed for task 'generateOpenApiDocs'.
Unable to connect to http://localhost:8080/v3/api-docs waited for 30 seconds
It seems that for some reason it does not set up the server. How can I fix it?
Is it possible to skip the server part? Can I configure springdoc to simply generate files on build?
If you are deploying REST APIs with spring-boot, you are relying on a servlet container.
The necessry metadata for the OpenAPI spec are only available by spring framework on runtime, which explains the choice of generation at runtime.
You can define any embeded servlet container, during your integration tests to generate the OpenAPI Spec.
This is how I resolved the issue
Specify the path
In your properties file enter:
springdoc:
api-docs:
path: /{your path}
Configure the plugin
In your build.gradle file enter:
openApi {
apiDocsUrl.set("http://localhost:{your port}/your path)
}
This happens because sometimes embedded server took sometime to start and it has 30 sec default setting. Please add the below properties in your openAPI block and it will work fine for you. Please see the below sample:
openApi {
apiDocsUrl.set("http://localhost:9090/v3/api-docs.yaml")
outputDir.set(file("Your Directory path"))
outputFileName.set("openapi.yaml")
forkProperties.set("-Dserver.port=9090")
waitTimeInSeconds.set(60)
}
You need to add the dependency below, an updated version may exist depending on when you're seeing this - intellij would tell you and help upgrade:
implementation('org.springdoc:springdoc-openapi-ui:1.6.11')
Then add the line below to your application.properties file:
springdoc.api-docs.path=/api-docs
Perhaps also get rid of the plugin, it's not necessary as long as you have the above dependency. I got rid of mine and things work fine.
After the dependency is resolved, run the app normally with intellij run buttons or the commandline.
With the app running, visit http://localhost:8080/swagger-ui/index.html - assuming your app is running on port 8080. If not, use the right port accordingly.
Also, you can check out https://github.com/springdoc/springdoc-openapi-gradle-plugin/issues/10 and https://github.com/springdoc/springdoc-openapi-gradle-plugin/issues/10#issuecomment-594010078 - those were helpful when I faced the same issue, showed me part of what to do.

Adding swagger to existing aws lambda (API Gateway)

Does anyone know of a link to a useful documentation on how to add swagger documentation to an existing aws lambda (API Gateway)? Some sort of a noob tutorial as I am totally new to swagger.
I have found some links, such as the following, which were not so useful or not specific to lambda:
https://blog.cloudboost.io/adding-swagger-to-existing-node-js-project-92a6624b855b
https://github.com/swagger-api/swagger-node
I have only used Swagger with API Gateway with the old v0.5 version of serverless framework as there was a plugin that supported this easily.
However, when serverless matured into v1.0 and up, at that time, there were no good plugins for Swagger integration.
Here are links you can check:
Serverless Github Issue: Swagger Integration
Reckon-Limited/serverless_swagger
doapp-ryanp/serverless-plugin-swag
I don't personally use the above though as my big serverless projects are now using GraphQL (where API documentation is part of the standard tooling :-) instead of REST.
In my backend team we do the documentation using a tool that smart bear makes available, the swagger inspector and through it we finish adjusting the doc with the swagger hub.
Swagger inspector makes a request on your endpoint and basically extracts the necessary documentation, but some things you need to adjust, it is not the best solution, but it helps ...

How to set up a swagger-ui standalone server/application?

I would like to set up a standalone swagger-ui application, to view the different APIs from different servers in one central place.
In a second step I would like to customise swagger-ui to show multiple APIs at once.
I don't want to add swagger-ui to all the servers that provide swagger api-docs though.
To do so I would like to use spring boot and thought this should be an easy task. However, I have trouble getting it to work.
Here is what I did:
Generated a Spring Boot application using https://start.spring.io
included spring-boot-starter-web
added io.springfox:springfox-swagger-ui:2.3.1 dependency
When opening http://localhost:8080/swagger-ui.html I see a 404 error and UI seems broken:
Is there any reason for using Spring-boot instead of a simple web server for this?
See for example here with Nginx, including some basic authentication (pretty old link but still looking alright), or in the ReadMe of the swagger-ui github reposiory directly for easily serving with Connect/gulp-serve inside Docker (the setup can also be reproduced directly without Docker if wanted).
Also I have no idea why you're getting resources requested by the page on a different port... Just ask in case you still need help now on this topic.

Spring YARN: How to create a Tracking UI and correctly wire a proxy to it?

I want to deploy an application with a web interface. I want to use Spring YARN for this because that eases all the basic setup, and I can start the application with java -jar.
What steps do I have to do to:
have my application expose a web interface
have the tracking URI I get when submitting it proxy to that web interface
Unfortunately, I cannot find anything about this on the net, there is npthing on that particular issue in the Spring documentation and Google searches do not get me the correct results either.
Easiest way to do this is simply use Spring YARN Boot application model and framework is then trying to do the heavy lifting on your behalf. I actually showed a demo of this during my session at SpringOne 2GX 2014. You can find my session recording from youtube https://www.youtube.com/watch?v=qlvX7_r9aUA.
Interesting stuff for this particular feature is at the end (starting from 1:16:22) and you can see how web server address is registered into YARN resource manager and how I query it using a Spring YARN Boot CLI (around 1:32:13). Spring YARN will actually see that there is an embedded servlet context and registers it automatically. In this demo property "server.port=0" makes tomcat to choose random port which is then registered.
Code for this particular UI demo can be found from github https://github.com/SpringOne2GX-2014/JanneValkealahti-SpringYarn/tree/master/gs-yarn-rabbit. Demo was around RabbitMQ just to have some real UI functionality and not just a dummy hello world page.
There's also more up-to-date sample in https://github.com/spring-projects/spring-hadoop-samples/tree/master/boot/yarn-store-groups which doesn't have a real UI(just Boot management endpoints). Thought it's relatively easy to add Spring MVC magic there just by following normal Boot functionality(i.e. following https://spring.io/guides/gs/rest-service).
Lemmy know if this helps!

Resources