Current section

Files

Jump to
oaspec src oaspec@capability.erl
Raw

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]).
-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", 23).
?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 and basic auth"/utf8>>},
{capability,
<<"oauth2"/utf8>>,
<<"security"/utf8>>,
supported,
<<"OAuth2 flows with scopes"/utf8>>},
{capability,
<<"openIdConnect"/utf8>>,
<<"security"/utf8>>,
supported,
<<"OpenID Connect"/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", 187).
?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", 194).
?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", 202).
?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).