-module(oaisp@info).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/oaisp/info.gleam").
-export([info/2, to_json/1, decoder/0]).
-export_type([info/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(" The top-level metadata for the emitted OpenAPI document.\n").
-type info() :: {info,
binary(),
binary(),
gleam@option:option(binary()),
list(binary())}.
-file("src/oaisp/info.gleam", 26).
?DOC(
" An [`Info`](#Info) with no description and no servers. Spread it to set\n"
" those fields.\n"
).
-spec info(binary(), binary()) -> info().
info(Title, Version) ->
{info, Title, Version, none, []}.
-file("src/oaisp/info.gleam", 32).
?DOC(false).
-spec to_json(info()) -> gleam@json:json().
to_json(Info) ->
gleam@json:object(
[{<<"title"/utf8>>, gleam@json:string(erlang:element(2, Info))},
{<<"version"/utf8>>, gleam@json:string(erlang:element(3, Info))},
{<<"description"/utf8>>,
gleam@json:nullable(
erlang:element(4, Info),
fun gleam@json:string/1
)},
{<<"servers"/utf8>>,
gleam@json:array(
erlang:element(5, Info),
fun gleam@json:string/1
)}]
).
-file("src/oaisp/info.gleam", 43).
?DOC(false).
-spec decoder() -> gleam@dynamic@decode:decoder(info()).
decoder() ->
gleam@dynamic@decode:field(
<<"title"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Title) ->
gleam@dynamic@decode:field(
<<"version"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Version) ->
gleam@dynamic@decode:field(
<<"description"/utf8>>,
gleam@dynamic@decode:optional(
{decoder, fun gleam@dynamic@decode:decode_string/1}
),
fun(Description) ->
gleam@dynamic@decode:field(
<<"servers"/utf8>>,
gleam@dynamic@decode:list(
{decoder,
fun gleam@dynamic@decode:decode_string/1}
),
fun(Servers) ->
gleam@dynamic@decode:success(
{info,
Title,
Version,
Description,
Servers}
)
end
)
end
)
end
)
end
).