When creating an API Gateway using an OAS3
definition, the path and query parameter types get changed to strings. I can't find any AWS documentation stating the expected behavior or why this is. I know when configuring the API Gateway manually it doesn't expose a type
for path/query variables, but is there a way to get API Gateway to keep the OAS3
path/query parameter type for documentation sake?
We're trying to use the Serverless Developer Portal to host our API documentation and we need to expose the correct parameter types; e.g. for a limit
query parameter we need it to display as an integer
.
Here's a SAM for a basic example. The path parameter param
is an integer
and the swagger generated documentation displays it correctly, however API Gateway changes it to a string
and the generated documentation shows it as a string
:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
ComplexityScoreProxy:
Type: AWS::Serverless::Api
Properties:
StageName: dev
DefinitionBody:
openapi: 3.0.1
info:
version: "1"
title: Aws API Gateway Boolean Test
paths:
/{param}:
get:
x-amazon-apigateway-integration:
type: http_proxy
uri: https://example.com
httpMethod: GET
responses:
"200":
statusCode: 200
parameters:
- name: param
in: path
required: true
schema:
type: integer
responses:
"200":
description: OK
Put the SAM in tempalte.yaml and run cloudformation to deploy:
aws cloudformation deploy --template-file template.yaml --stack-name boolean-test
Get the ID
aws apigateway get-rest-apis --query "items[?name=='Aws API Gateway Boolean Test'].id"
Retrieve the OAS replacing the --rest-api-id
with the correct id:
aws apigateway get-export --parameters extensions='apigateway' --rest-api-id XXXXXXXXXX --stage-name dev --export-type swagger latestoas.json
The exported OAS3 definition shows the parameter as a string:
"paths" : {
"/{param}" : {
"get" : {
"parameters" : [ {
"name" : "param",
"in" : "path",
"required" : true,
"schema" : {
"type" : "string"
}
} ],
Also, viewing the generated swagger documentation in the Serverless Developer Portal displays the param
as a string
.
type: integer
being imported as a string. Anyone come across resolution for this in the 2 years since this post? – Crackbrain