#1 2025-12-06 06:56:13

anouri
Member
Registered: 2024-02-11
Posts: 165

TBcd data type problem

Hi.
I have interface based service:

function TestBcd(const Val: Tbcd): TServiceCustomAnswer;

it is shown in swagger like this:
{
  "Val": {
    "Precision": 0,
    "SignSpecialPlaces": 0,
    "Fraction": [
      "string"
    ]
  }
}

but I want swagger shows:
{
  "Val": "string"
}


service method works when I pass parameter as string : "123456789.123456".

when I try to define this data type in template mustache file I got an error: (Parser error on line 623 duplicated mapping key)

"TBcd": {
    "type": "string",
    "description": "A string value that can be TBCD example : \"123456.123\""
}

Last edited by anouri (2025-12-06 09:01:02)

Offline

#2 2025-12-06 19:54:26

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

Re: TBcd data type problem

IIRC you could just include mormot.db.rad.pas unit in your project.
Then it would register TBcd and serialize it as JSON "string" to keep the precision.

With a two seconds search of "TBcd JSON" in the forum, you would have found
https://synopse.info/forum/viewtopic.php?id=7100

Offline

#3 2025-12-08 13:32:42

anouri
Member
Registered: 2024-02-11
Posts: 165

Re: TBcd data type problem

Hi AB.

I don't have problem with TBCD itself. Framework works correctly. My problem is in swagger.

I try my best not to waste your valuable time as much as possible. But in cases where I cannot solve the problem in any other way, I am forced to raise it here.

Last edited by anouri (2025-12-08 13:32:59)

Offline

#4 2025-12-08 15:27:43

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

Re: TBcd data type problem

Ok now I understand.

Please try with
https://github.com/synopse/mORMot2/commit/828a19555

Offline

Board footer

Powered by FluxBB