@VisibleForTesting
    static OpenAPI createDocumentation(
            String title, DocumentingRestEndpoint restEndpoint, RestAPIVersion apiVersion) {
        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, title, apiVersion);

        List<MessageHeaders> specs =
                restEndpoint.getSpecs().stream()
                        .filter(spec -> spec.getSupportedAPIVersions().contains(apiVersion))
                        .filter(ApiSpecGeneratorUtils::shouldBeDocumented)
                        .collect(Collectors.toList());
        final Set<String> usedOperationIds = new HashSet<>();
        specs.forEach(spec -> add(spec, openApi, usedOperationIds));

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

        sortProperties(openApi);
        sortSchemas(openApi);

        return openApi;
    }
@Test
    void testAdditionalFields(@TempDir Path tmpDir) throws Exception {
        final OpenAPI documentation =
                OpenApiSpecGenerator.createDocumentation(
                        "title",
                        DocumentingRestEndpoint.forRestHandlerSpecifications(
                                new TestAdditionalFieldsMessageHeaders("operation1")),
                        RuntimeRestAPIVersion.V0);
        assertThat(documentation.getComponents().getSchemas())
                .extractingByKey("AdditionalFieldsRequestBody")
                .satisfies(
                        x ->
                                assertThat(x.getAdditionalProperties())
                                        .isInstanceOf(StringSchema.class));
    }