Springfox: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 54: Line 54:


<font color=darkgray>How is the artifact generated? Where?</font>
<font color=darkgray>How is the artifact generated? Where?</font>
==Generating the Swagger Specification==
==UI Support==
<syntaxhighlight lang='groovy'>
dependencies {
    compile 'io.springfox:springfox-swagger-ui:2.9.2'
}
</syntaxhighlight>

Revision as of 21:53, 14 February 2019

External

Internal

Overview

Springfox is a suite of Java libraries for automating the generation of machine and human readable specification for JSON APIs written with Spring Framework. Springfox works by examining an application, once, at runtime to infer API semantics based on Spring configurations, class structure and various compile time java annotations.

Gradle Dependencies

repositories {

   jcenter()
}

dependencies {

    compileOnly "io.springfox:springfox-swagger2:2.9.2"
}

Essential Classes

  • springfox.documentation.spring.web.plugins.Docket: the primary API configuration mechanism.
  • ApiSelectorBuilder provides fine grained control over the endpoints exposed via swagger.

Annotations

Security Schemas

The following security schemas are available to protect the API:

  • ApiKey
  • BasicAuth
  • OAuth

Models

Non-reachable Model

A model that should be described in the generated specification but is not explicitly used in any operation.

Generating Swagger/OpenAPI Specification from Spring Code with Springfox

General Considerations

How is the artifact generated? Where?

Generating the Swagger Specification

UI Support

dependencies {

    compile 'io.springfox:springfox-swagger-ui:2.9.2'
}