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

Feature request: support API mappings

Open fbambusi opened this issue 3 years ago • 1 comments

Describe the bug It may be the case that, in a microservices-based architecture, the Serverless Framework is used to create and maintain different services, each one responsible for a REST resource.

Should these services be deployed on AWS, it is possible that a different mapping is used to forward the requests to different services based on their prefix.

For example, there can be service S1, responsible for resource R1, and service S2, responsible for resource R2. In this situation, the requests like example.com/R1/* will be forwarded to S1, while requests like example.com/R2 will be forwarded to S2.

In case S1 is implemented via the serverless framework, the HTTP paths of its Lambdas will not contain the prefix R1, nor will the HTTP paths of S2 services contain the prefix R2: in both cases, the prefixes will be added via an API gateway mapping.

However, it would be useful that the documentation generated for S1 and S2 contained prefixes R1, R2, because in this way it would be easier to produce a unified documentation by merging the two openapi.yml | json files.

Expected behavior The Documenter plugin could contains an option to prepend a prefix to all paths.

	
custom:
  documentation:
    version: '1'
    title: 'My API'


    prefix: R1


    description: 'This is my API'
    models: {}
    externalDocumentation:
      url: https://google.com
      description: A link to google
    servers:
      url: https://example.com
      description: The server
    tags:
      - name: tag1
        description: this is a tag
        externalDocumentation:
          url: https://npmjs.com
          description: A link to npm


fbambusi avatar Oct 25 '22 14:10 fbambusi

Hey @fbambusi I note that the Open API documentation allows for servers to be specified at the top level, the path level and the operation level. Is that basically what you would want?

custom:
  documentation:
    version: '1'
    title: 'My API'
    description: 'This is my API'
    models: {}
    externalDocumentation:
      url: https://google.com
      description: A link to google
    servers:
      url: https://example.com/R1
      description: The server
    tags:
      - name: tag1
        description: this is a tag
        externalDocumentation:
          url: https://npmjs.com
          description: A link to npm
  functions:
    delete:
      events:
        - http:
          path: /delete

    create:
      events:
        - http:
          path: /
          servers:
            url: https://example.com/S2
            description: The other server
         

so in this instance, it would map /delete to https://example.com/R1 and create to https://example.com/S2

JaredCE avatar Nov 04 '22 15:11 JaredCE

I have not heard back about this and will close this issue for now. If this is still a problem, please feel free to re-open or open a new issue.

JaredCE avatar Jun 18 '24 09:06 JaredCE