temando / serverless-openapi-documentation

Serverless 1.0 plugin to generate OpenAPI V3 documentation from serverless configuration
MIT License
93 stars 127 forks source link

Error: [ERROR clone] Invalid parameters after run `serverless openapi generate` #47

Open yeukfei02 opened 2 years ago

yeukfei02 commented 2 years ago

serverless.yml

org: yeukfei05
app: random-user-api-serverless
service: random-user-api-serverless

frameworkVersion: '2'
useDotenv: true

provider:
  name: aws
  runtime: nodejs14.x
  stage: prod
  region: ap-southeast-1
  apiName: random-user-api-serverless-prod
  tracing:
    apiGateway: true
    lambda: true
  environment:
    NODE_ENV: production
    MY_AWS_ACCESS_KEY: ${param:MY_AWS_ACCESS_KEY}
    MY_AWS_SECRET_ACCESS_KEY: ${param:MY_AWS_SECRET_ACCESS_KEY}
    JWT_SECRET: ${param:JWT_SECRET}
  iam:
    role:
      statements:
        - Effect: 'Allow'
          Action:
            - 'xray:PutTraceSegments'
            - 'xray:PutTelemetryRecords'
          Resource:
            - '*'
  apiGateway:
    shouldStartNameWithService: true
    description: random user api serverless prod
  lambdaHashingVersion: 20201221
  architecture: arm64
  timeout: 30

functions:
  main:
    handler: src/main/handler.getMain
    events:
      - http:
          path: /api
          method: get
          cors: true

  signup:
    handler: src/signup/handler.signup
    events:
      - http:
          path: /api/user/signup
          method: post
          cors: true

  login:
    handler: src/login/handler.login
    events:
      - http:
          path: /api/user/login
          method: post
          cors: true

  authorize:
    handler: src/authorize/handler.authorize

  createRandomUser:
    handler: src/createRandomUser/handler.createRandomUser
    events:
      - http:
          path: /api/random-user
          method: post
          cors: true
          authorizer:
            name: authorize

  getRandomUser:
    handler: src/getRandomUser/handler.getRandomUser
    events:
      - http:
          path: /api/random-user
          method: get
          cors: true
          authorizer:
            name: authorize

  getRandomUserById:
    handler: src/getRandomUserById/handler.getRandomUserById
    events:
      - http:
          path: /api/random-user/{id}
          method: get
          cors: true
          authorizer:
            name: authorize

  updateRandomUserById:
    handler: src/updateRandomUserById/handler.updateRandomUserById
    events:
      - http:
          path: /api/random-user/{id}
          method: put
          cors: true
          authorizer:
            name: authorize

  deleteRandomUserById:
    handler: src/deleteRandomUserById/handler.deleteRandomUserById
    events:
      - http:
          path: /api/random-user/{id}
          method: delete
          cors: true
          authorizer:
            name: authorize

plugins:
  - serverless-layers
  - serverless-plugin-typescript
  - serverless-offline
  - serverless-openapi-documentation

custom:
  serverless-layers:
    - common:
        packageManager: yarn
        dependenciesPath: ./package.json
        layersDeploymentBucket: random-user-api-serverless-serverless-layers

package.json

{
  "name": "random-user-api-serverless",
  "version": "0.2.8",
  "main": "app.js",
  "repository": "https://github.com/yeukfei02/random-user-api-serverless.git",
  "author": "Donald Wu <yeukfei02@gmail.com>",
  "license": "MIT",
  "dependencies": {
    "aws-sdk": "^2.772.0",
    "aws-xray-sdk": "^3.2.0",
    "axios": "0.19.2",
    "bcryptjs": "^2.4.3",
    "dotenv": "^8.2.0",
    "dynamoose": "^2.5.0",
    "jsonwebtoken": "^8.5.1",
    "lodash": "^4.17.20",
    "moment": "^2.29.1",
    "moment-timezone": "^0.5.31",
    "uuid": "^8.3.1"
  },
  "devDependencies": {
    "@types/aws-lambda": "^8.10.63",
    "@types/aws-sdk": "^2.7.0",
    "@types/bcryptjs": "^2.4.2",
    "@types/jest": "^26.0.14",
    "@types/jsonwebtoken": "^8.5.0",
    "@types/lambda-tester": "^3.6.0",
    "@types/lodash": "^4.14.161",
    "@types/moment-timezone": "^0.5.30",
    "@types/node": "^17.0.13",
    "@types/serverless": "^1.78.44",
    "@types/uuid": "^8.3.0",
    "@typescript-eslint/eslint-plugin": "^4.4.0",
    "@typescript-eslint/parser": "^4.4.0",
    "aws-lambda": "^1.0.6",
    "codecov": "^3.8.0",
    "eslint": "^7.10.0",
    "eslint-config-prettier": "^6.12.0",
    "eslint-plugin-prettier": "^3.1.4",
    "git-cz": "^4.7.1",
    "husky": "^4.3.0",
    "jest": "^26.5.2",
    "lambda-tester": "^4.0.1",
    "prettier": "^2.1.2",
    "serverless": "2.72.2",
    "serverless-layers": "^2.5.1",
    "serverless-offline": "^8.4.0",
    "serverless-openapi-documentation": "^0.4.0",
    "serverless-plugin-typescript": "^2.1.1",
    "standard-version": "^9.0.0",
    "ts-jest": "^26.4.1",
    "ts-node": "^9.0.0",
    "typescript": "^4.0.3"
  },
  "scripts": {
    "dev": "serverless offline start",
    "deploy": "serverless deploy",
    "package": "serverless package",
    "dashboard": "serverless dashboard",
    "remove": "serverless remove",
    "lint": "eslint '*/**/*.{ts,tsx}' --quiet --fix",
    "test": "jest --detectOpenHandles",
    "commit": "git-cz",
    "release": "standard-version"
  },
  "husky": {
    "hooks": {
      "pre-commit": "yarn lint",
      "pre-push": "yarn lint"
    }
  }
}

error:

serverless openapi generate
Running "serverless" from node_modules
Serverless: Using provider credentials, configured via dashboard: https://app.serverless.com/yeukfei05/apps/random-user-api-serverless/random-user-api-serverless/prod/ap-southeast-1/providers

 Serverless Warning --------------------------------------

  CLI options definitions were upgraded with "type" property (which could be one of "string", "boolean", "multiple"). Below listed plugins do not predefine type for introduced options:
   - ServerlessOpenApiDocumentation for "output", "format", "indent"

  Please report this issue in plugin issue tracker.

OpenAPI v3 Documentation Generator

 Error ---------------------------------------------------

  Error: [ERROR clone] Invalid parameters
      at Object.Clone.clone (/Users/donaldwu/Documents/GitHub/random-user-api-serverless/node_modules/lutils/clone/clone.js:18:23)
      at new DefinitionGenerator (/Users/donaldwu/Documents/GitHub/random-user-api-serverless/node_modules/serverless-openapi-documentation/DefinitionGenerator.js:21:31)
      at ServerlessOpenApiDocumentation.generate (/Users/donaldwu/Documents/GitHub/random-user-api-serverless/node_modules/serverless-openapi-documentation/ServerlessOpenApiDocumentation.js:83:27)
      at PluginManager.runHooks (/Users/donaldwu/Documents/GitHub/random-user-api-serverless/node_modules/serverless/lib/classes/PluginManager.js:601:41)
      at PluginManager.invoke (/Users/donaldwu/Documents/GitHub/random-user-api-serverless/node_modules/serverless/lib/classes/PluginManager.js:639:20)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)
      at async PluginManager.run (/Users/donaldwu/Documents/GitHub/random-user-api-serverless/node_modules/serverless/lib/classes/PluginManager.js:700:7)
      at async Serverless.run (/Users/donaldwu/Documents/GitHub/random-user-api-serverless/node_modules/serverless/lib/Serverless.js:468:5)
      at async /Users/donaldwu/Documents/GitHub/random-user-api-serverless/node_modules/serverless/scripts/serverless.js:836:9

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              14.18.0
     Framework Version:         2.72.2 (local)
     Plugin Version:            5.5.4
     SDK Version:               4.3.0
     Components Version:        3.18.2

sls version: 2.72.2 node version: 14.18.0

I try to play with this plugin with my sls project, but got this error. looking for suggestions and bug fixes, thank you.

Rafat97 commented 2 years ago

Use top of this plugin.

plugins:
  - serverless-layers
  - serverless-plugin-typescript
  - serverless-offline
  - serverless-openapi-documentation

to

plugins:
  - serverless-openapi-documentation
  - serverless-layers
  - serverless-plugin-typescript
  - serverless-offline

Also add custom.documentation

custom:
  documentation:
    version: '1'
    title: 'My API'
    description: 'This is my API'
    models: {}
yeukfei02 commented 2 years ago

@Rafat97

use at the top of the plugin also has an error, and this repo the doc said should be after serverless-offline.

btw I did not use this lib already also this repo is not maintained

Rafat97 commented 2 years ago

@yeukfei02 Yaa, you are right . this repo is not maintained any more. are you use use any alternative for documentation generation ?

yeukfei02 commented 2 years ago

@Rafat97

I use postman collection to publish documenation

Rafat97 commented 2 years ago

@Rafat97

I use postman collection to publish documenation

Ok. nice