openapix icon indicating copy to clipboard operation
openapix copied to clipboard

Allow for support of multiple sources

Open rayk47 opened this issue 2 years ago • 1 comments

Given I have multiple APIs and API paths I would like to load multiple yaml files and have openapix merge them. For example

const api = new openapix.Api(this, 'Hello-API', {
      restApiProps:{ 
        restApiName: 'Hello API',
        description: 'An API for saying hello',
        defaultCorsPreflightOptions:{
          allowOrigins:Cors.ALL_ORIGINS,
          allowHeaders:Cors.DEFAULT_HEADERS,
          allowMethods:Cors.ALL_METHODS
        }
      },
      source: "This only supports one very large yaml of APIs",
      paths: {
        '/hello': {
          get: new openapix.LambdaIntegration(this, getHelloAllHandler),
          post: new openapix.LambdaIntegration(this, postHelloHandler),
        },
        '/goodbye': {
          get: new openapix.LambdaIntegration(this, getGoodbyeAllHandler),
          post: new openapix.LambdaIntegration(this, postGoodbyeHandler),
        },
      },
      validators: {
        'all': {
          validateRequestBody: true,
          validateRequestParameters: true,
          default: true, // set this as the "API level" default validator (there can be only one)
        },
        'params-only' : {
          validateRequestBody: false,
          validateRequestParameters: true,
        },
      },
    })

In the case above I would like to define a source for each of the APIs so that I can maintain individual API yamls instead of one huge yaml that all of my developers have to maintain. This would support the use of lambdas and cutting up the application APIs to allow multiple developers to work in parallel without conflicts. One way this could be done is by adding "source" at the path level.

rayk47 avatar Jan 20 '23 19:01 rayk47

Hi,

I think that this feature is not in the scope of the project , but I would recommend to read this article which describes the process and tooling needed to get it done : https://davidgarcia.dev/posts/how-to-split-open-api-spec-into-multiple-files/

I believe that it is just what you are looking for 😃

mpiltz avatar Jan 26 '23 06:01 mpiltz