Packages

OpenAPI code generation for Gleam — parse specs, generate types, routes, clients, and React Query/SWR hooks

Current section

Files

Jump to
nori src nori@server.erl
Raw

src/nori@server.erl

-module(nori@server).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/nori/server.gleam").
-export([new/1, with_description/2, variable/1, variable_with_enum/2]).
-export_type([server/0, server_variable/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(
" Server and ServerVariable types for OpenAPI specifications.\n"
"\n"
" Servers define the base URLs for API endpoints.\n"
).
-type server() :: {server,
binary(),
gleam@option:option(binary()),
gleam@dict:dict(binary(), server_variable()),
gleam@dict:dict(binary(), gleam@json:json())}.
-type server_variable() :: {server_variable,
list(binary()),
binary(),
gleam@option:option(binary()),
gleam@dict:dict(binary(), gleam@json:json())}.
-file("src/nori/server.gleam", 43).
?DOC(" Creates a `Server` with just a URL.\n").
-spec new(binary()) -> server().
new(Url) ->
{server, Url, none, maps:new(), maps:new()}.
-file("src/nori/server.gleam", 53).
?DOC(" Creates a `Server` with a URL and description.\n").
-spec with_description(binary(), binary()) -> server().
with_description(Url, Description) ->
{server, Url, {some, Description}, maps:new(), maps:new()}.
-file("src/nori/server.gleam", 63).
?DOC(" Creates a `ServerVariable` with just a default value.\n").
-spec variable(binary()) -> server_variable().
variable(Default) ->
{server_variable, [], Default, none, maps:new()}.
-file("src/nori/server.gleam", 73).
?DOC(" Creates a `ServerVariable` with enum values and a default.\n").
-spec variable_with_enum(list(binary()), binary()) -> server_variable().
variable_with_enum(Enum_values, Default) ->
{server_variable, Enum_values, Default, none, maps:new()}.