-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 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", 188). ?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", 195). ?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", 203). ?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", 208). ?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>>.