temando / serverless-openapi-documentation

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

Ability to alter OperationID #22

Open MarkySparky opened 6 years ago

MarkySparky commented 6 years ago

I have multiple methods per function for some of my lambdas. i.e. I have a GET, PATCH and DELETE in one lambda (due to Amazon limitation of about 35 endpoints per service (each endpoint generated several cloud formation items, and it's bursting to 200 limit AWS set))

usersId:
  handler: serverless/lambdas/usersId.main
  name: users-${self:provider.stage}-${self:service}-usersId
  events:
    - http:
        id: getUsersId
        method: get
        path: 'users/{userId}'
        documentation: ${file(./serverless/serverless.docs.yml):endpoints.getUsersId}
    - http:
        id: patchUsersId
        method: patch
        path: 'users/{userId}'
        documentation: ${file(./serverless/serverless.docs.yml):endpoints.patchUsersId}
    - http:
        method: delete
        path: 'users/{userId}'
        documentation: ${file(./serverless/serverless.docs.yml):endpoints.deleteUsersId}

Currently, operationId is generated from the lambda name, in this case usersId - this applies to all my endpoints in the one lambda file.

I'd like to specify it in the docs section for each method so that I dont get an error stating I cant have duplicate operationIds. i.e.

patchUsersId:
    operationId: patchUsersId
    tags:
      - users
    pathParams:
      - name: userId
        description: The userid for the current user
        schema:
          type: "string"
          pattern: "^[-a-z0-9_]+$"
    summary: "Patch a user by their users_id"
    description: "Patch a user by their users_id, handles not found"
    requestModels:
        application/json: patchUpdateUserRequest
    methodResponses:
      - statusCode: 200
        responseBody:
          description: Response
        responseModels:
          application/json: EmptyResponse
willtan930 commented 5 years ago

I'd like to utilize a single lambda for multiple API operations, thereby having a single pool that can service all operations rather than multiple lambda pools (for improved utilization of lambdas in AWS and maintaining a number to be kept warm). This issue prevents the generation of OpenAPI docs in the Jenkins pipeline.