Packages
oaspec
0.11.0
0.68.0
0.67.0
0.66.0
0.65.0
0.64.0
0.63.0
0.62.0
0.61.0
0.60.0
0.59.0
0.58.1
0.58.0
0.57.0
0.56.0
0.55.0
0.54.0
0.53.0
0.52.0
0.51.0
0.50.0
0.49.0
0.48.0
0.47.0
0.46.0
0.45.0
0.44.0
0.43.0
0.42.0
0.41.0
0.40.0
0.39.0
0.38.0
0.37.0
0.36.0
0.35.0
0.34.0
0.33.0
0.32.0
0.31.0
0.30.0
0.29.0
0.28.0
0.27.0
0.26.0
0.25.0
0.24.0
0.23.0
0.22.0
0.21.0
0.20.0
0.19.0
0.18.0
0.17.0
0.16.0
0.15.0
0.14.0
0.13.0
0.12.0
0.11.0
0.10.0
0.9.0
0.8.0
0.7.0
0.6.3
0.6.1
0.6.0
0.5.0
0.4.0
0.3.0
0.1.3
Generate Gleam code from OpenAPI 3.x specifications
Current section
Files
Jump to
Current section
Files
src/oaspec@capability.erl
-module(oaspec@capability).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/oaspec/capability.gleam").
-export([registry/0, unsupported_schema_keywords/0, is_unsupported_security_type/1, by_level/1, generate_boundaries_markdown/0]).
-export_type([support_level/0, capability/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.
-type support_level() :: supported |
normalizable |
parsed_not_used |
unsupported |
not_handled.
-type capability() :: {capability,
binary(),
binary(),
support_level(),
binary()}.
-file("src/oaspec/capability.gleam", 24).
?DOC(" The single source of truth for feature support.\n").
-spec registry() -> list(capability()).
registry() ->
[{capability,
<<"object"/utf8>>,
<<"schema"/utf8>>,
supported,
<<"Object schemas with properties"/utf8>>},
{capability,
<<"string"/utf8>>,
<<"schema"/utf8>>,
supported,
<<"String schemas with enum, format, pattern"/utf8>>},
{capability,
<<"integer"/utf8>>,
<<"schema"/utf8>>,
supported,
<<"Integer schemas"/utf8>>},
{capability,
<<"number"/utf8>>,
<<"schema"/utf8>>,
supported,
<<"Number schemas"/utf8>>},
{capability,
<<"boolean"/utf8>>,
<<"schema"/utf8>>,
supported,
<<"Boolean schemas"/utf8>>},
{capability,
<<"array"/utf8>>,
<<"schema"/utf8>>,
supported,
<<"Array schemas with items"/utf8>>},
{capability,
<<"allOf"/utf8>>,
<<"schema"/utf8>>,
supported,
<<"Schema composition"/utf8>>},
{capability,
<<"oneOf"/utf8>>,
<<"schema"/utf8>>,
supported,
<<"Schema composition with discriminator"/utf8>>},
{capability,
<<"anyOf"/utf8>>,
<<"schema"/utf8>>,
supported,
<<"Schema composition with discriminator"/utf8>>},
{capability,
<<"nullable"/utf8>>,
<<"schema"/utf8>>,
supported,
<<"Nullable fields"/utf8>>},
{capability,
<<"additionalProperties"/utf8>>,
<<"schema"/utf8>>,
supported,
<<"Typed, untyped, forbidden"/utf8>>},
{capability,
<<"$ref"/utf8>>,
<<"schema"/utf8>>,
supported,
<<"Local $ref resolution"/utf8>>},
{capability,
<<"enum"/utf8>>,
<<"schema"/utf8>>,
supported,
<<"String enum values"/utf8>>},
{capability,
<<"discriminator"/utf8>>,
<<"schema"/utf8>>,
supported,
<<"With propertyName and mapping"/utf8>>},
{capability,
<<"const"/utf8>>,
<<"schema"/utf8>>,
normalizable,
<<"Normalized to single-value enum"/utf8>>},
{capability,
<<"type: [T, null]"/utf8>>,
<<"schema"/utf8>>,
normalizable,
<<"Normalized to nullable"/utf8>>},
{capability,
<<"type: [T1, T2]"/utf8>>,
<<"schema"/utf8>>,
normalizable,
<<"Normalized to oneOf"/utf8>>},
{capability,
<<"$defs"/utf8>>,
<<"schema"/utf8>>,
unsupported,
<<"Move definitions to components/schemas"/utf8>>},
{capability,
<<"prefixItems"/utf8>>,
<<"schema"/utf8>>,
unsupported,
<<"Tuple types not supported"/utf8>>},
{capability,
<<"if"/utf8>>,
<<"schema"/utf8>>,
unsupported,
<<"Use oneOf/anyOf instead"/utf8>>},
{capability,
<<"then"/utf8>>,
<<"schema"/utf8>>,
unsupported,
<<"Use oneOf/anyOf instead"/utf8>>},
{capability,
<<"else"/utf8>>,
<<"schema"/utf8>>,
unsupported,
<<"Use oneOf/anyOf instead"/utf8>>},
{capability,
<<"dependentSchemas"/utf8>>,
<<"schema"/utf8>>,
unsupported,
<<"Not supported"/utf8>>},
{capability,
<<"not"/utf8>>,
<<"schema"/utf8>>,
unsupported,
<<"Negation not supported"/utf8>>},
{capability,
<<"unevaluatedProperties"/utf8>>,
<<"schema"/utf8>>,
unsupported,
<<"Not supported"/utf8>>},
{capability,
<<"unevaluatedItems"/utf8>>,
<<"schema"/utf8>>,
unsupported,
<<"Not supported"/utf8>>},
{capability,
<<"contentEncoding"/utf8>>,
<<"schema"/utf8>>,
unsupported,
<<"Not supported"/utf8>>},
{capability,
<<"contentMediaType"/utf8>>,
<<"schema"/utf8>>,
unsupported,
<<"Not supported"/utf8>>},
{capability,
<<"contentSchema"/utf8>>,
<<"schema"/utf8>>,
unsupported,
<<"Not supported"/utf8>>},
{capability,
<<"apiKey"/utf8>>,
<<"security"/utf8>>,
supported,
<<"Header, query, cookie"/utf8>>},
{capability,
<<"http"/utf8>>,
<<"security"/utf8>>,
supported,
<<"Bearer, basic, and digest auth"/utf8>>},
{capability,
<<"oauth2"/utf8>>,
<<"security"/utf8>>,
supported,
<<"Bearer token attachment only; token acquisition and refresh are not generated"/utf8>>},
{capability,
<<"openIdConnect"/utf8>>,
<<"security"/utf8>>,
supported,
<<"Bearer token attachment only; discovery and token acquisition are not generated"/utf8>>},
{capability,
<<"mutualTLS"/utf8>>,
<<"security"/utf8>>,
unsupported,
<<"Not supported"/utf8>>},
{capability,
<<"path parameters"/utf8>>,
<<"parameter"/utf8>>,
supported,
<<"With schema validation"/utf8>>},
{capability,
<<"query parameters"/utf8>>,
<<"parameter"/utf8>>,
supported,
<<"Including deepObject"/utf8>>},
{capability,
<<"header parameters"/utf8>>,
<<"parameter"/utf8>>,
supported,
<<"String, int, float, bool"/utf8>>},
{capability,
<<"cookie parameters"/utf8>>,
<<"parameter"/utf8>>,
supported,
<<"With percent-decoding"/utf8>>},
{capability,
<<"allowReserved"/utf8>>,
<<"parameter"/utf8>>,
supported,
<<"Skips percent-encoding"/utf8>>},
{capability,
<<"application/json"/utf8>>,
<<"request"/utf8>>,
supported,
<<"JSON request bodies"/utf8>>},
{capability,
<<"application/x-www-form-urlencoded"/utf8>>,
<<"request"/utf8>>,
supported,
<<"Form bodies"/utf8>>},
{capability,
<<"multipart/form-data"/utf8>>,
<<"request"/utf8>>,
supported,
<<"Multipart upload"/utf8>>},
{capability,
<<"application/json"/utf8>>,
<<"response"/utf8>>,
supported,
<<"JSON responses"/utf8>>},
{capability,
<<"text/plain"/utf8>>,
<<"response"/utf8>>,
supported,
<<"Text passthrough"/utf8>>},
{capability,
<<"application/octet-stream"/utf8>>,
<<"response"/utf8>>,
supported,
<<"Binary passthrough"/utf8>>},
{capability,
<<"webhooks"/utf8>>,
<<"scope"/utf8>>,
parsed_not_used,
<<"Parsed but no codegen"/utf8>>},
{capability,
<<"externalDocs"/utf8>>,
<<"scope"/utf8>>,
parsed_not_used,
<<"Parsed but no codegen"/utf8>>},
{capability,
<<"tags"/utf8>>,
<<"scope"/utf8>>,
parsed_not_used,
<<"Parsed but no codegen"/utf8>>},
{capability,
<<"examples"/utf8>>,
<<"scope"/utf8>>,
parsed_not_used,
<<"Parsed but no codegen"/utf8>>},
{capability,
<<"links"/utf8>>,
<<"scope"/utf8>>,
parsed_not_used,
<<"Parsed but no codegen"/utf8>>},
{capability,
<<"xml"/utf8>>,
<<"scope"/utf8>>,
not_handled,
<<"XML annotations ignored"/utf8>>},
{capability,
<<"operation servers"/utf8>>,
<<"scope"/utf8>>,
parsed_not_used,
<<"Client uses top-level only"/utf8>>},
{capability,
<<"path servers"/utf8>>,
<<"scope"/utf8>>,
parsed_not_used,
<<"Client uses top-level only"/utf8>>},
{capability,
<<"response headers"/utf8>>,
<<"scope"/utf8>>,
parsed_not_used,
<<"Parsed but no codegen"/utf8>>},
{capability,
<<"encoding"/utf8>>,
<<"scope"/utf8>>,
parsed_not_used,
<<"Parsed but no codegen"/utf8>>}].
-file("src/oaspec/capability.gleam", 198).
?DOC(" Get the list of unsupported schema keywords from the registry.\n").
-spec unsupported_schema_keywords() -> list(binary()).
unsupported_schema_keywords() ->
_pipe = registry(),
_pipe@1 = gleam@list:filter(
_pipe,
fun(C) ->
(erlang:element(3, C) =:= <<"schema"/utf8>>) andalso (erlang:element(
4,
C
)
=:= unsupported)
end
),
gleam@list:map(_pipe@1, fun(C@1) -> erlang:element(2, C@1) end).
-file("src/oaspec/capability.gleam", 205).
?DOC(" Check if a security scheme type is unsupported.\n").
-spec is_unsupported_security_type(binary()) -> boolean().
is_unsupported_security_type(Type_name) ->
_pipe = registry(),
gleam@list:any(
_pipe,
fun(C) ->
((erlang:element(3, C) =:= <<"security"/utf8>>) andalso (erlang:element(
2,
C
)
=:= Type_name))
andalso (erlang:element(4, C) =:= unsupported)
end
).
-file("src/oaspec/capability.gleam", 213).
?DOC(" Get capabilities by level.\n").
-spec by_level(support_level()) -> list(capability()).
by_level(Level) ->
gleam@list:filter(registry(), fun(C) -> erlang:element(4, C) =:= Level end).
-file("src/oaspec/capability.gleam", 218).
?DOC(" Generate the \"Current Boundaries\" markdown section from the registry.\n").
-spec generate_boundaries_markdown() -> binary().
generate_boundaries_markdown() ->
Unsupported = by_level(unsupported),
Unsupported_names = begin
_pipe = gleam@list:map(
Unsupported,
fun(C) ->
<<<<"`"/utf8, (erlang:element(2, C))/binary>>/binary, "`"/utf8>>
end
),
gleam@string:join(_pipe, <<", "/utf8>>)
end,
Not_handled = by_level(not_handled),
Not_handled_names = begin
_pipe@1 = gleam@list:map(
Not_handled,
fun(C@1) ->
<<<<"`"/utf8, (erlang:element(2, C@1))/binary>>/binary,
"`"/utf8>>
end
),
gleam@string:join(_pipe@1, <<", "/utf8>>)
end,
Parsed_not_used = by_level(parsed_not_used),
Parsed_not_used_names = begin
_pipe@2 = gleam@list:map(
Parsed_not_used,
fun(C@2) -> erlang:element(2, C@2) end
),
gleam@string:join(_pipe@2, <<", "/utf8>>)
end,
Normalizable = by_level(normalizable),
Normalizable_lines = begin
_pipe@3 = gleam@list:map(
Normalizable,
fun(C@3) ->
<<<<<<"- `"/utf8, (erlang:element(2, C@3))/binary>>/binary,
"`: "/utf8>>/binary,
(erlang:element(5, C@3))/binary>>
end
),
gleam@string:join(_pipe@3, <<"\n"/utf8>>)
end,
<<<<<<<<<<<<<<"## Current Boundaries
These are the most important limitations today:
- The following keywords are detected and rejected: "/utf8,
Unsupported_names/binary>>/binary,
"
- "/utf8>>/binary,
Not_handled_names/binary>>/binary,
" annotations are not handled by the parser
- Some fields are parsed and preserved but not yet used by codegen: "/utf8>>/binary,
Parsed_not_used_names/binary>>/binary,
"
- The following are normalized to supported equivalents:
"/utf8>>/binary,
Normalizable_lines/binary>>.