|
| 1 | +/* |
| 2 | + * Copyright 2019-2020 the original authors |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package io.openapiprocessor.api; |
| 18 | + |
| 19 | +import java.util.Map; |
| 20 | + |
| 21 | +/** |
| 22 | + * To make an openapi-processor available to a consumer (for example the openapi-processor-gradle |
| 23 | + * plugin) it must implement this interface and have a |
| 24 | + * {@code META-INF/services/io.openapiprocessor.api.OpenApiProcessor} property file in the |
| 25 | + * resources with the class name of the implementing class. |
| 26 | + * |
| 27 | + * <p> |
| 28 | + * A consumer should be able to provide access to any processor that is found on the class path. |
| 29 | + * |
| 30 | + * The gradle plugin uses the name provided by the api to configure the processor and to provide a |
| 31 | + * task to run it. This task will find and run an openapi-processor by using the |
| 32 | + * {@code OpenApiProcessor} service interface. By using an interface it does not need an explicit |
| 33 | + * dependency on a processor. |
| 34 | + * |
| 35 | + * @author Martin Hauner |
| 36 | + */ |
| 37 | +public interface OpenApiProcessorV1 { |
| 38 | + |
| 39 | + /** |
| 40 | + * The identifying name of the openapi-processor. *Should* be globally unique so a consumer of |
| 41 | + * this interface can distinguish between different openapi-processors. |
| 42 | + * |
| 43 | + * <p> |
| 44 | + * It is recommended to return here the last part of the full openapi-processor name. If the |
| 45 | + * processor jar name is {@code openapi-processor-spring} the name should be {@code spring}. |
| 46 | + * </p> |
| 47 | + * |
| 48 | + * @return the unique name of the openapi-processor |
| 49 | + */ |
| 50 | + String getName(); |
| 51 | + |
| 52 | + /** |
| 53 | + * Runs the openapi-processor with the given options. The options are key value pairs. Keys are |
| 54 | + * of type {@code String} and values are of any type. A property hierarchy is possible by using |
| 55 | + * {@code Map}s as value. |
| 56 | + * |
| 57 | + * @param options the openapi-processor configuration |
| 58 | + */ |
| 59 | + void run(Map<String, ?> options); |
| 60 | + |
| 61 | +} |
0 commit comments