Skip to content

Latest commit

 

History

History
68 lines (64 loc) · 2.4 KB

README_swagger.md

File metadata and controls

68 lines (64 loc) · 2.4 KB

Generate the swagger.json document for the JAX-RS annotations

The swagger.json file has been generated by the com.sebastian-daschner:jaxrs-analyzer-maven-plugin:jar:0.15 Maven plugin.

The following plugin must be added into the pom.xml of javaee7-angular project in order to re-generate the swagger.json document if you update the JAX-RS annotations of the RESTFul application.

          <plugin>
              <groupId>com.sebastian-daschner</groupId>
              <artifactId>jaxrs-analyzer-maven-plugin</artifactId>
              <version>0.15</version>
              <executions>
                  <execution>
                      <goals>
                          <goal>analyze-jaxrs</goal>
                      </goals>
                      <configuration>
                          <!-- Available backends are plaintext (default), swagger and asciidoc -->
                          <backend>swagger</backend>
                          <deployedDomain>localhost:8080</deployedDomain>
                      </configuration>
                  </execution>
              </executions>
          </plugin>

And copy the new file in the directory

cp ../javaee7-angular/target/jaxrs-analyzer/swagger.json .

Then, you should add the following statements into the swagger.json file

	...
	"info": {
		"description": "This is a sample of a simple RESTFul JavaEE server.",
                "version": "1.0.0",
		"title": "Addressbook",
		"termsOfService": "http://addressbook.io/terms/",
		"contact": {
			"email": "apiteam@addressbook.io"
		},
		"license": {
			"name": "Apache 2.0",
			"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
		}
	},
        "host": "localhost:8080",
        ...

Generate the static documentation (HTML)

sudo npm install -g yamljs
sudo npm install -g bootprint bootprint-openapi
sudo npm install -g html-inline

mkdir -p target
yaml2json --pretty api/swagger/swagger.yaml > target/swagger.json
bootprint openapi target/swagger.json target/docs
html-inline target/docs/index.html > target/docs/one_page_index.html

Generate the static documentation (PDF)

TODO see https://www.npmjs.com/package/swagger-spec-to-pdf

/usr/lib/node_modules/swagger-spec-to-pdf/bin/swagger2pdf -s target/swagger.json -t target/docs/swagger.pdf
swagger2pdf

Alternative : Generate the static documentation from (ADOC, HTML, PDF)

TODO https://github.com/Swagger2Markup/spring-swagger2markup-demo.git