serverless-openapi-documenter icon indicating copy to clipboard operation
serverless-openapi-documenter copied to clipboard

[BUG] - RestApiId set to empty object when deploying service with existing APIGateway

Open Fabs97 opened this issue 8 months ago • 0 comments

Describe the bug When deploying a service with an already existing APIGateway - hence passing the already existing ApiGW ID to the provider - and setting a request validator via a JSON schema, the resulting output seems to have a Resource of AWS::ApiGateway::Model with the RestAPIId set to an empty object (which is a no-go for cloudformation as it is required and of type string). I am not quite sure if this is a documentation or a bug issue nor I could find any place where this was being set by the library so it might not be the right place but the issue is appearing only when adding the request validator.

To Reproduce Steps to reproduce the behavior:

serverless.yml
  
provider:
  [...]
  apiGateway:
    restApiId: ${ssm:/your_parameter_apigw_id}
    restApiRootResourceId: ${ssm:your_parameter_apigw_root_id}
    request:
      schemas:
        post-test:
          name: post-test
          description: Request schema test.
          contentType: application/json
          schema: ${file(schema/request.json)}
[...]
functions:
  post_test:
    handler: handler.handler
    events:
      - http:
          path: /test
          method: post
          documentation: ${file(serverless.doc.yaml):documentation.endpoints.post_test}
          [...]
          request:
            schemas:
              application/json: post-test
schema/request.json

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "properties": {
    "name": {
      "title": "Name",
      "type": "string"
    }
  },
  "required": [
    "name"
  ],
  "title": "test",
  "type": "object"
}

.serverless/cloudformation-template-update-stack.json

[...]
"ApiGatewayTestRequestModel": {
      "Type": "AWS::ApiGateway::Model",
      "Properties": {
        "RestApiId": {},
        "Schema": {
          "$schema": "http://json-schema.org/draft-04/schema#",
          "properties": {
            "name": {
              "title": "Name",
              "type": "string"
            }
          },
          "required": [
            "name"
          ],
          "title": "test",
          "type": "object"
        },
        "ContentType": "application/json",
        "Name": "post-test",
        "Description": "Request schema test."
      }
    },
[...]

Expected behavior I would expect to have the RestApiId filled as a string with the ssm parameter I added in the serverless.yml specification, instead the CF template is created as an empty object, which goes against the CF specification.

Desktop (please complete the following information):

  • Serverless version: 4.17.2
  • serverless-openapi-documenter version 0.0.114

Additional context No additional context

Fabs97 avatar Aug 06 '25 17:08 Fabs97