-
-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: "name" and "in" should not be included in openapi headers (#3417)
Exclude the "name" and "in" fields from openapi schema generated for headers. Add ``BaseSchemaObject._iter_fields()`` method that allows schema types to define the fields that should be included in their openapi schema representation and override that method for ``OpenAPIHeader``. Closes #3416
- Loading branch information
1 parent
a31d1c6
commit c372633
Showing
5 changed files
with
46 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from litestar import Litestar, Request, get | ||
from litestar.datastructures import ResponseHeader | ||
|
||
|
||
@get("/") | ||
async def hello_world1(request: Request) -> None: | ||
request.logger.info("inside request") | ||
return | ||
|
||
|
||
app1 = Litestar( | ||
route_handlers=[hello_world1], | ||
response_headers=[ResponseHeader(name="X-Version", value="ABCD", description="Test")], | ||
) | ||
|
||
|
||
def test_included_header_fields() -> None: | ||
# https://github.com/litestar-org/litestar/issues/3416 | ||
|
||
assert app1.openapi_schema.to_schema()["paths"]["/"]["get"]["responses"]["200"]["headers"] == { | ||
"X-Version": { | ||
"allowEmptyValue": False, | ||
"allowReserved": False, | ||
"deprecated": False, | ||
"description": "Test", | ||
"required": False, | ||
"schema": {"type": "string"}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters