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
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [30.0.1] - 2025-06-03
## [31.0.1] - 2025-08-28
- Winter openapi now supports enum for order_by query parameter

## [31.0.0] - 2025-06-03
- Winter was made compatible with the latest version of 'uritemplate'
- 'uritemplate' doesn't follow semantic versioning so exact version was pinned
- 'uritemplate' doesn't follow semantic versioning so an exact version was pinned
- GH runners were updated from 20.04 to 22.04

## [30.0.0] - 2025-02-27
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "winter"
version = "31.0.0"
version = "31.0.1"
homepage = "https://github.com/WinterFramework/winter"
description = "Web Framework with focus on python typing, dataclasses and modular design"
authors = ["Alexander Egorov <[email protected]>"]
Expand Down
19 changes: 16 additions & 3 deletions tests/winter_openapi/test_page_position_argument_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def method(self, arg1: object): # pragma: no cover
def test_page_position_argument_inspector_with_allowed_order_by_fields(default_sort):
class TestAPI:
@winter.route_get("ordered_resource")
@winter.web.pagination.order_by(["id"], default_sort=default_sort)
@winter.web.pagination.order_by(["id","name","created_at"], default_sort=default_sort)
def method(self, arg1: PagePosition): # pragma: no cover
pass

Expand All @@ -72,11 +72,24 @@ def method(self, arg1: PagePosition): # pragma: no cover
"allowEmptyValue": False,
"allowReserved": False,
"deprecated": False,
"description": "Comma separated order by fields. Allowed fields: id.",
"description": "Comma separated order by fields.",
"in": "query",
"name": "order_by",
"required": False,
"schema": {"items": {"type": "string"}, "type": "array"},
"schema": {
"items": {
"type": "string",
'enum': [
'created_at',
'-created_at',
'id',
'-id',
'name',
'-name'
]
},
"type": "array"
},
}

if default_sort:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,22 @@ def inspect_parameters(self, route: 'Route', schema_registry: 'SchemaRegistry')
if order_by_annotation.default_sort is not None else
None
)
enum_values = []
for field in map(str, sorted(order_by_annotation.allowed_fields)):
enum_values.append(field)
enum_values.append('-' + field)

order_by_parameter = Parameter(
name=self._page_position_argument_resolver.order_by_name,
description=f'Comma separated order by fields. Allowed fields: {allowed_order_by_fields}.',
description=f'Comma separated order by fields.',
required=False,
param_in="query",
param_schema=Schema(
type=DataTypes.ARRAY,
default=default_sort,
items=Schema(
type=DataTypes.STRING,
enum=enum_values,
)
),
)
Expand Down