petstore_api_client 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.editorconfig +33 -0
- data/.env.example +50 -0
- data/.github/CODEOWNERS +36 -0
- data/.github/workflows/ci.yml +157 -0
- data/.ruby-version +1 -0
- data/CONTRIBUTORS.md +39 -0
- data/LICENSE +21 -0
- data/README.md +684 -0
- data/Rakefile +12 -0
- data/lib/petstore_api_client/api_client.rb +60 -0
- data/lib/petstore_api_client/authentication/api_key.rb +107 -0
- data/lib/petstore_api_client/authentication/base.rb +113 -0
- data/lib/petstore_api_client/authentication/composite.rb +178 -0
- data/lib/petstore_api_client/authentication/none.rb +42 -0
- data/lib/petstore_api_client/authentication/oauth2.rb +305 -0
- data/lib/petstore_api_client/client.rb +87 -0
- data/lib/petstore_api_client/clients/concerns/pagination.rb +124 -0
- data/lib/petstore_api_client/clients/concerns/resource_operations.rb +121 -0
- data/lib/petstore_api_client/clients/pet_client.rb +119 -0
- data/lib/petstore_api_client/clients/store_client.rb +37 -0
- data/lib/petstore_api_client/configuration.rb +318 -0
- data/lib/petstore_api_client/connection.rb +55 -0
- data/lib/petstore_api_client/errors.rb +70 -0
- data/lib/petstore_api_client/middleware/authentication.rb +44 -0
- data/lib/petstore_api_client/models/api_response.rb +31 -0
- data/lib/petstore_api_client/models/base.rb +60 -0
- data/lib/petstore_api_client/models/category.rb +17 -0
- data/lib/petstore_api_client/models/named_entity.rb +36 -0
- data/lib/petstore_api_client/models/order.rb +55 -0
- data/lib/petstore_api_client/models/pet.rb +225 -0
- data/lib/petstore_api_client/models/tag.rb +20 -0
- data/lib/petstore_api_client/paginated_collection.rb +133 -0
- data/lib/petstore_api_client/request.rb +225 -0
- data/lib/petstore_api_client/response.rb +193 -0
- data/lib/petstore_api_client/validators/array_presence_validator.rb +15 -0
- data/lib/petstore_api_client/validators/enum_validator.rb +17 -0
- data/lib/petstore_api_client/version.rb +5 -0
- data/lib/petstore_api_client.rb +55 -0
- metadata +252 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 2807ed8c8d8182bc30d54bc1b5ac995f328c72b32fee7749db6cb1b68ef613ea
|
|
4
|
+
data.tar.gz: 4e34e6e5e0180e4f3161910931849e7c77f48467ab079cda832c5d2944a85f2d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 18af185433ce4e77b55660dd01ac43436339b95f8366c75f6c32676a95a8319991b8481c623fdb1c84b8ddec8e1e009558a53b1bdc5dcd23b52df29d1d138eb7
|
|
7
|
+
data.tar.gz: '0847eb04e3dbc161026ca7e3bfbb2634ead1b9a967560c45900a462fed09fd4b3575be17326614aef5b29d86d17bd8b9152ef269f844dd186fd1a4f5ff8346c3'
|
data/.editorconfig
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# EditorConfig helps maintain consistent coding styles
|
|
2
|
+
# See https://editorconfig.org
|
|
3
|
+
|
|
4
|
+
root = true
|
|
5
|
+
|
|
6
|
+
[*]
|
|
7
|
+
charset = utf-8
|
|
8
|
+
end_of_line = lf
|
|
9
|
+
insert_final_newline = true
|
|
10
|
+
trim_trailing_whitespace = true
|
|
11
|
+
|
|
12
|
+
[*.rb]
|
|
13
|
+
indent_style = space
|
|
14
|
+
indent_size = 2
|
|
15
|
+
|
|
16
|
+
[*.{yml,yaml}]
|
|
17
|
+
indent_style = space
|
|
18
|
+
indent_size = 2
|
|
19
|
+
|
|
20
|
+
[*.md]
|
|
21
|
+
trim_trailing_whitespace = false
|
|
22
|
+
|
|
23
|
+
[Gemfile]
|
|
24
|
+
indent_style = space
|
|
25
|
+
indent_size = 2
|
|
26
|
+
|
|
27
|
+
[Rakefile]
|
|
28
|
+
indent_style = space
|
|
29
|
+
indent_size = 2
|
|
30
|
+
|
|
31
|
+
[*.gemspec]
|
|
32
|
+
indent_style = space
|
|
33
|
+
indent_size = 2
|
data/.env.example
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Petstore API Client - Environment Variables Example
|
|
2
|
+
# Copy this file to .env and fill in your actual credentials
|
|
3
|
+
# IMPORTANT: Never commit .env file to git!
|
|
4
|
+
|
|
5
|
+
# ============================================
|
|
6
|
+
# API Configuration
|
|
7
|
+
# ============================================
|
|
8
|
+
PETSTORE_BASE_URL=https://petstore.swagger.io/v2
|
|
9
|
+
|
|
10
|
+
# ============================================
|
|
11
|
+
# Authentication - Choose ONE strategy
|
|
12
|
+
# ============================================
|
|
13
|
+
|
|
14
|
+
# Strategy 1: API Key Authentication (default)
|
|
15
|
+
# Uncomment to use API key auth:
|
|
16
|
+
# PETSTORE_API_KEY=special-key
|
|
17
|
+
|
|
18
|
+
# Strategy 2: OAuth2 Authentication
|
|
19
|
+
# Uncomment to use OAuth2 auth:
|
|
20
|
+
# PETSTORE_OAUTH2_CLIENT_ID=your-client-id
|
|
21
|
+
# PETSTORE_OAUTH2_CLIENT_SECRET=your-client-secret
|
|
22
|
+
# PETSTORE_OAUTH2_TOKEN_URL=https://petstore.swagger.io/oauth/token
|
|
23
|
+
# PETSTORE_OAUTH2_SCOPE=read:pets write:pets
|
|
24
|
+
|
|
25
|
+
# Strategy 3: Both API Key + OAuth2
|
|
26
|
+
# Uncomment both sections above to send both headers
|
|
27
|
+
|
|
28
|
+
# Strategy 4: No Authentication
|
|
29
|
+
# Leave all auth variables commented out
|
|
30
|
+
|
|
31
|
+
# ============================================
|
|
32
|
+
# Client Configuration
|
|
33
|
+
# ============================================
|
|
34
|
+
PETSTORE_TIMEOUT=30
|
|
35
|
+
PETSTORE_OPEN_TIMEOUT=10
|
|
36
|
+
PETSTORE_RETRY_ENABLED=true
|
|
37
|
+
PETSTORE_MAX_RETRIES=2
|
|
38
|
+
|
|
39
|
+
# ============================================
|
|
40
|
+
# Pagination
|
|
41
|
+
# ============================================
|
|
42
|
+
PETSTORE_DEFAULT_PAGE_SIZE=25
|
|
43
|
+
PETSTORE_MAX_PAGE_SIZE=100
|
|
44
|
+
|
|
45
|
+
# ============================================
|
|
46
|
+
# Development/Testing
|
|
47
|
+
# ============================================
|
|
48
|
+
# RAILS_ENV=development
|
|
49
|
+
# RACK_ENV=development
|
|
50
|
+
DEBUG=false
|
data/.github/CODEOWNERS
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Code Owners for Petstore API Client
|
|
2
|
+
# These users will be automatically requested for review when PRs are opened
|
|
3
|
+
|
|
4
|
+
# Default owners for everything in the repo
|
|
5
|
+
* @hammadxcm
|
|
6
|
+
|
|
7
|
+
# Authentication system
|
|
8
|
+
/lib/petstore_api_client/authentication/ @hammadxcm
|
|
9
|
+
/spec/authentication/ @hammadxcm
|
|
10
|
+
|
|
11
|
+
# Core API client
|
|
12
|
+
/lib/petstore_api_client/client.rb @hammadxcm
|
|
13
|
+
/lib/petstore_api_client/api_client.rb @hammadxcm
|
|
14
|
+
/lib/petstore_api_client/configuration.rb @hammadxcm
|
|
15
|
+
|
|
16
|
+
# Models
|
|
17
|
+
/lib/petstore_api_client/models/ @hammadxcm
|
|
18
|
+
/spec/models/ @hammadxcm
|
|
19
|
+
|
|
20
|
+
# Client endpoints
|
|
21
|
+
/lib/petstore_api_client/clients/ @hammadxcm
|
|
22
|
+
/spec/clients/ @hammadxcm
|
|
23
|
+
|
|
24
|
+
# CI/CD and configuration
|
|
25
|
+
/.github/ @hammadxcm
|
|
26
|
+
/Gemfile @hammadxcm
|
|
27
|
+
/petstore_api_client.gemspec @hammadxcm
|
|
28
|
+
/.rubocop.yml @hammadxcm
|
|
29
|
+
|
|
30
|
+
# Documentation
|
|
31
|
+
/README.md @hammadxcm
|
|
32
|
+
/CONTRIBUTORS.md @hammadxcm
|
|
33
|
+
|
|
34
|
+
# Security-sensitive files
|
|
35
|
+
/.gitignore @hammadxcm
|
|
36
|
+
/.env.example @hammadxcm
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Petstore API Client - CI/CD Pipeline
|
|
2
|
+
# Author: Hammad Khan (@hammadxcm)
|
|
3
|
+
# Repository: https://github.com/hammadxcm/petstore-api-client
|
|
4
|
+
|
|
5
|
+
name: CI
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
branches: [ main, develop ]
|
|
10
|
+
pull_request:
|
|
11
|
+
branches: [ main, develop ]
|
|
12
|
+
workflow_dispatch: # Allow manual trigger
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
test:
|
|
16
|
+
name: Tests (Ruby ${{ matrix.ruby }})
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
strategy:
|
|
19
|
+
fail-fast: false
|
|
20
|
+
matrix:
|
|
21
|
+
ruby: ['3.2', '3.3']
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- name: ๐ฅ Checkout code
|
|
25
|
+
uses: actions/checkout@v4
|
|
26
|
+
|
|
27
|
+
- name: ๐ Set up Ruby ${{ matrix.ruby }}
|
|
28
|
+
uses: ruby/setup-ruby@v1
|
|
29
|
+
with:
|
|
30
|
+
ruby-version: ${{ matrix.ruby }}
|
|
31
|
+
bundler-cache: true
|
|
32
|
+
|
|
33
|
+
- name: ๐ฆ Install dependencies
|
|
34
|
+
run: bundle install --jobs 4 --retry 3
|
|
35
|
+
|
|
36
|
+
- name: ๐งช Run tests
|
|
37
|
+
run: bundle exec rspec
|
|
38
|
+
|
|
39
|
+
- name: ๐ Upload coverage (Ruby 3.3 only)
|
|
40
|
+
if: matrix.ruby == '3.3'
|
|
41
|
+
uses: actions/upload-artifact@v4
|
|
42
|
+
with:
|
|
43
|
+
name: coverage-report
|
|
44
|
+
path: coverage/
|
|
45
|
+
|
|
46
|
+
lint:
|
|
47
|
+
name: RuboCop
|
|
48
|
+
runs-on: ubuntu-latest
|
|
49
|
+
|
|
50
|
+
steps:
|
|
51
|
+
- name: ๐ฅ Checkout code
|
|
52
|
+
uses: actions/checkout@v4
|
|
53
|
+
|
|
54
|
+
- name: ๐ Set up Ruby
|
|
55
|
+
uses: ruby/setup-ruby@v1
|
|
56
|
+
with:
|
|
57
|
+
ruby-version: '3.3'
|
|
58
|
+
bundler-cache: true
|
|
59
|
+
|
|
60
|
+
- name: ๐ฆ Install dependencies
|
|
61
|
+
run: bundle install --jobs 4 --retry 3
|
|
62
|
+
|
|
63
|
+
- name: ๐ Run RuboCop
|
|
64
|
+
run: bundle exec rubocop
|
|
65
|
+
|
|
66
|
+
security:
|
|
67
|
+
name: Security Audit
|
|
68
|
+
runs-on: ubuntu-latest
|
|
69
|
+
|
|
70
|
+
steps:
|
|
71
|
+
- name: ๐ฅ Checkout code
|
|
72
|
+
uses: actions/checkout@v4
|
|
73
|
+
|
|
74
|
+
- name: ๐ Set up Ruby
|
|
75
|
+
uses: ruby/setup-ruby@v1
|
|
76
|
+
with:
|
|
77
|
+
ruby-version: '3.3'
|
|
78
|
+
bundler-cache: true
|
|
79
|
+
|
|
80
|
+
- name: ๐ Run bundle audit
|
|
81
|
+
run: |
|
|
82
|
+
gem install bundler-audit
|
|
83
|
+
bundle audit check --update
|
|
84
|
+
|
|
85
|
+
build:
|
|
86
|
+
name: Build Gem
|
|
87
|
+
runs-on: ubuntu-latest
|
|
88
|
+
needs: [test, lint]
|
|
89
|
+
|
|
90
|
+
steps:
|
|
91
|
+
- name: ๐ฅ Checkout code
|
|
92
|
+
uses: actions/checkout@v4
|
|
93
|
+
|
|
94
|
+
- name: ๐ Set up Ruby
|
|
95
|
+
uses: ruby/setup-ruby@v1
|
|
96
|
+
with:
|
|
97
|
+
ruby-version: '3.3'
|
|
98
|
+
bundler-cache: true
|
|
99
|
+
|
|
100
|
+
- name: ๐ฆ Build gem
|
|
101
|
+
run: gem build petstore_api_client.gemspec
|
|
102
|
+
|
|
103
|
+
- name: ๐ค Upload gem artifact
|
|
104
|
+
uses: actions/upload-artifact@v4
|
|
105
|
+
with:
|
|
106
|
+
name: petstore-api-client-gem
|
|
107
|
+
path: '*.gem'
|
|
108
|
+
|
|
109
|
+
coverage:
|
|
110
|
+
name: Coverage Report
|
|
111
|
+
runs-on: ubuntu-latest
|
|
112
|
+
needs: test
|
|
113
|
+
|
|
114
|
+
steps:
|
|
115
|
+
- name: ๐ฅ Checkout code
|
|
116
|
+
uses: actions/checkout@v4
|
|
117
|
+
|
|
118
|
+
- name: ๐ Set up Ruby
|
|
119
|
+
uses: ruby/setup-ruby@v1
|
|
120
|
+
with:
|
|
121
|
+
ruby-version: '3.3'
|
|
122
|
+
bundler-cache: true
|
|
123
|
+
|
|
124
|
+
- name: ๐ฆ Install dependencies
|
|
125
|
+
run: bundle install
|
|
126
|
+
|
|
127
|
+
- name: ๐งช Run tests with coverage
|
|
128
|
+
run: bundle exec rspec
|
|
129
|
+
|
|
130
|
+
- name: ๐ Check coverage threshold
|
|
131
|
+
run: |
|
|
132
|
+
COVERAGE=$(ruby -e "require 'json'; data = JSON.parse(File.read('coverage/.last_run.json')); puts data['result']['line']")
|
|
133
|
+
echo "Coverage: $COVERAGE%"
|
|
134
|
+
if (( $(echo "$COVERAGE < 95" | bc -l) )); then
|
|
135
|
+
echo "โ Coverage $COVERAGE% is below 95% threshold"
|
|
136
|
+
exit 1
|
|
137
|
+
fi
|
|
138
|
+
echo "โ
Coverage $COVERAGE% meets threshold"
|
|
139
|
+
|
|
140
|
+
report:
|
|
141
|
+
name: Test Summary
|
|
142
|
+
runs-on: ubuntu-latest
|
|
143
|
+
needs: [test, lint, security, build, coverage]
|
|
144
|
+
if: always()
|
|
145
|
+
|
|
146
|
+
steps:
|
|
147
|
+
- name: ๐ Generate summary
|
|
148
|
+
run: |
|
|
149
|
+
echo "## ๐ฏ CI/CD Pipeline Results" >> $GITHUB_STEP_SUMMARY
|
|
150
|
+
echo "" >> $GITHUB_STEP_SUMMARY
|
|
151
|
+
echo "| Job | Status |" >> $GITHUB_STEP_SUMMARY
|
|
152
|
+
echo "|-----|--------|" >> $GITHUB_STEP_SUMMARY
|
|
153
|
+
echo "| Tests | ${{ needs.test.result == 'success' && 'โ
Passed' || 'โ Failed' }} |" >> $GITHUB_STEP_SUMMARY
|
|
154
|
+
echo "| Linting | ${{ needs.lint.result == 'success' && 'โ
Passed' || 'โ Failed' }} |" >> $GITHUB_STEP_SUMMARY
|
|
155
|
+
echo "| Security | ${{ needs.security.result == 'success' && 'โ
Passed' || 'โ Failed' }} |" >> $GITHUB_STEP_SUMMARY
|
|
156
|
+
echo "| Build | ${{ needs.build.result == 'success' && 'โ
Passed' || 'โ Failed' }} |" >> $GITHUB_STEP_SUMMARY
|
|
157
|
+
echo "| Coverage | ${{ needs.coverage.result == 'success' && 'โ
Passed' || 'โ Failed' }} |" >> $GITHUB_STEP_SUMMARY
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.2.0
|
data/CONTRIBUTORS.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Contributors
|
|
2
|
+
|
|
3
|
+
## ๐จโ๐ป Core Maintainer
|
|
4
|
+
|
|
5
|
+
**Hammad Khan** ([@hammadxcm](https://github.com/hammadxcm))
|
|
6
|
+
- ๐๏ธ Project architect and lead developer
|
|
7
|
+
- ๐ OAuth2 authentication system
|
|
8
|
+
- ๐งช Test suite (454 tests, 96.91% coverage)
|
|
9
|
+
- ๐ Documentation and guides
|
|
10
|
+
- ๐ CI/CD pipeline setup
|
|
11
|
+
|
|
12
|
+
## ๐ How to Contribute
|
|
13
|
+
|
|
14
|
+
We welcome contributions from the community!
|
|
15
|
+
|
|
16
|
+
**Getting Started:**
|
|
17
|
+
1. Fork the repository
|
|
18
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
19
|
+
3. Write tests for your changes
|
|
20
|
+
4. Ensure all tests pass (`bundle exec rspec`)
|
|
21
|
+
5. Run linter (`bundle exec rubocop`)
|
|
22
|
+
6. Commit your changes
|
|
23
|
+
7. Push to your fork and create a Pull Request
|
|
24
|
+
|
|
25
|
+
All contributions should maintain the existing code quality standards and include appropriate tests.
|
|
26
|
+
|
|
27
|
+
## ๐ Code of Conduct
|
|
28
|
+
|
|
29
|
+
We are committed to providing a welcoming and inspiring community for all. Please be respectful and constructive.
|
|
30
|
+
|
|
31
|
+
## ๐ Acknowledgments
|
|
32
|
+
|
|
33
|
+
- Built with inspiration from industry-standard gems like [Octokit](https://github.com/octokit/octokit.rb) and [Slack Ruby Client](https://github.com/slack-ruby/slack-ruby-client)
|
|
34
|
+
- OAuth2 implementation follows [OAuth 2.0 RFC 6749](https://tools.ietf.org/html/rfc6749)
|
|
35
|
+
- Petstore API by [Swagger/OpenAPI](https://petstore.swagger.io/)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
**Want to be listed here?** Submit a Pull Request! All contributions are appreciated. ๐
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Petstore API Client Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|