mirror of
https://github.com/Smaug123/WoofWare.Myriad
synced 2025-10-05 20:18:43 +00:00
Add swagger v3 types and remove v2 types from surface (#390)
This commit is contained in:
@@ -3,7 +3,7 @@ namespace WoofWare.Myriad.Plugins.Test
|
||||
open System.Text.Json.Nodes
|
||||
open NUnit.Framework
|
||||
open FsUnitTyped
|
||||
open WoofWare.Myriad.Plugins
|
||||
open WoofWare.Myriad.Plugins.SwaggerV2
|
||||
|
||||
[<TestFixture>]
|
||||
module TestSwaggerParse =
|
||||
|
6
WoofWare.Myriad.Plugins/AssemblyInfo.fs
Normal file
6
WoofWare.Myriad.Plugins/AssemblyInfo.fs
Normal file
@@ -0,0 +1,6 @@
|
||||
module internal WoofWare.Myriad.Plugins.AssemblyInfo
|
||||
|
||||
open System.Runtime.CompilerServices
|
||||
|
||||
[<assembly : InternalsVisibleTo("WoofWare.Myriad.Plugins.Test")>]
|
||||
do ()
|
66
WoofWare.Myriad.Plugins/HttpMethod.fs
Normal file
66
WoofWare.Myriad.Plugins/HttpMethod.fs
Normal file
@@ -0,0 +1,66 @@
|
||||
namespace WoofWare.Myriad.Plugins
|
||||
|
||||
open System
|
||||
|
||||
/// An HTTP method. This is System.Net.Http.HttpMethod, but
|
||||
/// a proper discriminated union.
|
||||
type HttpMethod =
|
||||
/// HTTP Get
|
||||
| Get
|
||||
/// HTTP Post
|
||||
| Post
|
||||
/// HTTP Delete
|
||||
| Delete
|
||||
/// HTTP Patch
|
||||
| Patch
|
||||
/// HTTP Options
|
||||
| Options
|
||||
/// HTTP Head
|
||||
| Head
|
||||
/// HTTP Put
|
||||
| Put
|
||||
/// HTTP Trace
|
||||
| Trace
|
||||
|
||||
/// Convert to the standard library's enum type.
|
||||
member this.ToDotNet () : System.Net.Http.HttpMethod =
|
||||
match this with
|
||||
| HttpMethod.Get -> System.Net.Http.HttpMethod.Get
|
||||
| HttpMethod.Post -> System.Net.Http.HttpMethod.Post
|
||||
| HttpMethod.Delete -> System.Net.Http.HttpMethod.Delete
|
||||
| HttpMethod.Patch -> System.Net.Http.HttpMethod.Patch
|
||||
| HttpMethod.Options -> System.Net.Http.HttpMethod.Options
|
||||
| HttpMethod.Head -> System.Net.Http.HttpMethod.Head
|
||||
| HttpMethod.Put -> System.Net.Http.HttpMethod.Put
|
||||
| HttpMethod.Trace -> System.Net.Http.HttpMethod.Trace
|
||||
|
||||
/// Human-readable string representation.
|
||||
override this.ToString () : string =
|
||||
match this with
|
||||
| HttpMethod.Get -> "Get"
|
||||
| HttpMethod.Post -> "Post"
|
||||
| HttpMethod.Delete -> "Delete"
|
||||
| HttpMethod.Patch -> "Patch"
|
||||
| HttpMethod.Options -> "Options"
|
||||
| HttpMethod.Head -> "Head"
|
||||
| HttpMethod.Put -> "Put"
|
||||
| HttpMethod.Trace -> "Trace"
|
||||
|
||||
/// Throws on invalid inputs.
|
||||
static member Parse (s : string) : HttpMethod =
|
||||
if String.Equals (s, "get", StringComparison.OrdinalIgnoreCase) then
|
||||
HttpMethod.Get
|
||||
elif String.Equals (s, "post", StringComparison.OrdinalIgnoreCase) then
|
||||
HttpMethod.Post
|
||||
elif String.Equals (s, "patch", StringComparison.OrdinalIgnoreCase) then
|
||||
HttpMethod.Patch
|
||||
elif String.Equals (s, "delete", StringComparison.OrdinalIgnoreCase) then
|
||||
HttpMethod.Delete
|
||||
elif String.Equals (s, "head", StringComparison.OrdinalIgnoreCase) then
|
||||
HttpMethod.Head
|
||||
elif String.Equals (s, "options", StringComparison.OrdinalIgnoreCase) then
|
||||
HttpMethod.Options
|
||||
elif String.Equals (s, "put", StringComparison.OrdinalIgnoreCase) then
|
||||
HttpMethod.Put
|
||||
else
|
||||
failwith $"Unrecognised method: %s{s}"
|
48
WoofWare.Myriad.Plugins/JsonHelpers.fs
Normal file
48
WoofWare.Myriad.Plugins/JsonHelpers.fs
Normal file
@@ -0,0 +1,48 @@
|
||||
namespace WoofWare.Myriad.Plugins
|
||||
|
||||
open System.Text.Json.Nodes
|
||||
|
||||
[<AutoOpen>]
|
||||
module internal JsonHelpers =
|
||||
let inline asString (n : JsonNode) (key : string) : string =
|
||||
match n.[key] with
|
||||
| null -> failwith $"Expected node to have a key '%s{key}', but it did not: %s{n.ToJsonString ()}"
|
||||
| s -> s.GetValue<string> ()
|
||||
|
||||
[<RequiresExplicitTypeArguments>]
|
||||
let inline asOpt<'ret> (n : JsonNode) (key : string) : 'ret option =
|
||||
match n.[key] with
|
||||
| null -> None
|
||||
| s -> s.GetValue<'ret> () |> Some
|
||||
|
||||
let inline asObj (n : JsonNode) (key : string) : JsonObject =
|
||||
match n.[key] with
|
||||
| null -> failwith $"Expected node to have a key '%s{key}', but it did not: %s{n.ToJsonString ()}"
|
||||
| o -> o.AsObject ()
|
||||
|
||||
let inline asObjOpt (n : JsonNode) (key : string) : JsonObject option =
|
||||
match n.[key] with
|
||||
| null -> None
|
||||
| o -> o.AsObject () |> Some
|
||||
|
||||
let inline asArr (n : JsonNode) (key : string) : JsonArray =
|
||||
match n.[key] with
|
||||
| null -> failwith $"Expected node to have a key '%s{key}', but it did not: %s{n.ToJsonString ()}"
|
||||
| o -> o.AsArray ()
|
||||
|
||||
let inline asArrOpt (n : JsonNode) (key : string) : JsonArray option =
|
||||
match n.[key] with
|
||||
| null -> None
|
||||
| o -> o.AsArray () |> Some
|
||||
|
||||
[<RequiresExplicitTypeArguments>]
|
||||
let inline asArr'<'v> (n : JsonNode) (key : string) : 'v list =
|
||||
match n.[key] with
|
||||
| null -> failwith $"Expected node to have a key '%s{key}', but it did not: %s{n.ToJsonString ()}"
|
||||
| o -> o.AsArray () |> Seq.map (fun v -> v.GetValue<'v> ()) |> Seq.toList
|
||||
|
||||
[<RequiresExplicitTypeArguments>]
|
||||
let inline asArrOpt'<'v> (n : JsonNode) (key : string) : 'v list option =
|
||||
match n.[key] with
|
||||
| null -> None
|
||||
| o -> o.AsArray () |> Seq.map (fun v -> v.GetValue<'v> ()) |> Seq.toList |> Some
|
504
WoofWare.Myriad.Plugins/OpenApi3.fs
Normal file
504
WoofWare.Myriad.Plugins/OpenApi3.fs
Normal file
@@ -0,0 +1,504 @@
|
||||
module internal WoofWare.Myriad.Plugins.OpenApi3
|
||||
|
||||
open System
|
||||
open System.Text.Json.Nodes
|
||||
|
||||
type ExternalDocumentation =
|
||||
{
|
||||
/// A short description of the target documentation, possibly in CommonMark.
|
||||
Description : string option
|
||||
/// The URL for the target documentation.
|
||||
Url : Uri
|
||||
}
|
||||
|
||||
type Schema = | Schema of unit
|
||||
|
||||
type Example =
|
||||
{
|
||||
/// Short description for the example.
|
||||
Summary : string option
|
||||
/// Long description for the example, possibly CommonMark.
|
||||
Description : string option
|
||||
Value : Choice<JsonNode, Uri> option
|
||||
}
|
||||
|
||||
type Reference =
|
||||
{
|
||||
/// The reference string.
|
||||
Ref : string
|
||||
}
|
||||
|
||||
type Tag =
|
||||
{
|
||||
/// The name of the tag.
|
||||
Name : string
|
||||
/// A short description for the tag, possibly CommonMark.
|
||||
Description : string option
|
||||
/// Additional external documentation for this tag.
|
||||
ExternalDocs : ExternalDocumentation option
|
||||
}
|
||||
|
||||
type ServerVariable =
|
||||
{
|
||||
/// An enumeration of string values to be used if the substitution options are from a limited set.
|
||||
Enum : string list option
|
||||
/// The default value to use for substitution, and to send, if an alternate value is not supplied.
|
||||
/// Unlike the Schema Object’s default, this value MUST be provided by the consumer.
|
||||
Default : string
|
||||
/// An optional description for the server variable, possibly in CommonMark.
|
||||
Description : string option
|
||||
}
|
||||
|
||||
type Server =
|
||||
{
|
||||
/// A URL to the target host.
|
||||
/// This URL supports Server Variables and MAY be relative, to indicate that the host location is relative to the location where the OpenAPI document is being served.
|
||||
/// Variable substitutions will be made when a variable is named in {brackets}.
|
||||
Url : Uri
|
||||
/// Describes the host designated by the URL, possibly with CommonMark.
|
||||
Description : string option
|
||||
/// Used for substituting in the Url.
|
||||
Variables : Map<string, ServerVariable> option
|
||||
}
|
||||
|
||||
type StringFormat =
|
||||
/// base64-encoded characters
|
||||
| Byte
|
||||
/// any sequence of octets
|
||||
| Binary
|
||||
/// As defined by full-date - RFC3339 Section 5.6
|
||||
| Date
|
||||
/// As defined by date-time - RFC3339 Section 5.6
|
||||
| DateTime
|
||||
/// A hint to UIs to obscure input
|
||||
| Password
|
||||
| Verbatim of string
|
||||
|
||||
type IntegerFormat =
|
||||
/// Signed 32 bits
|
||||
| Int32
|
||||
/// Signed 64 bits
|
||||
| Int64
|
||||
| Verbatim of string
|
||||
|
||||
type NumberFormat =
|
||||
| Float
|
||||
| Double
|
||||
| Verbatim of string
|
||||
|
||||
type DataFormat =
|
||||
| Integer of IntegerFormat option
|
||||
| Number of NumberFormat option
|
||||
| String of StringFormat option
|
||||
| Boolean of format : string option
|
||||
|
||||
type Contact =
|
||||
{
|
||||
/// The identifying name of the contact person/organization.
|
||||
Name : string option
|
||||
/// The URL pointing to the contact information.
|
||||
Url : Uri option
|
||||
/// This MUST be in email address format.
|
||||
Email : string option
|
||||
}
|
||||
|
||||
type License =
|
||||
{
|
||||
/// The license name used for the API.
|
||||
Name : string
|
||||
/// A URL to the license used for the API.
|
||||
Url : Uri option
|
||||
}
|
||||
|
||||
type OpenApiInfo =
|
||||
{
|
||||
/// Title of the application
|
||||
Title : string
|
||||
/// Short description of the application, might be in CommonMark
|
||||
Description : string option
|
||||
/// Link to the ToS of the application
|
||||
TermsOfService : Uri option
|
||||
/// The contact information for the exposed API.
|
||||
Contact : Contact option
|
||||
/// The license information for the exposed API.
|
||||
License : License option
|
||||
/// The version of the OpenAPI document (which is distinct from the OpenAPI Specification version or the API implementation version).
|
||||
Version : string
|
||||
}
|
||||
|
||||
type Encoding =
|
||||
{
|
||||
/// The Content-Type for encoding a specific property.
|
||||
/// Default value depends on the property type:
|
||||
/// for string with format being binary – application/octet-stream;
|
||||
/// for other primitive types – text/plain;
|
||||
/// for object - application/json;
|
||||
/// for array – the default is defined based on the inner type.
|
||||
/// The value can be a specific media type (e.g. application/json), a wildcard media type (e.g. image/*), or a comma-separated list of the two types.
|
||||
ContentType : string option
|
||||
/// A map allowing additional information to be provided as headers, for example Content-Disposition.
|
||||
/// Content-Type is described separately and SHALL be ignored in this section.
|
||||
/// This property SHALL be ignored if the request body media type is not a multipart.
|
||||
Headers : Map<string, Choice<Header, Reference>> option
|
||||
/// Describes how a specific property value will be serialized depending on its type.
|
||||
/// See Parameter Object for details on the style property.
|
||||
/// The behavior follows the same values as query parameters, including default values.
|
||||
/// This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded.
|
||||
Style : string option
|
||||
/// When this is true, property values of type array or object generate separate parameters for each value of the array, or key-value-pair of the map.
|
||||
/// For other types of properties this property has no effect.
|
||||
/// When style is form, the default value is true.
|
||||
/// For all other styles, the default value is false.
|
||||
/// This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded.
|
||||
Explode : bool option
|
||||
/// Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986] Section 2.2 :/?#[]@!$&'()*+,;=
|
||||
/// to be included without percent-encoding.
|
||||
/// The default value is false.
|
||||
/// This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded.
|
||||
AllowReserved : bool option
|
||||
}
|
||||
|
||||
and MediaType =
|
||||
{
|
||||
/// The schema defining the type used for the request body.
|
||||
Schema : Choice<Schema, Reference> option
|
||||
Example : Choice<JsonNode, Map<string, Choice<Example, Reference>>> option
|
||||
/// A map between a property name and its encoding information.
|
||||
/// The key, being the property name, MUST exist in the schema as a property.
|
||||
/// The encoding object SHALL only apply to requestBody objects when the media type is multipart or application/x-www-form-urlencoded.
|
||||
Encoding : Map<string, Encoding> option
|
||||
}
|
||||
|
||||
/// The Header Object basically follows the structure of the Parameter Object.
|
||||
/// All traits that are affected by the location MUST be applicable to a location of header (for example, style).
|
||||
and Header =
|
||||
{
|
||||
/// A brief description of the header, possibly CommonMark.
|
||||
Description : string option
|
||||
/// Determines whether this header is mandatory.
|
||||
/// If the header location is “path”, this property is REQUIRED and its value MUST be true.
|
||||
/// Otherwise, the property MAY be included and its default value is false.
|
||||
Required : bool option
|
||||
/// Specifies that a header is deprecated and SHOULD be transitioned out of usage.
|
||||
Deprecated : bool option
|
||||
/// Sets the ability to pass empty-valued headers.
|
||||
/// This is valid only for query headers and allows sending a header with an empty value.
|
||||
/// Default value is false.
|
||||
/// If style is used, and if behavior is n/a (cannot be serialized), the value of allowEmptyValue SHALL be ignored.
|
||||
AllowEmptyValue : bool option
|
||||
/// Describes how the header value will be serialized depending on the type of the header value.
|
||||
/// Default values (based on value of in): for query - form; for path - simple; for header - simple; for cookie - form.
|
||||
Style : string option
|
||||
/// When this is true, header values of type array or object generate separate headers for each value of the array or key-value pair of the map.
|
||||
/// For other types of headers this property has no effect.
|
||||
/// When style is form, the default value is true.
|
||||
/// For all other styles, the default value is false.
|
||||
Explode : bool option
|
||||
/// Determines whether the header value SHOULD allow reserved characters, as defined by [RFC3986] Section 2.2 :/?#[]@!$&'()*+,;=
|
||||
/// to be included without percent-encoding.
|
||||
/// This property only applies to headers with an in value of query.
|
||||
/// The default value is false.
|
||||
AllowReserved : bool option
|
||||
/// The schema defining the type used for the header.
|
||||
Schema : Choice<Schema, Reference> option
|
||||
Example : Choice<JsonNode, Map<string, Choice<Example, Reference>>> option
|
||||
/// A map containing the representations for the header.
|
||||
/// The key is the media type and the value describes it.
|
||||
/// The map MUST only contain one entry.
|
||||
Content : Map<string, MediaType> option
|
||||
}
|
||||
|
||||
type LinkOperation =
|
||||
/// A relative or absolute reference to an OAS operation.
|
||||
/// This field is mutually exclusive of the operationId field, and MUST point to an Operation Object.
|
||||
/// Relative operationRef values MAY be used to locate an existing Operation Object in the OpenAPI definition.
|
||||
| Ref of string
|
||||
/// The name of an existing, resolvable OAS operation, as defined with a unique operationId.
|
||||
/// This field is mutually exclusive of the operationRef field.
|
||||
| Id of string
|
||||
|
||||
type RuntimeExpression = | RuntimeExpression of unit
|
||||
|
||||
type Link =
|
||||
{
|
||||
/// A relative or absolute reference to an OAS operation.
|
||||
/// This field is mutually exclusive of the operationId field, and MUST point to an Operation Object. Relative operationRef values MAY be used to locate an existing Operation Object in the OpenAPI definition.
|
||||
Operation : LinkOperation option
|
||||
/// A map representing parameters to pass to an operation as specified with operationId or identified via operationRef.
|
||||
/// The key is the parameter name to be used, whereas the value can be a constant or an expression to be evaluated and passed to the linked operation.
|
||||
/// The parameter name can be qualified using the parameter location [{in}.]{name} for operations that use the same parameter name in different locations (e.g. path.id).
|
||||
Parameters : Map<string, Choice<JsonNode, RuntimeExpression>> option
|
||||
/// A literal value or {expression} to use as a request body when calling the target operation.
|
||||
RequestBody : Choice<JsonNode, RuntimeExpression> option
|
||||
/// A description of the link, possibly CommonMark.
|
||||
Description : string option
|
||||
/// A server object to be used by the target operation.
|
||||
Server : Server option
|
||||
}
|
||||
|
||||
type Response =
|
||||
{
|
||||
/// A short description of the response, possibly CommonMark.
|
||||
Description : string
|
||||
/// Maps a header name to its definition.
|
||||
/// [RFC7230] Page 22 states header names are case insensitive.
|
||||
/// If a response header is defined with the name "Content-Type", it SHALL be ignored.
|
||||
Headers : Map<string, Choice<Header, Reference>> option
|
||||
/// A map containing descriptions of potential response payloads.
|
||||
/// The key is a media type or media type range, see [RFC7231] Appendix D, and the value describes it.
|
||||
/// For responses that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/*
|
||||
Content : Map<string, MediaType> option
|
||||
/// A map of operations links that can be followed from the response.
|
||||
/// The key of the map is a short name for the link, following the naming constraints of the names for Component Objects.
|
||||
Links : Map<string, Choice<Link, Reference>> option
|
||||
}
|
||||
|
||||
type Responses =
|
||||
{
|
||||
/// The documentation of responses other than the ones declared for specific HTTP response codes.
|
||||
/// Use this field to cover undeclared responses.
|
||||
Default : Choice<Response, Reference> option
|
||||
/// Map from HTTP status code to expected response.
|
||||
/// The keys are allowed to be "2XX" for example, hence being strings and not ints.
|
||||
Patterns : Map<string, Choice<Response, Reference>> option
|
||||
}
|
||||
|
||||
type SecuritySchemeIn =
|
||||
| Query
|
||||
| Header
|
||||
| Cookie
|
||||
|
||||
type OauthFlow =
|
||||
{
|
||||
/// The authorization URL to be used for this flow.
|
||||
AuthorizationUrl : Uri
|
||||
/// The token URL to be used for this flow.
|
||||
TokenUrl : Uri
|
||||
/// The URL to be used for obtaining refresh tokens.
|
||||
RefreshUrl : Uri option
|
||||
/// The available scopes for the OAuth2 security scheme. A map between the scope name and a short description for it.
|
||||
Scopes : Map<string, string>
|
||||
}
|
||||
|
||||
type SecurityRequirement =
|
||||
{
|
||||
/// Each name MUST correspond to a security scheme which is declared in the Security Schemes under the Components Object.
|
||||
/// If the security scheme is of type "oauth2" or "openIdConnect", then the value is a list of scope names required for the execution.
|
||||
/// For other security scheme types, the array MUST be empty.
|
||||
Fields : Map<string, string list> option
|
||||
}
|
||||
|
||||
type OauthFlows =
|
||||
{
|
||||
/// Configuration for the OAuth Implicit flow
|
||||
Implicit : OauthFlow
|
||||
/// Configuration for the OAuth Resource Owner Password flow
|
||||
Password : OauthFlow
|
||||
/// Configuration for the OAuth Client Credentials flow.
|
||||
ClientCredentials : OauthFlow
|
||||
/// Configuration for the OAuth Authorization Code flow.
|
||||
AuthorizationCode : OauthFlow
|
||||
}
|
||||
|
||||
type SecurityScheme =
|
||||
| ApiKey of description : string option * name : string * inValue : SecuritySchemeIn
|
||||
| Http of description : string option * scheme : string * bearerFormat : string option
|
||||
| Oauth2 of description : string option * OauthFlows
|
||||
| OpenIdConnect of description : string option * url : Uri
|
||||
|
||||
type ParameterIn =
|
||||
/// Used together with Path Templating, where the parameter value is actually part of the operation’s URL.
|
||||
/// This does not include the host or base path of the API.
|
||||
/// For example, in /items/{itemId}, the path parameter is itemId.
|
||||
| Path
|
||||
/// Custom headers that are expected as part of the request.
|
||||
/// Note that [RFC7230] Page 22 states header names are case insensitive.
|
||||
| Header
|
||||
/// Parameters that are appended to the URL. For example, in /items?id=###, the query parameter is id.
|
||||
| Query
|
||||
/// Used to pass a specific cookie value to the API.
|
||||
| Cookie
|
||||
|
||||
/// A unique parameter is defined by a combination of a name and location.
|
||||
type Parameter =
|
||||
{
|
||||
/// Name of the parameter, case sensitive.
|
||||
/// If in is "path", the name field MUST correspond to the associated path segment from the path field in the Paths Object.
|
||||
/// See Path Templating for further information.
|
||||
/// If in is "header" and the name field is "Accept", "Content-Type" or "Authorization", the parameter definition SHALL be ignored.
|
||||
/// For all other cases, the name corresponds to the parameter name used by the in property.
|
||||
Name : string
|
||||
/// The location of the parameter.
|
||||
In : ParameterIn
|
||||
/// A brief description of the parameter, possibly CommonMark.
|
||||
Description : string option
|
||||
/// Determines whether this parameter is mandatory.
|
||||
/// If the parameter location is “path”, this property is REQUIRED and its value MUST be true.
|
||||
/// Otherwise, the property MAY be included and its default value is false.
|
||||
Required : bool option
|
||||
/// Specifies that a parameter is deprecated and SHOULD be transitioned out of usage.
|
||||
Deprecated : bool option
|
||||
/// Sets the ability to pass empty-valued parameters.
|
||||
/// This is valid only for query parameters and allows sending a parameter with an empty value.
|
||||
/// Default value is false.
|
||||
/// If style is used, and if behavior is n/a (cannot be serialized), the value of allowEmptyValue SHALL be ignored.
|
||||
AllowEmptyValue : bool option
|
||||
/// Describes how the parameter value will be serialized depending on the type of the parameter value.
|
||||
/// Default values (based on value of in): for query - form; for path - simple; for header - simple; for cookie - form.
|
||||
Style : string option
|
||||
/// When this is true, parameter values of type array or object generate separate parameters for each value of the array or key-value pair of the map.
|
||||
/// For other types of parameters this property has no effect.
|
||||
/// When style is form, the default value is true.
|
||||
/// For all other styles, the default value is false.
|
||||
Explode : bool option
|
||||
/// Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986] Section 2.2 :/?#[]@!$&'()*+,;=
|
||||
/// to be included without percent-encoding.
|
||||
/// This property only applies to parameters with an in value of query.
|
||||
/// The default value is false.
|
||||
AllowReserved : bool option
|
||||
/// The schema defining the type used for the parameter.
|
||||
Schema : Choice<Schema, Reference> option
|
||||
Example : Choice<JsonNode, Map<string, Choice<Example, Reference>>> option
|
||||
/// A map containing the representations for the parameter.
|
||||
/// The key is the media type and the value describes it.
|
||||
/// The map MUST only contain one entry.
|
||||
Content : Map<string, MediaType> option
|
||||
}
|
||||
|
||||
type RequestBody =
|
||||
{
|
||||
/// A brief description of the request body. This could contain examples of use.
|
||||
/// Possibly CommonMark.
|
||||
Description : string option
|
||||
/// The content of the request body.
|
||||
/// The key is a media type or media type range, see [RFC7231] Appendix D, and the value describes it.
|
||||
/// For requests that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/*
|
||||
Content : Map<string, MediaType>
|
||||
/// Determines if the request body is required in the request. Defaults to false.
|
||||
Required : bool option
|
||||
}
|
||||
|
||||
type Callback =
|
||||
{
|
||||
/// For the semantics of the keys, see https://spec.openapis.org/oas/v3.0.0#key-expression
|
||||
Patterns : Map<string, PathItem> option
|
||||
}
|
||||
|
||||
and Operation =
|
||||
{
|
||||
/// A list of tags for API documentation control.
|
||||
/// Tags can be used for logical grouping of operations by resources or any other qualifier.
|
||||
Tags : string list option
|
||||
/// A short summary of what the operation does.
|
||||
Summary : string option
|
||||
/// A verbose explanation of the operation behavior, possibly in CommonMark.
|
||||
Description : string option
|
||||
/// Additional external documentation for this operation.
|
||||
ExternalDocs : ExternalDocumentation
|
||||
/// Unique string used to identify the operation.
|
||||
/// The id MUST be unique among all operations described in the API.
|
||||
/// Tools and libraries MAY use the operationId to uniquely identify an operation, therefore,
|
||||
/// it is RECOMMENDED to follow common programming naming conventions.
|
||||
OperationId : string option
|
||||
/// A list of parameters that are applicable for this operation.
|
||||
/// If a parameter is already defined at the Path Item, the new definition will override it but can never remove it.
|
||||
/// The list MUST NOT include duplicated parameters.
|
||||
/// A unique parameter is defined by a combination of a name and location.
|
||||
/// The list can use the Reference Object to link to parameters that are defined at the OpenAPI Object’s components/parameters.
|
||||
Parameters : Choice<Parameter, Reference> list option
|
||||
/// The request body applicable for this operation.
|
||||
/// The requestBody is only supported in HTTP methods where the HTTP 1.1 specification [RFC7231] Section 4.3.1 has explicitly defined semantics for request bodies.
|
||||
/// In other cases where the HTTP spec is vague, requestBody SHALL be ignored by consumers.
|
||||
RequestBody : Choice<RequestBody, Reference> option
|
||||
/// The list of possible responses as they are returned from executing this operation.
|
||||
Responses : Responses
|
||||
/// A map of possible out-of band callbacks related to the parent operation.
|
||||
/// The key is a unique identifier for the Callback Object.
|
||||
/// Each value in the map is a Callback Object that describes a request that may be initiated by the API provider and the expected responses.
|
||||
/// The key value used to identify the callback object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation.
|
||||
Callbacks : Map<string, Choice<Callback, Reference>> option
|
||||
/// Default value is "false".
|
||||
Deprecated : bool option
|
||||
/// A declaration of which security mechanisms can be used for this operation.
|
||||
/// The list of values includes alternative security requirement objects that can be used.
|
||||
/// Only one of the security requirement objects need to be satisfied to authorize a request.
|
||||
/// This definition overrides any declared top-level security.
|
||||
/// To remove a top-level security declaration, an empty array can be used.
|
||||
Security : SecurityRequirement list option
|
||||
/// An alternative server array to service this operation.
|
||||
/// If an alternative server object is specified at the Path Item Object or Root level, it will be overridden by this value.
|
||||
Servers : Server list option
|
||||
}
|
||||
|
||||
and PathItem =
|
||||
{
|
||||
/// Allows for an external definition of this path item.
|
||||
/// The referenced structure MUST be in the format of a Path Item Object.
|
||||
/// If there are conflicts between the referenced definition and this Path Item’s definition, the behavior is undefined.
|
||||
Ref : string option
|
||||
/// A string summary, intended to apply to all operations in this path.
|
||||
Summary : string option
|
||||
/// A string description, intended to apply to all operations in this path, possibly in CommonMark
|
||||
Description : string option
|
||||
/// A definition of a GET operation on this path.
|
||||
Get : Operation option
|
||||
/// A definition of a PUT operation on this path.
|
||||
Put : Operation option
|
||||
/// A definition of a POST operation on this path.
|
||||
Post : Operation option
|
||||
/// A definition of a DELETE operation on this path.
|
||||
Delete : Operation option
|
||||
/// A definition of an OPTIONS operation on this path.
|
||||
Options : Operation option
|
||||
/// A definition of a HEAD operation on this path.
|
||||
Head : Operation option
|
||||
/// A definition of a PATCH operation on this path.
|
||||
Patch : Operation option
|
||||
/// A definition of a TRACE operation on this path.
|
||||
Trace : Operation option
|
||||
/// An alternative server array to service all operations in this path.
|
||||
Servers : Server list option
|
||||
/// A list of parameters that are applicable for all the operations described under this path.
|
||||
/// These parameters can be overridden at the operation level, but cannot be removed there.
|
||||
/// The list MUST NOT include duplicated parameters.
|
||||
/// A unique parameter is defined by a combination of a name and location.
|
||||
/// The list can use the Reference Object to link to parameters that are defined at the OpenAPI Object’s components/parameters.
|
||||
Parameters : Choice<Parameter, Reference> list option
|
||||
}
|
||||
|
||||
type Paths =
|
||||
{
|
||||
/// A relative path to an individual endpoint.
|
||||
/// The field name MUST begin with a slash.
|
||||
/// The path is appended (no relative URL resolution) to the expanded URL from the Server Object’s url field in order to construct the full URL.
|
||||
/// Path templating is allowed.
|
||||
/// When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts.
|
||||
/// Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical.
|
||||
/// In case of ambiguous matching, it’s up to the tooling to decide which one to use.
|
||||
Fields : Map<string, PathItem> option
|
||||
}
|
||||
|
||||
type Components =
|
||||
{
|
||||
Schemas : Map<string, Choice<Schema, Reference>>
|
||||
Responses : Map<string, Choice<Response, Reference>>
|
||||
Parameters : Map<string, Choice<Parameter, Reference>>
|
||||
Examples : Map<string, Choice<Example, Reference>>
|
||||
RequestBodies : Map<string, Choice<RequestBody, Reference>>
|
||||
Headers : Map<string, Choice<Header, Reference>>
|
||||
SecuritySchemes : Map<string, Choice<SecurityScheme, Reference>>
|
||||
Links : Map<string, Choice<Link, Reference>>
|
||||
Callbacks : Map<string, Choice<Callback, Reference>>
|
||||
}
|
||||
|
||||
type OpenApiSpec =
|
||||
{
|
||||
OpenApi : Version
|
||||
Info : OpenApiInfo
|
||||
Servers : Server list option
|
||||
Paths : Paths
|
||||
Components : Components option
|
||||
Security : SecurityRequirement list option
|
||||
Tags : Tag list option
|
||||
ExternalDocs : ExternalDocumentation option
|
||||
}
|
@@ -1,84 +1,7 @@
|
||||
WoofWare.Myriad.Plugins.AdditionalProperties inherit obj, implements WoofWare.Myriad.Plugins.AdditionalProperties System.IEquatable, System.Collections.IStructuralEquatable - union type with 2 cases
|
||||
WoofWare.Myriad.Plugins.AdditionalProperties+Constrained inherit WoofWare.Myriad.Plugins.AdditionalProperties
|
||||
WoofWare.Myriad.Plugins.AdditionalProperties+Constrained.get_Item [method]: unit -> WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.AdditionalProperties+Constrained.Item [property]: [read-only] WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.AdditionalProperties+Tags inherit obj
|
||||
WoofWare.Myriad.Plugins.AdditionalProperties+Tags.Constrained [static field]: int = 1
|
||||
WoofWare.Myriad.Plugins.AdditionalProperties+Tags.Never [static field]: int = 0
|
||||
WoofWare.Myriad.Plugins.AdditionalProperties.Equals [method]: (WoofWare.Myriad.Plugins.AdditionalProperties, System.Collections.IEqualityComparer) -> bool
|
||||
WoofWare.Myriad.Plugins.AdditionalProperties.get_IsConstrained [method]: unit -> bool
|
||||
WoofWare.Myriad.Plugins.AdditionalProperties.get_IsNever [method]: unit -> bool
|
||||
WoofWare.Myriad.Plugins.AdditionalProperties.get_Never [static method]: unit -> WoofWare.Myriad.Plugins.AdditionalProperties
|
||||
WoofWare.Myriad.Plugins.AdditionalProperties.get_Tag [method]: unit -> int
|
||||
WoofWare.Myriad.Plugins.AdditionalProperties.IsConstrained [property]: [read-only] bool
|
||||
WoofWare.Myriad.Plugins.AdditionalProperties.IsNever [property]: [read-only] bool
|
||||
WoofWare.Myriad.Plugins.AdditionalProperties.Never [static property]: [read-only] WoofWare.Myriad.Plugins.AdditionalProperties
|
||||
WoofWare.Myriad.Plugins.AdditionalProperties.NewConstrained [static method]: WoofWare.Myriad.Plugins.Definition -> WoofWare.Myriad.Plugins.AdditionalProperties
|
||||
WoofWare.Myriad.Plugins.AdditionalProperties.Tag [property]: [read-only] int
|
||||
WoofWare.Myriad.Plugins.ArgParserGenerator inherit obj, implements Myriad.Core.IMyriadGenerator
|
||||
WoofWare.Myriad.Plugins.ArgParserGenerator..ctor [constructor]: unit
|
||||
WoofWare.Myriad.Plugins.ArrayTypeDefinition inherit obj, implements WoofWare.Myriad.Plugins.ArrayTypeDefinition System.IEquatable, System.Collections.IStructuralEquatable
|
||||
WoofWare.Myriad.Plugins.ArrayTypeDefinition..ctor [constructor]: WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.ArrayTypeDefinition.Equals [method]: (WoofWare.Myriad.Plugins.ArrayTypeDefinition, System.Collections.IEqualityComparer) -> bool
|
||||
WoofWare.Myriad.Plugins.ArrayTypeDefinition.get_Items [method]: unit -> WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.ArrayTypeDefinition.Items [property]: [read-only] WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.ArrayTypeDefinition.Parse [static method]: System.Text.Json.Nodes.JsonNode -> WoofWare.Myriad.Plugins.ArrayTypeDefinition
|
||||
WoofWare.Myriad.Plugins.CreateCatamorphismGenerator inherit obj, implements Myriad.Core.IMyriadGenerator
|
||||
WoofWare.Myriad.Plugins.CreateCatamorphismGenerator..ctor [constructor]: unit
|
||||
WoofWare.Myriad.Plugins.Definition inherit obj, implements WoofWare.Myriad.Plugins.Definition System.IEquatable, System.Collections.IStructuralEquatable - union type with 8 cases
|
||||
WoofWare.Myriad.Plugins.Definition+Array inherit WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Definition+Array.get_Item [method]: unit -> WoofWare.Myriad.Plugins.ArrayTypeDefinition
|
||||
WoofWare.Myriad.Plugins.Definition+Array.Item [property]: [read-only] WoofWare.Myriad.Plugins.ArrayTypeDefinition
|
||||
WoofWare.Myriad.Plugins.Definition+Handle inherit WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Definition+Handle.get_Item [method]: unit -> string
|
||||
WoofWare.Myriad.Plugins.Definition+Handle.Item [property]: [read-only] string
|
||||
WoofWare.Myriad.Plugins.Definition+Integer inherit WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Definition+Integer.format [property]: [read-only] string option
|
||||
WoofWare.Myriad.Plugins.Definition+Integer.get_format [method]: unit -> string option
|
||||
WoofWare.Myriad.Plugins.Definition+Object inherit WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Definition+Object.get_Item [method]: unit -> WoofWare.Myriad.Plugins.ObjectTypeDefinition
|
||||
WoofWare.Myriad.Plugins.Definition+Object.Item [property]: [read-only] WoofWare.Myriad.Plugins.ObjectTypeDefinition
|
||||
WoofWare.Myriad.Plugins.Definition+Tags inherit obj
|
||||
WoofWare.Myriad.Plugins.Definition+Tags.Array [static field]: int = 2
|
||||
WoofWare.Myriad.Plugins.Definition+Tags.Boolean [static field]: int = 4
|
||||
WoofWare.Myriad.Plugins.Definition+Tags.File [static field]: int = 7
|
||||
WoofWare.Myriad.Plugins.Definition+Tags.Handle [static field]: int = 0
|
||||
WoofWare.Myriad.Plugins.Definition+Tags.Integer [static field]: int = 6
|
||||
WoofWare.Myriad.Plugins.Definition+Tags.Object [static field]: int = 1
|
||||
WoofWare.Myriad.Plugins.Definition+Tags.String [static field]: int = 3
|
||||
WoofWare.Myriad.Plugins.Definition+Tags.Unspecified [static field]: int = 5
|
||||
WoofWare.Myriad.Plugins.Definition.Boolean [static property]: [read-only] WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Definition.Equals [method]: (WoofWare.Myriad.Plugins.Definition, System.Collections.IEqualityComparer) -> bool
|
||||
WoofWare.Myriad.Plugins.Definition.File [static property]: [read-only] WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Definition.get_Boolean [static method]: unit -> WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Definition.get_File [static method]: unit -> WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Definition.get_IsArray [method]: unit -> bool
|
||||
WoofWare.Myriad.Plugins.Definition.get_IsBoolean [method]: unit -> bool
|
||||
WoofWare.Myriad.Plugins.Definition.get_IsFile [method]: unit -> bool
|
||||
WoofWare.Myriad.Plugins.Definition.get_IsHandle [method]: unit -> bool
|
||||
WoofWare.Myriad.Plugins.Definition.get_IsInteger [method]: unit -> bool
|
||||
WoofWare.Myriad.Plugins.Definition.get_IsObject [method]: unit -> bool
|
||||
WoofWare.Myriad.Plugins.Definition.get_IsString [method]: unit -> bool
|
||||
WoofWare.Myriad.Plugins.Definition.get_IsUnspecified [method]: unit -> bool
|
||||
WoofWare.Myriad.Plugins.Definition.get_String [static method]: unit -> WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Definition.get_Tag [method]: unit -> int
|
||||
WoofWare.Myriad.Plugins.Definition.get_Unspecified [static method]: unit -> WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Definition.IsArray [property]: [read-only] bool
|
||||
WoofWare.Myriad.Plugins.Definition.IsBoolean [property]: [read-only] bool
|
||||
WoofWare.Myriad.Plugins.Definition.IsFile [property]: [read-only] bool
|
||||
WoofWare.Myriad.Plugins.Definition.IsHandle [property]: [read-only] bool
|
||||
WoofWare.Myriad.Plugins.Definition.IsInteger [property]: [read-only] bool
|
||||
WoofWare.Myriad.Plugins.Definition.IsObject [property]: [read-only] bool
|
||||
WoofWare.Myriad.Plugins.Definition.IsString [property]: [read-only] bool
|
||||
WoofWare.Myriad.Plugins.Definition.IsUnspecified [property]: [read-only] bool
|
||||
WoofWare.Myriad.Plugins.Definition.NewArray [static method]: WoofWare.Myriad.Plugins.ArrayTypeDefinition -> WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Definition.NewHandle [static method]: string -> WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Definition.NewInteger [static method]: string option -> WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Definition.NewObject [static method]: WoofWare.Myriad.Plugins.ObjectTypeDefinition -> WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Definition.Parse [static method]: System.Text.Json.Nodes.JsonObject -> WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Definition.String [static property]: [read-only] WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Definition.Tag [property]: [read-only] int
|
||||
WoofWare.Myriad.Plugins.Definition.Unspecified [static property]: [read-only] WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.HttpClientGenerator inherit obj, implements Myriad.Core.IMyriadGenerator
|
||||
WoofWare.Myriad.Plugins.HttpClientGenerator..ctor [constructor]: unit
|
||||
WoofWare.Myriad.Plugins.HttpMethod inherit obj, implements WoofWare.Myriad.Plugins.HttpMethod System.IEquatable, System.Collections.IStructuralEquatable, WoofWare.Myriad.Plugins.HttpMethod System.IComparable, System.IComparable, System.Collections.IStructuralComparable - union type with 8 cases
|
||||
@@ -134,162 +57,7 @@ WoofWare.Myriad.Plugins.JsonParseGenerator inherit obj, implements Myriad.Core.I
|
||||
WoofWare.Myriad.Plugins.JsonParseGenerator..ctor [constructor]: unit
|
||||
WoofWare.Myriad.Plugins.JsonSerializeGenerator inherit obj, implements Myriad.Core.IMyriadGenerator
|
||||
WoofWare.Myriad.Plugins.JsonSerializeGenerator..ctor [constructor]: unit
|
||||
WoofWare.Myriad.Plugins.MimeType inherit obj, implements WoofWare.Myriad.Plugins.MimeType System.IEquatable, System.Collections.IStructuralEquatable, WoofWare.Myriad.Plugins.MimeType System.IComparable, System.IComparable, System.Collections.IStructuralComparable - union type with 1 cases
|
||||
WoofWare.Myriad.Plugins.MimeType.Equals [method]: (WoofWare.Myriad.Plugins.MimeType, System.Collections.IEqualityComparer) -> bool
|
||||
WoofWare.Myriad.Plugins.MimeType.get_Item [method]: unit -> string
|
||||
WoofWare.Myriad.Plugins.MimeType.get_Tag [method]: unit -> int
|
||||
WoofWare.Myriad.Plugins.MimeType.Item [property]: [read-only] string
|
||||
WoofWare.Myriad.Plugins.MimeType.NewMimeType [static method]: string -> WoofWare.Myriad.Plugins.MimeType
|
||||
WoofWare.Myriad.Plugins.MimeType.Tag [property]: [read-only] int
|
||||
WoofWare.Myriad.Plugins.ObjectTypeDefinition inherit obj, implements WoofWare.Myriad.Plugins.ObjectTypeDefinition System.IEquatable, System.Collections.IStructuralEquatable
|
||||
WoofWare.Myriad.Plugins.ObjectTypeDefinition..ctor [constructor]: (string option, Map<string, WoofWare.Myriad.Plugins.Definition> option, Map<string, System.Text.Json.Nodes.JsonNode>, string list option, WoofWare.Myriad.Plugins.AdditionalProperties option, System.Text.Json.Nodes.JsonObject option)
|
||||
WoofWare.Myriad.Plugins.ObjectTypeDefinition.AdditionalProperties [property]: [read-only] WoofWare.Myriad.Plugins.AdditionalProperties option
|
||||
WoofWare.Myriad.Plugins.ObjectTypeDefinition.Description [property]: [read-only] string option
|
||||
WoofWare.Myriad.Plugins.ObjectTypeDefinition.Equals [method]: (WoofWare.Myriad.Plugins.ObjectTypeDefinition, System.Collections.IEqualityComparer) -> bool
|
||||
WoofWare.Myriad.Plugins.ObjectTypeDefinition.Example [property]: [read-only] System.Text.Json.Nodes.JsonObject option
|
||||
WoofWare.Myriad.Plugins.ObjectTypeDefinition.Extras [property]: [read-only] Map<string, System.Text.Json.Nodes.JsonNode>
|
||||
WoofWare.Myriad.Plugins.ObjectTypeDefinition.get_AdditionalProperties [method]: unit -> WoofWare.Myriad.Plugins.AdditionalProperties option
|
||||
WoofWare.Myriad.Plugins.ObjectTypeDefinition.get_Description [method]: unit -> string option
|
||||
WoofWare.Myriad.Plugins.ObjectTypeDefinition.get_Example [method]: unit -> System.Text.Json.Nodes.JsonObject option
|
||||
WoofWare.Myriad.Plugins.ObjectTypeDefinition.get_Extras [method]: unit -> Map<string, System.Text.Json.Nodes.JsonNode>
|
||||
WoofWare.Myriad.Plugins.ObjectTypeDefinition.get_Properties [method]: unit -> Map<string, WoofWare.Myriad.Plugins.Definition> option
|
||||
WoofWare.Myriad.Plugins.ObjectTypeDefinition.get_Required [method]: unit -> string list option
|
||||
WoofWare.Myriad.Plugins.ObjectTypeDefinition.Parse [static method]: System.Text.Json.Nodes.JsonObject -> WoofWare.Myriad.Plugins.ObjectTypeDefinition
|
||||
WoofWare.Myriad.Plugins.ObjectTypeDefinition.Properties [property]: [read-only] Map<string, WoofWare.Myriad.Plugins.Definition> option
|
||||
WoofWare.Myriad.Plugins.ObjectTypeDefinition.Required [property]: [read-only] string list option
|
||||
WoofWare.Myriad.Plugins.OperationId inherit obj, implements WoofWare.Myriad.Plugins.OperationId System.IEquatable, System.Collections.IStructuralEquatable, WoofWare.Myriad.Plugins.OperationId System.IComparable, System.IComparable, System.Collections.IStructuralComparable - union type with 1 cases
|
||||
WoofWare.Myriad.Plugins.OperationId.Equals [method]: (WoofWare.Myriad.Plugins.OperationId, System.Collections.IEqualityComparer) -> bool
|
||||
WoofWare.Myriad.Plugins.OperationId.get_Item [method]: unit -> string
|
||||
WoofWare.Myriad.Plugins.OperationId.get_Tag [method]: unit -> int
|
||||
WoofWare.Myriad.Plugins.OperationId.Item [property]: [read-only] string
|
||||
WoofWare.Myriad.Plugins.OperationId.NewOperationId [static method]: string -> WoofWare.Myriad.Plugins.OperationId
|
||||
WoofWare.Myriad.Plugins.OperationId.Tag [property]: [read-only] int
|
||||
WoofWare.Myriad.Plugins.ParameterIn inherit obj, implements WoofWare.Myriad.Plugins.ParameterIn System.IEquatable, System.Collections.IStructuralEquatable, WoofWare.Myriad.Plugins.ParameterIn System.IComparable, System.IComparable, System.Collections.IStructuralComparable - union type with 4 cases
|
||||
WoofWare.Myriad.Plugins.ParameterIn+Path inherit WoofWare.Myriad.Plugins.ParameterIn
|
||||
WoofWare.Myriad.Plugins.ParameterIn+Path.get_name [method]: unit -> string
|
||||
WoofWare.Myriad.Plugins.ParameterIn+Path.name [property]: [read-only] string
|
||||
WoofWare.Myriad.Plugins.ParameterIn+Query inherit WoofWare.Myriad.Plugins.ParameterIn
|
||||
WoofWare.Myriad.Plugins.ParameterIn+Query.get_name [method]: unit -> string
|
||||
WoofWare.Myriad.Plugins.ParameterIn+Query.name [property]: [read-only] string
|
||||
WoofWare.Myriad.Plugins.ParameterIn+Tags inherit obj
|
||||
WoofWare.Myriad.Plugins.ParameterIn+Tags.Body [static field]: int = 2
|
||||
WoofWare.Myriad.Plugins.ParameterIn+Tags.Path [static field]: int = 0
|
||||
WoofWare.Myriad.Plugins.ParameterIn+Tags.Query [static field]: int = 1
|
||||
WoofWare.Myriad.Plugins.ParameterIn+Tags.Unrecognised [static field]: int = 3
|
||||
WoofWare.Myriad.Plugins.ParameterIn+Unrecognised inherit WoofWare.Myriad.Plugins.ParameterIn
|
||||
WoofWare.Myriad.Plugins.ParameterIn+Unrecognised.get_name [method]: unit -> string
|
||||
WoofWare.Myriad.Plugins.ParameterIn+Unrecognised.get_op [method]: unit -> string
|
||||
WoofWare.Myriad.Plugins.ParameterIn+Unrecognised.name [property]: [read-only] string
|
||||
WoofWare.Myriad.Plugins.ParameterIn+Unrecognised.op [property]: [read-only] string
|
||||
WoofWare.Myriad.Plugins.ParameterIn.Body [static property]: [read-only] WoofWare.Myriad.Plugins.ParameterIn
|
||||
WoofWare.Myriad.Plugins.ParameterIn.Equals [method]: (WoofWare.Myriad.Plugins.ParameterIn, System.Collections.IEqualityComparer) -> bool
|
||||
WoofWare.Myriad.Plugins.ParameterIn.get_Body [static method]: unit -> WoofWare.Myriad.Plugins.ParameterIn
|
||||
WoofWare.Myriad.Plugins.ParameterIn.get_IsBody [method]: unit -> bool
|
||||
WoofWare.Myriad.Plugins.ParameterIn.get_IsPath [method]: unit -> bool
|
||||
WoofWare.Myriad.Plugins.ParameterIn.get_IsQuery [method]: unit -> bool
|
||||
WoofWare.Myriad.Plugins.ParameterIn.get_IsUnrecognised [method]: unit -> bool
|
||||
WoofWare.Myriad.Plugins.ParameterIn.get_Tag [method]: unit -> int
|
||||
WoofWare.Myriad.Plugins.ParameterIn.IsBody [property]: [read-only] bool
|
||||
WoofWare.Myriad.Plugins.ParameterIn.IsPath [property]: [read-only] bool
|
||||
WoofWare.Myriad.Plugins.ParameterIn.IsQuery [property]: [read-only] bool
|
||||
WoofWare.Myriad.Plugins.ParameterIn.IsUnrecognised [property]: [read-only] bool
|
||||
WoofWare.Myriad.Plugins.ParameterIn.NewPath [static method]: string -> WoofWare.Myriad.Plugins.ParameterIn
|
||||
WoofWare.Myriad.Plugins.ParameterIn.NewQuery [static method]: string -> WoofWare.Myriad.Plugins.ParameterIn
|
||||
WoofWare.Myriad.Plugins.ParameterIn.NewUnrecognised [static method]: (string, string) -> WoofWare.Myriad.Plugins.ParameterIn
|
||||
WoofWare.Myriad.Plugins.ParameterIn.Tag [property]: [read-only] int
|
||||
WoofWare.Myriad.Plugins.RemoveOptionsGenerator inherit obj, implements Myriad.Core.IMyriadGenerator
|
||||
WoofWare.Myriad.Plugins.RemoveOptionsGenerator..ctor [constructor]: unit
|
||||
WoofWare.Myriad.Plugins.Response inherit obj, implements WoofWare.Myriad.Plugins.Response System.IEquatable, System.Collections.IStructuralEquatable
|
||||
WoofWare.Myriad.Plugins.Response..ctor [constructor]: (string, WoofWare.Myriad.Plugins.Definition)
|
||||
WoofWare.Myriad.Plugins.Response.Description [property]: [read-only] string
|
||||
WoofWare.Myriad.Plugins.Response.Equals [method]: (WoofWare.Myriad.Plugins.Response, System.Collections.IEqualityComparer) -> bool
|
||||
WoofWare.Myriad.Plugins.Response.get_Description [method]: unit -> string
|
||||
WoofWare.Myriad.Plugins.Response.get_Schema [method]: unit -> WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Response.Parse [static method]: System.Text.Json.Nodes.JsonObject -> WoofWare.Myriad.Plugins.Response
|
||||
WoofWare.Myriad.Plugins.Response.Schema [property]: [read-only] WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.Scheme inherit obj, implements WoofWare.Myriad.Plugins.Scheme System.IEquatable, System.Collections.IStructuralEquatable, WoofWare.Myriad.Plugins.Scheme System.IComparable, System.IComparable, System.Collections.IStructuralComparable - union type with 1 cases
|
||||
WoofWare.Myriad.Plugins.Scheme.Equals [method]: (WoofWare.Myriad.Plugins.Scheme, System.Collections.IEqualityComparer) -> bool
|
||||
WoofWare.Myriad.Plugins.Scheme.get_Item [method]: unit -> string
|
||||
WoofWare.Myriad.Plugins.Scheme.get_Tag [method]: unit -> int
|
||||
WoofWare.Myriad.Plugins.Scheme.Item [property]: [read-only] string
|
||||
WoofWare.Myriad.Plugins.Scheme.NewScheme [static method]: string -> WoofWare.Myriad.Plugins.Scheme
|
||||
WoofWare.Myriad.Plugins.Scheme.Tag [property]: [read-only] int
|
||||
WoofWare.Myriad.Plugins.Swagger inherit obj, implements WoofWare.Myriad.Plugins.Swagger System.IEquatable, System.Collections.IStructuralEquatable
|
||||
WoofWare.Myriad.Plugins.Swagger..ctor [constructor]: (WoofWare.Myriad.Plugins.MimeType list, WoofWare.Myriad.Plugins.MimeType list, WoofWare.Myriad.Plugins.Scheme list, System.Version, WoofWare.Myriad.Plugins.SwaggerInfo, string, Map<string, Map<WoofWare.Myriad.Plugins.HttpMethod, WoofWare.Myriad.Plugins.SwaggerEndpoint>>, Map<string, WoofWare.Myriad.Plugins.Definition>, Map<string, WoofWare.Myriad.Plugins.Response>)
|
||||
WoofWare.Myriad.Plugins.Swagger.BasePath [property]: [read-only] string
|
||||
WoofWare.Myriad.Plugins.Swagger.Consumes [property]: [read-only] WoofWare.Myriad.Plugins.MimeType list
|
||||
WoofWare.Myriad.Plugins.Swagger.Definitions [property]: [read-only] Map<string, WoofWare.Myriad.Plugins.Definition>
|
||||
WoofWare.Myriad.Plugins.Swagger.Equals [method]: (WoofWare.Myriad.Plugins.Swagger, System.Collections.IEqualityComparer) -> bool
|
||||
WoofWare.Myriad.Plugins.Swagger.get_BasePath [method]: unit -> string
|
||||
WoofWare.Myriad.Plugins.Swagger.get_Consumes [method]: unit -> WoofWare.Myriad.Plugins.MimeType list
|
||||
WoofWare.Myriad.Plugins.Swagger.get_Definitions [method]: unit -> Map<string, WoofWare.Myriad.Plugins.Definition>
|
||||
WoofWare.Myriad.Plugins.Swagger.get_Info [method]: unit -> WoofWare.Myriad.Plugins.SwaggerInfo
|
||||
WoofWare.Myriad.Plugins.Swagger.get_Paths [method]: unit -> Map<string, Map<WoofWare.Myriad.Plugins.HttpMethod, WoofWare.Myriad.Plugins.SwaggerEndpoint>>
|
||||
WoofWare.Myriad.Plugins.Swagger.get_Produces [method]: unit -> WoofWare.Myriad.Plugins.MimeType list
|
||||
WoofWare.Myriad.Plugins.Swagger.get_Responses [method]: unit -> Map<string, WoofWare.Myriad.Plugins.Response>
|
||||
WoofWare.Myriad.Plugins.Swagger.get_Schemes [method]: unit -> WoofWare.Myriad.Plugins.Scheme list
|
||||
WoofWare.Myriad.Plugins.Swagger.get_Swagger [method]: unit -> System.Version
|
||||
WoofWare.Myriad.Plugins.Swagger.Info [property]: [read-only] WoofWare.Myriad.Plugins.SwaggerInfo
|
||||
WoofWare.Myriad.Plugins.Swagger.Paths [property]: [read-only] Map<string, Map<WoofWare.Myriad.Plugins.HttpMethod, WoofWare.Myriad.Plugins.SwaggerEndpoint>>
|
||||
WoofWare.Myriad.Plugins.Swagger.Produces [property]: [read-only] WoofWare.Myriad.Plugins.MimeType list
|
||||
WoofWare.Myriad.Plugins.Swagger.Responses [property]: [read-only] Map<string, WoofWare.Myriad.Plugins.Response>
|
||||
WoofWare.Myriad.Plugins.Swagger.Schemes [property]: [read-only] WoofWare.Myriad.Plugins.Scheme list
|
||||
WoofWare.Myriad.Plugins.Swagger.Swagger [property]: [read-only] System.Version
|
||||
WoofWare.Myriad.Plugins.SwaggerClientGenerator inherit obj, implements Myriad.Core.IMyriadGenerator
|
||||
WoofWare.Myriad.Plugins.SwaggerClientGenerator..ctor [constructor]: unit
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint inherit obj, implements WoofWare.Myriad.Plugins.SwaggerEndpoint System.IEquatable, System.Collections.IStructuralEquatable
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint..ctor [constructor]: (WoofWare.Myriad.Plugins.MimeType list option, WoofWare.Myriad.Plugins.MimeType list option, string list, string, WoofWare.Myriad.Plugins.OperationId, WoofWare.Myriad.Plugins.SwaggerParameter list option, Map<int, WoofWare.Myriad.Plugins.Definition>)
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint.Consumes [property]: [read-only] WoofWare.Myriad.Plugins.MimeType list option
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint.Equals [method]: (WoofWare.Myriad.Plugins.SwaggerEndpoint, System.Collections.IEqualityComparer) -> bool
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint.get_Consumes [method]: unit -> WoofWare.Myriad.Plugins.MimeType list option
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint.get_OperationId [method]: unit -> WoofWare.Myriad.Plugins.OperationId
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint.get_Parameters [method]: unit -> WoofWare.Myriad.Plugins.SwaggerParameter list option
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint.get_Produces [method]: unit -> WoofWare.Myriad.Plugins.MimeType list option
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint.get_Responses [method]: unit -> Map<int, WoofWare.Myriad.Plugins.Definition>
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint.get_Summary [method]: unit -> string
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint.get_Tags [method]: unit -> string list
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint.OperationId [property]: [read-only] WoofWare.Myriad.Plugins.OperationId
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint.Parameters [property]: [read-only] WoofWare.Myriad.Plugins.SwaggerParameter list option
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint.Parse [static method]: System.Text.Json.Nodes.JsonObject -> WoofWare.Myriad.Plugins.SwaggerEndpoint
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint.Produces [property]: [read-only] WoofWare.Myriad.Plugins.MimeType list option
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint.Responses [property]: [read-only] Map<int, WoofWare.Myriad.Plugins.Definition>
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint.Summary [property]: [read-only] string
|
||||
WoofWare.Myriad.Plugins.SwaggerEndpoint.Tags [property]: [read-only] string list
|
||||
WoofWare.Myriad.Plugins.SwaggerInfo inherit obj, implements WoofWare.Myriad.Plugins.SwaggerInfo System.IEquatable, System.Collections.IStructuralEquatable
|
||||
WoofWare.Myriad.Plugins.SwaggerInfo..ctor [constructor]: (string, string, WoofWare.Myriad.Plugins.SwaggerLicense, System.Version)
|
||||
WoofWare.Myriad.Plugins.SwaggerInfo.Description [property]: [read-only] string
|
||||
WoofWare.Myriad.Plugins.SwaggerInfo.Equals [method]: (WoofWare.Myriad.Plugins.SwaggerInfo, System.Collections.IEqualityComparer) -> bool
|
||||
WoofWare.Myriad.Plugins.SwaggerInfo.get_Description [method]: unit -> string
|
||||
WoofWare.Myriad.Plugins.SwaggerInfo.get_License [method]: unit -> WoofWare.Myriad.Plugins.SwaggerLicense
|
||||
WoofWare.Myriad.Plugins.SwaggerInfo.get_Title [method]: unit -> string
|
||||
WoofWare.Myriad.Plugins.SwaggerInfo.get_Version [method]: unit -> System.Version
|
||||
WoofWare.Myriad.Plugins.SwaggerInfo.License [property]: [read-only] WoofWare.Myriad.Plugins.SwaggerLicense
|
||||
WoofWare.Myriad.Plugins.SwaggerInfo.Parse [static method]: System.Text.Json.Nodes.JsonObject -> WoofWare.Myriad.Plugins.SwaggerInfo
|
||||
WoofWare.Myriad.Plugins.SwaggerInfo.Title [property]: [read-only] string
|
||||
WoofWare.Myriad.Plugins.SwaggerInfo.Version [property]: [read-only] System.Version
|
||||
WoofWare.Myriad.Plugins.SwaggerLicense inherit obj, implements WoofWare.Myriad.Plugins.SwaggerLicense System.IEquatable, System.Collections.IStructuralEquatable
|
||||
WoofWare.Myriad.Plugins.SwaggerLicense..ctor [constructor]: (string, System.Uri option, string option)
|
||||
WoofWare.Myriad.Plugins.SwaggerLicense.Equals [method]: (WoofWare.Myriad.Plugins.SwaggerLicense, System.Collections.IEqualityComparer) -> bool
|
||||
WoofWare.Myriad.Plugins.SwaggerLicense.get_Identifier [method]: unit -> string option
|
||||
WoofWare.Myriad.Plugins.SwaggerLicense.get_Name [method]: unit -> string
|
||||
WoofWare.Myriad.Plugins.SwaggerLicense.get_Url [method]: unit -> System.Uri option
|
||||
WoofWare.Myriad.Plugins.SwaggerLicense.Identifier [property]: [read-only] string option
|
||||
WoofWare.Myriad.Plugins.SwaggerLicense.Name [property]: [read-only] string
|
||||
WoofWare.Myriad.Plugins.SwaggerLicense.Parse [static method]: System.Text.Json.Nodes.JsonObject -> WoofWare.Myriad.Plugins.SwaggerLicense
|
||||
WoofWare.Myriad.Plugins.SwaggerLicense.Url [property]: [read-only] System.Uri option
|
||||
WoofWare.Myriad.Plugins.SwaggerModule inherit obj
|
||||
WoofWare.Myriad.Plugins.SwaggerModule.parse [static method]: string -> WoofWare.Myriad.Plugins.Swagger
|
||||
WoofWare.Myriad.Plugins.SwaggerParameter inherit obj, implements WoofWare.Myriad.Plugins.SwaggerParameter System.IEquatable, System.Collections.IStructuralEquatable
|
||||
WoofWare.Myriad.Plugins.SwaggerParameter..ctor [constructor]: (WoofWare.Myriad.Plugins.Definition, string option, WoofWare.Myriad.Plugins.ParameterIn, string, bool option)
|
||||
WoofWare.Myriad.Plugins.SwaggerParameter.Description [property]: [read-only] string option
|
||||
WoofWare.Myriad.Plugins.SwaggerParameter.Equals [method]: (WoofWare.Myriad.Plugins.SwaggerParameter, System.Collections.IEqualityComparer) -> bool
|
||||
WoofWare.Myriad.Plugins.SwaggerParameter.get_Description [method]: unit -> string option
|
||||
WoofWare.Myriad.Plugins.SwaggerParameter.get_In [method]: unit -> WoofWare.Myriad.Plugins.ParameterIn
|
||||
WoofWare.Myriad.Plugins.SwaggerParameter.get_Name [method]: unit -> string
|
||||
WoofWare.Myriad.Plugins.SwaggerParameter.get_Required [method]: unit -> bool option
|
||||
WoofWare.Myriad.Plugins.SwaggerParameter.get_Type [method]: unit -> WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.SwaggerParameter.In [property]: [read-only] WoofWare.Myriad.Plugins.ParameterIn
|
||||
WoofWare.Myriad.Plugins.SwaggerParameter.Name [property]: [read-only] string
|
||||
WoofWare.Myriad.Plugins.SwaggerParameter.Parse [static method]: System.Text.Json.Nodes.JsonObject -> WoofWare.Myriad.Plugins.SwaggerParameter
|
||||
WoofWare.Myriad.Plugins.SwaggerParameter.Required [property]: [read-only] bool option
|
||||
WoofWare.Myriad.Plugins.SwaggerParameter.Type [property]: [read-only] WoofWare.Myriad.Plugins.Definition
|
||||
WoofWare.Myriad.Plugins.SwaggerClientGenerator..ctor [constructor]: unit
|
@@ -24,10 +24,10 @@ type internal Endpoint =
|
||||
{
|
||||
DocString : PreXmlDoc
|
||||
Produces : Produces
|
||||
ReturnType : Definition
|
||||
ReturnType : SwaggerV2.Definition
|
||||
Method : WoofWare.Myriad.Plugins.HttpMethod
|
||||
Operation : OperationId
|
||||
Parameters : SwaggerParameter list
|
||||
Operation : SwaggerV2.OperationId
|
||||
Parameters : SwaggerV2.SwaggerParameter list
|
||||
Endpoint : string
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ type internal TypeEntry =
|
||||
type internal Types =
|
||||
{
|
||||
ByHandle : IReadOnlyDictionary<string, TypeEntry>
|
||||
ByDefinition : IReadOnlyDictionary<Definition, TypeEntry>
|
||||
ByDefinition : IReadOnlyDictionary<SwaggerV2.Definition, TypeEntry>
|
||||
}
|
||||
|
||||
[<RequireQualifiedAccess>]
|
||||
@@ -50,33 +50,33 @@ module internal SwaggerClientGenerator =
|
||||
|
||||
let internal log (_ : string) = ()
|
||||
|
||||
let renderType (types : Types) (defn : Definition) : SynType option =
|
||||
let renderType (types : Types) (defn : SwaggerV2.Definition) : SynType option =
|
||||
match types.ByDefinition.TryGetValue defn with
|
||||
| true, v -> Some v.Signature
|
||||
| false, _ ->
|
||||
|
||||
match defn with
|
||||
| Definition.Handle h ->
|
||||
| SwaggerV2.Definition.Handle h ->
|
||||
match types.ByHandle.TryGetValue h with
|
||||
| false, _ -> None
|
||||
| true, v -> Some v.Signature
|
||||
| Definition.Object _ -> failwith "should not hit"
|
||||
| Definition.Array _ -> failwith "should not hit"
|
||||
| Definition.Unspecified -> failwith "should not hit"
|
||||
| Definition.String -> SynType.string |> Some
|
||||
| Definition.Boolean -> SynType.bool |> Some
|
||||
| Definition.Integer _ -> SynType.int |> Some
|
||||
| Definition.File -> SynType.createLongIdent' [ "System" ; "IO" ; "Stream" ] |> Some
|
||||
| SwaggerV2.Definition.Object _ -> failwith "should not hit"
|
||||
| SwaggerV2.Definition.Array _ -> failwith "should not hit"
|
||||
| SwaggerV2.Definition.Unspecified -> failwith "should not hit"
|
||||
| SwaggerV2.Definition.String -> SynType.string |> Some
|
||||
| SwaggerV2.Definition.Boolean -> SynType.bool |> Some
|
||||
| SwaggerV2.Definition.Integer _ -> SynType.int |> Some
|
||||
| SwaggerV2.Definition.File -> SynType.createLongIdent' [ "System" ; "IO" ; "Stream" ] |> Some
|
||||
|
||||
/// Returns None if we lacked the information required to do this.
|
||||
/// bigCache is a map of e.g. {"securityDefinition": {Defn : F# type}}.
|
||||
let rec defnToType
|
||||
(anonymousTypeCount : int ref)
|
||||
(handlesMap : Dictionary<string, TypeEntry>)
|
||||
(bigCache : Dictionary<string, Dictionary<Definition, TypeEntry>>)
|
||||
(bigCache : Dictionary<string, Dictionary<SwaggerV2.Definition, TypeEntry>>)
|
||||
(thisKey : string)
|
||||
(typeName : string option)
|
||||
(d : Definition)
|
||||
(d : SwaggerV2.Definition)
|
||||
: TypeEntry option
|
||||
=
|
||||
let cache =
|
||||
@@ -111,7 +111,7 @@ module internal SwaggerClientGenerator =
|
||||
|
||||
let result =
|
||||
match d with
|
||||
| Definition.Object obj ->
|
||||
| SwaggerV2.Definition.Object obj ->
|
||||
let requiredFields = obj.Required |> Option.defaultValue [] |> Set.ofList
|
||||
|
||||
let namedProperties =
|
||||
@@ -123,7 +123,7 @@ module internal SwaggerClientGenerator =
|
||||
// Special case for when this is a reference to this very type
|
||||
let isOurself =
|
||||
match defn with
|
||||
| Definition.Handle h ->
|
||||
| SwaggerV2.Definition.Handle h ->
|
||||
match h.Split '/' with
|
||||
| [| "#" ; location ; ty |] when location = thisKey && Some ty = typeName ->
|
||||
SynType.named ty |> Some
|
||||
@@ -198,8 +198,8 @@ module internal SwaggerClientGenerator =
|
||||
|> SynField.make
|
||||
|> List.singleton
|
||||
|> Some
|
||||
| Some AdditionalProperties.Never -> Some []
|
||||
| Some (AdditionalProperties.Constrained defn) ->
|
||||
| Some SwaggerV2.AdditionalProperties.Never -> Some []
|
||||
| Some (SwaggerV2.AdditionalProperties.Constrained defn) ->
|
||||
let defn' = defnToType anonymousTypeCount handlesMap bigCache thisKey None defn
|
||||
|
||||
match defn' with
|
||||
@@ -277,7 +277,7 @@ module internal SwaggerClientGenerator =
|
||||
|
||||
defn |> Some
|
||||
|
||||
| Definition.Array elt ->
|
||||
| SwaggerV2.Definition.Array elt ->
|
||||
let child = defnToType anonymousTypeCount handlesMap bigCache thisKey None elt.Items
|
||||
|
||||
match child with
|
||||
@@ -290,37 +290,37 @@ module internal SwaggerClientGenerator =
|
||||
}
|
||||
|
||||
Some defn
|
||||
| Definition.String ->
|
||||
| SwaggerV2.Definition.String ->
|
||||
{
|
||||
Signature = SynType.string
|
||||
FSharpDefinition = None
|
||||
}
|
||||
|> Some
|
||||
| Definition.Boolean ->
|
||||
| SwaggerV2.Definition.Boolean ->
|
||||
{
|
||||
Signature = SynType.bool
|
||||
FSharpDefinition = None
|
||||
}
|
||||
|> Some
|
||||
| Definition.Unspecified ->
|
||||
| SwaggerV2.Definition.Unspecified ->
|
||||
{
|
||||
Signature = SynType.unit
|
||||
FSharpDefinition = None
|
||||
}
|
||||
|> Some
|
||||
| Definition.Integer _ ->
|
||||
| SwaggerV2.Definition.Integer _ ->
|
||||
{
|
||||
Signature = SynType.createLongIdent' [ "int" ]
|
||||
FSharpDefinition = None
|
||||
}
|
||||
|> Some
|
||||
| Definition.File ->
|
||||
| SwaggerV2.Definition.File ->
|
||||
{
|
||||
Signature = SynType.createLongIdent' [ "System" ; "IO" ; "Stream" ]
|
||||
FSharpDefinition = None
|
||||
}
|
||||
|> Some
|
||||
| Definition.Handle s ->
|
||||
| SwaggerV2.Definition.Handle s ->
|
||||
let split = s.Split '/' |> List.ofArray
|
||||
|
||||
match split with
|
||||
@@ -382,14 +382,14 @@ module internal SwaggerClientGenerator =
|
||||
|> List.map (fun par ->
|
||||
let inParam =
|
||||
match par.In with
|
||||
| ParameterIn.Unrecognised (f, name) ->
|
||||
| SwaggerV2.ParameterIn.Unrecognised (f, name) ->
|
||||
log
|
||||
$"Skipping %O{ep.Operation} at %s{ep.Endpoint}: unrecognised In parameter %s{f} with name %s{name}"
|
||||
|
||||
None
|
||||
| ParameterIn.Body -> Some IsIn.Body
|
||||
| ParameterIn.Query name -> Some (IsIn.Query name)
|
||||
| ParameterIn.Path name -> Some (IsIn.Path name)
|
||||
| SwaggerV2.ParameterIn.Body -> Some IsIn.Body
|
||||
| SwaggerV2.ParameterIn.Query name -> Some (IsIn.Query name)
|
||||
| SwaggerV2.ParameterIn.Path name -> Some (IsIn.Path name)
|
||||
|
||||
match inParam with
|
||||
| None -> None
|
||||
@@ -515,6 +515,200 @@ module internal SwaggerClientGenerator =
|
||||
open Myriad.Core
|
||||
open System.IO
|
||||
|
||||
[<RequireQualifiedAccess>]
|
||||
module internal SwaggerV2Generator =
|
||||
let generate (pars : Map<string, string>) (contents : SwaggerV2.SwaggerV2) : Output =
|
||||
let scheme =
|
||||
let preferred = SwaggerV2.Scheme "https"
|
||||
|
||||
if List.isEmpty contents.Schemes then
|
||||
failwith "no schemes specified in API spec!"
|
||||
|
||||
if List.contains preferred contents.Schemes then
|
||||
preferred
|
||||
else
|
||||
List.head contents.Schemes
|
||||
|
||||
let clientDocstring = contents.Info.Description |> PreXmlDoc.create
|
||||
|
||||
let basePath = contents.BasePath
|
||||
|
||||
let typeDefs =
|
||||
let bigCache = Dictionary<_, Dictionary<_, _>> ()
|
||||
|
||||
let countAll () =
|
||||
(0, bigCache) ||> Seq.fold (fun count (KeyValue (_, v)) -> count + v.Count)
|
||||
|
||||
let byHandle = Dictionary ()
|
||||
let anonymousTypeCount = ref 0
|
||||
|
||||
let rec go (contents : ((string * SwaggerV2.Definition) * string) list) =
|
||||
let lastRound = countAll ()
|
||||
|
||||
contents
|
||||
|> List.filter (fun ((name, defn), defnClass) ->
|
||||
let doIt =
|
||||
SwaggerClientGenerator.defnToType
|
||||
anonymousTypeCount
|
||||
byHandle
|
||||
bigCache
|
||||
defnClass
|
||||
(Some name)
|
||||
defn
|
||||
|
||||
match doIt with
|
||||
| None -> true
|
||||
| Some _ -> false
|
||||
)
|
||||
|> fun remaining ->
|
||||
if not remaining.IsEmpty then
|
||||
let currentCount = countAll ()
|
||||
|
||||
if currentCount = lastRound then
|
||||
for (name, remaining), kind in remaining do
|
||||
SwaggerClientGenerator.log $"Remaining: %s{name} (%s{kind})"
|
||||
|
||||
SwaggerClientGenerator.log "--------"
|
||||
|
||||
for KeyValue (handle, defn) in byHandle do
|
||||
SwaggerClientGenerator.log $"Known: %s{handle} %O{defn}"
|
||||
|
||||
// TODO: ohh noooooo the Gitea spec is genuinely circular,
|
||||
// it's impossible to construct a Repository type
|
||||
// we're going to have to somehow detect this case and break the cycle
|
||||
// by artificially making a property optional
|
||||
// :sob: Gitea why are you like this
|
||||
// failwith "Made no further progress rendering types"
|
||||
()
|
||||
else
|
||||
go remaining
|
||||
|
||||
seq {
|
||||
for defnClass in [ "definitions" ; "responses" ] do
|
||||
match defnClass with
|
||||
| "definitions" ->
|
||||
for KeyValue (k, v) in contents.Definitions do
|
||||
yield (k, v), defnClass
|
||||
| "responses" ->
|
||||
for KeyValue (k, v) in contents.Responses do
|
||||
yield (k, v.Schema), defnClass
|
||||
| _ -> failwith "oh no"
|
||||
}
|
||||
|> Seq.toList
|
||||
|> go
|
||||
|
||||
let result = Dictionary ()
|
||||
|
||||
for KeyValue (_container, types) in bigCache do
|
||||
for KeyValue (defn, rendered) in types do
|
||||
result.TryAdd (defn, rendered) |> ignore<bool>
|
||||
|
||||
{
|
||||
ByHandle = byHandle
|
||||
ByDefinition = result :> IReadOnlyDictionary<_, _>
|
||||
}
|
||||
|
||||
let summary =
|
||||
contents.Paths
|
||||
|> Seq.collect (fun (KeyValue (path, endpoints)) ->
|
||||
endpoints
|
||||
|> Seq.choose (fun (KeyValue (method, endpoint)) ->
|
||||
let docstring = endpoint.Summary |> PreXmlDoc.create
|
||||
|
||||
let produces =
|
||||
match endpoint.Produces with
|
||||
| None -> Produces.Produces "json"
|
||||
| Some [] -> failwith $"API specified empty Produces: %s{path} (%O{method})"
|
||||
| Some [ SwaggerV2.MimeType "application/octet-stream" ] -> Produces.OctetStream
|
||||
| Some [ SwaggerV2.MimeType "application/json" ] -> Produces.Produces "json"
|
||||
| Some [ SwaggerV2.MimeType (StartsWith "text/" t) ] -> Produces.Produces t
|
||||
| Some [ SwaggerV2.MimeType s ] ->
|
||||
failwithf
|
||||
$"we don't support non-JSON Produces right now, got: %s{s} (%s{path} %O{method})"
|
||||
| Some (_ :: _) ->
|
||||
failwith $"we don't support multiple Produces right now, at %s{path} (%O{method})"
|
||||
|
||||
let returnType =
|
||||
endpoint.Responses
|
||||
|> Seq.choose (fun (KeyValue (response, defn)) ->
|
||||
if 200 <= response && response < 300 then
|
||||
Some defn
|
||||
else
|
||||
None
|
||||
)
|
||||
|> Seq.toList
|
||||
|
||||
let returnType =
|
||||
match returnType with
|
||||
| [ t ] -> Some t
|
||||
| [] -> failwith $"got no successful response results, %s{path} %O{method}"
|
||||
| _ ->
|
||||
SwaggerClientGenerator.log
|
||||
$"Ignoring %s{path} %O{method} due to multiple success responses"
|
||||
// can't be bothered to work out how to deal with multiple success
|
||||
// results right now
|
||||
None
|
||||
|
||||
match returnType with
|
||||
| None -> None
|
||||
| Some returnType ->
|
||||
|
||||
{
|
||||
Method = method
|
||||
Produces = produces
|
||||
DocString = docstring
|
||||
ReturnType = returnType
|
||||
Operation = endpoint.OperationId
|
||||
Parameters = endpoint.Parameters |> Option.defaultValue []
|
||||
Endpoint = path
|
||||
}
|
||||
|> Some
|
||||
)
|
||||
|> Seq.toList
|
||||
)
|
||||
|> Seq.toList
|
||||
|
||||
let config =
|
||||
let createMock =
|
||||
match Map.tryFind "GENERATEMOCKVISIBILITY" pars with
|
||||
| None -> None
|
||||
| Some v ->
|
||||
match v.ToLowerInvariant () with
|
||||
| "internal" -> Some true
|
||||
| "public" -> Some false
|
||||
| _ ->
|
||||
failwith
|
||||
$"Expected GenerateMockVisibility parameter to be 'internal' or 'public', but was: '%s{v.ToLowerInvariant ()}'"
|
||||
|
||||
let className =
|
||||
match Map.tryFind "CLASSNAME" pars with
|
||||
| None -> failwith "You must supply the <ClassName /> parameter in <MyriadParams />."
|
||||
| Some v -> v
|
||||
|
||||
{
|
||||
CreateMock = createMock
|
||||
ClassName = className
|
||||
}
|
||||
|
||||
let ty =
|
||||
SwaggerClientGenerator.computeType config basePath typeDefs clientDocstring summary
|
||||
|
||||
[
|
||||
yield
|
||||
SynModuleDecl.Open (
|
||||
SynOpenDeclTarget.ModuleOrNamespace (
|
||||
SynLongIdent.createS' [ "WoofWare" ; "Myriad" ; "Plugins" ],
|
||||
range0
|
||||
),
|
||||
range0
|
||||
)
|
||||
yield SwaggerClientGenerator.instantiateRequiredTypes typeDefs
|
||||
yield! ty
|
||||
]
|
||||
|> SynModuleOrNamespace.createNamespace [ Ident.create config.ClassName ]
|
||||
|> List.singleton
|
||||
|> Output.Ast
|
||||
|
||||
/// Myriad generator that stamps out an interface and class to access a Swagger-specified API.
|
||||
[<MyriadGenerator("swagger-client")>]
|
||||
type SwaggerClientGenerator () =
|
||||
@@ -523,206 +717,19 @@ type SwaggerClientGenerator () =
|
||||
member _.ValidInputExtensions = [ ".json" ]
|
||||
|
||||
member _.Generate (context : GeneratorContext) =
|
||||
let contents = File.ReadAllText context.InputFilename |> Swagger.parse
|
||||
let pars = MyriadParamParser.render context.AdditionalParameters
|
||||
|
||||
let scheme =
|
||||
let preferred = Scheme "https"
|
||||
let pars =
|
||||
pars
|
||||
|> Map.toSeq
|
||||
|> Seq.map (fun (k, v) -> k.ToUpperInvariant (), v)
|
||||
|> Map.ofSeq
|
||||
|
||||
if List.isEmpty contents.Schemes then
|
||||
failwith "no schemes specified in API spec!"
|
||||
if pars.IsEmpty then
|
||||
failwith "No parameters given. You must supply the <ClassName /> parameter in <MyriadParams />."
|
||||
|
||||
if List.contains preferred contents.Schemes then
|
||||
preferred
|
||||
else
|
||||
List.head contents.Schemes
|
||||
let contents = File.ReadAllText context.InputFilename |> SwaggerV2.parse
|
||||
|
||||
let clientDocstring = contents.Info.Description |> PreXmlDoc.create
|
||||
|
||||
let basePath = contents.BasePath
|
||||
|
||||
let typeDefs =
|
||||
let bigCache = Dictionary<_, Dictionary<_, _>> ()
|
||||
|
||||
let countAll () =
|
||||
(0, bigCache) ||> Seq.fold (fun count (KeyValue (_, v)) -> count + v.Count)
|
||||
|
||||
let byHandle = Dictionary ()
|
||||
let anonymousTypeCount = ref 0
|
||||
|
||||
let rec go (contents : ((string * Definition) * string) list) =
|
||||
let lastRound = countAll ()
|
||||
|
||||
contents
|
||||
|> List.filter (fun ((name, defn), defnClass) ->
|
||||
let doIt =
|
||||
SwaggerClientGenerator.defnToType
|
||||
anonymousTypeCount
|
||||
byHandle
|
||||
bigCache
|
||||
defnClass
|
||||
(Some name)
|
||||
defn
|
||||
|
||||
match doIt with
|
||||
| None -> true
|
||||
| Some _ -> false
|
||||
)
|
||||
|> fun remaining ->
|
||||
if not remaining.IsEmpty then
|
||||
let currentCount = countAll ()
|
||||
|
||||
if currentCount = lastRound then
|
||||
for (name, remaining), kind in remaining do
|
||||
SwaggerClientGenerator.log $"Remaining: %s{name} (%s{kind})"
|
||||
|
||||
SwaggerClientGenerator.log "--------"
|
||||
|
||||
for KeyValue (handle, defn) in byHandle do
|
||||
SwaggerClientGenerator.log $"Known: %s{handle} %O{defn}"
|
||||
|
||||
// TODO: ohh noooooo the Gitea spec is genuinely circular,
|
||||
// it's impossible to construct a Repository type
|
||||
// we're going to have to somehow detect this case and break the cycle
|
||||
// by artificially making a property optional
|
||||
// :sob: Gitea why are you like this
|
||||
// failwith "Made no further progress rendering types"
|
||||
()
|
||||
else
|
||||
go remaining
|
||||
|
||||
seq {
|
||||
for defnClass in [ "definitions" ; "responses" ] do
|
||||
match defnClass with
|
||||
| "definitions" ->
|
||||
for KeyValue (k, v) in contents.Definitions do
|
||||
yield (k, v), defnClass
|
||||
| "responses" ->
|
||||
for KeyValue (k, v) in contents.Responses do
|
||||
yield (k, v.Schema), defnClass
|
||||
| _ -> failwith "oh no"
|
||||
}
|
||||
|> Seq.toList
|
||||
|> go
|
||||
|
||||
let result = Dictionary ()
|
||||
|
||||
for KeyValue (_container, types) in bigCache do
|
||||
for KeyValue (defn, rendered) in types do
|
||||
result.TryAdd (defn, rendered) |> ignore<bool>
|
||||
|
||||
{
|
||||
ByHandle = byHandle
|
||||
ByDefinition = result :> IReadOnlyDictionary<_, _>
|
||||
}
|
||||
|
||||
let summary =
|
||||
contents.Paths
|
||||
|> Seq.collect (fun (KeyValue (path, endpoints)) ->
|
||||
endpoints
|
||||
|> Seq.choose (fun (KeyValue (method, endpoint)) ->
|
||||
let docstring = endpoint.Summary |> PreXmlDoc.create
|
||||
|
||||
let produces =
|
||||
match endpoint.Produces with
|
||||
| None -> Produces.Produces "json"
|
||||
| Some [] -> failwith $"API specified empty Produces: %s{path} (%O{method})"
|
||||
| Some [ MimeType "application/octet-stream" ] -> Produces.OctetStream
|
||||
| Some [ MimeType "application/json" ] -> Produces.Produces "json"
|
||||
| Some [ MimeType (StartsWith "text/" t) ] -> Produces.Produces t
|
||||
| Some [ MimeType s ] ->
|
||||
failwithf
|
||||
$"we don't support non-JSON Produces right now, got: %s{s} (%s{path} %O{method})"
|
||||
| Some (_ :: _) ->
|
||||
failwith $"we don't support multiple Produces right now, at %s{path} (%O{method})"
|
||||
|
||||
let returnType =
|
||||
endpoint.Responses
|
||||
|> Seq.choose (fun (KeyValue (response, defn)) ->
|
||||
if 200 <= response && response < 300 then
|
||||
Some defn
|
||||
else
|
||||
None
|
||||
)
|
||||
|> Seq.toList
|
||||
|
||||
let returnType =
|
||||
match returnType with
|
||||
| [ t ] -> Some t
|
||||
| [] -> failwith $"got no successful response results, %s{path} %O{method}"
|
||||
| _ ->
|
||||
SwaggerClientGenerator.log
|
||||
$"Ignoring %s{path} %O{method} due to multiple success responses"
|
||||
// can't be bothered to work out how to deal with multiple success
|
||||
// results right now
|
||||
None
|
||||
|
||||
match returnType with
|
||||
| None -> None
|
||||
| Some returnType ->
|
||||
|
||||
{
|
||||
Method = method
|
||||
Produces = produces
|
||||
DocString = docstring
|
||||
ReturnType = returnType
|
||||
Operation = endpoint.OperationId
|
||||
Parameters = endpoint.Parameters |> Option.defaultValue []
|
||||
Endpoint = path
|
||||
}
|
||||
|> Some
|
||||
)
|
||||
|> Seq.toList
|
||||
)
|
||||
|> Seq.toList
|
||||
|
||||
let config =
|
||||
let pars = MyriadParamParser.render context.AdditionalParameters
|
||||
|
||||
let pars =
|
||||
pars
|
||||
|> Map.toSeq
|
||||
|> Seq.map (fun (k, v) -> k.ToUpperInvariant (), v)
|
||||
|> Map.ofSeq
|
||||
|
||||
if pars.IsEmpty then
|
||||
failwith "No parameters given. You must supply the <ClassName /> parameter in <MyriadParams />."
|
||||
|
||||
let createMock =
|
||||
match Map.tryFind "GENERATEMOCKVISIBILITY" pars with
|
||||
| None -> None
|
||||
| Some v ->
|
||||
match v.ToLowerInvariant () with
|
||||
| "internal" -> Some true
|
||||
| "public" -> Some false
|
||||
| _ ->
|
||||
failwith
|
||||
$"Expected GenerateMockVisibility parameter to be 'internal' or 'public', but was: '%s{v.ToLowerInvariant ()}'"
|
||||
|
||||
let className =
|
||||
match Map.tryFind "CLASSNAME" pars with
|
||||
| None -> failwith "You must supply the <ClassName /> parameter in <MyriadParams />."
|
||||
| Some v -> v
|
||||
|
||||
{
|
||||
CreateMock = createMock
|
||||
ClassName = className
|
||||
}
|
||||
|
||||
let ty =
|
||||
SwaggerClientGenerator.computeType config basePath typeDefs clientDocstring summary
|
||||
|
||||
[
|
||||
yield
|
||||
SynModuleDecl.Open (
|
||||
SynOpenDeclTarget.ModuleOrNamespace (
|
||||
SynLongIdent.createS' [ "WoofWare" ; "Myriad" ; "Plugins" ],
|
||||
range0
|
||||
),
|
||||
range0
|
||||
)
|
||||
yield SwaggerClientGenerator.instantiateRequiredTypes typeDefs
|
||||
yield! ty
|
||||
]
|
||||
|> SynModuleOrNamespace.createNamespace [ Ident.create config.ClassName ]
|
||||
|> List.singleton
|
||||
|> Output.Ast
|
||||
match contents with
|
||||
| Ok contents -> SwaggerV2Generator.generate pars contents
|
||||
| Error node -> failwith "Input was not a Swagger 2 spec"
|
||||
|
@@ -1,53 +1,8 @@
|
||||
namespace WoofWare.Myriad.Plugins
|
||||
module internal WoofWare.Myriad.Plugins.SwaggerV2
|
||||
|
||||
open System
|
||||
open System.Text.Json.Nodes
|
||||
|
||||
[<AutoOpen>]
|
||||
module internal JsonHelpers =
|
||||
let inline asString (n : JsonNode) (key : string) : string =
|
||||
match n.[key] with
|
||||
| null -> failwith $"Expected node to have a key '%s{key}', but it did not: %s{n.ToJsonString ()}"
|
||||
| s -> s.GetValue<string> ()
|
||||
|
||||
[<RequiresExplicitTypeArguments>]
|
||||
let inline asOpt<'ret> (n : JsonNode) (key : string) : 'ret option =
|
||||
match n.[key] with
|
||||
| null -> None
|
||||
| s -> s.GetValue<'ret> () |> Some
|
||||
|
||||
let inline asObj (n : JsonNode) (key : string) : JsonObject =
|
||||
match n.[key] with
|
||||
| null -> failwith $"Expected node to have a key '%s{key}', but it did not: %s{n.ToJsonString ()}"
|
||||
| o -> o.AsObject ()
|
||||
|
||||
let inline asObjOpt (n : JsonNode) (key : string) : JsonObject option =
|
||||
match n.[key] with
|
||||
| null -> None
|
||||
| o -> o.AsObject () |> Some
|
||||
|
||||
let inline asArr (n : JsonNode) (key : string) : JsonArray =
|
||||
match n.[key] with
|
||||
| null -> failwith $"Expected node to have a key '%s{key}', but it did not: %s{n.ToJsonString ()}"
|
||||
| o -> o.AsArray ()
|
||||
|
||||
let inline asArrOpt (n : JsonNode) (key : string) : JsonArray option =
|
||||
match n.[key] with
|
||||
| null -> None
|
||||
| o -> o.AsArray () |> Some
|
||||
|
||||
[<RequiresExplicitTypeArguments>]
|
||||
let inline asArr'<'v> (n : JsonNode) (key : string) : 'v list =
|
||||
match n.[key] with
|
||||
| null -> failwith $"Expected node to have a key '%s{key}', but it did not: %s{n.ToJsonString ()}"
|
||||
| o -> o.AsArray () |> Seq.map (fun v -> v.GetValue<'v> ()) |> Seq.toList
|
||||
|
||||
[<RequiresExplicitTypeArguments>]
|
||||
let inline asArrOpt'<'v> (n : JsonNode) (key : string) : 'v list option =
|
||||
match n.[key] with
|
||||
| null -> None
|
||||
| o -> o.AsArray () |> Seq.map (fun v -> v.GetValue<'v> ()) |> Seq.toList |> Some
|
||||
|
||||
/// A MIME type, like "application/json"
|
||||
type MimeType =
|
||||
/// A MIME type, like "application/json"
|
||||
@@ -434,71 +389,8 @@ type Response =
|
||||
Schema = schema
|
||||
}
|
||||
|
||||
/// An HTTP method. This is System.Net.Http.HttpMethod, but
|
||||
/// a proper discriminated union.
|
||||
type HttpMethod =
|
||||
/// HTTP Get
|
||||
| Get
|
||||
/// HTTP Post
|
||||
| Post
|
||||
/// HTTP Delete
|
||||
| Delete
|
||||
/// HTTP Patch
|
||||
| Patch
|
||||
/// HTTP Options
|
||||
| Options
|
||||
/// HTTP Head
|
||||
| Head
|
||||
/// HTTP Put
|
||||
| Put
|
||||
/// HTTP Trace
|
||||
| Trace
|
||||
|
||||
/// Convert to the standard library's enum type.
|
||||
member this.ToDotNet () : System.Net.Http.HttpMethod =
|
||||
match this with
|
||||
| HttpMethod.Get -> System.Net.Http.HttpMethod.Get
|
||||
| HttpMethod.Post -> System.Net.Http.HttpMethod.Post
|
||||
| HttpMethod.Delete -> System.Net.Http.HttpMethod.Delete
|
||||
| HttpMethod.Patch -> System.Net.Http.HttpMethod.Patch
|
||||
| HttpMethod.Options -> System.Net.Http.HttpMethod.Options
|
||||
| HttpMethod.Head -> System.Net.Http.HttpMethod.Head
|
||||
| HttpMethod.Put -> System.Net.Http.HttpMethod.Put
|
||||
| HttpMethod.Trace -> System.Net.Http.HttpMethod.Trace
|
||||
|
||||
/// Human-readable string representation.
|
||||
override this.ToString () : string =
|
||||
match this with
|
||||
| HttpMethod.Get -> "Get"
|
||||
| HttpMethod.Post -> "Post"
|
||||
| HttpMethod.Delete -> "Delete"
|
||||
| HttpMethod.Patch -> "Patch"
|
||||
| HttpMethod.Options -> "Options"
|
||||
| HttpMethod.Head -> "Head"
|
||||
| HttpMethod.Put -> "Put"
|
||||
| HttpMethod.Trace -> "Trace"
|
||||
|
||||
/// Throws on invalid inputs.
|
||||
static member Parse (s : string) : HttpMethod =
|
||||
if String.Equals (s, "get", StringComparison.OrdinalIgnoreCase) then
|
||||
HttpMethod.Get
|
||||
elif String.Equals (s, "post", StringComparison.OrdinalIgnoreCase) then
|
||||
HttpMethod.Post
|
||||
elif String.Equals (s, "patch", StringComparison.OrdinalIgnoreCase) then
|
||||
HttpMethod.Patch
|
||||
elif String.Equals (s, "delete", StringComparison.OrdinalIgnoreCase) then
|
||||
HttpMethod.Delete
|
||||
elif String.Equals (s, "head", StringComparison.OrdinalIgnoreCase) then
|
||||
HttpMethod.Head
|
||||
elif String.Equals (s, "options", StringComparison.OrdinalIgnoreCase) then
|
||||
HttpMethod.Options
|
||||
elif String.Equals (s, "put", StringComparison.OrdinalIgnoreCase) then
|
||||
HttpMethod.Put
|
||||
else
|
||||
failwith $"Unrecognised method: %s{s}"
|
||||
|
||||
/// A Swagger API specification.
|
||||
type Swagger =
|
||||
type SwaggerV2 =
|
||||
{
|
||||
/// Global collection of MIME types which any endpoint expects to consume its inputs in.
|
||||
/// This may be overridden on any individual endpoint by that endpoint.
|
||||
@@ -526,58 +418,63 @@ type Swagger =
|
||||
Responses : Map<string, Response>
|
||||
}
|
||||
|
||||
[<RequireQualifiedAccess>]
|
||||
module Swagger =
|
||||
/// Parse a JSON-schema-based specification of a Swagger 2.0 API and
|
||||
/// build the strongly-typed version. Throws on invalid inputs.
|
||||
let parse (s : string) : Swagger =
|
||||
let node = JsonNode.Parse s
|
||||
let consumes = asArr'<string> node "consumes" |> List.map MimeType
|
||||
let produces = asArr'<string> node "produces" |> List.map MimeType
|
||||
let schemes = asArr'<string> node "schemes" |> List.map Scheme
|
||||
let swagger = asString node "swagger" |> Version.Parse
|
||||
let info = asObj node "info" |> SwaggerInfo.Parse
|
||||
let basePath = asString node "basePath"
|
||||
/// Parse a JSON-schema-based specification of a Swagger 2.0 API and
|
||||
/// build the strongly-typed version. Throws on invalid inputs; returns Error if the input is JSON but has a Swagger
|
||||
/// version that is not in the 2.0 series.
|
||||
let parse (s : string) : Result<SwaggerV2, JsonNode> =
|
||||
let node = JsonNode.Parse s
|
||||
let swagger = asString node "swagger" |> Version.Parse
|
||||
|
||||
let definitions =
|
||||
asObj node "definitions"
|
||||
|> Seq.map (fun (KeyValue (key, value)) ->
|
||||
let value = value.AsObject ()
|
||||
key, Definition.Parse value
|
||||
)
|
||||
|> Map.ofSeq
|
||||
if swagger.Major <> 2 then
|
||||
Error node
|
||||
else
|
||||
|
||||
let paths =
|
||||
asObj node "paths"
|
||||
|> Seq.map (fun (KeyValue (key, value)) ->
|
||||
let contents =
|
||||
value.AsObject ()
|
||||
|> Seq.map (fun (KeyValue (endpoint, contents)) ->
|
||||
let contents = contents.AsObject ()
|
||||
HttpMethod.Parse endpoint, SwaggerEndpoint.Parse contents
|
||||
)
|
||||
|> Map.ofSeq
|
||||
let consumes = asArr'<string> node "consumes" |> List.map MimeType
|
||||
let produces = asArr'<string> node "produces" |> List.map MimeType
|
||||
let schemes = asArr'<string> node "schemes" |> List.map Scheme
|
||||
let info = asObj node "info" |> SwaggerInfo.Parse
|
||||
let basePath = asString node "basePath"
|
||||
|
||||
key, contents
|
||||
)
|
||||
|> Map.ofSeq
|
||||
let definitions =
|
||||
asObj node "definitions"
|
||||
|> Seq.map (fun (KeyValue (key, value)) ->
|
||||
let value = value.AsObject ()
|
||||
key, Definition.Parse value
|
||||
)
|
||||
|> Map.ofSeq
|
||||
|
||||
let responses =
|
||||
asObj node "responses"
|
||||
|> Seq.map (fun (KeyValue (key, value)) ->
|
||||
let value = value.AsObject ()
|
||||
key, Response.Parse value
|
||||
)
|
||||
|> Map.ofSeq
|
||||
let paths =
|
||||
asObj node "paths"
|
||||
|> Seq.map (fun (KeyValue (key, value)) ->
|
||||
let contents =
|
||||
value.AsObject ()
|
||||
|> Seq.map (fun (KeyValue (endpoint, contents)) ->
|
||||
let contents = contents.AsObject ()
|
||||
HttpMethod.Parse endpoint, SwaggerEndpoint.Parse contents
|
||||
)
|
||||
|> Map.ofSeq
|
||||
|
||||
{
|
||||
Consumes = consumes
|
||||
Produces = produces
|
||||
Schemes = schemes
|
||||
Swagger = swagger
|
||||
Info = info
|
||||
BasePath = basePath
|
||||
Paths = paths
|
||||
Definitions = definitions
|
||||
Responses = responses
|
||||
}
|
||||
key, contents
|
||||
)
|
||||
|> Map.ofSeq
|
||||
|
||||
let responses =
|
||||
asObj node "responses"
|
||||
|> Seq.map (fun (KeyValue (key, value)) ->
|
||||
let value = value.AsObject ()
|
||||
key, Response.Parse value
|
||||
)
|
||||
|> Map.ofSeq
|
||||
|
||||
{
|
||||
Consumes = consumes
|
||||
Produces = produces
|
||||
Schemes = schemes
|
||||
Swagger = swagger
|
||||
Info = info
|
||||
BasePath = basePath
|
||||
Paths = paths
|
||||
Definitions = definitions
|
||||
Responses = responses
|
||||
}
|
||||
|> Ok
|
@@ -28,6 +28,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.fs" />
|
||||
<Compile Include="List.fs"/>
|
||||
<Compile Include="Text.fs" />
|
||||
<Compile Include="Measure.fs" />
|
||||
@@ -41,7 +42,10 @@
|
||||
<Compile Include="HttpClientGenerator.fs"/>
|
||||
<Compile Include="CataGenerator.fs" />
|
||||
<Compile Include="ArgParserGenerator.fs" />
|
||||
<Compile Include="Swagger.fs" />
|
||||
<Compile Include="JsonHelpers.fs" />
|
||||
<Compile Include="HttpMethod.fs" />
|
||||
<Compile Include="SwaggerV2.fs" />
|
||||
<Compile Include="OpenApi3.fs" />
|
||||
<Compile Include="SwaggerClientGenerator.fs" />
|
||||
<None Include="ApacheLicence.txt" />
|
||||
<EmbeddedResource Include="version.json"/>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "7.0",
|
||||
"version": "8.0",
|
||||
"publicReleaseRefSpec": [
|
||||
"^refs/heads/main$"
|
||||
],
|
||||
@@ -11,4 +11,4 @@
|
||||
":/README.md",
|
||||
":/Directory.Build.props"
|
||||
]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user