unit OpenAPI.Json.Serializer;

interface

uses
  Classes,
  Bcl.Json, Bcl.Json.Serializer,
  OpenAPI.Document;

type
  TSerializer = class(TJsonSerializer)
  public
    constructor Create;
    class function DocumentToJson(Document: TDocument): string;
  end;

implementation

uses
  OpenAPI.Json.Converters;

{ TSerializer }

constructor TSerializer.Create;
begin
  inherited Create(TOpenAPIJsonConverters.Create, True);
end;

class function TSerializer.DocumentToJson(Document: TDocument): string;
var
  serializer: TSerializer;
begin
  serializer := TSerializer.Create;
  try
    result := serializer.Write(Document);
  finally
    serializer.Free;
  end;
end;

end.

