companieshouse / specs.developer.ch.gov.uk

API specifications (OpenAPI 3.0+) for the Companies House Developer Hub
MIT License
5 stars 1 forks source link

Day and month fields aren't integers #14

Open mhemmings opened 4 years ago

mhemmings commented 4 years ago

Apologies if this is the incorrect repo; not sure if it's a documentation or implementation issue.

The docs define all day and month fields as integers (e.g. https://github.com/companieshouse/specs.developer.ch.gov.uk/blob/351632ccb69e1a13e7bd222caabe48d6d7957f5f/openapi3render/markdown_specs/companyProfile.html.md#schemaaccountinformation).

However, the API api.companieshouse.gov.uk returns them as strings.

For example:

GET https://api.companieshouse.gov.uk/company/00000006 returns

{
   "accounts" : {
      "accounting_reference_date" : {
         "day" : "31",
         "month" : "12"
      },
...
}

From my testing, this appears to be true for the day/month fields in accounts.accounting_reference_date, foreign_company_details.accounts.account_period_to, foreign_company_details.accounts.account_period_from and foreign_company_details.accounts.must_file_within

CH-JonathanBlake commented 4 years ago

Correct me if I'm wrong but the JSON schema rejects numbers as strings as numbers. https://json-schema.org/understanding-json-schema/reference/numeric.html So I think the fault is in the example you gave us, it should look like:

{
   "accounts" : {
      "accounting_reference_date" : {
         "day" : 31,
         "month" : 12
      },
...
}
mhemmings commented 4 years ago

Yes that's what I'd expect, and that's what the docs say to expect. However the API returns strings

CH-JonathanBlake commented 4 years ago

Okay if this is the behavior of the actual API implementation, then this is the wrong repo. The purpose of this is mostly around recieving broken dapperdocs specs and converting them into valid OpenAPI3.