serverless-aws-documentation
serverless-aws-documentation copied to clipboard
Can't set type of query paramaters
Hi, I am trying to set type of parameters that i am defining in query parameters as Integer. But the plugin doesn't set the provided type in documentation rather default type as 'String' is being set in the API Gateway. I am trying to input documentation as follows:
documentation:
summary: "Get Order"
description: "Get Specific order"
requestHeaders:
-
name: "Authorization"
description: "Auth Header description"
pathParams:
-
name: "id"
required: true
description: "ID of the order you want to get details of the orders"
methodResponses:
-
statusCode: "200"
responseBody:
description: "Response body description"
responseHeaders:
-
name: "x-superheader"
description: "this is a super header"
responseModels:
"application/json": "CreateResponse"
-
statusCode: "400"
responseModels:
"application/json": "ErrorResponse"
Seems to be the same issue as #36. This was closed with #48.
If this is a different issue, please say so, and I will open this ticket again :)
This is a different issue than #36 . My issue is that i am not able to define the type of input that a query parameter accepts. Sorry i provided the code without query parameters. Code i am using is the one below:
documentation:
summary: "Get all attributes"
description: "Gets all the attributes present in the system"
requestHeaders:
-
name: "Authorization"
description: "Custom Authorizer Header Token"
queryParams:
-
name: "offset"
description: "No of records to skip"
type: "Integer"
-
name: "sort"
description: "sort by column name"
type: "Integer"
methodResponses:
-
statusCode: "200"
responseBody:
description: "Response body description"
responseHeaders:
-
name: "x-superheader"
description: "this is a super header"
responseModels:
"application/json": "CreateResponse"
-
statusCode: "400"
responseModels:
"application/json": "ErrorResponse"
As you can see i provided the type of offset and sort queryParams as integer. But in documentation it is still set as string only.
Ok, reopened the issue
Seems type validation isn't working for queryParams yet. Is this possible to be implemented? would be great.
Here's how my serverless.yml config looks like:
service: foo
package:
individually: true
plugins:
- serverless-reqvalidator-plugin
- serverless-aws-documentation
provider:
name: aws
stage: prod
runtime: nodejs6.10
region: us-east-1
environment: ${file(env.yml):${self:provider.stage}}
custom:
documentation:
api:
info:
title: Foo
models:
- name: CreateUserRequest
contentType: 'application/json'
schema:
required:
- email
- password
properties:
email:
type: string
password:
type: string
functions:
createUser:
handler: src/functions/user.create
events:
- http:
documentation:
queryParams:
- name: 'key'
description: 'private key'
type: string
required: true
requestModels:
'application/json': CreateUserRequest
path: users/create
method: post
cors: true
reqValidatorName: exampleValidator
resources:
Resources:
onlyBody:
Type: 'AWS::ApiGateway::RequestValidator'
Properties:
Name: 'example-validator'
RestApiId:
Ref: ApiGatewayRestApi
ValidateRequestBody: true
ValidateRequestParameters: true
It should throw out a validation error when key URL parameter isn't a string but seems it ignores it.