Skip to content

Commit 9607d16

Browse files
committed
update readme with complete example
1 parent ea763b6 commit 9607d16

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ python -m build
3333
pip install dist/serverless_openapi_generator-1.0.0-py3-none-any.whl
3434
```
3535

36+
or run as `uv` tool:
37+
38+
```bash
39+
uvx --from git+https://github.com/tkfoss/python-serverless-openapi-documentation.git openapi-gen generate-spec openapi.json --serverless-yml-path path/to/your/serverless.yml
40+
```
41+
42+
For more information on running tools with `uv`, see the [official documentation](https://docs.astral.sh/uv/guides/tools/#running-tools).
43+
3644
### CLI
3745

3846
The tool now uses a sub-command structure for different stages of the generation process.
@@ -162,6 +170,21 @@ The workflow is as follows:
162170

163171
> **Note:** For the Pydantic schema generation to work correctly, the Python environment where you run `openapi-gen` must have all the dependencies of your project installed. This is because the tool needs to import your Pydantic models to generate the schemas.
164172

173+
### Complete Example
174+
175+
Here is a complete example of how to generate a validated OpenAPI specification from a Python project with Pydantic models:
176+
177+
```bash
178+
# Step 1: Generate JSON schemas from your Pydantic models
179+
openapi-gen generate-schemas --pydantic-source ./src --output-dir ./openapi_models
180+
181+
# Step 2: Generate a serverless.yml file
182+
openapi-gen generate-serverless --schema-dir ./openapi_models --project-dir .
183+
184+
# Step 3: Generate the OpenAPI specification and validate it
185+
openapi-gen generate-spec openapi.json --serverless-yml-path serverless.yml --validate
186+
```
187+
165188
## License
166189

167190
MIT

0 commit comments

Comments
 (0)