CAMEL-9156: Adding Camel commands for rest api docs
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/55d675b9 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/55d675b9 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/55d675b9 Branch: refs/heads/master Commit: 55d675b941f89e1e4d3b5da2c80257f96fa1eda0 Parents: f69b6ea Author: Claus Ibsen <[email protected]> Authored: Thu Sep 24 15:17:20 2015 +0200 Committer: Claus Ibsen <[email protected]> Committed: Thu Sep 24 15:17:20 2015 +0200 ---------------------------------------------------------------------- .../commands/AbstractLocalCamelController.java | 2 +- .../apache/camel/karaf/commands/RestApiDoc.java | 34 ++++++++++++++++++++ .../OSGI-INF/blueprint/camel-commands.xml | 9 ++++++ 3 files changed, 44 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/55d675b9/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractLocalCamelController.java ---------------------------------------------------------------------- diff --git a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractLocalCamelController.java b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractLocalCamelController.java index 2fd62f0..823e5b3 100644 --- a/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractLocalCamelController.java +++ b/platforms/commands/commands-core/src/main/java/org/apache/camel/commands/AbstractLocalCamelController.java @@ -410,7 +410,7 @@ public abstract class AbstractLocalCamelController extends AbstractCamelControll return null; } - return context.getRestRegistry().apiDocsAsJson(); + return context.getRestRegistry().apiDocAsJson(); } public List<Map<String, String>> getEndpoints(String camelContextName) throws Exception { http://git-wip-us.apache.org/repos/asf/camel/blob/55d675b9/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RestApiDoc.java ---------------------------------------------------------------------- diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RestApiDoc.java b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RestApiDoc.java new file mode 100644 index 0000000..dfdbbbb --- /dev/null +++ b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/RestApiDoc.java @@ -0,0 +1,34 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.karaf.commands; + +import org.apache.camel.commands.RestApiDocCommand; +import org.apache.felix.gogo.commands.Argument; +import org.apache.felix.gogo.commands.Command; + +@Command(scope = "camel", name = "rest-api-doc", description = "List the Camel REST services API documentation (requires camel-swagger-java on classpath)") +public class RestApiDoc extends CamelCommandSupport { + + @Argument(index = 0, name = "name", description = "The Camel context name where to look for the REST services", required = true, multiValued = false) + String name; + + protected Object doExecute() throws Exception { + RestApiDocCommand command = new RestApiDocCommand(name); + return command.execute(camelController, System.out, System.err); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/55d675b9/platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/camel-commands.xml ---------------------------------------------------------------------- diff --git a/platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/camel-commands.xml b/platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/camel-commands.xml index ba134bf..30e9a8f 100644 --- a/platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/camel-commands.xml +++ b/platforms/karaf/commands/src/main/resources/OSGI-INF/blueprint/camel-commands.xml @@ -206,6 +206,15 @@ <null/> </completers> </command> + <command name="camel/rest-api-doc"> + <action class="org.apache.camel.karaf.commands.RestApiDoc"> + <property name="camelController" ref="camelController"/> + </action> + <completers> + <ref component-id="camelContextCompleter"/> + <null/> + </completers> + </command> <command name="camel/rest-show"> <action class="org.apache.camel.karaf.commands.RestShow"> <property name="camelController" ref="camelController"/>
