{"id":22325893,"url":"https://github.com/jamesbriggs/perl-petstore-enhanced","last_synced_at":"2026-04-04T16:32:01.536Z","repository":{"id":84299451,"uuid":"68494265","full_name":"jamesbriggs/perl-petstore-enhanced","owner":"jamesbriggs","description":"Perl Swagger2.pm and Mojolicious enhanced sample REST API Server Framework","archived":false,"fork":false,"pushed_at":"2018-09-14T01:15:35.000Z","size":161,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T06:11:25.112Z","etag":null,"topics":["golang","java","perl","perl5","python","rest","rest-api","ruby"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jamesbriggs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2016-09-18T03:42:56.000Z","updated_at":"2023-01-24T18:15:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"2e4dc338-c944-478c-bf00-449f038f74f7","html_url":"https://github.com/jamesbriggs/perl-petstore-enhanced","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jamesbriggs/perl-petstore-enhanced","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesbriggs%2Fperl-petstore-enhanced","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesbriggs%2Fperl-petstore-enhanced/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesbriggs%2Fperl-petstore-enhanced/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesbriggs%2Fperl-petstore-enhanced/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jamesbriggs","download_url":"https://codeload.github.com/jamesbriggs/perl-petstore-enhanced/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jamesbriggs%2Fperl-petstore-enhanced/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31405703,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T10:20:44.708Z","status":"ssl_error","status_checked_at":"2026-04-04T10:20:06.846Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["golang","java","perl","perl5","python","rest","rest-api","ruby"],"created_at":"2024-12-04T02:14:18.101Z","updated_at":"2026-04-04T16:32:01.513Z","avatar_url":"https://github.com/jamesbriggs.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Perl Petstore Enhanced REST API Framework\n=========================================\n\n**Summary**\n\nThis is a much enhanced, yet still minimal, version of the Swagger Petstore sample code using Perl Mojolicious/Swagger2.\n\nUsing this sample code and installation guide as a framework, an experienced programmer can write a feature-rich REST API server in about an hour.\n\n**Overview**\n\nAnybody can hand-roll a REST API server, but the tricky part is generating and maintaining 100% accurate validation and documentation for end-users.\n\nPerl Swagger2 lets you define your API spec in YAML or JSON, then automatically generates the following:\n\n- input and output parameter validation\n- controller (aka dispatcher or router) to map URLs to function calls\n- displays API documentation in HTML for end-users\n- automatic content negotiation for JSON, XML and text.\n- displays routes for debugging:\n\n```\n\n  +/               GET  \"infoPets\"\n\n  +/doc            GET  \"docPets\"\n\n  +/pets           GET  \"listPets\"\n\n  +/pets           PUT  \"createPets\"\n\n  +/pets        DELETE  \"deletePets\"\n\n  +/admin/ping     GET  \"pingPets\"\n\n  +/admin/menu     GET  \"menuPets\"\n\n  +/pets/(:petId)  GET  \"showPetById\"\n\n\n```\n\n**API Consumer Features**\n\n- GET /api/v1.0 shows HTML route summary (instead of only being available on error pages)\n- GET /api/v1.0/doc shows API spec in HTML format\n- paging with offset and limit in /pets\n- content negotiation with ?format=json and ?format=xml to automatically select output format for non-documentation routes\n- HTTP method override for client programs to use POST with X-HTTP-Method-Override: {PATCH, PUT, DELETE} where necessary\n- Param and Basic Authentication for both API and browser clients. Default is username=Perl, password=Bender.     \n- non-trivial sample code for several programming languages (bash, Go, Java, Perl, PHP, Python, Ruby) in samples/ with authentication, error handling and timeout.\n\n**Developer Features**\n\n- sets common options like mode=production, secrets and title\n- /admin route with separate admin username and password\n- has complete set of typical development directories, including public/, samples/, t/, and templates/\n- shows how to correctly version the API in the format v1.0\n- stores sample pet data in an array to avoid database dependencies\n- command line examples of various Mojo and Swagger2 test and validation features in make.sh\n- up-to-date Swagger2 api.spec properties in JSON and YAML formats\n- shows how to override automatic rendering by the Swagger2 controller using render()\n- good test coverage.\n\n**Operations Features**\n\n- built-in process health-check monitoring endpoint: /admin/ping =\u003e pong\n- my_throttle skeleton function\n- mod_perl compatible - just add your functions to Pet.pm\n- minimal dependencies - likely works with your existing version of Perl\n- adequate authentication for Intranet use already built-in.\n\n**Getting Started**\n\n```\n\ngit clone git@github.com:jamesbriggs/perl-petstore-enhanced.git\n\nsu\n\ncpan Mojolicious Mojolicious::Plugin::MethodOverride Swagger2 XML::Simple Test::Mojo JSON\n\nchown -R root:root perl-petstore-enhanced/pets\n\ncd perl-petstore-enhanced/pets\n\nvi api.spec # configure 'host', 'basePath' and 'contact' properties near top of file\n\nvi cgi-bin/pets.cgi set.sh # configure the install path, username, password, domain, schema  and base_url\n\nsource set.sh\n\nprove\n\n```\n\n- decide where you want to install the pets/ folder for your web server\n- configuration can be as simple as this:\n`Alias /api /home/\u003cmyuser\u003e/public_html/pets/cgi-bin/pets.cgi/api`\n- verify Authorization header is being passed along by httpd if you want auth:\nHTTP_AUTHORIZATION='Basic XXXXXXXXXXX'\nFor more info, see: http://stackoverflow.com/questions/26475885/authorization-header-missing-in-php-post-request\n- Point your browser at http://www.example.com/api/v1.0/\n\n**Getting Finished**\n\n- now you can finish writing your own API with customized module and endpoint names\n- change \"Pets\" to your module name, then \"Pet\" to your module name\n- run the `prove` test command\n- download Postman to easier do REST API development\n\n**Convert Spec**\n\n- Paste api.spec into http://editor.swagger.io/#/ to convert swagger spec from YAML to JSON (and back)\n\n**Privacy and Security**\n\nThe point of an API server is to, well, serve.\n\nBut you can take the following security precautions before deploying on a web server:\n\n- it's mandatory to use SSL in production or over the Internet because of payload injection or credentials sniffing\n- non-SSL connections should be rejected outright, not redirected\n- move the Controller module to some place outside DocumentRoot, like /perllib\n- put configuration settings and passwords some place outside DocumentRoot, like /perllib\n- remove the development templates, which display your environment settings.\n- the Petstore files and directories should be owned by root and not writable by anybody else\n- if you use a database, ensure your queries that allow user input use placeholders like ?.\n\nSome more general web server security tips:\n\n- httpd should run as a non-privileged user like `httpd, UID=510, GID=510`\n- if it is a restricted access server, use an iptables rule or TCP wrappers to only allow VPN access\n\n**Todo**\n\n- cleanup /doc and 404 page content\n- role auth?\n\n**Links**\n\nSome things to think about:\n\n- http://docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonRequestHeaders.html\n- https://github.com/adnan-kamili/rest-api-response-format\n- http://www.berenddeboer.net/rest/authentication.html\n\n![cass_top screenshot](perl-petstore-enhanced-info.png?raw=true \"Perl Petstore Enhanced Info screenshot\")\n![cass_top screenshot](perl-petstore-enhanced-prove.png?raw=true \"Perl Petstore Enhanced Prove screenshot\")\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamesbriggs%2Fperl-petstore-enhanced","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjamesbriggs%2Fperl-petstore-enhanced","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjamesbriggs%2Fperl-petstore-enhanced/lists"}