Skip to content

Commit

Permalink
Integrate openapi-to-adoc with annotation processor. Fixed typos
Browse files Browse the repository at this point in the history
  • Loading branch information
altro3 committed Oct 1, 2023
1 parent 978cc4e commit 0cc6aa6
Show file tree
Hide file tree
Showing 55 changed files with 162 additions and 646 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
projectVersion=6.0.0-SNAPSHOT
projectVersion=6.0.0-11
projectGroup=io.micronaut.openapi
micronautDocsVersion=2.0.0
groovyVersion=4.0.15
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package io.micronaut.openapi.adoc;

/**
* Configuration propertis for Openapi-to-adoc converter.
* Configuration properties for Openapi-to-adoc converter.
*
* @since 5.2.0
*/
Expand All @@ -25,29 +25,29 @@ public interface OpenApiToAdocConfigProperty {
/**
* Prefix for custom sub-template names.
*/
String MICRONAUT_OPENAPI_ADOC_TEMPLATE_PREFIX = "micronaut.openapi.adoc.template.";
String MICRONAUT_OPENAPI_ADOC_TEMPLATE_PREFIX = "micronaut.openapi.adoc.templates.";
/**
* Is convertion to Asciidoc enabled.
* Is conversion to Asciidoc enabled.
*/
String MICRONAUT_OPENAPI_ADOC_ENABLED = "micronaut.openapi.adoc.enabled";
/**
* Custom template directory.
*/
String MICRONAUT_OPENAPI_ADOC_TEMPLATES_DIR_PATH = "micronaut.openapi.adoc.template-dir";
String MICRONAUT_OPENAPI_ADOC_TEMPLATES_DIR_PATH = "micronaut.openapi.adoc.template.dir";
/**
* Custom final template filename.
*/
String MICRONAUT_OPENAPI_ADOC_TEMPLATE_FILENAME = "micronaut.openapi.adoc.template-filename";
String MICRONAUT_OPENAPI_ADOC_TEMPLATE_FILENAME = "micronaut.openapi.adoc.template.filename";
/**
* Result adoc file output directory.
*/
String MICRONAUT_OPENAPI_ADOC_OUTPUT_DIR_PATH = "micronaut.openapi.adoc.output-dir";
String MICRONAUT_OPENAPI_ADOC_OUTPUT_DIR_PATH = "micronaut.openapi.adoc.output.dir";
/**
* Result adoc filename.
*/
String MICRONAUT_OPENAPI_ADOC_OUTPUT_FILENAME = "micronaut.openapi.adoc.output-filename";
String MICRONAUT_OPENAPI_ADOC_OUTPUT_FILENAME = "micronaut.openapi.adoc.output.filename";
/**
* OpenAPI file path.
*/
String MICRONAUT_OPENAPI_ADOC_OPENAPI_PATH = "micronaut.openapi.adoc.openapi-path";
String MICRONAUT_OPENAPI_ADOC_OPENAPI_PATH = "micronaut.openapi.adoc.openapi.path";
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Map;

import io.micronaut.openapi.OpenApiUtils;
import io.micronaut.openapi.adoc.md.MdToAdocConverter;
import io.micronaut.openapi.adoc.utils.SwaggerUtils;
import io.swagger.v3.oas.models.OpenAPI;

Expand Down Expand Up @@ -71,7 +72,7 @@ private OpenApiToAdocConverter() {
}

/**
* Convertion from openAPI format to asciidoc format.
* Conversion from openAPI format to asciidoc format.
*
* @throws TemplateException som problems with freemarker templates
* @throws IOException some problems with files
Expand Down Expand Up @@ -112,6 +113,8 @@ public static void convert() throws TemplateException, IOException {
*/
public static void convert(OpenAPI openApi, Map props, Writer writer) throws TemplateException, IOException {

MdToAdocConverter.convert(openApi);

var model = new HashMap<String, Object>();
model.put("info", openApi.getInfo());
model.put("externalDocs", openApi.getExternalDocs());
Expand Down Expand Up @@ -164,7 +167,8 @@ private static Configuration getFreemarkerConfig(String[] customTemplatesDirs) t
if (customTemplatesDirs != null && customTemplatesDirs.length > 0) {
var templateLoaders = new ArrayList<TemplateLoader>();
for (var templateDir : customTemplatesDirs) {
templateDir = templateDir.strip();
templateDir = templateDir.strip()
.replace("\\", "/");
if (templateDir.startsWith(CLASSPATH_SCHEME)) {
templateLoaders.add(new ClassTemplateLoader(OpenApiToAdocConverter.class, templateDir.substring(CLASSPATH_SCHEME.length())));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.pegdown.ast.RootNode;

/**
* Convert-methods from MD fromat to AsciiDoc.
* Convert-methods from MD format to AsciiDoc.
*
* @since 5.2.0
*/
Expand Down Expand Up @@ -133,9 +133,13 @@ public static void convert(OpenAPI openApi) {
processParameters(openApi.getComponents().getParameters().values());
}
processExamples(openApi.getComponents().getExamples());
processRequestBodies(openApi.getComponents().getRequestBodies().values());
if (CollectionUtils.isNotEmpty(openApi.getComponents().getRequestBodies())) {
processRequestBodies(openApi.getComponents().getRequestBodies().values());
}
processHeaders(openApi.getComponents().getHeaders());
processSecuritySchemas(openApi.getComponents().getSecuritySchemes().values());
if (CollectionUtils.isNotEmpty(openApi.getComponents().getSecuritySchemes())) {
processSecuritySchemas(openApi.getComponents().getSecuritySchemes().values());
}
processLinks(openApi.getComponents().getLinks());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<#list paths as pathsStr, path>
<#list path.readOperationsMap() as method, operation>

=== __${method}__ `${pathsStr}` ${operation.getSummary()?trim}
=== __${method}__ `${pathsStr}`<#if operation.getSummary()?has_content> ${operation.getSummary()?trim}</#if>
<#if operation.getDescription()?has_content>
${operation.getDescription()?trim}

Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 0cc6aa6

Please sign in to comment.