Search in sources :

Example 1 with MessageHeaders

use of org.apache.flink.runtime.rest.messages.MessageHeaders in project flink by apache.

the class OpenApiSpecGenerator method createDocumentationFile.

@VisibleForTesting
static void createDocumentationFile(DocumentingRestEndpoint restEndpoint, RestAPIVersion apiVersion, Path outputFile) throws IOException {
    final OpenAPI openApi = new OpenAPI();
    // eagerly initialize some data-structures to simplify operations later on
    openApi.setPaths(new io.swagger.v3.oas.models.Paths());
    openApi.setComponents(new Components());
    setInfo(openApi, apiVersion);
    List<MessageHeaders> specs = restEndpoint.getSpecs().stream().filter(spec -> spec.getSupportedAPIVersions().contains(apiVersion)).filter(OpenApiSpecGenerator::shouldBeDocumented).collect(Collectors.toList());
    specs.forEach(spec -> add(spec, openApi));
    final List<Schema> asyncOperationSchemas = collectAsyncOperationResultVariants(specs);
    // this adds the schema for every JSON object
    openApi.components(new Components().schemas(new HashMap<>(modelConverterContext.getDefinedModels())));
    injectAsyncOperationResultSchema(openApi, asyncOperationSchemas);
    overrideIdSchemas(openApi);
    overrideSerializeThrowableSchema(openApi);
    Files.deleteIfExists(outputFile);
    Files.write(outputFile, Yaml.pretty(openApi).getBytes(StandardCharsets.UTF_8));
}
Also used : Components(io.swagger.v3.oas.models.Components) HashMap(java.util.HashMap) ComposedSchema(io.swagger.v3.oas.models.media.ComposedSchema) ArraySchema(io.swagger.v3.oas.models.media.ArraySchema) Schema(io.swagger.v3.oas.models.media.Schema) AsynchronousOperationStatusMessageHeaders(org.apache.flink.runtime.rest.handler.async.AsynchronousOperationStatusMessageHeaders) MessageHeaders(org.apache.flink.runtime.rest.messages.MessageHeaders) OpenAPI(io.swagger.v3.oas.models.OpenAPI) VisibleForTesting(org.apache.flink.annotation.VisibleForTesting)

Aggregations

Components (io.swagger.v3.oas.models.Components)1 OpenAPI (io.swagger.v3.oas.models.OpenAPI)1 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)1 ComposedSchema (io.swagger.v3.oas.models.media.ComposedSchema)1 Schema (io.swagger.v3.oas.models.media.Schema)1 HashMap (java.util.HashMap)1 VisibleForTesting (org.apache.flink.annotation.VisibleForTesting)1 AsynchronousOperationStatusMessageHeaders (org.apache.flink.runtime.rest.handler.async.AsynchronousOperationStatusMessageHeaders)1 MessageHeaders (org.apache.flink.runtime.rest.messages.MessageHeaders)1