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));
}
Aggregations