Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ Run `tox run -e schema-docs` after changing supported inputs or model backends.

| Format | Status | Evidence | Notes |
|--------|--------|----------|-------|
| OpenAPI YAML | tested | `tests/data/openapi/**/*.yaml` (34 fixtures) | Primary fixture format exercised under `tests/data/openapi/**/*.yaml`. |
| OpenAPI YAML | tested | `tests/data/openapi/**/*.yaml` (39 fixtures) | Primary fixture format exercised under `tests/data/openapi/**/*.yaml`. |
| OpenAPI JSON | tested | `tests/main/test_main.py::test_generate_from_json_input` | Covered by the JSON conversion CLI test in `tests/main/test_main.py`. |
| Remote HTTP `$ref` targets | tested | `tests/main/test_main.py::test_generate_remote_ref` | Covered by the remote `$ref` generation test against a live HTTP server. |

Expand All @@ -562,7 +562,7 @@ Run `tox run -e schema-docs` after changing supported inputs or model backends.
| Suite | Fixtures | Example files | Notes |
|-------|----------|---------------|-------|
| Default template | 20 | `body_and_parameters.yaml`, `content_in_parameters.yaml`, `content_in_parameters_inline.yaml` | Core single-file generation scenarios exercised by the main CLI tests. |
| Coverage fixtures | 10 | `callbacks.yaml`, `callbacks_with_operation_id.yaml`, `faux_immutability.yaml` | Focused fixtures for callbacks, non-200 responses, and other regression edges. |
| Coverage fixtures | 14 | `callbacks.yaml`, `callbacks_with_operation_id.yaml`, `faux_immutability.yaml` | Focused fixtures for callbacks, non-200 responses, and other regression edges. |
| Custom template overrides | 1 | `custom_security.yaml` | Template override coverage for `--template-dir`. |
| Timestamp suppression | 1 | `simple.yaml` | Fixtures that exercise `--disable-timestamp`. |
| Remote references | 1 | `body_and_parameters.yaml` | Fixtures whose `$ref` targets are resolved over HTTP at test time. |
Expand Down
4 changes: 2 additions & 2 deletions docs/supported_formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Run `tox run -e schema-docs` after changing supported inputs or model backends.

| Format | Status | Evidence | Notes |
|--------|--------|----------|-------|
| OpenAPI YAML | tested | `tests/data/openapi/**/*.yaml` (34 fixtures) | Primary fixture format exercised under `tests/data/openapi/**/*.yaml`. |
| OpenAPI YAML | tested | `tests/data/openapi/**/*.yaml` (39 fixtures) | Primary fixture format exercised under `tests/data/openapi/**/*.yaml`. |
| OpenAPI JSON | tested | `tests/main/test_main.py::test_generate_from_json_input` | Covered by the JSON conversion CLI test in `tests/main/test_main.py`. |
| Remote HTTP `$ref` targets | tested | `tests/main/test_main.py::test_generate_remote_ref` | Covered by the remote `$ref` generation test against a live HTTP server. |

Expand All @@ -16,7 +16,7 @@ Run `tox run -e schema-docs` after changing supported inputs or model backends.
| Suite | Fixtures | Example files | Notes |
|-------|----------|---------------|-------|
| Default template | 20 | `body_and_parameters.yaml`, `content_in_parameters.yaml`, `content_in_parameters_inline.yaml` | Core single-file generation scenarios exercised by the main CLI tests. |
| Coverage fixtures | 10 | `callbacks.yaml`, `callbacks_with_operation_id.yaml`, `faux_immutability.yaml` | Focused fixtures for callbacks, non-200 responses, and other regression edges. |
| Coverage fixtures | 14 | `callbacks.yaml`, `callbacks_with_operation_id.yaml`, `faux_immutability.yaml` | Focused fixtures for callbacks, non-200 responses, and other regression edges. |
| Custom template overrides | 1 | `custom_security.yaml` | Template override coverage for `--template-dir`. |
| Timestamp suppression | 1 | `simple.yaml` | Fixtures that exercise `--disable-timestamp`. |
| Remote references | 1 | `body_and_parameters.yaml` | Fixtures whose `$ref` targets are resolved over HTTP at test time. |
Expand Down
4 changes: 2 additions & 2 deletions fastapi_code_generator/prompt_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@
'\n'
'| Format | Status | Evidence | Notes |\n'
'|--------|--------|----------|-------|\n'
'| OpenAPI YAML | tested | `tests/data/openapi/**/*.yaml` (34 '
'| OpenAPI YAML | tested | `tests/data/openapi/**/*.yaml` (39 '
'fixtures) | Primary fixture format exercised under '
'`tests/data/openapi/**/*.yaml`. |\n'
'| OpenAPI JSON | tested | '
Expand All @@ -552,7 +552,7 @@
'`content_in_parameters.yaml`, '
'`content_in_parameters_inline.yaml` | Core single-file '
'generation scenarios exercised by the main CLI tests. |\n'
'| Coverage fixtures | 10 | `callbacks.yaml`, '
'| Coverage fixtures | 14 | `callbacks.yaml`, '
'`callbacks_with_operation_id.yaml`, `faux_immutability.yaml` '
'| Focused fixtures for callbacks, non-200 responses, and '
'other regression edges. |\n'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# generated by fastapi-codegen:
# filename: api.yaml

from __future__ import annotations

from typing import List

from fastapi import FastAPI

from .models import Pet

app = FastAPI(
version='1.0.0',
title='Swagger Petstore',
)


@app.get('/pets', response_model=List[Pet])
def list_pets() -> List[Pet]:
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# generated by fastapi-codegen:
# filename: api.yaml

from __future__ import annotations

from pydantic import BaseModel


class Pet(BaseModel):
id: int
name: str
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
)


@app.post('/upload', response_model=None)
@app.post('/upload', response_model=None, status_code=204)
def create_upload() -> None:
pass
31 changes: 31 additions & 0 deletions tests/data/openapi/coverage/formatter_parent_pyproject/api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
paths:
/pets:
get:
operationId: listPets
responses:
'200':
description: A paged array of pets
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
components:
schemas:
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tool.poetry]
name = "openapi-srv"
version = "0.1.0"
18 changes: 18 additions & 0 deletions tests/main/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,24 @@ def test_generate_from_json_input(tmp_path: Path, output_dir: Path) -> None:
validate_generated_code(output_dir)


@freeze_time("2020-06-19")
def test_generate_with_parent_pyproject_formatter_settings(tmp_path: Path) -> None:
fixture_dir = DATA_PATH / OPEN_API_COVERAGE_DIR_NAME / "formatter_parent_pyproject"
project_dir = tmp_path / "project"
output_dir = project_dir / "app3"
input_path = project_dir / "api.yaml"
project_dir.mkdir()
copy2(fixture_dir / "api.yaml", input_path)
copy2(fixture_dir / "pyproject.toml", project_dir / "pyproject.toml")

run_cli_and_assert(
input_path=input_path,
output_path=output_dir,
expected_path=EXPECTED_OPENAPI_PATH / "coverage" / "formatter_parent_pyproject",
extra_args=["--disable-timestamp"],
)


@freeze_time("2020-06-19")
def test_generate_request_body_without_schema(output_dir: Path) -> None:
run_cli_and_assert(
Expand Down
Loading