Last active
August 29, 2020 15:13
-
-
Save kevinswiber/ca0e169d9d64cad7a08d403d22709ad9 to your computer and use it in GitHub Desktop.
OpenAPI Spec in HCL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swagger = "2.0" | |
info { | |
version = "1.0.0" | |
title = "Swagger Petstore" | |
description = "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification" | |
terms_of_service = "http://swagger.io/terms" | |
contact { | |
name = "Swagger API Team" | |
} | |
license { | |
name = "MIT" | |
} | |
} | |
host = "petstore.swagger.io" | |
base_path = "/api" | |
schemes = ["http"] | |
consumes = ["application/json"] | |
produces = ["application/json"] | |
path "/pet" { | |
get { | |
description = "Returns all pets from the system that the user has access to" | |
produces = ["application/json"] | |
response "200" { | |
description = "A list of pets." | |
schema { | |
type = "array" | |
items { | |
"$ref" = "${definition.pet}" | |
} | |
} | |
} | |
} | |
} | |
definition "pet" { | |
type = "object" | |
required = ["id", "name"] | |
properties { | |
id { | |
type = "integer" | |
format = "int64" | |
} | |
name { | |
type = "string" | |
} | |
tag { | |
type = "string" | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swagger = "2.0" | |
info { | |
version = "1.0.0" | |
title = "Swagger Petstore" | |
description = "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification" | |
termsOfService = "http://swagger.io/terms" | |
contact { | |
name = "Swagger API Team" | |
} | |
license { | |
name = "MIT" | |
} | |
} | |
host = "petstore.swagger.io" | |
basePath = "/api" | |
schemes = ["http"] | |
consumes = ["application/json"] | |
produces = ["application/json"] | |
paths { | |
"/pets" { | |
get { | |
description = "Returns all pets from the system that the user has access to" | |
produces = ["application/json"] | |
responses { | |
"200" { | |
description = "A list of pets." | |
schema { | |
type = "array" | |
items { | |
"$ref" = "#/definitions/Pet" | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
definitions { | |
Pet { | |
type = "object" | |
required = ["id", "name"] | |
properties { | |
id { | |
type = "integer" | |
format = "int64" | |
} | |
name { | |
type = "string" | |
} | |
tag { | |
type = "string" | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HOCON | |
swagger = "2.0" | |
info { | |
version = "1.0.0" | |
title = "Swagger Petstore" | |
description = "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification" | |
terms_of_service = "http://swagger.io/terms" | |
contact { | |
name = "Swagger API Team" | |
} | |
license { | |
name = "MIT" | |
} | |
} | |
host = "petstore.swagger.io" | |
base_path = "/api" | |
schemes = ["http"] | |
consumes = ["application/json"] | |
produces = ["application/json"] | |
paths { | |
"/pet" { | |
get { | |
description = "Returns all pets from the system that the user has access to" | |
produces = ["application/json"] | |
response "200" { | |
description = "A list of pets." | |
schema { | |
type = "array" | |
items { | |
"$ref" = "${definition.pet}" | |
} | |
} | |
} | |
} | |
} | |
} | |
definitions { | |
pet { | |
type = "object" | |
required = ["id", "name"] | |
properties { | |
id { | |
type = "integer" | |
format = "int64" | |
} | |
name { | |
type = "string" | |
} | |
tag { | |
type = "string" | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
swagger: "2.0" | |
info: | |
version: "1.0.0" | |
title: "Swagger Petstore" | |
description: "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification" | |
termsOfService: "http://swagger.io/terms/" | |
contact: | |
name: "Swagger API Team" | |
license: | |
name: "MIT" | |
host: "petstore.swagger.io" | |
basePath: "/api" | |
schemes: | |
- "http" | |
consumes: | |
- "application/json" | |
produces: | |
- "application/json" | |
paths: | |
/pets: | |
get: | |
description: "Returns all pets from the system that the user has access to" | |
produces: | |
- "application/json" | |
responses: | |
"200": | |
description: "A list of pets." | |
schema: | |
type: "array" | |
items: | |
$ref: "#/definitions/Pet" | |
definitions: | |
Pet: | |
type: "object" | |
required: | |
- "id" | |
- "name" | |
properties: | |
id: | |
type: "integer" | |
format: "int64" | |
name: | |
type: "string" | |
tag: | |
type: "string" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment