https://github.com/niku/generate_elixir_code_from_openapi_definition
Generate an elixir code from OpenAPI definition
https://github.com/niku/generate_elixir_code_from_openapi_definition
Last synced: about 1 month ago
JSON representation
Generate an elixir code from OpenAPI definition
- Host: GitHub
- URL: https://github.com/niku/generate_elixir_code_from_openapi_definition
- Owner: niku
- Created: 2018-02-22T12:42:31.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-02-22T15:18:35.000Z (over 8 years ago)
- Last Synced: 2025-01-12T16:41:33.716Z (over 1 year ago)
- Language: Elixir
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GenerateElixirCodeFromOpenapiDefinition
Generate an elixir code from OpenAPI definition.
## Usage
```
$ cat test/fixtures/simple.yaml
swagger: "2.0"
info:
version: "0.0.1"
title: "Minimal API Sepcification"
paths:
/greetings/hello:
get:
operationId: "hello"
parameters: []
responses:
200:
description: "succeeded"
schema:
type: "string"
example: "hello"
post:
operationId: "hello with name"
parameters: []
responses:
200:
description: "succeeded"
schema:
type: "string"
example: "hello niku"
$ mix run -e 'IO.puts GenerateElixirCodeFromOpenapiDefinition.generate("test/fixtures/simple.yaml")'
defmodule MyRouter do
use Plug.Router
plug :match
plug :dispatch
get "/greetings/hello" do
send_resp(conn, 200, "hello")
end
post "/greetings/hello" do
send_resp(conn, 200, "hello niku")
end
match _ do
send_resp(conn, 404, "oops")
end
end
```