Debug SWAGGER on Webspehre Liberty Profile - swagger

I have an JAX-RS application running on IBM Websphere Liberty Profile.
Also I have included SWAGGER 1.5.3.
The application compiles fine and generates swagger files in webapp directory. But when I try to access it via URL, it says NO API FOUND and the spinner keep spinning.
There are no errors registered on browser console neither any errors in server console.
I do not know whats wrong with it, without any errors its hard to debug.
Where can I see the detailed errors/exceptions.

WebSphere Liberty has native support for Swagger v2 using the apiDiscovery-1.0 feature. If you enable that you should see your APIs in https://host:https_port/ibm/api/docs.
By the way, there's support for the newer OpenAPI v3 spec, via the Microprofile OpenAPI programming model. You can use Liberty's mpOpenAPI-1.0 feature for that.

Related

Apache Wicket REST with Swagger UI

One of my project is using Apache Wicket 6.x and I have some API (resources) using wicketstuff-rest and it is working perfectly.
But for my API documentations, I am maintaining a google document for these APIs. Problem is that whenever there are changes in any of the API, or even on new APIs... I need to update this API documentation. Chances are, this documentation may not be updated.
On my other springboot projects, I am using swagger and the API documentation can be viewed via swagger-ui.
I wonder if I can use swagger-ui with existing apache wicket 6.x project so that whenever there are new API(s) or any change on the existing API(s)... it will reflect in swagger-ui without the need to maintain any API documentation.
What I currently search is swagger2markup, but this seems to be old and I am having problems with the setup and there are very few resources on how to set this up.
Anyone who successfully setup swagger-ui with apache wicket rest?
Care to share resource/links on tutorials or how to setup swagger-ui on apache wicket rest?
Thanks!
I don't have an easy solution for you with Swagger but if you use Spring already then you could use Spring REST Docs to generate the documentation from the unit tests.

Springdoc OpenAPI ui does not honor context-path in "location"

Setup:
I am using the Java library springdoc-openapi-ui in version 1.4.0 (via Maven) without any customization in a simple spring-boot project.
The Swagger page is generated under
https://my-url.com/my-context-path/swagger-ui/index.html
and the api-docs under
https://my-url.com/my-context-path/v3/api-docs/
both of these work and I can reach them. So far so good!
Now the problem:
When simply navigating to https://my-url.com/my-context-path/swagger-ui.html I am getting a HTTP Status 302 and a location attribute set in the response header that is supposed to redirect me to the swagger page from above (I assume).
However, the URL in the location attribute misses the context path! It looks like this:
https://my-url.com/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config
It redirects to a page that does not exist and I am getting a 404 error code. Note, that the configUrl also seems to be missing the context-path.
Any ideas why this occurs and how it can be fixed?
This Github Issue seemed to be the same problem, but in the end it is stated that the problem is fixed: https://github.com/springdoc/springdoc-openapi/issues/37 and that is for a previous version than mine.
Okay so the issue is that springdoc-openapi-ui is unaware of your app context path unless it is defined in spring boot, which may not be possible for everybody.
Hopefull it does support the non-standard header X-Forwarded-Prefix that can be sent by your gateway.
I my case (Kubernetes), the Ingress can be configured in your chart by simply adding nginx.ingress.kubernetes.io/x-forwarded-prefix: "true"
And in your application config you also need to specify
server:
forward-headers-strategy: framework
to use Spring's support for handling forwarded headers.
Sources:
https://github.com/kubernetes/ingress-nginx/issues/3670
https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#x-forwarded-prefix-header
https://github.com/springdoc/springdoc-openapi/issues/607
There are no know issues about context-path usage. As you can #37 is resolved and that reported it has confirmed that!
Just make sure you follow the instructions of setting context-path on standard spring-boot application.
You can test the configuration of your context path, in the different demos samples:
https://github.com/springdoc/springdoc-openapi-demos
If you have any problem, you can log an issue by provinding a minimal/reproducible sample or with unit tests that reproduces the problem.
In order to configure a swagger-ui correctly when an external context-path is configured use the follow configuration.
springdoc.swagger-ui.config-url=/context-path/api-docs/swagger-config
springdoc.swagger-ui.url=/context-path/api-docs
springdoc.api-docs.path=/api-docs

ASPNetBoilerPlate and Swagger UI All API Calls Return 400 Error

I have created a new application using the ASPNetBoilerplate MVC 5x template. I have integrated Swagger UI according to the link:
https://aspnetboilerplate.com/Pages/Documents/Swagger-UI-Integration
Again using the MVC 5x version
When I run the app and use http://localhost:/swagger to access the API and try to run any of the GetAll methods, I get a 400 error.
I have modified the .cs file and created the .js files by cutting the code directly from the documentation and made the required changes.
What am I missing?
Thanks
I hope you are not navigating to http://localhost:/swagger because there's a typo error. Correct url is http://localhost/swagger
There's no official support for bearer token for Swagger UI Api calls. But you can checkout the link below. A developer achieves what you want
https://github.com/aspnetboilerplate/module-zero-core-template/pull/87

Glassfish 4 Web Profile - Cannot access remote EJB

I cannot access remote EJB beans of our application server within a web application running on Glassfish 3 web-profile using jndi lookup.
Using full profile for our web-application or even testing with a console application we have no problem accessing jndi remote beans.
Exception:
Unable to acquire SerialContextProvider for SerialContext
We just hoped to make our web servers more lightweight.
The Web Profile version of Glassfish only contains EJB Lite, which doesn't support #Remote interfaces. You need the Full Profile which supports the full EJB 3 spec.
From the oracle docs:
The Web Profile of the GlassFishTM Server supports the EJB 3.1 Lite
specification, which allows enterprise beans within web applications,
among other features. The full GlassFish Server supports the entire
EJB 3.1 specification. For details, see JSR 318.
You can find a comparision of features included in Web Profile and Full Profile here (It was made for Glassfish 3.1.1 but it should be nearly the same for Glassfish 4 except some newer versions of some features). You can find a nice feature comparision between EJB 3.1 Lite and Full in this article.
Update:
As you wrote in the comment (and the initial question) you are not using any enterprise beans directly in your web application, but you are retrieving bean instances via JNDI. This doesn't work with the Web Profile of Glassfish because the functionality for remote lookups is not there, e.g. the CORBA and ORB modules are missing (there are some basic CORBA OMG APIs but only because they are needed by other modules).
As your goal was to make the server more lightweight, maybe this is another option for you: You can remove unused components and modules with the pkg command-line-tool or with the graphical utility updatetool. You could install the Full Profile of Glassfish and then remove obsolete components step by step to make the server more lightweight. More details about the tools can be found in the oracle docs.
See also:
Can EJB 3.1 Lite be exposed via Remote interface?
How to know what glassfish is - full plaform or web profile?
EE6 web profile … no EJB container?
GLASSFISH-14459 corba classes are part of web profile

Change Automatic Generated WSDL 2.0 in WSO2 Application Server

How can I change WSDL2.0 of a service that will be deployed on WSO2 Application Server?
I want to change WSDL content of a service that developed and will be deployed on WSO2 Application Server. I moved custom WSDL file to META-INF directory and set useOriginalwsdl=true property. but only WSDL version 1.1 is that affected by this property. I want to use the custom WSDL 2.0 for my service in WSO2 Application Server. How can I do it?
WSO2 Application Server uses Axis2 1.6.x and useOriginalwsdl=true is in fact not supported for WSDL 2.0. See following JIRA.
https://issues.apache.org/jira/browse/AXIS2-5191
According to the JIRA, it is fixed in Axis2 1.7.0, which is not yet released.
If you really want to use that feature, it might be easier to patch the existing version of Axis2. The fix attached to the JIRA is simple, but I'm not really sure how much code changes are required. The patch is provided for axis2 trunk and therefore I cannot really tell without trying first!
Also the code for Axis2 versions used in WSO2 products are in WSO2 repository. For example, WSO2 Application Server 5.1.0 uses axis2 1.6.1-wso2v9 according to Carbon Release Matrix.
I hope this helps!

Resources