|
| 1 | +/* |
| 2 | + * Copyright 2023 https://github.com/openapi-processor/openapi-processor-api |
| 3 | + * PDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +package io.openapiprocessor.api.v2; |
| 7 | + |
| 8 | +import java.util.Map; |
| 9 | + |
| 10 | +/** |
| 11 | + * To make an openapi-processor available to a consumer (for example the openapi-processor-gradle |
| 12 | + * plugin) it must implement this interface and have a |
| 13 | + * {@code META-INF/services/io.openapiprocessor.api.v1.OpenApiProcessor} property file in the |
| 14 | + * resources with the class name of the implementing class. |
| 15 | + * |
| 16 | + * <p> |
| 17 | + * A consumer should be able to provide access to any processor that is found on the class path. |
| 18 | + * |
| 19 | + * The gradle plugin uses the name provided by the api to configure the processor and to provide a |
| 20 | + * task to run it. This task will find and run an openapi-processor by using the |
| 21 | + * {@code OpenApiProcessor} service interface. By using an interface it does not need an explicit |
| 22 | + * dependency on a processor. |
| 23 | + */ |
| 24 | +public interface OpenApiProcessor { |
| 25 | + |
| 26 | + /** |
| 27 | + * The identifying name of the openapi-processor. *Should* be globally unique so a consumer of |
| 28 | + * this interface can distinguish between different openapi-processors. |
| 29 | + * |
| 30 | + * <p> |
| 31 | + * It is recommended to return here the last part of the full openapi-processor name. If the |
| 32 | + * processor jar name is {@code openapi-processor-spring} the name should be {@code spring}. |
| 33 | + * </p> |
| 34 | + * |
| 35 | + * @return the unique name of the openapi-processor |
| 36 | + */ |
| 37 | + String getName(); |
| 38 | + |
| 39 | + /** |
| 40 | + * Runs the openapi-processor with the given options. The options are key value pairs. Keys are |
| 41 | + * of type {@code String} and values are of any type. A property hierarchy is possible by using |
| 42 | + * {@code Map}s as value. |
| 43 | + * |
| 44 | + * @param options the openapi-processor configuration |
| 45 | + */ |
| 46 | + void run(Map<String, ?> options); |
| 47 | + |
| 48 | +} |
0 commit comments