Swagger2Markup / swagger2markup-maven-project-template

This is a Swagger2Markup Maven template project which uses the swagger2markup-maven-plugin to convert a contract-first Swagger specification into an AsciiDoctor-based HTML documentation.
50 stars 47 forks source link

Using markdown in the extensions #9

Open voz opened 7 years ago

voz commented 7 years ago

Thanks for this project template! It works great for asciidoc doc extensions as they are used in the project right now.

Is it possible to employ markdown extensions instead?

Just renaming .adoc files into .md and changing the text inside seems not to work: the extensions do not appear in the generated docs.

RobWin commented 7 years ago

Thx. Please have a look at http://swagger2markup.github.io/swagger2markup/1.3.1/ chapter 5.5.1 configuration

voz commented 7 years ago

@RobWin thanks, I've checked and I see the parameter swagger2markup.extensions.dynamicOverview.markupLanguage which I specified in my gradle task below.

Indeed, the conversion of markdown to asciidoc now happens but as long as the extension of the file is .adoc. If I change the extension of the file with markdown into .md then the converted content doesn't appear anymore in the generated overview.adoc. Any idea why?

convertSwagger2markup {
    swaggerInput file("src/docs/swagger/swagger_petstore.yaml").getAbsolutePath()
    outputDir asciiDocOutputDir
    config =['swagger2markup.markupLanguage' : 'ASCIIDOC',
              'swagger2markup.outputLanguage' : 'EN',
              'swagger2markup.pathsGroupedBy' : 'TAGS',
              'swagger2markup.generatedExamplesEnabled' : 'true',
              'swagger2markup.pathSecuritySectionEnabled' : 'false',
              'swagger2markup.basePathPrefixEnabled' : 'true',
              'swagger2markup.extensions.dynamicDefinitions.contentPath' : file('src/docs/asciidoc/extensions/definitions').absolutePath,
              'swagger2markup.extensions.dynamicDefinitions.markupLanguage' : 'MARKDOWN',
              'swagger2markup.extensions.dynamicOverview.contentPath' : file('src/docs/asciidoc/extensions/overview').absolutePath,
              'swagger2markup.extensions.dynamicOverview.markupLanguage' : 'MARKDOWN',
              'swagger2markup.extensions.dynamicPaths.contentPath' : file('src/docs/asciidoc/extensions/paths').absolutePath,
              'swagger2markup.extensions.dynamicPaths.markupLanguage' : 'MARKDOWN',
              'swagger2markup.extensions.dynamicSecurity.contentPath' : file('src/docs/asciidoc/extensions/security').absolutePath,
              'swagger2markup.extensions.dynamicSecurity.markupLanguage' : 'MARKDOWN']
}
RobWin commented 7 years ago

Yes, you can only use .md files when you change swagger2markup.markupLanguage to MARKDOWN, as far as I remember.

voz commented 7 years ago

@RobWin the problem is that markdown in .md doesn't work even when I set swagger2markup.markupLanguage to MARKDOWN. I can write markdown in .adocand it works with the parameter set, but not in .md. Let me know if I explained it clearly :)

RobWin commented 7 years ago

In the meantime, can you use AsciiDoc instead?

voz commented 7 years ago

@RobWin yes, going to use AsciiDoc for now. Maybe, I'll get some time to investigate the cause for .md not working. Any hint where to look?

RobWin commented 7 years ago

It should be the import files extension. See https://github.com/Swagger2Markup/swagger2markup-extensions/blob/master/swagger2markup-import-files-ext/src/main/java/io/github/swagger2markup/extensions/DynamicDefinitionsDocumentExtension.java

Stoakes commented 6 years ago

Hi,

I'm dealing with the same issue. My current workaround is to use .md.adoc as file extension, but it is more a hack than a real solution.

I've been looking at your code to figure out if I could open a pull request to fix that behaviour. But I don't see where the extensionMarkupLanguage is managed.

RobWin commented 6 years ago

Hi, the bug might be in this line: https://github.com/Swagger2Markup/swagger2markup-extensions/blob/d572be66b65acf9f34dc42022c4fc15c241aa325/swagger2markup-extension-commons/src/main/java/io/github/swagger2markup/extensions/DynamicContentExtension.java#L55

If swagger2markup.markupLanguage is ASCIIDOC, we are looking only for files with a adoc extension. If swagger2markup.markupLanguage is MARKDOWN, we are looking only for files with a md extension.

The extensionMarkupLanguage is only used to check if we need to convert MARKDOWN into ASCIIDOC. But instead we should also use it to look for files with a md extension.