A language for describing resource-oriented APIs & turning them into Swagger or resource diagrams. Oriented around the concepts we want to expose in the APIs.
Apache License 2.0
23
stars
7
forks
source link
Use "type: integer" for int attributes, pagination, and http status codes #4
Got some funny situations where auto-generated examples would generate these long decimals for things that should definitely be integers. Depending on how you generate your documentation and auto-generated examples, you get something like this for the response for a POST:
Or for some of our stats use cases, you can specify the maximum members in a segment ("cap"), which is always going to be an integer, but we got
I realized it's because of this in genswagger.ts:
case "int":
schema.type = "number" // should be "integer"
break
Changes
The only important changes are in src/genswagger.ts. Specifically, I changed so that the following are type: integer instead of type: number:
Any uses of the reslang primitive int
MULTIGET request pagination offset
MULTIGET request limit
MULTIGET response header X-Total-Count
httpStatusCode property in the Error definition
The other changes are just updating swagger.expecteds for tests. I'm not sure what you want to do about models/direct2dist/distribution.yaml and concepts/distribution-swagger.yaml, or the actual open API spec that dist has in their repo, for that matter.
Context
Got some funny situations where auto-generated examples would generate these long decimals for things that should definitely be integers. Depending on how you generate your documentation and auto-generated examples, you get something like this for the response for a POST: Or for some of our stats use cases, you can specify the maximum members in a segment (
"cap"
), which is always going to be an integer, but we gotI realized it's because of this in
genswagger.ts
:Changes
The only important changes are in
src/genswagger.ts
. Specifically, I changed so that the following aretype: integer
instead oftype: number
:int
X-Total-Count
httpStatusCode
property in theError
definitionThe other changes are just updating
swagger.expected
s for tests. I'm not sure what you want to do aboutmodels/direct2dist/distribution.yaml
andconcepts/distribution-swagger.yaml
, or the actual open API spec that dist has in their repo, for that matter.