{"id":15716025,"url":"https://github.com/thebenforce/serverless-swagger-api","last_synced_at":"2025-05-07T14:47:03.826Z","repository":{"id":38175469,"uuid":"186489185","full_name":"theBenForce/serverless-swagger-api","owner":"theBenForce","description":"Simplifies the process of generating an API Gateway API from a swagger file.","archived":false,"fork":false,"pushed_at":"2022-12-11T01:12:45.000Z","size":1472,"stargazers_count":15,"open_issues_count":25,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-04T01:06:45.264Z","etag":null,"topics":["aws","aws-api-gateway","aws-apigateway","serverless","serverless-framework","swagger"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theBenForce.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-13T20:16:42.000Z","updated_at":"2021-11-10T21:08:47.000Z","dependencies_parsed_at":"2023-01-26T13:31:33.659Z","dependency_job_id":null,"html_url":"https://github.com/theBenForce/serverless-swagger-api","commit_stats":null,"previous_names":["drg-adaptive/serverless-swagger-api"],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theBenForce%2Fserverless-swagger-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theBenForce%2Fserverless-swagger-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theBenForce%2Fserverless-swagger-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theBenForce%2Fserverless-swagger-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theBenForce","download_url":"https://codeload.github.com/theBenForce/serverless-swagger-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252898725,"owners_count":21821675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-api-gateway","aws-apigateway","serverless","serverless-framework","swagger"],"created_at":"2024-10-03T21:43:50.444Z","updated_at":"2025-05-07T14:47:03.807Z","avatar_url":"https://github.com/theBenForce.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Serverless Swagger API\n\n[![Build Status](https://travis-ci.org/theBenForce/serverless-swagger-api.svg)](https://travis-ci.org/drg-adaptive/serverless-swagger-api)\n[![Maintainability](https://api.codeclimate.com/v1/badges/006339522a8624e9bacb/maintainability)](https://codeclimate.com/github/drg-adaptive/serverless-swagger-api/maintainability)\n[![npm version](https://badge.fury.io/js/serverless-swagger-api.svg)](https://badge.fury.io/js/serverless-swagger-api)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fdrg-adaptive%2Fserverless-swagger-api.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fdrg-adaptive%2Fserverless-swagger-api?ref=badge_shield)\n\nThis is a serverless plugin that simplifies the process of creating an AWS API Gateway from a swagger file.\n\n## Installation\n\n```bash\nyarn add --dev serverless-swagger-api\n```\n\n## Configuration\n\n### Lambda Functions\n\nYou must manually create your own lambda functions in the serverless configuration. Once the methods are created, they will be referenced in the swagger file.\n\n### Swagger File\n\nAdd a `x-lambda-name` property to every path method to bind a part of the api to a lambda. Values specified for `x-lambda-name` is AWS CloudFormation resource names, i.e., [values in the form of `{normalizedFunctionName}LambdaFunction`](https://www.serverless.com/framework/docs/providers/aws/guide/resources#aws-cloudformation-resource-reference). For more information about naming rules, please refer to the [description](https://www.serverless.com/framework/docs/providers/aws/guide/resources#override-aws-cloudformation-resource) in the Serverless Framework documentation.\n\n```yaml\npaths:\n  /testPath:\n    get:\n      x-lambda-name: TestPathLambdaFunction\n      ...\n```\n\n#### CORS Configuration\n\nAdd a `x-cors` property to the path you want to add CORS options responses to.\n\n```yaml\npaths:\n  /testPath:\n    x-cors: true\n```\n\nIf you want to specify a specific attribute, provide one of the following properties\n\n| Property | Description                         | Default                                                       |\n| -------- | ----------------------------------- | ------------------------------------------------------------- |\n| origin   | A string specifying allowed origins | \\*                                                            |\n| headers  | An array of headers to be allowed   | Constructed from the parameters property of every path method |\n| methods  | An array of methods to be allowed   | Constructed by looking at all methods defined for a path      |\n\n### Plugin Settings\n\nNow you need to tell the swagger api plugin about your configuration file. Add a `swaggerApi` property to the custom section of your serverless configuration. You can add as many apis as you want by adding children to the `swaggerApi.apis` property.\n\n#### updateDeployments\n\nWill automatically update API gateway deployments if not set to `false`.\n\n#### usePackageVersion\n\nThe `info.version` value in your OpenAPI file will be overwritten with the version in `package.json`.\n\n#### apis\n\nAn object containing all of the APIs to be defined in this stack.\n\n```yaml\ncustom:\n  swaggerApi:\n    updateDeployments: true\n    usePackageVersion: true\n    apis:\n      PrimaryApi:\n        Name: ${self:provider.stage}-${self:service}-PrimaryApi\n        Body: ${file(./some-swagger-file.yaml)}\n        Lambda: ExampleLambdaFunction\n        Stage: dev\n```\n\n##### Properties\n\nEach API object has the following properties\n\n| Name   | Required | Description                                                                                                                                                          |\n| ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| Name   | Yes      | Name of the API that will be used as the `Name` parameter when creating the `AWS::ApiGateway::RestApi` CloudFormation object                                         |\n| Body   | Yes      | The swagger/openapi file that defines the API                                                                                                                        |\n| Stage  | Yes      | The name of the API Gateway stage that will be created                                                                                                               |\n| Lambda | No       | Default lambda name that will be used if `x-lambda-name` isn't provided on a path (see the description of `x-lambda-name` for the value to be specified as the name) |\n\n## Created Resources\n\n### IAM Roles\nAn IAM role is created for each API with the name `PrimaryApiServiceRole`\n\n## License\n\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fdrg-adaptive%2Fserverless-swagger-api.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fdrg-adaptive%2Fserverless-swagger-api?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthebenforce%2Fserverless-swagger-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthebenforce%2Fserverless-swagger-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthebenforce%2Fserverless-swagger-api/lists"}