unit OpenAPI.Classes.Info;

interface

uses
  OpenAPI.Json.Attributes, OpenAPI.Types;

type
  // The object provides metadata about the API.
  [OAJsonInclusion, OAJsonNaming]
  TInfo = class
  strict private
    type
      // Contact information for the exposed API.
      [OAJsonInclusion, OAJsonNaming]
      TContact = class
      private
        FName: string;
        FEmail: TEmail;
        FUrl: TUrl;
      public
        // The identifying name of the contact person/organization.
        property Name: string read FName write FName;
        // 	The URL pointing to the contact information.
        property Url: TUrl read FUrl write FUrl;
        // The email address of the contact person/organization.
        property Email: TEmail read FEmail write FEmail;
      end;

      // License information for the exposed API.
      [OAJsonInclusion, OAJsonNaming]
      TLicense = class
      strict private
        FName: string;
        FUrl: TUrl;
      public
        // Required. The license name used for the API.
        property Name: string read FName write FName;
        // A URL to the license used for the API.
        property Url: TUrl read FUrl write FUrl;
      end;
  strict private
    FDescription: string;
    FVersion: string;
    FTitle: string;
    FTermsOfService: string;
    FContact: TContact;
    FLicense: TLicense;
    function GetContact: TContact;
    function GetLicense: TLicense;
  public
    destructor Destroy; override;
    // 	Required. The title of the application.
    property Title: string read FTitle write FTitle;
    // A short description of the application.
    property Description: string read FDescription write FDescription;
    // The Terms of Service for the API.
    property TermsOfService: string read FTermsOfService write FTermsOfService;
    // The contact information for the exposed API.
    property Contact: TContact read GetContact;
    // The license information for the exposed API.
    property License: TLicense read GetLicense;
    // Required. Provides the version of the application API.
    property Version: string read FVersion write FVersion;
  end;

implementation

{ TInfo }

destructor TInfo.Destroy;
begin
  FContact.Free;
  FLicense.Free;
  inherited;
end;

function TInfo.GetContact: TContact;
begin
  if FContact = nil then
    FContact := TContact.Create;
  result := FContact;
end;

function TInfo.GetLicense: TLicense;
begin
  if FLicense = nil then
    FLicense := TLicense.Create;
  result := FLicense;
end;

end.

