This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new d8da0a7 restdsl-openapi/swagger-plugin: support for component-starter
dep (#3908)
d8da0a7 is described below
commit d8da0a764791e32975da078ea26d2229961f4ac7
Author: Jose Montoya <[email protected]>
AuthorDate: Sat Jun 13 02:14:02 2020 -0500
restdsl-openapi/swagger-plugin: support for component-starter dep (#3908)
* restdsl-openapi/swagger-plugin: support for component-starter dep
This enables the plugins to identify rest component through
org.apache.camel.springboot:camel-{component}-starter dependencies
* checkstyle
* resdsl-openapi/swagger-plugin: fix spring boot group id suggestion
Fixes suggestion of rest component dependency if spring boot is detected
---
.../src/it/spring-boot-starter-support/pom.xml | 61 ++
.../src/spec/openapi.json | 1093 ++++++++++++++++++++
.../it/spring-boot-starter-support/verify.groovy | 22 +
.../generator/openapi/AbstractGenerateMojo.java | 34 +-
.../maven/generator/openapi/GenerateMojo.java | 29 +-
.../maven/generator/openapi/GenerateXmlMojo.java | 28 +-
.../src/it/spring-boot-starter-support/pom.xml | 61 ++
.../src/spec/swagger.json | 1 +
.../it/spring-boot-starter-support/verify.groovy | 22 +
.../generator/swagger/AbstractGenerateMojo.java | 34 +-
.../maven/generator/swagger/GenerateMojo.java | 29 +-
.../maven/generator/swagger/GenerateXmlMojo.java | 28 +-
12 files changed, 1332 insertions(+), 110 deletions(-)
diff --git
a/tooling/maven/camel-restdsl-openapi-plugin/src/it/spring-boot-starter-support/pom.xml
b/tooling/maven/camel-restdsl-openapi-plugin/src/it/spring-boot-starter-support/pom.xml
new file mode 100644
index 0000000..58b704e
--- /dev/null
+++
b/tooling/maven/camel-restdsl-openapi-plugin/src/it/spring-boot-starter-support/pom.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.camel.maven.generator.openapi.it</groupId>
+ <artifactId>spring-boot-starter-support</artifactId>
+ <version>1-SNAPSHOT</version>
+
+ <description>A simple IT verifying the spring boot starter support use
case.</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>@project.artifactId@</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <id>simple</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.springboot</groupId>
+ <artifactId>camel-netty-http-starter</artifactId>
+ <version>@project.version@</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git
a/tooling/maven/camel-restdsl-openapi-plugin/src/it/spring-boot-starter-support/src/spec/openapi.json
b/tooling/maven/camel-restdsl-openapi-plugin/src/it/spring-boot-starter-support/src/spec/openapi.json
new file mode 100644
index 0000000..3ccbf1b
--- /dev/null
+++
b/tooling/maven/camel-restdsl-openapi-plugin/src/it/spring-boot-starter-support/src/spec/openapi.json
@@ -0,0 +1,1093 @@
+{
+ "openapi": "3.0.2",
+ "info": {
+ "title": "Swagger Petstore",
+ "version": "1.0.0",
+ "description": "This is a sample server Petstore server. You can find
out more about Swagger at [http://swagger.io](http://swagger.io) or on
[irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can
use the api key `special-key` to test the authorization filters.",
+ "termsOfService": "http://swagger.io/terms/",
+ "contact": {
+ "email": "[email protected]"
+ },
+ "license": {
+ "name": "Apache 2.0",
+ "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
+ }
+ },
+ "servers": [
+ {
+ "url": "http://petstore.swagger.io/api/v3"
+ }
+ ],
+ "paths": {
+ "/pet": {
+ "put": {
+ "requestBody": {
+ "description": "Pet object that needs to be added to the
store",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Pet"
+ }
+ },
+ "application/xml": {
+ "schema": {
+ "$ref": "#/components/schemas/Pet"
+ }
+ }
+ },
+ "required": true
+ },
+ "tags": [
+ "pet"
+ ],
+ "responses": {
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "Pet not found"
+ },
+ "405": {
+ "description": "Validation exception"
+ }
+ },
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ],
+ "operationId": "updatePet",
+ "summary": "Update an existing pet",
+ "description": ""
+ },
+ "post": {
+ "requestBody": {
+ "description": "Pet object that needs to be added to the
store",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Pet"
+ }
+ },
+ "application/xml": {
+ "schema": {
+ "$ref": "#/components/schemas/Pet"
+ }
+ }
+ },
+ "required": true
+ },
+ "tags": [
+ "pet"
+ ],
+ "parameters": [
+ {
+ "name": "verbose",
+ "description": "Verbose data",
+ "schema": {
+ "default": false,
+ "type": "boolean"
+ },
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "405": {
+ "description": "Invalid input"
+ }
+ },
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ],
+ "operationId": "addPet",
+ "summary": "Add a new pet to the store",
+ "description": ""
+ }
+ },
+ "/pet/findByStatus": {
+ "get": {
+ "tags": [
+ "pet"
+ ],
+ "parameters": [
+ {
+ "style": "form",
+ "explode": true,
+ "name": "status",
+ "description": "Status values that need to be
considered for filter",
+ "schema": {
+ "type": "array",
+ "items": {
+ "default": "available",
+ "enum": [
+ "available",
+ "pending",
+ "sold"
+ ],
+ "type": "string"
+ }
+ },
+ "in": "query",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "content": {
+ "application/xml": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Pet"
+ }
+ }
+ },
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Pet"
+ }
+ }
+ }
+ },
+ "description": "successful operation"
+ },
+ "400": {
+ "description": "Invalid status value"
+ }
+ },
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ],
+ "operationId": "findPetsByStatus",
+ "summary": "Finds Pets by status",
+ "description": "Multiple status values can be provided with
comma separated strings"
+ }
+ },
+ "/pet/findByTags": {
+ "get": {
+ "tags": [
+ "pet"
+ ],
+ "parameters": [
+ {
+ "style": "form",
+ "explode": true,
+ "name": "tags",
+ "description": "Tags to filter by",
+ "schema": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "in": "query",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "content": {
+ "application/xml": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Pet"
+ }
+ }
+ },
+ "application/json": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Pet"
+ }
+ }
+ }
+ },
+ "description": "successful operation"
+ },
+ "400": {
+ "description": "Invalid tag value"
+ }
+ },
+ "deprecated": true,
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ],
+ "operationId": "findPetsByTags",
+ "summary": "Finds Pets by tags",
+ "description": "Muliple tags can be provided with comma
separated strings. Use tag1, tag2, tag3 for testing."
+ }
+ },
+ "/pet/{petId}": {
+ "get": {
+ "tags": [
+ "pet"
+ ],
+ "parameters": [
+ {
+ "name": "petId",
+ "description": "ID of pet to return",
+ "schema": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "content": {
+ "application/xml": {
+ "schema": {
+ "$ref": "#/components/schemas/Pet"
+ }
+ },
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Pet"
+ }
+ }
+ },
+ "description": "successful operation"
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "Pet not found"
+ }
+ },
+ "security": [
+ {
+ "api_key": []
+ }
+ ],
+ "operationId": "getPetById",
+ "summary": "Find pet by ID",
+ "description": "Returns a single pet"
+ },
+ "post": {
+ "requestBody": {
+ "content": {
+ "application/x-www-form-urlencoded": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "description": "Updated name of the
pet",
+ "type": "string"
+ },
+ "status": {
+ "description": "Updated status of the
pet",
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "required": true
+ },
+ "tags": [
+ "pet"
+ ],
+ "parameters": [
+ {
+ "name": "petId",
+ "description": "ID of pet that needs to be updated",
+ "schema": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "405": {
+ "description": "Invalid input"
+ }
+ },
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ],
+ "operationId": "updatePetWithForm",
+ "summary": "Updates a pet in the store with form data",
+ "description": ""
+ },
+ "delete": {
+ "tags": [
+ "pet"
+ ],
+ "parameters": [
+ {
+ "name": "api_key",
+ "schema": {
+ "type": "string"
+ },
+ "in": "header",
+ "required": false
+ },
+ {
+ "name": "petId",
+ "description": "Pet id to delete",
+ "schema": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "Pet not found"
+ }
+ },
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ],
+ "operationId": "deletePet",
+ "summary": "Deletes a pet",
+ "description": ""
+ }
+ },
+ "/pet/{petId}/uploadImage": {
+ "post": {
+ "requestBody": {
+ "content": {
+ "multipart/form-data": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "additionalMetadata": {
+ "description": "Additional data to
pass to server",
+ "type": "string"
+ },
+ "file": {
+ "format": "binary",
+ "description": "file to upload",
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "required": true
+ },
+ "tags": [
+ "pet"
+ ],
+ "parameters": [
+ {
+ "name": "petId",
+ "description": "ID of pet to update",
+ "schema": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/ApiResponse"
+ }
+ }
+ },
+ "description": "successful operation"
+ }
+ },
+ "security": [
+ {
+ "petstore_auth": [
+ "write:pets",
+ "read:pets"
+ ]
+ }
+ ],
+ "operationId": "uploadFile",
+ "summary": "uploads an image",
+ "description": ""
+ }
+ },
+ "/store/inventory": {
+ "get": {
+ "tags": [
+ "store"
+ ],
+ "responses": {
+ "200": {
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "additionalProperties": {
+ "format": "int32",
+ "type": "integer"
+ }
+ }
+ }
+ },
+ "description": "successful operation"
+ }
+ },
+ "security": [
+ {
+ "api_key": []
+ }
+ ],
+ "operationId": "getInventory",
+ "summary": "Returns pet inventories by status",
+ "description": "Returns a map of status codes to quantities"
+ }
+ },
+ "/store/order": {
+ "post": {
+ "requestBody": {
+ "description": "order placed for purchasing the pet",
+ "content": {
+ "*/*": {
+ "schema": {
+ "$ref": "#/components/schemas/Order"
+ }
+ }
+ },
+ "required": true
+ },
+ "tags": [
+ "store"
+ ],
+ "responses": {
+ "200": {
+ "content": {
+ "application/xml": {
+ "schema": {
+ "$ref": "#/components/schemas/Order"
+ }
+ },
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Order"
+ }
+ }
+ },
+ "description": "successful operation"
+ },
+ "400": {
+ "description": "Invalid Order"
+ }
+ },
+ "operationId": "placeOrder",
+ "summary": "Place an order for a pet",
+ "description": ""
+ }
+ },
+ "/store/order/{orderId}": {
+ "get": {
+ "tags": [
+ "store"
+ ],
+ "parameters": [
+ {
+ "name": "orderId",
+ "description": "ID of pet that needs to be fetched",
+ "schema": {
+ "format": "int64",
+ "maximum": 10,
+ "minimum": 1,
+ "type": "integer"
+ },
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "content": {
+ "application/xml": {
+ "schema": {
+ "$ref": "#/components/schemas/Order"
+ }
+ },
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Order"
+ }
+ }
+ },
+ "description": "successful operation"
+ },
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "Order not found"
+ }
+ },
+ "operationId": "getOrderById",
+ "summary": "Find purchase order by ID",
+ "description": "For valid response try integer IDs with value
>= 1 and <= 10. Other values will generated exceptions"
+ },
+ "delete": {
+ "tags": [
+ "store"
+ ],
+ "parameters": [
+ {
+ "name": "orderId",
+ "description": "ID of the order that needs to be
deleted",
+ "schema": {
+ "format": "int64",
+ "minimum": 1,
+ "type": "integer"
+ },
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "400": {
+ "description": "Invalid ID supplied"
+ },
+ "404": {
+ "description": "Order not found"
+ }
+ },
+ "operationId": "deleteOrder",
+ "summary": "Delete purchase order by ID",
+ "description": "For valid response try integer IDs with
positive integer value. Negative or non-integer values will generate API errors"
+ }
+ },
+ "/user": {
+ "post": {
+ "requestBody": {
+ "description": "Created user object",
+ "content": {
+ "*/*": {
+ "schema": {
+ "$ref": "#/components/schemas/User"
+ }
+ }
+ },
+ "required": true
+ },
+ "tags": [
+ "user"
+ ],
+ "responses": {
+ "default": {
+ "description": "successful operation"
+ }
+ },
+ "operationId": "createUser",
+ "summary": "Create user",
+ "description": "This can only be done by the logged in user."
+ }
+ },
+ "/user/createWithArray": {
+ "post": {
+ "requestBody": {
+ "description": "List of user object",
+ "content": {
+ "*/*": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/User"
+ }
+ }
+ }
+ },
+ "required": true
+ },
+ "tags": [
+ "user"
+ ],
+ "responses": {
+ "default": {
+ "description": "successful operation"
+ }
+ },
+ "operationId": "createUsersWithArrayInput",
+ "summary": "Creates list of users with given input array",
+ "description": ""
+ }
+ },
+ "/user/createWithList": {
+ "post": {
+ "requestBody": {
+ "description": "List of user object",
+ "content": {
+ "*/*": {
+ "schema": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/User"
+ }
+ }
+ }
+ },
+ "required": true
+ },
+ "tags": [
+ "user"
+ ],
+ "responses": {
+ "default": {
+ "description": "successful operation"
+ }
+ },
+ "operationId": "createUsersWithListInput",
+ "summary": "Creates list of users with given input array",
+ "description": ""
+ }
+ },
+ "/user/login": {
+ "get": {
+ "tags": [
+ "user"
+ ],
+ "parameters": [
+ {
+ "name": "username",
+ "description": "The user name for login",
+ "schema": {
+ "type": "string"
+ },
+ "in": "query",
+ "required": true
+ },
+ {
+ "name": "password",
+ "description": "The password for login in clear text",
+ "schema": {
+ "type": "string"
+ },
+ "in": "query",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "headers": {
+ "X-Rate-Limit": {
+ "schema": {
+ "format": "int32",
+ "type": "integer"
+ },
+ "description": "calls per hour allowed by the
user"
+ },
+ "X-Expires-After": {
+ "schema": {
+ "format": "date-time",
+ "type": "string"
+ },
+ "description": "date in UTC when token expires"
+ }
+ },
+ "content": {
+ "application/xml": {
+ "schema": {
+ "type": "string"
+ }
+ },
+ "application/json": {
+ "schema": {
+ "type": "string"
+ }
+ }
+ },
+ "description": "successful operation"
+ },
+ "400": {
+ "description": "Invalid username/password supplied"
+ }
+ },
+ "operationId": "loginUser",
+ "summary": "Logs user into the system",
+ "description": ""
+ }
+ },
+ "/user/logout": {
+ "get": {
+ "tags": [
+ "user"
+ ],
+ "responses": {
+ "default": {
+ "description": "successful operation"
+ }
+ },
+ "operationId": "logoutUser",
+ "summary": "Logs out current logged in user session",
+ "description": ""
+ }
+ },
+ "/user/{username}": {
+ "get": {
+ "tags": [
+ "user"
+ ],
+ "parameters": [
+ {
+ "name": "username",
+ "description": "The name that needs to be fetched. Use
user1 for testing. ",
+ "schema": {
+ "type": "string"
+ },
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "content": {
+ "application/xml": {
+ "schema": {
+ "$ref": "#/components/schemas/User"
+ }
+ },
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/User"
+ }
+ }
+ },
+ "description": "successful operation"
+ },
+ "400": {
+ "description": "Invalid username supplied"
+ },
+ "404": {
+ "description": "User not found"
+ }
+ },
+ "operationId": "getUserByName",
+ "summary": "Get user by user name",
+ "description": ""
+ },
+ "put": {
+ "requestBody": {
+ "description": "Updated user object",
+ "content": {
+ "*/*": {
+ "schema": {
+ "$ref": "#/components/schemas/User"
+ }
+ }
+ },
+ "required": true
+ },
+ "tags": [
+ "user"
+ ],
+ "parameters": [
+ {
+ "name": "username",
+ "description": "name that need to be updated",
+ "schema": {
+ "type": "string"
+ },
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "400": {
+ "description": "Invalid user supplied"
+ },
+ "404": {
+ "description": "User not found"
+ }
+ },
+ "operationId": "updateUser",
+ "summary": "Updated user",
+ "description": "This can only be done by the logged in user."
+ },
+ "delete": {
+ "tags": [
+ "user"
+ ],
+ "parameters": [
+ {
+ "name": "username",
+ "description": "The name that needs to be deleted",
+ "schema": {
+ "type": "string"
+ },
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "400": {
+ "description": "Invalid username supplied"
+ },
+ "404": {
+ "description": "User not found"
+ }
+ },
+ "operationId": "deleteUser",
+ "summary": "Delete user",
+ "description": "This can only be done by the logged in user."
+ }
+ }
+ },
+ "components": {
+ "schemas": {
+ "Order": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "petId": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "quantity": {
+ "format": "int32",
+ "type": "integer"
+ },
+ "shipDate": {
+ "format": "date-time",
+ "type": "string"
+ },
+ "status": {
+ "description": "Order Status",
+ "enum": [
+ "placed",
+ "approved",
+ "delivered"
+ ],
+ "type": "string"
+ },
+ "complete": {
+ "default": false,
+ "type": "boolean"
+ }
+ },
+ "xml": {
+ "name": "Order"
+ }
+ },
+ "Category": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "name": {
+ "type": "string"
+ }
+ },
+ "xml": {
+ "name": "Category"
+ }
+ },
+ "User": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "username": {
+ "type": "string"
+ },
+ "firstName": {
+ "type": "string"
+ },
+ "lastName": {
+ "type": "string"
+ },
+ "email": {
+ "type": "string"
+ },
+ "password": {
+ "type": "string"
+ },
+ "phone": {
+ "type": "string"
+ },
+ "userStatus": {
+ "format": "int32",
+ "description": "User Status",
+ "type": "integer"
+ }
+ },
+ "xml": {
+ "name": "User"
+ }
+ },
+ "Tag": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "name": {
+ "type": "string"
+ }
+ },
+ "xml": {
+ "name": "Tag"
+ }
+ },
+ "Pet": {
+ "required": [
+ "name",
+ "photoUrls"
+ ],
+ "type": "object",
+ "properties": {
+ "id": {
+ "format": "int64",
+ "type": "integer"
+ },
+ "category": {
+ "$ref": "#/components/schemas/Category"
+ },
+ "name": {
+ "type": "string",
+ "example": "doggie"
+ },
+ "photoUrls": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "xml": {
+ "name": "photoUrl",
+ "wrapped": true
+ }
+ },
+ "tags": {
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Tag"
+ },
+ "xml": {
+ "name": "tag",
+ "wrapped": true
+ }
+ },
+ "status": {
+ "description": "pet status in the store",
+ "enum": [
+ "available",
+ "pending",
+ "sold"
+ ],
+ "type": "string"
+ }
+ },
+ "xml": {
+ "name": "Pet"
+ }
+ },
+ "ApiResponse": {
+ "type": "object",
+ "properties": {
+ "code": {
+ "format": "int32",
+ "type": "integer"
+ },
+ "type": {
+ "type": "string"
+ },
+ "message": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "securitySchemes": {
+ "petstore_auth": {
+ "flows": {
+ "implicit": {
+ "authorizationUrl":
"http://petstore.swagger.io/oauth/dialog",
+ "scopes": {
+ "write:pets": "modify pets in your account",
+ "read:pets": "read your pets"
+ }
+ }
+ },
+ "type": "oauth2"
+ },
+ "api_key": {
+ "type": "apiKey",
+ "name": "api_key",
+ "in": "header"
+ }
+ }
+ },
+ "tags": [
+ {
+ "name": "pet",
+ "description": "Everything about your Pets",
+ "externalDocs": {
+ "description": "Find out more",
+ "url": "http://swagger.io"
+ }
+ },
+ {
+ "name": "store",
+ "description": "Access to Petstore orders"
+ },
+ {
+ "name": "user",
+ "description": "Operations about user",
+ "externalDocs": {
+ "description": "Find out more about our store",
+ "url": "http://swagger.io"
+ }
+ }
+ ],
+ "externalDocs": {
+ "description": "Find out more about Swagger",
+ "url": "http://swagger.io"
+ }
+}
diff --git
a/tooling/maven/camel-restdsl-openapi-plugin/src/it/spring-boot-starter-support/verify.groovy
b/tooling/maven/camel-restdsl-openapi-plugin/src/it/spring-boot-starter-support/verify.groovy
new file mode 100644
index 0000000..ff7241e
--- /dev/null
+++
b/tooling/maven/camel-restdsl-openapi-plugin/src/it/spring-boot-starter-support/verify.groovy
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+def File restdsl = new File(basedir,
"target/generated-sources/restdsl-openapi/io/swagger/petstore/SwaggerPetstore.java")
+
+def String data = restdsl.text
+
+assert data.contains('restConfiguration().component("netty-http");')
diff --git
a/tooling/maven/camel-restdsl-openapi-plugin/src/main/java/org/apache/camel/maven/generator/openapi/AbstractGenerateMojo.java
b/tooling/maven/camel-restdsl-openapi-plugin/src/main/java/org/apache/camel/maven/generator/openapi/AbstractGenerateMojo.java
index 24bb158..0eda5f5 100644
---
a/tooling/maven/camel-restdsl-openapi-plugin/src/main/java/org/apache/camel/maven/generator/openapi/AbstractGenerateMojo.java
+++
b/tooling/maven/camel-restdsl-openapi-plugin/src/main/java/org/apache/camel/maven/generator/openapi/AbstractGenerateMojo.java
@@ -211,7 +211,7 @@ abstract class AbstractGenerateMojo extends AbstractMojo {
protected String detectRestComponentFromClasspath() {
for (final Dependency dep : mavenProject.getDependencies()) {
- if ("org.apache.camel".equals(dep.getGroupId())) {
+ if ("org.apache.camel".equals(dep.getGroupId()) ||
"org.apache.camel.springboot".equals(dep.getGroupId())) {
final String aid = dep.getArtifactId();
final Optional<String> comp =
Arrays.asList(DEFAULT_REST_CONSUMER_COMPONENTS).stream()
.filter(c -> aid.startsWith("camel-" + c)).findFirst();
@@ -295,4 +295,36 @@ abstract class AbstractGenerateMojo extends AbstractMojo {
return (OasDocument) Library.readDocument(node);
}
}
+
+ protected String findAppropriateComponent() {
+ String comp = detectRestComponentFromClasspath();
+ if (comp != null) {
+ getLog().info("Detected Camel Rest component from classpath: " +
comp);
+ } else {
+ comp = "servlet";
+
+ String gid = "org.apache.camel";
+ String aid = "camel-servlet";
+
+ // is it spring boot?
+ if (detectSpringBootFromClasspath()) {
+ gid = "org.apache.camel.springboot";
+ aid = "camel-servlet-starter";
+ }
+
+ String dep = "\n\t\t<dependency>"
+ + "\n\t\t\t<groupId>" + gid + "</groupId>"
+ + "\n\t\t\t<artifactId>" + aid + "</artifactId>";
+ String ver = detectCamelVersionFromClasspath();
+ if (ver != null) {
+ dep += "\n\t\t\t<version>" + ver + "</version>";
+ }
+ dep += "\n\t\t</dependency>\n";
+
+ getLog().info("Cannot detect Rest component from classpath. Will
use servlet as Rest component.");
+ getLog().info("Add the following dependency in the Maven pom.xml
file:\n" + dep + "\n");
+ }
+
+ return comp;
+ }
}
diff --git
a/tooling/maven/camel-restdsl-openapi-plugin/src/main/java/org/apache/camel/maven/generator/openapi/GenerateMojo.java
b/tooling/maven/camel-restdsl-openapi-plugin/src/main/java/org/apache/camel/maven/generator/openapi/GenerateMojo.java
index 2ab1a8c..a162511 100644
---
a/tooling/maven/camel-restdsl-openapi-plugin/src/main/java/org/apache/camel/maven/generator/openapi/GenerateMojo.java
+++
b/tooling/maven/camel-restdsl-openapi-plugin/src/main/java/org/apache/camel/maven/generator/openapi/GenerateMojo.java
@@ -93,33 +93,8 @@ public class GenerateMojo extends AbstractGenerateMojo {
final Path outputPath = new File(outputDirectory).toPath();
if (restConfiguration) {
- String comp = detectRestComponentFromClasspath();
- if (comp != null) {
- getLog().info("Detected Camel Rest component from classpath: "
+ comp);
- generator.withRestComponent(comp);
- } else {
- comp = "servlet";
-
- // is it spring boot?
- String aid = "camel-servlet";
- if (detectSpringBootFromClasspath()) {
- aid = "camel-servlet-starter";
- }
-
- String dep = "\n\t\t<dependency>"
- + "\n\t\t\t<groupId>org.apache.camel</groupId>"
- + "\n\t\t\t<artifactId>" + aid + "</artifactId>";
- String ver = detectCamelVersionFromClasspath();
- if (ver != null) {
- dep += "\n\t\t\t<version>" + ver + "</version>";
- }
- dep += "\n\t\t</dependency>\n";
-
- getLog().info("Cannot detect Rest component from classpath.
Will use servlet as Rest component.");
- getLog().info("Add the following dependency in the Maven
pom.xml file:\n" + dep + "\n");
-
- generator.withRestComponent("servlet");
- }
+ String comp = findAppropriateComponent();
+ generator.withRestComponent(comp);
if (ObjectHelper.isNotEmpty(apiContextPath)) {
generator.withApiContextPath(apiContextPath);
diff --git
a/tooling/maven/camel-restdsl-openapi-plugin/src/main/java/org/apache/camel/maven/generator/openapi/GenerateXmlMojo.java
b/tooling/maven/camel-restdsl-openapi-plugin/src/main/java/org/apache/camel/maven/generator/openapi/GenerateXmlMojo.java
index 7d9cca1..4dfb35c 100644
---
a/tooling/maven/camel-restdsl-openapi-plugin/src/main/java/org/apache/camel/maven/generator/openapi/GenerateXmlMojo.java
+++
b/tooling/maven/camel-restdsl-openapi-plugin/src/main/java/org/apache/camel/maven/generator/openapi/GenerateXmlMojo.java
@@ -80,33 +80,7 @@ public class GenerateXmlMojo extends AbstractGenerateMojo {
}
if (restConfiguration) {
- String comp = detectRestComponentFromClasspath();
- if (comp != null) {
- getLog().info("Detected Camel Rest component from classpath: "
+ comp);
- generator.withRestComponent(comp);
- } else {
- comp = "servlet";
-
- // is it spring boot?
- String aid = "camel-servlet";
- if (detectSpringBootFromClasspath()) {
- aid = "camel-servlet-starter";
- }
-
- String dep = "\n\t\t<dependency>"
- + "\n\t\t\t<groupId>org.apache.camel</groupId>"
- + "\n\t\t\t<artifactId>" + aid + "</artifactId>";
- final String ver = detectCamelVersionFromClasspath();
- if (ver != null) {
- dep += "\n\t\t\t<version>" + ver + "</version>";
- }
- dep += "\n\t\t</dependency>\n";
-
- getLog().info("Cannot detect Rest component from classpath.
Will use servlet as Rest component.");
- getLog().info("Add the following dependency in the Maven
pom.xml file:\n" + dep + "\n");
-
- generator.withRestComponent(comp);
- }
+ generator.withRestComponent(findAppropriateComponent());
}
try {
diff --git
a/tooling/maven/camel-restdsl-swagger-plugin/src/it/spring-boot-starter-support/pom.xml
b/tooling/maven/camel-restdsl-swagger-plugin/src/it/spring-boot-starter-support/pom.xml
new file mode 100644
index 0000000..6d71852
--- /dev/null
+++
b/tooling/maven/camel-restdsl-swagger-plugin/src/it/spring-boot-starter-support/pom.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.camel.maven.generator.swagger.it</groupId>
+ <artifactId>spring-boot-starter-support</artifactId>
+ <version>1-SNAPSHOT</version>
+
+ <description>A simple IT verifying the spring boot starter support use
case.</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compiler.source>1.8</maven.compiler.source>
+ <maven.compiler.target>1.8</maven.compiler.target>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>@project.artifactId@</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <id>simple</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.springboot</groupId>
+ <artifactId>camel-netty-http-starter</artifactId>
+ <version>@project.version@</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git
a/tooling/maven/camel-restdsl-swagger-plugin/src/it/spring-boot-starter-support/src/spec/swagger.json
b/tooling/maven/camel-restdsl-swagger-plugin/src/it/spring-boot-starter-support/src/spec/swagger.json
new file mode 100644
index 0000000..816847f
--- /dev/null
+++
b/tooling/maven/camel-restdsl-swagger-plugin/src/it/spring-boot-starter-support/src/spec/swagger.json
@@ -0,0 +1 @@
+{"swagger":"2.0","info":{"description":"This is a sample server Petstore
server. You can find out more about Swagger at
[http://swagger.io](http://swagger.io) or on [irc.freenode.net,
#swagger](http://swagger.io/irc/). For this sample, you can use the api key
`special-key` to test the authorization
filters.","version":"1.0.0","title":"Swagger
Petstore","termsOfService":"http://swagger.io/terms/","contact":{"email":"[email protected]"},"license":{"name":"Apache
2.0","url":"http://www.a [...]
\ No newline at end of file
diff --git
a/tooling/maven/camel-restdsl-swagger-plugin/src/it/spring-boot-starter-support/verify.groovy
b/tooling/maven/camel-restdsl-swagger-plugin/src/it/spring-boot-starter-support/verify.groovy
new file mode 100644
index 0000000..ef9b1e6
--- /dev/null
+++
b/tooling/maven/camel-restdsl-swagger-plugin/src/it/spring-boot-starter-support/verify.groovy
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+def File restdsl = new File(basedir,
"target/generated-sources/restdsl-swagger/io/swagger/petstore/SwaggerPetstore.java")
+
+def String data = restdsl.text
+
+assert data.contains('restConfiguration().component("netty-http");')
diff --git
a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/AbstractGenerateMojo.java
b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/AbstractGenerateMojo.java
index aa13766..37d8606 100644
---
a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/AbstractGenerateMojo.java
+++
b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/AbstractGenerateMojo.java
@@ -209,7 +209,7 @@ abstract class AbstractGenerateMojo extends AbstractMojo {
protected String detectRestComponentFromClasspath() {
for (final Dependency dep : mavenProject.getDependencies()) {
- if ("org.apache.camel".equals(dep.getGroupId())) {
+ if ("org.apache.camel".equals(dep.getGroupId()) ||
"org.apache.camel.springboot".equals(dep.getGroupId())) {
final String aid = dep.getArtifactId();
final Optional<String> comp =
Arrays.asList(DEFAULT_REST_CONSUMER_COMPONENTS).stream()
.filter(c -> aid.startsWith("camel-" + c)).findFirst();
@@ -273,4 +273,36 @@ abstract class AbstractGenerateMojo extends AbstractMojo {
return null;
}
+ protected String findAppropriateComponent() {
+ String comp = detectRestComponentFromClasspath();
+ if (comp != null) {
+ getLog().info("Detected Camel Rest component from classpath: " +
comp);
+ } else {
+ comp = "servlet";
+
+ String gid = "org.apache.camel";
+ String aid = "camel-servlet";
+
+ // is it spring boot?
+ if (detectSpringBootFromClasspath()) {
+ gid = "org.apache.camel.springboot";
+ aid = "camel-servlet-starter";
+ }
+
+ String dep = "\n\t\t<dependency>"
+ + "\n\t\t\t<groupId>" + gid + "</groupId>"
+ + "\n\t\t\t<artifactId>" + aid + "</artifactId>";
+ String ver = detectCamelVersionFromClasspath();
+ if (ver != null) {
+ dep += "\n\t\t\t<version>" + ver + "</version>";
+ }
+ dep += "\n\t\t</dependency>\n";
+
+ getLog().info("Cannot detect Rest component from classpath. Will
use servlet as Rest component.");
+ getLog().info("Add the following dependency in the Maven pom.xml
file:\n" + dep + "\n");
+ }
+
+ return comp;
+ }
+
}
diff --git
a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateMojo.java
b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateMojo.java
index 39c3238..d45e974 100644
---
a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateMojo.java
+++
b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateMojo.java
@@ -91,34 +91,9 @@ public class GenerateMojo extends AbstractGenerateMojo {
final Path outputPath = new File(outputDirectory).toPath();
if (restConfiguration) {
- String comp = detectRestComponentFromClasspath();
- if (comp != null) {
- getLog().info("Detected Camel Rest component from classpath: "
+ comp);
- generator.withRestComponent(comp);
- } else {
- comp = "servlet";
-
- // is it spring boot?
- String aid = "camel-servlet";
- if (detectSpringBootFromClasspath()) {
- aid = "camel-servlet-starter";
- }
-
- String dep = "\n\t\t<dependency>"
- + "\n\t\t\t<groupId>org.apache.camel</groupId>"
- + "\n\t\t\t<artifactId>" + aid + "</artifactId>";
- String ver = detectCamelVersionFromClasspath();
- if (ver != null) {
- dep += "\n\t\t\t<version>" + ver + "</version>";
- }
- dep += "\n\t\t</dependency>\n";
+ String comp = findAppropriateComponent();
+ generator.withRestComponent(comp);
- getLog().info("Cannot detect Rest component from classpath.
Will use servlet as Rest component.");
- getLog().info("Add the following dependency in the Maven
pom.xml file:\n" + dep + "\n");
-
- generator.withRestComponent("servlet");
- }
-
if (ObjectHelper.isNotEmpty(apiContextPath)) {
generator.withApiContextPath(apiContextPath);
}
diff --git
a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateXmlMojo.java
b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateXmlMojo.java
index 14d7904..1301d62 100644
---
a/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateXmlMojo.java
+++
b/tooling/maven/camel-restdsl-swagger-plugin/src/main/java/org/apache/camel/maven/generator/swagger/GenerateXmlMojo.java
@@ -78,33 +78,7 @@ public class GenerateXmlMojo extends AbstractGenerateMojo {
}
if (restConfiguration) {
- String comp = detectRestComponentFromClasspath();
- if (comp != null) {
- getLog().info("Detected Camel Rest component from classpath: "
+ comp);
- generator.withRestComponent(comp);
- } else {
- comp = "servlet";
-
- // is it spring boot?
- String aid = "camel-servlet";
- if (detectSpringBootFromClasspath()) {
- aid = "camel-servlet-starter";
- }
-
- String dep = "\n\t\t<dependency>"
- + "\n\t\t\t<groupId>org.apache.camel</groupId>"
- + "\n\t\t\t<artifactId>" + aid + "</artifactId>";
- final String ver = detectCamelVersionFromClasspath();
- if (ver != null) {
- dep += "\n\t\t\t<version>" + ver + "</version>";
- }
- dep += "\n\t\t</dependency>\n";
-
- getLog().info("Cannot detect Rest component from classpath.
Will use servlet as Rest component.");
- getLog().info("Add the following dependency in the Maven
pom.xml file:\n" + dep + "\n");
-
- generator.withRestComponent(comp);
- }
+ generator.withRestComponent(findAppropriateComponent());
}
try {