Skip to content

Instantly share code, notes, and snippets.

@kevinswiber
Last active August 29, 2020 15:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinswiber/ca0e169d9d64cad7a08d403d22709ad9 to your computer and use it in GitHub Desktop.
Save kevinswiber/ca0e169d9d64cad7a08d403d22709ad9 to your computer and use it in GitHub Desktop.
OpenAPI Spec in HCL
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"
}
}
}
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"
}
}
}
}
// 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"
}
}
}
}
---
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