Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swagger support for RestApi #5391

Closed
2 tasks
vertti opened this issue Dec 12, 2019 · 3 comments
Closed
2 tasks

swagger support for RestApi #5391

vertti opened this issue Dec 12, 2019 · 3 comments
Assignees
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway effort/large Large work item – several weeks of effort feature-request A feature should be added or improved.

Comments

@vertti
Copy link

vertti commented Dec 12, 2019

I'd like to attach our API's Swagger documentation (swagger.json) to the Api Gateway rest api. Apparently you can do it simply by including a Body field to the rest api Properties but it seems this is not supported by CDK?

Use Case

We took the base swagger json generated by API Gateway and improved it by adding documentation to it. Now I'd like to include it to the Cloudformation so it's available for browsing in the API Gateway Documenatiion page in the AWS Console.

Proposed Solution

Here is blog post showing how you can add the swagger doc directly under the Body like:

AWSTemplateFormatVersion: '2010-09-09'
Resources:
  PlayersAPI:
    Type: AWS::ApiGateway::RestApi
    Properties:
      Name: Player API
      Description: A demo API for Player management
      Body: # Swagger Specification body goes here
  • 👋 I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change

This is a 🚀 Feature Request

@vertti vertti added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Dec 12, 2019
@SomayaB SomayaB added @aws-cdk/aws-apigateway Related to Amazon API Gateway docs/generated Related to the generated API Reference documentation labels Dec 13, 2019
@vertti
Copy link
Author

vertti commented Dec 16, 2019

Currently you can attach the custom json with the following:

import openapiJson = require('./resources/openapi.json')

..
const cfnRestApi = api.node.defaultChild as CfnRestApi
cfnRestApi.body = openapiJson

where api is an instance of LambdaRestApi.

@nija-at
Copy link
Contributor

nija-at commented Feb 5, 2020

If I understand correctly, uploading the swagger.json or swagger.yaml file into the Body or the BodyS3Location property would also modify the Rest API methods and resources, and not only documentation.

@nija-at nija-at changed the title Attach Swagger.json to LambdaRestApi swagger support for RestApi Feb 5, 2020
@nija-at nija-at added effort/large Large work item – several weeks of effort and removed docs/generated Related to the generated API Reference documentation needs-triage This issue or PR still needs to be triaged. labels Feb 5, 2020
@nija-at
Copy link
Contributor

nija-at commented Feb 13, 2020

This is a duplicate of #1461.

Apologies for the churn, but it would be useful to move your 👍 reactions and any additional comments to the other issue.

@nija-at nija-at closed this as completed Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-apigateway Related to Amazon API Gateway effort/large Large work item – several weeks of effort feature-request A feature should be added or improved.
Projects
None yet
Development

No branches or pull requests

3 participants