alma-cdk / openapix

Combine the power of AWS CDK & OpenAPI YAML Schema Definitions
https://constructs.dev/packages/@alma-cdk/openapix/
94 stars 6 forks source link

Allow for support of multiple sources #46

Open rayk47 opened 1 year ago

rayk47 commented 1 year ago

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.

mpiltz commented 1 year ago

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 😃