Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New module: openapi-adoc #1233

Merged
merged 13 commits into from
Oct 25, 2023
Merged

Conversation

altro3
Copy link
Collaborator

@altro3 altro3 commented Oct 1, 2023

Introduce new module to convert openAPI json and yml format to Asciidoc format. After it you can convert it to Markdown, HTML, PDF or DOCX.

Base template looks like this (PDF format):

изображение

изображение

You can customize full template or only part of it.

I integrated it with annotation processor as a optional module. To use it you just need add dependency to annotation processor classpath:

annotationProcessor("io.micronaut.openapi:micronaut-openapi-adoc")

Need to merge it first: micronaut-projects/micronaut-build#623

# Conflicts:
#	gradle/libs.versions.toml
#	openapi-common/build.gradle
#	openapi-to-adoc/build.gradle
#	openapi-to-adoc/src/main/java/io/micronaut/openapi/adoc/TemplatePaths.java
#	openapi-to-adoc/src/main/java/io/micronaut/openapi/adoc/md/ToAsciiDocSerializer.java
#	openapi-to-adoc/src/main/java/io/micronaut/openapi/adoc/utils/SwaggerUtils.java
@altro3 altro3 mentioned this pull request Oct 11, 2023
# Conflicts:
#	openapi/src/main/java/io/micronaut/openapi/view/SwaggerUIConfig.java
@altro3
Copy link
Collaborator Author

altro3 commented Oct 12, 2023

@graemerocher and what about this new module? Created 2 weeks ago, but nobody review it :-(

*
* @since 5.2.0
*/
public final class CollectionUtils {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed there is already this type in micronaut-core module

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I know, but the idea is to not depend on this library.

By the way, I saw that it will still appear in the dependencies, because... it is added by the Build plugin. How to correctly remove this background dependency?

same problem in other modules: openapi-annotations, openapi-generator...

}

public static String loadFileFromClasspath(String location) {
String file = location.replaceAll("\\\\", "/");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to check there are no path traversal vulnerabilities here. //cc @yawkat

public static OpenAPI readOpenApiFromLocation(String location) {

var isJson = location.endsWith(".json");
var adjustedLocation = location.replaceAll("\\\\", "/").toLowerCase();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here with path traversal

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm.. i still don't understand, what problem with my code? Your example is not the same, as my case. My location can be in URI format, can be just file system path, can be pah inside jar or classpath. This is the easiest and fastest way to get rid of problems with different slashes in the path and OS

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok since this is build time only it is probably fine

@graemerocher
Copy link
Contributor

@graemerocher
Copy link
Contributor

Sorry for the delay in reviewing PRs, appreciate all your work which is a significant contribution!

@graemerocher graemerocher merged commit 5d6de2f into micronaut-projects:master Oct 25, 2023
6 checks passed
@graemerocher graemerocher added the type: enhancement New feature or request label Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants