open_api.cr
OpenAPI
Aims at providing a complete more or less type safe mapping of OpenAPI specification. Currently supported version: 3.0.1. Use it to either write or parse OpenAPI specs.
Installation
Add this to your application's shard.yml
:
dependencies:
open_api:
github: jreinert/open_api.cr
Usage
Writing specs
require "open_api"
OpenAPI.build do |api|
doc = api.document(
openapi: "3.0.1"
info: {
title: "Catlib",
version: "0.1"
},
paths: {
"/meow" => api.path_item(
get: {
tags: ["cats"],
request_body: {
ref: "#/components/schemas/cat"
}
}
)
},
components: {
schemas: {
:cat => api.schema(
type: "object",
description: "A cat"
)
}
}
)
puts doc.to_json
)
Parsing specs
require "open_api"
File.open("openapi.yml") do |file|
doc = OpenAPI.from_yaml(file)
puts doc.to_json
end
Contributing
- Fork it (https://github.com/jreinert/open_api.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- jreinert Joakim Reinert - creator, maintainer
Repository
open_api.cr
Owner
Statistic
- 13
- 5
- 0
- 0
- 0
- over 3 years ago
- August 30, 2018
License
MIT License
Links
Synced at
Thu, 07 Nov 2024 11:13:15 GMT
Languages