service: myservice

frameworkVersion: '3'

provider:
  name: aws
  stage: dev
  runtime: nodejs12.x
  region: eu-central-1

plugins:
  - serverless-plugin-test-helper
  - serverless-openapi-integration-helper
  - serverless-random-gateway-deployment-id

openApiIntegration:
  inputFile: api.yml
  package: true
  cors: true
  autoMock: true
  mapping:
    - stage: dev
      path: integrations
    - stage: test
      path: mocks

functions:

resources:
  Outputs:
    GatewayUrl: # This is the key that will be used in the generated outputs file
      Description: This is a helper for functional tests
      Value: !Join
        - ''
        - - 'https://'
          - !Ref ApiGatewayRestApi
          - '.execute-api.'
          - ${opt:region, self:provider.region}
          - '.amazonaws.com/'
          - ${opt:stage, self:provider.stage}

  Resources:
      ApiGatewayRestApi:
        Type: AWS::ApiGateway::RestApi
        Properties:
          ApiKeySourceType: HEADER
          Body: ~ #autogenerated by plugin
          Description: User Registration (${opt:stage, self:provider.stage})
          FailOnWarnings: false
          Name: ${opt:stage, self:provider.stage}-gateway
          EndpointConfiguration:
            Types:
              - REGIONAL
      ApiGatewayDeployment:
        Type: AWS::ApiGateway::Deployment
        Properties:
          Description: ${opt:stage, self:provider.stage}
          RestApiId: !Ref ApiGatewayRestApi
      ApiGatewayStage:
        Type: AWS::ApiGateway::Stage
        Properties:
          StageName: ${opt:stage, self:provider.stage}
          Description: ${opt:stage, self:provider.stage} Stage
          RestApiId: !Ref ApiGatewayRestApi
          DeploymentId: !Ref ApiGatewayDeployment
          Variables:
            BaseUrl: http://www.example.com

