question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for Decimal (monetary) data

See original GitHub issue

Related to: https://github.com/OAI/OpenAPI-Specification/issues/1517

Here is a printout from Open Banking in the UK. “Amount” is the field of interest.

HTTP/1.1 200 OK
x-fapi-interaction-id: 93bac548-d2de-4546-b106-880a5018460d
Content-Type: application/json
 
{
  "Data": {
    "DirectDebit": [
      {
        "AccountId": "22289",
        "DirectDebitId": "DD03",
        "MandateIdentification": "Caravanners",
        "DirectDebitStatusCode": "Active",
        "Name": "Towbar Club 3 - We Love Towbars",
        "PreviousPaymentDateTime": "2017-04-05T10:43:07+00:00",
        "PreviousPaymentAmount": {
          "Amount": "0.57",
          "Currency": "GBP"
        }
      }
    ]
  },
  "Links": {
    "Self": "https://api.alphabank.com/open-banking/v2.0/accounts/22289/direct-debits/"
  },
  "Meta": {
    "TotalPages": 1
  }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
darrelmillercommented, Apr 2, 2018

@cyberphone Yes. Here is the ANBF grammar for how to serialize a JSON Number over the wire in UTF-8 text.

And your last comment gets to the heart of the matter. OpenAPI is not in the business of telling people how to serialize data. That is the job of media type specifications. We are in the business of trying to describe in a platform independent manner what people chose to do.

2reactions
cyberphonecommented, Apr 2, 2018

Sure, I’m unarguable NOT an expert on OpenAPI and JSON Schema. I did though read the table of data types: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#data-types I found dateTime and saw that it is mapped into RFC3339 formatted “strings”.

I would reuse that idea for Decimal unless there is something fundamentally wrong with doing that. The W3C folks’ format specification would probably suffice.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use the DECIMAL Data Type for Money Values - Vertabelo
Find out which data type should be used for money values in SQL!
Read more >
Model Monetary Data — MongoDB Manual
Applications that handle monetary data often require the ability to capture fractional units of currency and need to emulate decimal rounding with exact ......
Read more >
Decimal Safety Right on The Money - FP Complete
We developed a library for operating on decimal numbers that guards you from errors. Come learn how it works and how you can...
Read more >
Money and Decimal Data Types for Monetary Values with SQL ...
In this article, we look at the differences between storing monetary values in SQL Server using the money data type versus the decimal...
Read more >
Which data type would you choose for storing currency values ...
Primitive type — int and long are also useful for monetary calculations if decimal precision is not required. We should really avoid using ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found