Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenAPI UI + PathParams containing / character #30410

Open
ewoudwerkman opened this issue Dec 13, 2024 · 0 comments
Open

OpenAPI UI + PathParams containing / character #30410

ewoudwerkman opened this issue Dec 13, 2024 · 0 comments

Comments

@ewoudwerkman
Copy link

ewoudwerkman commented Dec 13, 2024

I recently updated my OpenLiberty application from Microprofile 4.1 to 6.1 which includes an upgrade of the OpenAPI spec and implementation. One of the things that is 'fixed' is the OpenAPI UI is the encoding of forward slashes ('/') to their encoded version (%2F) (see swagger-api/swagger-js#1331).

This change breaks OpenLiberty to use path params that are encoded, when using the OpenAPI user interface. For example:

@GET
@Path("/resource/public/{resourceURL:.+}")
public Response getPublicResource(@PathParam("resourceURL") String resourceURL, @Context HttpHeaders headers) {
}

You get the following error when using the /openapi/ui endpoint and using the try-it-out button for the above request:
URI has encoded forward slash [%2F] character.

[INFO] [13-12-2024 10:36:24:042 CET] 0000014e com.ibm.ws.webcontainer.webapp                               E SRVE0315E: An exception occurred: java.lang.Throwable: java.io.IOException: CWWWC0005I: The request URI has invalid or improperly encoded characters: [/store/resource/public/%2Fexported_es.esdl] . URI has encoded forward slash [%2F] character.
[INFO] 	at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:5154)
[INFO] 	at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.handleRequest(DynamicVirtualHost.java:328)
[INFO] 	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1047)
[INFO] 	at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:293)
[INFO] 	at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:1260)
[INFO] 	at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.wrapHandlerAndExecute(HttpDispatcherLink.java:476)
[INFO] 	at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:435)
[INFO] 	at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:569)
[INFO] 	at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:503)
[INFO] 	at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:363)
[INFO] 	at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:330)
[INFO] 	at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:169)
[INFO] 	at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:77)
[INFO] 	at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:516)
[INFO] 	at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:586)
[INFO] 	at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:970)
[INFO] 	at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1059)
[INFO] 	at com.ibm.ws.threading.internal.ExecutorServiceImpl$RunnableWrapper.run(ExecutorServiceImpl.java:298)
[INFO] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
[INFO] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
[INFO] 	at java.base/java.lang.Thread.run(Thread.java:1583)
[INFO] Caused by: java.io.IOException: CWWWC0005I: The request URI has invalid or improperly encoded characters: [/store/resource/public/%2Fexported_es.esdl] . URI has encoded forward slash [%2F] character.
[INFO] 	at com.ibm.wsspi.webcontainer.util.RequestUtils.verifyEncodedCharacter(RequestUtils.java:1087)
[INFO] 	at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1160)
[INFO] 	at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:5096)

StackOverflow shows some hits for Tomcat (e.g. https://stackoverflow.com/questions/38435024/how-can-i-pass-string-path-param-containing-slash-character) and SpringBoot (https://stackoverflow.com/questions/13482020/encoded-slash-2f-with-spring-requestmapping-path-param-gives-http-400/58303792#58303792), but I don't know how I can configure this for OpenLiberty

As I cannot change/configure the OpenAPI UI, is there something I can do to configure OpenLiberty to accept these characters?

@ewoudwerkman ewoudwerkman changed the title OpenAPI + PathParams containing / character OpenAPI UI + PathParams containing / character Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants