-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
36b614a
commit c0c7419
Showing
9 changed files
with
273 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
defmodule BuildelWeb.ApiSpec do | ||
alias OpenApiSpex.{Info, OpenApi, Paths, Server} | ||
alias BuildelWeb.{Endpoint, Router} | ||
@behaviour OpenApi | ||
|
||
@impl OpenApi | ||
def spec do | ||
%OpenApi{ | ||
servers: [ | ||
Server.from_endpoint(Endpoint) | ||
], | ||
info: %Info{ | ||
title: "Buildel", | ||
version: "1.0" | ||
}, | ||
paths: Paths.from_router(Router) | ||
} | ||
|> OpenApiSpex.resolve_schema_modules() | ||
end | ||
end |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
defmodule BuildelWeb.Schemas.Errors do | ||
alias OpenApiSpex.Schema | ||
|
||
defmodule NotFoundResponse do | ||
require OpenApiSpex | ||
|
||
OpenApiSpex.schema(%{ | ||
type: :object, | ||
properties: %{ | ||
errors: %Schema{ | ||
type: :object, | ||
properties: %{ | ||
detail: %Schema{type: :string, description: "Error message"} | ||
} | ||
} | ||
} | ||
}) | ||
end | ||
|
||
defmodule UnauthorizedResponse do | ||
require OpenApiSpex | ||
|
||
OpenApiSpex.schema(%{ | ||
type: :object, | ||
properties: %{ | ||
errors: %Schema{ | ||
type: :object, | ||
properties: %{ | ||
detail: %Schema{type: :string, description: "Error message"} | ||
} | ||
} | ||
} | ||
}) | ||
end | ||
|
||
defmodule ForbiddenResponse do | ||
require OpenApiSpex | ||
|
||
OpenApiSpex.schema(%{ | ||
type: :object, | ||
properties: %{ | ||
errors: %Schema{ | ||
type: :object, | ||
properties: %{ | ||
detail: %Schema{type: :string, description: "Error message"} | ||
} | ||
} | ||
} | ||
}) | ||
end | ||
|
||
defmodule UnprocessableEntity do | ||
require OpenApiSpex | ||
|
||
OpenApiSpex.schema(%{ | ||
type: :object, | ||
properties: %{ | ||
errors: %Schema{ | ||
type: :object, | ||
additionalProperties: %Schema{ | ||
type: :array, | ||
items: %Schema{type: :string, description: "Field error message"} | ||
} | ||
} | ||
} | ||
}) | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
defmodule BuildelWeb.Schemas.Organizations do | ||
alias OpenApiSpex.Schema | ||
|
||
defmodule Organization do | ||
require OpenApiSpex | ||
|
||
OpenApiSpex.schema(%{ | ||
type: :object, | ||
properties: %{ | ||
id: %Schema{type: :integer, description: "Organization ID"}, | ||
name: %Schema{type: :string, description: "Organization name"}, | ||
api_key: %Schema{type: :string, description: "Organization API key"} | ||
} | ||
}) | ||
end | ||
|
||
defmodule IndexResponse do | ||
require OpenApiSpex | ||
|
||
OpenApiSpex.schema(%{ | ||
type: :object, | ||
properties: %{ | ||
data: %Schema{ | ||
type: :array, | ||
items: Organization | ||
} | ||
} | ||
}) | ||
end | ||
|
||
defmodule ShowResponse do | ||
require OpenApiSpex | ||
|
||
OpenApiSpex.schema(%{ | ||
type: :object, | ||
properties: %{ | ||
data: BuildelWeb.Schemas.Organizations.Organization | ||
} | ||
}) | ||
end | ||
|
||
defmodule CreateRequest do | ||
require OpenApiSpex | ||
|
||
OpenApiSpex.schema(%{ | ||
type: :object, | ||
properties: %{ | ||
name: %Schema{type: :string, description: "Organization name"} | ||
} | ||
}) | ||
end | ||
|
||
defmodule ShowApiKeyResponse do | ||
require OpenApiSpex | ||
|
||
OpenApiSpex.schema(%{ | ||
type: :object, | ||
properties: %{ | ||
data: %Schema{ | ||
type: :object, | ||
properties: %{ | ||
key: %Schema{type: :string, description: "Organization API key"} | ||
} | ||
} | ||
} | ||
}) | ||
end | ||
end |
This file contains 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
This file contains 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