Current section
Files
Jump to
Current section
Files
src/nori@codegen@ir.erl
-module(nori@codegen@ir).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/nori/codegen/ir.gleam").
-export_type([codegen_i_r/0, security_scheme_i_r/0, api_key_location_i_r/0, security_requirement_i_r/0, type_def/0, field/0, enum_variant/0, type_ref/0, primitive_type/0, endpoint/0, http_method/0, endpoint_param/0, param_location/0, request_body_i_r/0, response_i_r/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(
" Language-agnostic intermediate representation for code generation.\n"
"\n"
" Sits between the OpenAPI `Document` and language-specific generators.\n"
" Decouples parsing from generation: third-party emitters (other languages,\n"
" other frameworks) can consume `CodegenIR` without depending on the parser\n"
" or knowing the OpenAPI spec details.\n"
"\n"
" Build one with `nori.build_ir(doc)`, then walk it. The shape is intended\n"
" to be stable and human-readable — semantic versioning rules of nori\n"
" itself apply to this module.\n"
).
-type codegen_i_r() :: {codegen_i_r,
binary(),
binary(),
gleam@option:option(binary()),
list(type_def()),
list(endpoint()),
list(security_scheme_i_r()),
list(security_requirement_i_r())}.
-type security_scheme_i_r() :: {bearer_auth,
binary(),
gleam@option:option(binary())} |
{api_key_auth, binary(), binary(), api_key_location_i_r()} |
{basic_auth, binary()} |
{o_auth2_auth, binary()} |
{open_id_connect_auth, binary(), binary()}.
-type api_key_location_i_r() :: in_header | in_query | in_cookie.
-type security_requirement_i_r() :: {security_requirement_i_r,
binary(),
list(binary())}.
-type type_def() :: {record_type,
binary(),
list(field()),
gleam@option:option(binary())} |
{enum_type, binary(), list(enum_variant()), gleam@option:option(binary())} |
{union_type,
binary(),
list(type_ref()),
gleam@option:option(binary()),
gleam@option:option(binary())} |
{alias_type, binary(), type_ref(), gleam@option:option(binary())}.
-type field() :: {field,
binary(),
type_ref(),
boolean(),
gleam@option:option(binary()),
boolean(),
boolean()}.
-type enum_variant() :: {enum_variant, binary(), binary()}.
-type type_ref() :: {named, binary()} |
{primitive, primitive_type()} |
{array, type_ref()} |
{dict, type_ref(), type_ref()} |
{nullable, type_ref()} |
{optional, type_ref()} |
{literal, binary()} |
unknown.
-type primitive_type() :: p_string |
p_int |
p_float |
p_bool |
p_date_time |
p_date |
p_binary |
p_unit.
-type endpoint() :: {endpoint,
binary(),
http_method(),
binary(),
gleam@option:option(binary()),
gleam@option:option(binary()),
list(binary()),
list(endpoint_param()),
gleam@option:option(request_body_i_r()),
list(response_i_r()),
boolean(),
gleam@option:option(list(security_requirement_i_r()))}.
-type http_method() :: get | post | put | delete | patch | head | options.
-type endpoint_param() :: {endpoint_param,
binary(),
param_location(),
type_ref(),
boolean(),
gleam@option:option(binary())}.
-type param_location() :: path_param | query_param | header_param | cookie_param.
-type request_body_i_r() :: {request_body_i_r, binary(), type_ref(), boolean()}.
-type response_i_r() :: {response_i_r,
binary(),
binary(),
gleam@option:option(binary()),
gleam@option:option(type_ref())}.