{"id":26348637,"url":"https://github.com/altered-tech/swift-petstore-oas","last_synced_at":"2026-02-28T14:31:09.783Z","repository":{"id":281874324,"uuid":"914675145","full_name":"Altered-Tech/swift-petstore-oas","owner":"Altered-Tech","description":"Swift example of Petstore OpenApi Spec with contract validation","archived":false,"fork":false,"pushed_at":"2025-03-28T16:24:57.000Z","size":102,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-22T11:05:37.690Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/Altered-Tech.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-10T04:31:14.000Z","updated_at":"2025-03-20T18:18:40.000Z","dependencies_parsed_at":"2025-03-28T17:34:27.682Z","dependency_job_id":"73fc7286-a8dd-4384-82f9-d7267d36c89c","html_url":"https://github.com/Altered-Tech/swift-petstore-oas","commit_stats":null,"previous_names":["altered-tech/swift-petstore-oas"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Altered-Tech/swift-petstore-oas","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altered-Tech%2Fswift-petstore-oas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altered-Tech%2Fswift-petstore-oas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altered-Tech%2Fswift-petstore-oas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altered-Tech%2Fswift-petstore-oas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Altered-Tech","download_url":"https://codeload.github.com/Altered-Tech/swift-petstore-oas/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altered-Tech%2Fswift-petstore-oas/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267298756,"owners_count":24065889,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-03-16T08:16:18.362Z","updated_at":"2026-02-28T14:31:09.735Z","avatar_url":"https://github.com/Altered-Tech.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Petstore OpenAPI/SAM\n\nThis application illustrates how to utilize swift-openapi-generator with swift-openapi lambda to create multiple functions definitions in the SAM Template. It is available to deploy a Server-Side Swift workload on AWS using the [AWS Serverless Application Model (SAM)](https://aws.amazon.com/serverless/sam/) toolkit. It deploys the API using Amazon API Gateway. \n\n## Swagger UI Page\n\nhttps://altered-tech.github.io/swift-petstore-oas/\n\n## Architecture\n\n- OpenAPI Spec to define our API\n- Amazon API Gateway receives API requests\n- API Gateway invokes Lambda functions to process POST, PUT, GET, and DELETE events\n- Lambda functions written in Swift use the [AWS SDK for Swift](https://aws.amazon.com/sdk-for-swift/) and the [Swift AWS Lambda Runtime](https://github.com/swift-server/swift-aws-lambda-runtime) to retrieve and save items.\n- Schemathesis to contract validate that our server behaves as we believe it should against our OpenAPI spec in spec-driven development.\n\n## Prerequisites\n\nTo build this sample application on AWS, you need:\n\n- [AWS Account](https://console.aws.amazon.com/)\n- [AWS Command Line Interface (AWS CLI)](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html) - install the CLI and [configure](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html) it with credentials to your AWS account\n- [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html) - a command-line tool used to create serverless workloads on AWS\n- [Docker Desktop](https://www.docker.com/products/docker-desktop/) - to compile your Swift code for Linux deployment to AWS Lambda\n- [Swift](https://www.swift.org/getting-started/) version 6.0\n\nTo build for local testing, you need:\n\n- [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html) - a command-line tool used to create serverless workloads on AWS\n- [Docker Desktop](https://www.docker.com/products/docker-desktop/) - to compile your Swift code for Linux deployment to AWS Lambda\n- [Swift](https://www.swift.org/getting-started/) version 6.0\n\n## Build the application\n\nThe **swift package archive** command compiles your Swift code for deployment to Lambda.\n\n```\nswift package archive --allow-network-connections docker\n```\n\nThe **sam build** command packages your Swift Lambda functions for deployment to AWS.\n\n```bash\nsam build\n```\n\n### Deploy the application to AWS\n\nDeploying your SAM project creates the Lambda functions, API Gateway, and DynamoDB database in your AWS account.\n\n```bash\nsam deploy --guided\n```\n\nAccept the default response to every prompt, except the following warnings:\n\n```bash\nGetPetById      has no authentication. Is this okay? [y/N]: y\nGetPetsByStatus has no authentication. Is this okay? [y/N]: y\nGetPetsByTags   has no authentication. Is this okay? [y/N]: y\nUpdatePet       has no authentication. Is this okay? [y/N]: y\nAddPet          has no authentication. Is this okay? [y/N]: y\n```\n\nThe project creates a publicly accessible API endpoint. These are warnings to inform you the API does not have authorization. If you are interested in adding authorization to the API, please refer to the [SAM Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-httpapi.html).\n\n### Use the API\n\nAt the end of the deployment, SAM displays the endpoint of your API Gateway:\n\n```bash\nOutputs\n----------------------------------------------------------------------------------------\nKey                 SwiftAPIEndpoint\nDescription         API Gateway endpoint URL for your application\nValue               https://[your-api-id].execute-api.[your-aws-region].amazonaws.com\n----------------------------------------------------------------------------------------\n```\n\nUse cURL or a tool such as [Postman](https://www.postman.com/) to interact with your API. Replace **[your-api-endpoint]** with the SwiftAPIEndpoint value from the deployment output.\n\n**Retrieve all Pets by Tags**\n\n_Replace {Tag} with the tag of the pets you want to retrieve_ \n\n```bash\ncurl -X GET https://[your-api-endpoint]/pet/findByTag\\?tag\\={Tag}\n```\n\n**Retrieve all Pets by Status**\n\n_Replace {Status} with the status of the pets you want to retrieve (sold, available, pending)_ \n\n```bash\ncurl -X GET https://[your-api-endpoint]/pet/findByStatus\\?status\\={Status}\n```\n\n**Retrieve a specific Pet**\n\n_Replace {Pet ID} with the id of the pet you want to retrieve_\n\n```bash\ncurl -X GET https://[your-api-endpoint]/pet/{Pet ID}\n```\n\n**Update a specific Pet**\n\n_Replace json of the pet with the id of the pet you want to update_\n\n```bash\ncurl -X PUT https://[your-api-endpoint]/pet '{\"id\": 1, \"name\": \"bubbles\",\"status\": \"sold\",\"photoUrls\": [\"example.com\"]}' --header \"Content-Type: application/json\"\n```\n\n**Add a Pet**\n\n_Replace json with pet object to be added_\n\n```bash\ncurl -x POST https://[your-api-endpoint]/pet '{\"name\": \"bubbles\",\"status\": \"sold\",\"photoUrls\": [\"example.com\"]}' --header \"Content-Type: application/json\"\n```\n### Cleanup\n\nWhen finished with your application, use SAM to delete it from your AWS account. Answer **Yes (y)** to all prompts. This will delete all of the application resources created in your AWS account.\n\n```bash\nsam delete\n```\n\n## Test the API Locally\n\nSAM also allows you to execute your Lambda functions locally on your development computer. Follow these instructions to execute each Lambda function. Further capabilities can be explored in the [SAM Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-using-invoke.html).\n\n**Automated testing**\n\n```\n./test_locally.sh\n```\n\n**Manual testing**\n```\nswift package archive --allow-network-connections docker \u0026\u0026 sam build \u0026\u0026 sam local start-api --template template.yml --warm-containers EAGER --disable-authorizer\n\nor with debugging/verbose enabled\n\nswift package archive --verbose --allow-network-connections docker \u0026\u0026 sam build \u0026\u0026 sam local start-api --template template.yml --debug --warm-containers EAGER --disable-authorizer\n```\n\n**Retrieve all Pets by Tags**\n\n_Replace {Tag} with the tag of the pets you want to retrieve_ \n\n```bash\ncurl -X GET http://127.0.0.1:3000/pet/findByTag\\?tag\\={Tag}\n```\n\n**Retrieve all Pets by Status**\n\n_Replace {Status} with the status of the pets you want to retrieve (sold, available, pending, none)_ \n\n```bash\ncurl -X GET http://127.0.0.1:3000/pet/findByStatus\\?status\\={Status}\n```\n\n**Retrieve a specific Pet**\n\n_Replace {Pet ID} with the id of the pet you want to retrieve_\n\n```bash\ncurl -X GET http://127.0.0.1:3000/pet/{Pet ID}\n```\n\n**Update a specific Pet**\n\n_Replace json of the pet with the id of the pet you want to update_\n\n```bash\ncurl -X PUT http://127.0.0.1:3000/pet '{\"id\": 1, \"name\": \"bubbles\",\"status\": \"sold\",\"photoUrls\": [\"example.com\"]}' --header \"Content-Type: application/json\"\n```\n\n**Add a Pet**\n\n_Replace json with pet object to be added_\n\n```bash\ncurl -x POST http://127.0.0.1:3000/pet '{\"name\": \"bubbles\",\"status\": \"sold\",\"photoUrls\": [\"example.com\"]}' --header \"Content-Type: application/json\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltered-tech%2Fswift-petstore-oas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faltered-tech%2Fswift-petstore-oas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltered-tech%2Fswift-petstore-oas/lists"}