Offline swagger documentation using maven plugin - java

I am trying to generate swagger documentation, for that I need to start the server. I Want to generate swagger documentation offline (with out starting the server), I just got this link swagger-codegen-maven-plugin
But when I added above plugin to POM.xml (Suppose to generate HTML doc during maven build i feel), it is not at all doing anything. Please help.

Take a look at this plugin:
https://github.com/teamcarma/swagger-jaxrs-doclet
As the JSON resource listing is generated offline from source code it means that you do not need to add any runtime dependencies to your project and avoid potential headaches with different jar versions and jaxrs implementations. This also avoids increasing the size of your artifacts

To generate the HTML documentation, you need to set the value of the language tag in the configuration to HTML. In the example from your link, it is set to java. Change it to html. If you need both Java and HTML to be generated, have two execution blocks, one for Java, one for HTML.

Related

How to create open api documentation in .yaml format with maven?

I am building a rest api and part of the requirement is that we write documentation according to the open api specification. I am using (http://editor.swagger.io) to do this, and I find it irritating, and way less affective than creating normal javadoc. Is there a maven plugin, or something that can build documentation from comments in .yaml or .json format according to the open api specification? Thanks!
Seems like you're looking for that maven library https://springfox.github.io/springfox/docs/current/
It can automatically generate specifications in html

swagger codegen keyword additions

I have to maintain a project that uses Swagger to codegen the api interface. Looking at the model.mustache, I see this:
{{#models}}
{{#model}}{{#description}}
/**
* {{description}}
**/{{/description}}
and a bunch of other keywords like enum, defaultValue, vars, package, etc. Where do these come from? I've been scouring the internet trying to find swagger documentation on this but I cannot find anything. Lots of the links that refer to swagger info on github return 404 pages. In the end, what I want to be able to do is to have a property exist in my actual .json file that swagger is using to generate the interfaces and models to conditionally generate code. I saw that there is the
{{#property}}{{/property}}
{{^property}}{{/property}}
notation for if/else statements, but it doesn’t work on any property of my own .json. For example, in my json I have an id field. So if I wanted to do a contrived example
{{#id}}System.out.println(“test test”);{{/id}}
won’t work because swagger does not recognize the id tag. So my question is, can I add these tags?
there are lots of tools to help out. If you see broken links, please submit issues to the swagger-codegen project.
As of 2.1.x-M1, swagger-codegen has a very helpful "debug" mode which lets you list all the possible values for your environment. You can invoke it as follows:
java -DdebugModels -jar {path-to}/swagger-codegen-cli.jar generate {opts}
The supported debug flags are:
-DdebugModels: outputs the variables for each model discovered by codegen
-DdebugOperations: outputs the variables for each operation
-DdebugSupportingFiles: shows supporting file data (anything but models or operations)
-DdebugSwagger: shows the parsed swagger representation
I do see that these are missing from the README. Will make sure they get added.

How to add external tags file into CEDET in Emacs

I tried to use CEDET to get auto completion in Emacs and that works fine for C/C++. But I cannot find anything about how to use CEDET with Java without the help of JDEE, which is thought out of date and not compatible to CEDET 1.1. I got a tags file using utility found here but I don't know how to integrate that into CEDET system. According to CEDET's website, that's possible. But they don't explain how to do it. Is there someone willing to answer this question?
Here is some sample of the tags file generated by that utility:
java.applet.Applet$AccessibleApplet
protected java.applet.Applet$AccessibleApplet(java.applet.Applet)
public java.applet.Applet$AccessibleApplet.getAccessibleRole() returns javax.accessibility.AccessibleRole
public java.applet.Applet$AccessibleApplet.getAccessibleStateSet() returns javax.accessibility.AccessibleStateSet
It is possible to have CEDET pull in tags from a .jar file. It works by using javap to extract the tags in text form, and then it parses that data.
It isn't very easy to set up since in CEDET, the concept of where to find your library files is part of EDE, the project management system, not the parser and smart completion system. The only Java based project supported in CEDET 1.1 is Android.
The basics is to first enable the javap database by loading it with (require 'semanticdb-javap) in CEDET 1.1, or (require 'semantic/db-javap) in the bzr version of CEDET.
Once you've done that, you can configure it via the cedet-java-classpath-extension. I'm a little fuzzy on the details of what happens next, but folks have reported success on the mailing list.
If you use CEDET from the bzr repository, there is the ede-java-root project, which is similar to the ede-cpp-root project. That project type lets you configure what your library path is. The doc for that is in the ede/java-root.el file with the project type, and shows you the basics of how to use it.

Simple way to apply template to existing HTML code

Suppose I have a bunch of (very simple) HTML pages, that I want to apply a common 'theme".
These files are downloaded using various Groovy scripts, and I would like to apply to them this styling during a maven build. How could I do that ?
Using which framework/library could I do that ?
Furthermore notice I want to do that in a static fashion, that's to say I want to have the following process to occur
Files are downloaded by Groovy scripts
They are processed (in a "magical" fashion) by this library
They may be sent by FTP/SCP to an hosting server
Do you know such an easy to use library ?
Depends on the details of the task but having in mind the steps you've described you can consider using velocity templates.
I would suggest using sitemesh decorator. I am a user of old version but a new release is being worked on that allows you to do exactly what you are asking for. Do a google search on sitemesh and you should find lots of examples.
In a nutshell sitemesh decoration: basic html + template = decorated page.

Modifying POM settings from plugin code

I've just recently started writing Maven plugins and was wondering if there is a common way to modify the values within the pom.xml file e.g. changing an artifacts version number. With the exception of the line being modified I would want the remaining formatting within the xml file to be preserved. I'm just about to start manually doing this via Java DOM libraries, but wanted to check first if there are any Maven convenience classes/functions for this.
Thanks.
My advice would be to check how this is done in the maven-release-plugin. Actually, the interesting parts are in maven-release-manager. Get the sources and dig :)
I don't think there's a prescribed way of manipulating the pom. All the plugins I've seen and written use one of the many DOM libraries. The docs for the XOM Serializer explicitly mention that it respects all whitespace unless instructed otherwise.

Categories