unit OpenAPI.Types;

interface

uses
  Generics.Collections,
  Bcl.Json.Attributes,
  XData.JSchema.Classes;

type
  [JsonEnumValues('csv,ssv,tsv,pipes,multi')]
  TCollectionFormat =
  (
    CSV,
    SSV,
    TSV,
    Pipes,
    Multi
  );

  TEmail = string;

  [JsonEnumValues('body,query,path,header,formData')]
  TLocation =
  (
    // The payload that's appended to the HTTP request.
    // Since there can only be one payload, there can only be ONE body parameter.
    // The name of the body parameter has no effect on the parameter itself and is used for documentation purposes only.
    // Since Form parameters are also in the payload, body and form parameters cannot exist together for the same operation.
    Body,
    // Parameters that are appended to the URL. For example, in /items?id=###, the query parameter is id.
    Query,
    // 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.
    Header,
    // Used to describe the payload of an HTTP request when either application/x-www-form-urlencoded,
    // multipart/form-data or both are used as the content type of the request.
    // This is the only parameter type that can be used to send files, thus supporting the file type.
    // Since form parameters are sent in the payload, they cannot be declared together with a body parameter for the same operation.
    FormData
  );

  [JsonEnumValues('http,https,ws,wss')]
  TProtocol =
  (
    Http,
    Https,
    Ws,
    Wss
  );

  TProtocols = set of TProtocol;

  [JsonEnumValues('none,implicit,password,application,accessCode')]
  TSecurityFlow =
  (
    None,
    Implicit,
    Password,
    App,
    AccessCode
  );

  [JsonEnumValues('basic,apiKey,oauth2')]
  TSecuritySchemeType =
  (
    Basic,
    ApiKey,
    Oauth2
  );

  TUrl = string;

  TOpenAPIStrings = class(TList<string>)
  public
    class function Return(var OAS: TOpenAPIStrings): TOpenAPIStrings;
  end;

  TFileSchema = class(TJsonSchema)
  protected
    function GetType: string; override;
  end;

implementation

{ TOpenAPIStrings }

class function TOpenAPIStrings.Return(var OAS: TOpenAPIStrings): TOpenAPIStrings;
begin
  if OAS = nil then
    OAS := TOpenAPIStrings.Create;
  result := OAS;
end;

{ TFileSchema }

function TFileSchema.GetType: string;
begin
  result := 'file';
end;

end.


