openapi2cli 0.1.0__tar.gz → 0.1.1__tar.gz
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.
- openapi2cli-0.1.1/.github/workflows/ci.yml +53 -0
- openapi2cli-0.1.1/AGENTS.md +90 -0
- openapi2cli-0.1.1/CHANGELOG.md +21 -0
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/PKG-INFO +45 -4
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/README.md +44 -3
- openapi2cli-0.1.1/SKILL.md +81 -0
- openapi2cli-0.1.1/banner.png +0 -0
- openapi2cli-0.1.1/install.sh +28 -0
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/pyproject.toml +1 -1
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/tests/test_e2e.py +12 -12
- openapi2cli-0.1.0/.github/workflows/ci.yml +0 -60
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/.gitignore +0 -0
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/LICENSE +0 -0
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/openapi2cli/__init__.py +0 -0
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/openapi2cli/__main__.py +0 -0
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/openapi2cli/cli.py +0 -0
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/openapi2cli/generator.py +0 -0
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/openapi2cli/parser.py +0 -0
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/openapi2cli/runtime.py +0 -0
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/tests/__init__.py +0 -0
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/tests/fixtures/httpbin.json +0 -0
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/tests/fixtures/petstore.yaml +0 -0
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/tests/test_generator.py +0 -0
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/tests/test_parser.py +0 -0
- {openapi2cli-0.1.0 → openapi2cli-0.1.1}/tests/test_runtime.py +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
tags: ['v*']
|
|
7
|
+
pull_request:
|
|
8
|
+
branches: [main]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
python-version: ["3.9", "3.10", "3.11", "3.12"]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Install uv
|
|
21
|
+
uses: astral-sh/setup-uv@v4
|
|
22
|
+
|
|
23
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
24
|
+
run: uv python install ${{ matrix.python-version }}
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: uv sync --all-extras --dev
|
|
28
|
+
|
|
29
|
+
- name: Lint with ruff
|
|
30
|
+
run: uv run ruff check .
|
|
31
|
+
|
|
32
|
+
- name: Run tests
|
|
33
|
+
run: uv run pytest
|
|
34
|
+
|
|
35
|
+
publish:
|
|
36
|
+
needs: test
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
39
|
+
|
|
40
|
+
steps:
|
|
41
|
+
- uses: actions/checkout@v4
|
|
42
|
+
|
|
43
|
+
- name: Install uv
|
|
44
|
+
uses: astral-sh/setup-uv@v4
|
|
45
|
+
|
|
46
|
+
- name: Build package
|
|
47
|
+
run: uv build
|
|
48
|
+
|
|
49
|
+
- name: Publish to PyPI
|
|
50
|
+
env:
|
|
51
|
+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
|
|
52
|
+
run: uv publish --token $UV_PUBLISH_TOKEN
|
|
53
|
+
continue-on-error: true # Don't fail if version already exists
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
Instructions for AI agents working on this repository.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
**openapi2cli** generates CLI tools from OpenAPI 3.x specs. Built for AI agents who need to interact with APIs.
|
|
8
|
+
|
|
9
|
+
## Development
|
|
10
|
+
|
|
11
|
+
### Setup
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
git clone https://github.com/Olafs-World/openapi2cli.git
|
|
15
|
+
cd openapi2cli
|
|
16
|
+
uv sync
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Running Tests
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
uv run pytest
|
|
23
|
+
uv run ruff check .
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Testing Locally
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
uv run openapi2cli generate https://httpbin.org/spec.json --name httpbin
|
|
30
|
+
python httpbin_cli.py --help
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Project Structure
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
openapi2cli/
|
|
37
|
+
├── __init__.py # Package exports
|
|
38
|
+
├── cli.py # CLI entry point (argparse)
|
|
39
|
+
├── parser.py # OpenAPI spec parsing
|
|
40
|
+
├── generator.py # CLI code generation
|
|
41
|
+
├── runtime.py # Runtime helpers for generated CLIs
|
|
42
|
+
tests/
|
|
43
|
+
├── test_cli.py # CLI tests
|
|
44
|
+
├── test_parser.py # Parser tests
|
|
45
|
+
├── test_generator.py # Generator tests
|
|
46
|
+
├── test_runtime.py # Runtime tests
|
|
47
|
+
├── test_e2e.py # End-to-end tests
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Making a Release
|
|
51
|
+
|
|
52
|
+
1. **Bump version** in `pyproject.toml`
|
|
53
|
+
2. **Update CHANGELOG.md** with changes under new version header
|
|
54
|
+
3. **Commit**: `git commit -am "Bump version to X.Y.Z"`
|
|
55
|
+
4. **Tag**: `git tag vX.Y.Z`
|
|
56
|
+
5. **Push**: `git push && git push --tags`
|
|
57
|
+
|
|
58
|
+
CI will automatically publish to PyPI when the tag is pushed.
|
|
59
|
+
|
|
60
|
+
## Code Style
|
|
61
|
+
|
|
62
|
+
- Use `ruff` for linting
|
|
63
|
+
- Follow existing patterns in the codebase
|
|
64
|
+
- Generated CLIs should be standalone (single file, minimal deps)
|
|
65
|
+
- Support common auth patterns (API key, Bearer, Basic)
|
|
66
|
+
|
|
67
|
+
## Architecture
|
|
68
|
+
|
|
69
|
+
1. **Parser** - Reads OpenAPI spec, extracts endpoints/params
|
|
70
|
+
2. **Generator** - Creates Python CLI code from parsed spec
|
|
71
|
+
3. **Runtime** - Helper functions used by generated CLIs
|
|
72
|
+
|
|
73
|
+
## Limitations to Address
|
|
74
|
+
|
|
75
|
+
- Only OpenAPI 3.x (not Swagger 2.0)
|
|
76
|
+
- No file upload support yet
|
|
77
|
+
- OAuth2 flows not fully implemented
|
|
78
|
+
- Complex nested request bodies need `--data` JSON flag
|
|
79
|
+
|
|
80
|
+
## Dependencies
|
|
81
|
+
|
|
82
|
+
- `pyyaml` - YAML parsing
|
|
83
|
+
- `requests` - HTTP client (for generated CLIs)
|
|
84
|
+
- `pytest` - Testing (dev)
|
|
85
|
+
- `ruff` - Linting (dev)
|
|
86
|
+
|
|
87
|
+
## Git Conventions
|
|
88
|
+
|
|
89
|
+
- Commit messages: imperative mood ("Add feature" not "Added feature")
|
|
90
|
+
- Co-author AI contributions: `Co-authored-by: olaf-s-app[bot] <259723076+olaf-s-app[bot]@users.noreply.github.com>`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.1] - 2026-02-06
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- Use absolute URL for banner image on PyPI
|
|
12
|
+
|
|
13
|
+
## [0.1.0] - 2026-02-05
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- Initial release
|
|
17
|
+
- Generate CLI tools from OpenAPI 3.x specs
|
|
18
|
+
- Support for API key, Bearer token, and Basic auth
|
|
19
|
+
- Path, query, header, and body parameters
|
|
20
|
+
- JSON and text output formats
|
|
21
|
+
- Dry-run mode to preview requests
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openapi2cli
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Generate CLI tools from OpenAPI specs — built for AI agents
|
|
5
5
|
Project-URL: Homepage, https://github.com/Olafs-World/openapi2cli
|
|
6
6
|
Project-URL: Repository, https://github.com/Olafs-World/openapi2cli
|
|
@@ -31,6 +31,8 @@ Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
|
31
31
|
Requires-Dist: ruff>=0.1; extra == 'dev'
|
|
32
32
|
Description-Content-Type: text/markdown
|
|
33
33
|
|
|
34
|
+

|
|
35
|
+
|
|
34
36
|
# openapi2cli 🔧
|
|
35
37
|
|
|
36
38
|
[](https://github.com/Olafs-World/openapi2cli/actions/workflows/ci.yml)
|
|
@@ -62,6 +64,39 @@ AI agents are great at executing CLI commands. They're less great at crafting HT
|
|
|
62
64
|
|
|
63
65
|
## Installation
|
|
64
66
|
|
|
67
|
+
### One-liner
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
curl -fsSL https://raw.githubusercontent.com/Olafs-World/openapi2cli/main/install.sh | bash
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Quick run (no install)
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
uvx openapi2cli generate https://petstore3.swagger.io/api/v3/openapi.json --name petstore
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Install as CLI tool
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
uv tool install openapi2cli
|
|
83
|
+
openapi2cli generate https://httpbin.org/spec.json --name httpbin
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Add to a project
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
uv add openapi2cli
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Install as OpenClaw skill
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
clawhub install openapi2cli
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Or with pip:
|
|
99
|
+
|
|
65
100
|
```bash
|
|
66
101
|
pip install openapi2cli
|
|
67
102
|
```
|
|
@@ -231,13 +266,13 @@ git clone https://github.com/Olafs-World/openapi2cli.git
|
|
|
231
266
|
cd openapi2cli
|
|
232
267
|
|
|
233
268
|
# Install dev dependencies
|
|
234
|
-
|
|
269
|
+
uv sync --extra dev
|
|
235
270
|
|
|
236
271
|
# Run tests
|
|
237
|
-
pytest tests/ -v
|
|
272
|
+
uv run pytest tests/ -v
|
|
238
273
|
|
|
239
274
|
# Run only unit tests (no API calls)
|
|
240
|
-
pytest tests/ -v -m "not integration"
|
|
275
|
+
uv run pytest tests/ -v -m "not integration"
|
|
241
276
|
```
|
|
242
277
|
|
|
243
278
|
## How It Works
|
|
@@ -256,6 +291,12 @@ The generated CLI uses `requests` for HTTP and optionally `rich` for pretty outp
|
|
|
256
291
|
- Complex nested request bodies may need `--data` JSON flag
|
|
257
292
|
- OAuth2 flows not fully implemented (use `--token` with pre-obtained tokens)
|
|
258
293
|
|
|
294
|
+
## Links
|
|
295
|
+
|
|
296
|
+
- [PyPI](https://pypi.org/project/openapi2cli/)
|
|
297
|
+
- [GitHub](https://github.com/Olafs-World/openapi2cli)
|
|
298
|
+
- [ClawHub Skill](https://clawhub.com/skills/openapi2cli)
|
|
299
|
+
|
|
259
300
|
## License
|
|
260
301
|
|
|
261
302
|
MIT © [Olaf](https://olafs-world.vercel.app)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
1
3
|
# openapi2cli 🔧
|
|
2
4
|
|
|
3
5
|
[](https://github.com/Olafs-World/openapi2cli/actions/workflows/ci.yml)
|
|
@@ -29,6 +31,39 @@ AI agents are great at executing CLI commands. They're less great at crafting HT
|
|
|
29
31
|
|
|
30
32
|
## Installation
|
|
31
33
|
|
|
34
|
+
### One-liner
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
curl -fsSL https://raw.githubusercontent.com/Olafs-World/openapi2cli/main/install.sh | bash
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Quick run (no install)
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
uvx openapi2cli generate https://petstore3.swagger.io/api/v3/openapi.json --name petstore
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Install as CLI tool
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
uv tool install openapi2cli
|
|
50
|
+
openapi2cli generate https://httpbin.org/spec.json --name httpbin
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Add to a project
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
uv add openapi2cli
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Install as OpenClaw skill
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
clawhub install openapi2cli
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Or with pip:
|
|
66
|
+
|
|
32
67
|
```bash
|
|
33
68
|
pip install openapi2cli
|
|
34
69
|
```
|
|
@@ -198,13 +233,13 @@ git clone https://github.com/Olafs-World/openapi2cli.git
|
|
|
198
233
|
cd openapi2cli
|
|
199
234
|
|
|
200
235
|
# Install dev dependencies
|
|
201
|
-
|
|
236
|
+
uv sync --extra dev
|
|
202
237
|
|
|
203
238
|
# Run tests
|
|
204
|
-
pytest tests/ -v
|
|
239
|
+
uv run pytest tests/ -v
|
|
205
240
|
|
|
206
241
|
# Run only unit tests (no API calls)
|
|
207
|
-
pytest tests/ -v -m "not integration"
|
|
242
|
+
uv run pytest tests/ -v -m "not integration"
|
|
208
243
|
```
|
|
209
244
|
|
|
210
245
|
## How It Works
|
|
@@ -223,6 +258,12 @@ The generated CLI uses `requests` for HTTP and optionally `rich` for pretty outp
|
|
|
223
258
|
- Complex nested request bodies may need `--data` JSON flag
|
|
224
259
|
- OAuth2 flows not fully implemented (use `--token` with pre-obtained tokens)
|
|
225
260
|
|
|
261
|
+
## Links
|
|
262
|
+
|
|
263
|
+
- [PyPI](https://pypi.org/project/openapi2cli/)
|
|
264
|
+
- [GitHub](https://github.com/Olafs-World/openapi2cli)
|
|
265
|
+
- [ClawHub Skill](https://clawhub.com/skills/openapi2cli)
|
|
266
|
+
|
|
226
267
|
## License
|
|
227
268
|
|
|
228
269
|
MIT © [Olaf](https://olafs-world.vercel.app)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: openapi2cli
|
|
3
|
+
description: Generate CLI tools from OpenAPI specs. Use when you need to interact with any API that has an OpenAPI/Swagger spec - generates a ready-to-use CLI with commands, options, and authentication. Built for AI agents who need quick API access without writing HTTP requests.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# OpenAPI to CLI
|
|
7
|
+
|
|
8
|
+
Generate CLI tools from OpenAPI 3.x specs. Point at any spec, get a working CLI.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
uvx openapi2cli generate spec.yaml --name myapi # one-off
|
|
14
|
+
uv tool install openapi2cli # persistent
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### Generate a CLI
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# From URL
|
|
23
|
+
openapi2cli generate https://petstore3.swagger.io/api/v3/openapi.json --name petstore
|
|
24
|
+
|
|
25
|
+
# From local file
|
|
26
|
+
openapi2cli generate ./api-spec.yaml --name myapi --output myapi_cli.py
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Use the generated CLI
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# See available commands
|
|
33
|
+
./petstore_cli.py --help
|
|
34
|
+
|
|
35
|
+
# Commands are grouped by API tags
|
|
36
|
+
./petstore_cli.py pet find-by-status --status available
|
|
37
|
+
./petstore_cli.py store inventory
|
|
38
|
+
|
|
39
|
+
# Authentication via env vars
|
|
40
|
+
export PETSTORE_API_KEY=your-key
|
|
41
|
+
./petstore_cli.py pet get --pet-id 123
|
|
42
|
+
|
|
43
|
+
# JSON output for scripting
|
|
44
|
+
./petstore_cli.py pet list --output json | jq '.[0].name'
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Inspect a spec
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
openapi2cli inspect https://api.example.com/openapi.json
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Shows endpoints, parameters, and auth schemes without generating code.
|
|
54
|
+
|
|
55
|
+
## Generated CLI Features
|
|
56
|
+
|
|
57
|
+
- Commands grouped by API tags
|
|
58
|
+
- Options for all parameters and request body fields
|
|
59
|
+
- Auth support: API keys, Bearer tokens, env vars
|
|
60
|
+
- Output formats: json, table, raw
|
|
61
|
+
- Base URL override for staging/dev environments
|
|
62
|
+
|
|
63
|
+
## Python API
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from openapi2cli import OpenAPIParser, CLIGenerator
|
|
67
|
+
|
|
68
|
+
# Parse spec
|
|
69
|
+
parser = OpenAPIParser()
|
|
70
|
+
spec = parser.parse("https://api.example.com/openapi.json")
|
|
71
|
+
|
|
72
|
+
# Generate CLI
|
|
73
|
+
generator = CLIGenerator()
|
|
74
|
+
cli = generator.generate(spec, name="example")
|
|
75
|
+
cli.save("example_cli.py")
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Links
|
|
79
|
+
|
|
80
|
+
- PyPI: https://pypi.org/project/openapi2cli/
|
|
81
|
+
- GitHub: https://github.com/Olafs-World/openapi2cli
|
|
Binary file
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
echo "🔧 Installing openapi2cli..."
|
|
5
|
+
|
|
6
|
+
if command -v uv &>/dev/null; then
|
|
7
|
+
echo "Using uv..."
|
|
8
|
+
uv tool install openapi2cli
|
|
9
|
+
elif command -v pipx &>/dev/null; then
|
|
10
|
+
echo "Using pipx..."
|
|
11
|
+
pipx install openapi2cli
|
|
12
|
+
elif command -v pip3 &>/dev/null; then
|
|
13
|
+
echo "Using pip3..."
|
|
14
|
+
pip3 install --user openapi2cli
|
|
15
|
+
elif command -v pip &>/dev/null; then
|
|
16
|
+
echo "Using pip..."
|
|
17
|
+
pip install --user openapi2cli
|
|
18
|
+
else
|
|
19
|
+
echo "❌ No Python package manager found (uv, pipx, or pip)"
|
|
20
|
+
echo "Install uv: curl -LsSf https://astral.sh/uv/install.sh | sh"
|
|
21
|
+
exit 1
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
echo ""
|
|
25
|
+
echo "✅ openapi2cli installed!"
|
|
26
|
+
echo ""
|
|
27
|
+
echo "Try it:"
|
|
28
|
+
echo " openapi2cli generate https://httpbin.org/spec.json --name httpbin"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""End-to-end tests for
|
|
1
|
+
"""End-to-end tests for openapi2cli."""
|
|
2
2
|
|
|
3
3
|
import subprocess
|
|
4
4
|
import sys
|
|
@@ -10,13 +10,13 @@ FIXTURES = Path(__file__).parent / "fixtures"
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class TestCLIEndToEnd:
|
|
13
|
-
"""End-to-end tests for the
|
|
13
|
+
"""End-to-end tests for the openapi2cli command."""
|
|
14
14
|
|
|
15
15
|
def test_generate_from_file(self, tmp_path):
|
|
16
16
|
"""Can generate CLI from a local file."""
|
|
17
17
|
result = subprocess.run(
|
|
18
18
|
[
|
|
19
|
-
sys.executable, "-m", "
|
|
19
|
+
sys.executable, "-m", "openapi2cli",
|
|
20
20
|
"generate",
|
|
21
21
|
str(FIXTURES / "petstore.yaml"),
|
|
22
22
|
"--name", "petstore",
|
|
@@ -33,7 +33,7 @@ class TestCLIEndToEnd:
|
|
|
33
33
|
"""Can generate CLI from a URL."""
|
|
34
34
|
result = subprocess.run(
|
|
35
35
|
[
|
|
36
|
-
sys.executable, "-m", "
|
|
36
|
+
sys.executable, "-m", "openapi2cli",
|
|
37
37
|
"generate",
|
|
38
38
|
"https://httpbin.org/spec.json",
|
|
39
39
|
"--name", "httpbin",
|
|
@@ -51,7 +51,7 @@ class TestCLIEndToEnd:
|
|
|
51
51
|
# Generate
|
|
52
52
|
subprocess.run(
|
|
53
53
|
[
|
|
54
|
-
sys.executable, "-m", "
|
|
54
|
+
sys.executable, "-m", "openapi2cli",
|
|
55
55
|
"generate",
|
|
56
56
|
str(FIXTURES / "httpbin.json"),
|
|
57
57
|
"--name", "httpbin",
|
|
@@ -77,7 +77,7 @@ class TestCLIEndToEnd:
|
|
|
77
77
|
# Generate
|
|
78
78
|
subprocess.run(
|
|
79
79
|
[
|
|
80
|
-
sys.executable, "-m", "
|
|
80
|
+
sys.executable, "-m", "openapi2cli",
|
|
81
81
|
"generate",
|
|
82
82
|
str(FIXTURES / "httpbin.json"),
|
|
83
83
|
"--name", "httpbin",
|
|
@@ -104,9 +104,9 @@ class TestCLIEndToEnd:
|
|
|
104
104
|
assert "url" in result.stdout.lower() or "httpbin" in result.stdout.lower()
|
|
105
105
|
|
|
106
106
|
def test_help_command(self):
|
|
107
|
-
"""
|
|
107
|
+
"""openapi2cli --help works."""
|
|
108
108
|
result = subprocess.run(
|
|
109
|
-
[sys.executable, "-m", "
|
|
109
|
+
[sys.executable, "-m", "openapi2cli", "--help"],
|
|
110
110
|
capture_output=True,
|
|
111
111
|
text=True
|
|
112
112
|
)
|
|
@@ -115,9 +115,9 @@ class TestCLIEndToEnd:
|
|
|
115
115
|
assert "generate" in result.stdout.lower()
|
|
116
116
|
|
|
117
117
|
def test_version_command(self):
|
|
118
|
-
"""
|
|
118
|
+
"""openapi2cli --version works."""
|
|
119
119
|
result = subprocess.run(
|
|
120
|
-
[sys.executable, "-m", "
|
|
120
|
+
[sys.executable, "-m", "openapi2cli", "--version"],
|
|
121
121
|
capture_output=True,
|
|
122
122
|
text=True
|
|
123
123
|
)
|
|
@@ -134,7 +134,7 @@ class TestRealWorldSpecs:
|
|
|
134
134
|
# Generate CLI
|
|
135
135
|
gen_result = subprocess.run(
|
|
136
136
|
[
|
|
137
|
-
sys.executable, "-m", "
|
|
137
|
+
sys.executable, "-m", "openapi2cli",
|
|
138
138
|
"generate",
|
|
139
139
|
str(FIXTURES / "petstore.yaml"),
|
|
140
140
|
"--name", "petstore",
|
|
@@ -163,7 +163,7 @@ class TestRealWorldSpecs:
|
|
|
163
163
|
# Generate
|
|
164
164
|
subprocess.run(
|
|
165
165
|
[
|
|
166
|
-
sys.executable, "-m", "
|
|
166
|
+
sys.executable, "-m", "openapi2cli",
|
|
167
167
|
"generate",
|
|
168
168
|
"https://httpbin.org/spec.json",
|
|
169
169
|
"--name", "httpbin",
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [main]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [main]
|
|
8
|
-
|
|
9
|
-
jobs:
|
|
10
|
-
test:
|
|
11
|
-
runs-on: ubuntu-latest
|
|
12
|
-
strategy:
|
|
13
|
-
matrix:
|
|
14
|
-
python-version: ["3.9", "3.10", "3.11", "3.12"]
|
|
15
|
-
|
|
16
|
-
steps:
|
|
17
|
-
- uses: actions/checkout@v4
|
|
18
|
-
|
|
19
|
-
- name: Set up Python ${{ matrix.python-version }}
|
|
20
|
-
uses: actions/setup-python@v5
|
|
21
|
-
with:
|
|
22
|
-
python-version: ${{ matrix.python-version }}
|
|
23
|
-
|
|
24
|
-
- name: Install dependencies
|
|
25
|
-
run: |
|
|
26
|
-
python -m pip install --upgrade pip
|
|
27
|
-
pip install -e ".[dev]"
|
|
28
|
-
|
|
29
|
-
- name: Lint with ruff
|
|
30
|
-
run: ruff check api2cli/ tests/
|
|
31
|
-
|
|
32
|
-
- name: Run unit tests
|
|
33
|
-
run: pytest tests/ -v -m "not integration" --tb=short
|
|
34
|
-
|
|
35
|
-
- name: Run integration tests
|
|
36
|
-
run: pytest tests/ -v -m "integration" --tb=short
|
|
37
|
-
|
|
38
|
-
publish:
|
|
39
|
-
needs: test
|
|
40
|
-
runs-on: ubuntu-latest
|
|
41
|
-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
42
|
-
|
|
43
|
-
steps:
|
|
44
|
-
- uses: actions/checkout@v4
|
|
45
|
-
|
|
46
|
-
- name: Set up Python
|
|
47
|
-
uses: actions/setup-python@v5
|
|
48
|
-
with:
|
|
49
|
-
python-version: "3.11"
|
|
50
|
-
|
|
51
|
-
- name: Build package
|
|
52
|
-
run: |
|
|
53
|
-
pip install build
|
|
54
|
-
python -m build
|
|
55
|
-
|
|
56
|
-
- name: Publish to PyPI
|
|
57
|
-
uses: pypa/gh-action-pypi-publish@release/v1
|
|
58
|
-
with:
|
|
59
|
-
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
60
|
-
continue-on-error: true
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|