Swagger API Tools: Difference between revisions
Jump to navigation
Jump to search
Line 20: | Line 20: | ||
{{External|[https://github.com/ovidiuf/playground/blob/b5708d871c345934d890c1b17ca8a58bd8726dc7/swagger/swagger-parser-example/src/main/java/playground/swagger/YamlExamples.java#L11-L14 Render Swagger as Yaml]}} | {{External|[https://github.com/ovidiuf/playground/blob/b5708d871c345934d890c1b17ca8a58bd8726dc7/swagger/swagger-parser-example/src/main/java/playground/swagger/YamlExamples.java#L11-L14 Render Swagger as Yaml]}} | ||
<syntaxhighlight lang='java'> | |||
import io.swagger.models.Swagger; | |||
import io.swagger.util.Yaml; | |||
Swagger swagger = ... | |||
... | |||
Yaml.mapper().writeValueAsString(swagger); | |||
... | |||
</syntaxhighlight> | |||
=Swagger Parser= | =Swagger Parser= |
Revision as of 01:58, 23 February 2019
External
Internal
Swagger Core
- OpenAPI 3.0 implementation https://github.com/swagger-api/swagger-core
- OpenAPI 2.0 implementation https://github.com/swagger-api/swagger-core/tree/1.5
Swagger Core Playground Example
Render Swagger as Yaml
import io.swagger.models.Swagger;
import io.swagger.util.Yaml;
Swagger swagger = ...
...
Yaml.mapper().writeValueAsString(swagger);
...
Swagger Parser
- Swagger Parser 1.X (OpenAPI 2.0) https://github.com/swagger-api/swagger-parser/tree/v1
- Swagger Parser 2.X (OpenAPI 3.0) https://github.com/swagger-api/swagger-parser
Swagger Parser Overview
Swagger Parser dependes on Swagger Core.
Swagger Parser Playground Example
Dependencies
dependencies {
implementation "io.swagger:swagger-parser:1.0.42"
implementation "io.swagger:swagger-parser:1.0.42:sources"
}