#1 Today 06:31:30

DirkH
Member
Registered: 2025-09-26
Posts: 15

OpenApi Generator: Wrong Type (packed record) in array constructor

Hi and thanks for the great work.

I have the following Json REST Spec https://testdrive.polarion.com/polarion … nrest.json.
The mopenapi generator creates.

function TPolarionClient.GetAllDocuments(const Fields: TPolarionSparseFields;
  PageSize: integer; PageNumber: integer; const Include: RawUtf8;
  const Query: RawUtf8; const Sort: RawUtf8;
  const Revision: RawUtf8): TPolarionDocumentsListGetResponse;
begin
  fClient.Request('GET', '/all/documents', [], [
    'page[size]', PageSize,
    'page[number]', PageNumber,
    'fields', Fields,
    'include', Include,
    'query', Query,
    'sort', Sort,
    'revision', Revision], [],
    result, TypeInfo(TPolarionDocumentsListGetResponse));
end; 

The compiler says we are not allowed to put a (packed) record into an array constructor sad
polarion.client.pas(7835,15) Error: Wrong type "TPolarionSparseFields" in array constructor

Thanks so much for having a look into it.

Offline

#2 Today 07:35:46

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,528
Website

Re: OpenApi Generator: Wrong Type (packed record) in array constructor

You are right: "deepObject" URI parameters are not supported yet.

(What a complex format OpenAPI is!)

I will look into it.

Offline

#3 Today 12:05:00

DirkH
Member
Registered: 2025-09-26
Posts: 15

Re: OpenApi Generator: Wrong Type (packed record) in array constructor

I think there is an additional deduplication error.

"usersSingleGetResponse" in JSON has data.attributes.name. But in the DTO.pas file data "points" to a different attributes record, that has no "name" property (i guess it is pagesSingleGetResponse.data in json and not usersSingleGetResponse.data ) .

Offline

#4 Today 12:31:17

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,528
Website

Re: OpenApi Generator: Wrong Type (packed record) in array constructor

So this is not correct?

  TDtoApi2761 = packed record
    _Type: TEnumApi8;
    Id: RawUtf8;
    Revision: RawUtf8;
    Attributes: TDtoApi2764;
    Relationships: TDtoApi2779;
    Links: TDtoApi995;
    Meta: TDtoApi1354;
  end;

  // from #/components/schemas/usersSingleGetResponse
  TUsersSingleGetResponse = packed record
    Data: TDtoApi2761;
    // Related entities might be returned, see <a href="https://docs.sw.siemens.com/en-US/doc/230235217/PL20250606201928474.polarion_help_sc.xid2134849/xid2134871"
    // target="_blank">REST API User Guide</a>.
    Included: variant;
    Links: TDtoApi995;
  end;
  PUsersSingleGetResponse = ^TUsersSingleGetResponse;

Offline

#5 Today 13:06:07

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 15,528
Website

Re: OpenApi Generator: Wrong Type (packed record) in array constructor

Anyway, please try with
https://github.com/synopse/mORMot2/commit/fe1370e77

It should now at least compile.
Maybe there are still some issues.

Offline

Board footer

Powered by FluxBB