Tx Daniel.

Works like a charm :)

Best
- Gerald

> Daniel Langevin <daniel.lange...@shq.gouv.qc.ca> hat am 3. Februar 2020 20:28 
> geschrieben:
> 
>  
> Yes you Can
> 
> here my sample configuration in SPRING you can adapt it in blueprint.
> 
> after that just call http://yourhostname:8181/rest/XXX/api-doc 
> 
> Hope it's help
> 
> 
> ....
> ....
> ....
> 
> <osgi:reference id="httpService" 
> interface="org.osgi.service.http.HttpService"/>
> <bean id="XXXCamelServlet" 
> class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
> <bean class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
>       init-method="register"
>       destroy-method="unregister">
>       <property name="alias" value="/rest/XXX"/>
>       <property name="httpService" ref="httpService"/>
>       <property name="servlet" ref="XXXCamelServlet"/>
>       <property name="servletName" value="XXXCamelServlet"/>
> 
> </bean>
> 
> <camelContext id="Contexte-ABC-XXX" 
> xmlns="http://camel.apache.org/schema/spring"; trace="false">
> 
> <endpoint id="rte.XXX.rest.api-doc" 
> uri="rest-api:///api-doc?componentName=servlet"/>
> 
> <restConfiguration bindingMode="off" component="servlet"
>                    contextPath="/rest/UTL"
>                    host="{{smx.hostname}}"
>                    apiContextPath="/api-doc" apiContextListing="false"
>                    enableCORS="true">
>   <endpointProperty key="servletName" value="XXXCamelServlet" />
>   <dataFormatProperty key="prettyPrint" value="true"/>
>   <apiProperty key="base.path" value="/rest/UTL"/>
>   <apiProperty key="api.description" value="{{SMIX.ENV}} - REST Services 
> Doc."/>
>   <apiProperty key="api.title" value="Systeme XXX" />
>   <apiProperty key="api.version" value="1.0.4" />
>   <apiProperty key="api.contact.name" value="Company Contact"/>
>   <apiProperty key="api.contact.email" value="name.lastn...@server.org"/>
>   <apiProperty key="api.termsOfService" value="(C) Company 2020"/>
> </restConfiguration>
> 
> <rest path="/echo" consumes="text/html" produces="text/html">
>  <description>XXX - Echo rest service</description>
>  <get uri="ping">
>     <description>XXX - Test de connectivite </description>
>     <route id="rte.XXX.rest.echo">
>         <transform>
>            <constant>{{SMIX.ENV}}/XXX/echo  PONG.</constant>
>         </transform>
>     </route>
>  </get>
> </rest>
> ...
> ...
> ...
> 
> 
> 
> 
> Daniel Langevin
> Direction de l’assistance et des technologies
> Direction des ressources informationnelles
>  
> Société d’habitation du Québec
> Édifice Marie-Guyart
> 1054, rue Louis-Alexandre-Taschereau
> Aile Jacques-Parizeau, 1er étage
> Québec (Québec) G1R 5E7
> Téléphone : 418 643-4035, poste 1191
> Sans frais : 1 800 463-4315
> 
> 
> 
> 
> 
> >>> 
> De :  Gerald Kallas <catsh...@mailbox.org>
> À :   "users@camel.apache.org" <users@camel.apache.org>
> Date :        2020-02-03 12:33
> Objet :       REST API - Swagger file generation?
> 
> Dear community,
> 
> I've following REST API (see below).
> 
> Is it possible to call the endpoint with a special URI to retrieve the 
> Swagger file from the Blueprint defintion?
> 
> Best
> - Gerald
> 
> Configuration XML ..
> 
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";>
> 
>       <reference id="httpService" 
> interface="org.osgi.service.http.HttpService"/>
> 
>       <bean id="camelHttpTransportServlet" 
> class="org.apache.camel.component.servlet.CamelHttpTransportServlet"/>
> 
>       <bean id="servlet" 
> class="org.apache.camel.component.servlet.osgi.OsgiServletRegisterer"
>         init-method="register"
>         destroy-method="unregister">
>               <property name="alias" value="/api"/>
>               <property name="httpService" ref="httpService"/>
>               <property name="servlet" ref="camelHttpTransportServlet"/>
>       </bean>
> 
> </blueprint>
> 
> .. and REST API ..
> 
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";>
> 
>       <camelContext id="isp.routes.RST" 
> xmlns="http://camel.apache.org/schema/blueprint"; streamCache="true">
> 
>               <restConfiguration component="servlet" bindingMode="json" 
> contextPath="/api" port="443">
>                       <dataFormatProperty key="prettyPrint" value="true"/>
>               </restConfiguration>
> 
>               <rest path="/say">
>                       <get uri="/hello" consumes="application/json" 
> id="isp.routes.RST001">
>                               <to uri="direct:hello"/>
>                       </get>
>                       <get uri="/bye" consumes="application/json" 
> id="isp.routes.RST002">
>                               <to uri="direct:bye"/>
>                       </get>
>               </rest>
> 
>               <route id="isp.routes.RST003">
>                       <from uri="direct:hello"/>
>                       <setHeader name="Content-Type">
>                               <constant>application/json</constant>
>                       </setHeader>
>                       <transform>
>                               <constant>{"text": "Hello World"}</constant>
>                       </transform>
>               </route>
> 
>               <route id="isp.routes.RST004">
>                       <from uri="direct:bye"/>
>                       <setHeader name="Content-Type">
>                               <constant>application/json</constant>
>                       </setHeader>
>                       <transform>
>                               <constant>{"text": "Bye World"}</constant>
>                       </transform>
>               </route>
> 
>       </camelContext>
> 
> </blueprint>

Reply via email to