Open martin-sommerseth opened 3 years ago
Hi @martin-sommerseth , it is true that defining the path in two different is not convenient, however, the behaviour is expected.
The path
property in EventSource defines the endpoint where this function is invoked (Document). It is a required property.
The DefinitionBody
defines the paths of all Apis (Document), path
is necessary in OpenApi definition.
If DefinitionBody
is not defined in SAM template, an auto-generated DefinitionBody
will take the place, but the generated one will not include the detailed OpenApi definitions your provided in this example.
Please let us know if you have more suggestions on it. Thanks!
@wchengru isn't "the endpoint where this function is invoked" already defined in the openapi spec though, using the "x-amazon-apigateway-integration"? What further information does the eventSource path add here?
We could perhaps allow omitting properties in the event that can be determined from the OpenAPI definition; marking as feature request.
Our team is using SAM-functions for our APIs. To define the API we use open-API-specification, and AWS does not support the option to directly connect a SAM function to the open API specification. AWS requires us to define an EventSource to specify the endpoint. This means that we have to write our endpoint specification in two places, both in open-API-spec and in EventSource for the SAM function. We will then risk that our API documentation is different from our deployed API (endpoint paths could then be different).
We would highly appreciate it if this is something you could support.
Here is an example of the template we use today. You can see that we define the paths inside the DefinitionBody for the resource ServerlessApi as well as for the SAM-functions such as Result or Status.