Stream: hapi
Topic: OpenAPI/Swagger Support is Coming
James Agnew (Apr 17 2021 at 20:34):
Thought this might be of interest to HAPI FHIR users. I'm working on an interceptor that will auto-generate OpenAPI documentation based on the server's capabilities.
Would love to hear any feedback you might have: http://hapi.fhir.org/baseR4/swagger-ui/
Jens Villadsen (Apr 17 2021 at 20:59):
Jens Villadsen (Apr 17 2021 at 21:00):
neat ... just don't push the buttons ;)
Jens Villadsen (Apr 17 2021 at 21:01):
eventually it went through ;)
James Agnew (Apr 18 2021 at 12:49):
Heh yeah, a full FHIR server definitely has enough different operations that it basically kills Swagger-UI. I'm trying to figure out how to segment it..
James Agnew (Apr 18 2021 at 18:21):
Ok, I've set it up to segment by resource type in Swagger UI. That makes it way more usable.
Grahame Grieve (Apr 18 2021 at 23:16):
@Gino Canessa has done lots of work on swagger variants
Jordi Cabré (May 31 2021 at 12:41):
Hello everyone!
I'm using hapi-fhir-server-openapi:5.4.0
.
I'm trying to configure OpenApiInterceptor.
It works fine. Nevertheless, it only works when I add StructureDefinition
into suported_resource_types
.
My configuration is:
supported_resource_types:
- Patient
- Organization
- Practitioner
- Coverage
- StructureDefinition
When I remove StructureDefinition
, I'm getting this message on logs:
ExceptionHandlingInterceptor : Failure during REST processing: ca.uhn.fhir.rest.server.exceptions.InvalidRequestException: Unable to process request, this server does not know how to handle resources of type StructureDefinition - Can handle: [Coverage, Organization, Patient, Practitioner, SearchParameter]
Why do I need to add StructureDefinition
in order to openapi works?
Jose Costa Teixeira (Jun 02 2021 at 17:01):
pinging @Brecht Van Vooren for this OpenAPI interceptor
Jordi Cabré (Jun 15 2021 at 14:45):
Is there any way to get graphql schema?
Sarah G (Jul 02 2021 at 13:55):
Hi, does HAPI FHIR Swagger support protected APIs?
NARASIMHA MURTHY (Aug 17 2021 at 01:29):
Hi @Sarah Ghoddousifard
Even I am looking for direction on how to support HAPI FHIR swagger for protected APIs, which have Auth interceptors defined. Please let us know if you have made any progress on that.
Dajung Mun (Aug 18 2021 at 07:56):
Couldn't customize OpenApiInterceptor ?
I want to add a common authentication header to swagger.
Also, could you find out why the scheme-container is hidden in index.css of fhir-openapi?
Because of this, I can't put the auth header in swagger-ui.
Mourad (Sep 16 2021 at 13:32):
Hello guys,
I'm using OpenApi/swagger but I get error when I got to /swagger-ui/
:
- Here is my OpenAPI dependency :
<dependency>
<groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>hapi-fhir-server-openapi</artifactId>
<version>${openapi-version}</version>
</dependency>
-
I'm using hapi 5.5.1
-
here is my code :
@WebServlet(urlPatterns = {"/swagger/*"}, displayName = "FHIR Server")
public class OpenApi extends RestfulServer {
protected final WebApplicationContext myAppCtx;
public OpenApi(WebApplicationContext myAppCtx) {
this.myAppCtx = myAppCtx;
}
@Override
protected void initialize() throws ServletException {
// ... define your resource providers here ...
List<IResourceProvider> providers = new ArrayList<IResourceProvider>();
providers.add(myAppCtx.getBean(CompositionProvider.class));
setResourceProviders(providers);
// Now register the interceptor
OpenApiInterceptor openApiInterceptor = new OpenApiInterceptor();
registerInterceptor(openApiInterceptor);
}
}
- here is the error I get :
16-09-2021 15:25:54.674 [http-nio-47802-exec-3] ERROR c.u.f.r.s.i.ExceptionHandlingInterceptor - Failure during REST processing: java.lang.NullPointerException
java.lang.NullPointerException: null
at ca.uhn.fhir.context.FhirVersionEnum.forVersionString(FhirVersionEnum.java:240)
at ca.uhn.fhir.rest.openapi.OpenApiInterceptor.serveSwaggerUiHtml(OpenApiInterceptor.java:287)
at ca.uhn.fhir.rest.openapi.OpenApiInterceptor.handleResourceRequest(OpenApiInterceptor.java:226)
at ca.uhn.fhir.rest.openapi.OpenApiInterceptor.serveSwaggerUi(OpenApiInterceptor.java:206)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at ca.uhn.fhir.interceptor.executor.BaseInterceptorService$HookInvoker.invoke(BaseInterceptorService.java:563)
at ca.uhn.fhir.interceptor.executor.BaseInterceptorService.doCallHooks(BaseInterceptorService.java:300)
at ca.uhn.fhir.interceptor.executor.BaseInterceptorService.callHooks(BaseInterceptorService.java:289)
at ca.uhn.fhir.rest.server.RestfulServer.handleRequest(RestfulServer.java:1120)
at ca.uhn.fhir.rest.server.RestfulServer.doGet(RestfulServer.java:413)
at ca.uhn.fhir.rest.server.RestfulServer.service(RestfulServer.java:1855)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1747)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Can you tell me how to fix it please ?
Thank you
Hans van Amstel (Oct 26 2021 at 12:53):
I am trying to access: http://hapi.fhir.org/baseR4/swagger-ui/. this results in a timeout. Is this temporary? We are very interested in a swagger/openAPI representation of the FHIR restfull interface. Thanks in advance.
Notification Bot (Oct 26 2021 at 12:54):
Hans van Amstel has marked this topic as resolved.
Notification Bot (Oct 26 2021 at 12:55):
Hans van Amstel has marked this topic as unresolved.
Jens Villadsen (Nov 05 2021 at 15:13):
Jose Costa Teixeira said:
pinging Brecht Van Vooren for this OpenAPI interceptor
It's here: https://github.com/hapifhir/hapi-fhir-jpaserver-starter/pull/287 (among other things)
Jens Villadsen (Nov 05 2021 at 15:15):
to be specific: https://github.com/hapifhir/hapi-fhir-jpaserver-starter/pull/287/files#diff-b4c0421bcb3280a8e738550c830dba197057c515bcdd9579a52cbfe9adca2061R52
Jens Villadsen (Nov 10 2021 at 20:02):
Its added now in https://github.com/hapifhir/hapi-fhir-jpaserver-starter/commit/ea3f10ec86774abfaedf220f46a7b515f9751d26
Jens Villadsen (Nov 10 2021 at 20:02):
@Jose Costa Teixeira
Last updated: Apr 12 2022 at 19:14 UTC