Dredd: Make sure statusCode is always stored as either integer or string

Created on 26 Jul 2019  路  4Comments  路  Source: apiaryio/dredd

Currently the statusCode can be both. We should make sure it is always the same type and find the culprit which produces it with different types and fix it. One example where this is a problem:

https://github.com/apiaryio/dredd/blob/cd9538f482f00926a3642f71eeb03af81bcaf9ef/lib/TransactionRunner.js#L557-L563

Another example is the apiary reporter, which sends this over to the Apiary Test Reporting API and we need to coerce these values before saving them to the database.

bug

All 4 comments

Is there any benefit of storing it in a string? Some database-specific handling of numbers, etc.

I wouldn't say there is any particular reason why to store it in string. Perhaps to make the text diff on it in the past, but even that should have stayed in the black box of the validator.

Let's store it as a number then, which it is :) See no practical reason to use strings for storing numbers. More like code smells to me.

It is a best practice to store currency as a string in JSON to avoid floating point numbers "rounding" issues, but this is not the case.

Was this page helpful?
0 / 5 - 0 ratings