Skip to content

Commit

Permalink
Don't use ordered Meta, schemas are always ordered
Browse files Browse the repository at this point in the history
  • Loading branch information
lafrech committed Jan 7, 2025
1 parent 9663099 commit 93100a8
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 21 deletions.
18 changes: 2 additions & 16 deletions docs/openapi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -242,23 +242,9 @@ schema `properties`. Although objects are not ordered in JSON, OpenAPI
graphical interfaces tend to respect the order in which the `properties` are
defined in the ``properties`` object in the specification file.

When using an ordererd ``Schema``, the fields definition order is preserved
when generating the specification file and the `properties` are displayed in
that order.
``Schema`` classes keep fields in declaration order, and this order is preserved when
generating the specification file: the `properties` are displayed in that order.

This is typically done in a base class:

.. code-block:: python
:emphasize-lines: 2,3
class MyBaseSchema(ma.Schema):
class Meta:
ordered = True
class User(MyBaseSchema):
name = ma.fields.String()
surname = ma.fields.String()

Serve the OpenAPI Documentation
-------------------------------
Expand Down
4 changes: 0 additions & 4 deletions src/flask_smorest/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class PaginationParametersSchema(ma.Schema):
"""Deserializes pagination params into PaginationParameters"""

class Meta:
ordered = True
unknown = ma.EXCLUDE

page = ma.fields.Integer(
Expand Down Expand Up @@ -127,9 +126,6 @@ class PaginationMetadataSchema(ma.Schema):
previous_page = ma.fields.Int()
next_page = ma.fields.Int()

class Meta:
ordered = True


PAGINATION_HEADER = {
"description": "Pagination metadata",
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class DocSchema(CounterSchema):

class QueryArgsSchema(ma.Schema):
class Meta:
ordered = True
unknown = ma.EXCLUDE

arg1 = ma.fields.String()
Expand Down

0 comments on commit 93100a8

Please sign in to comment.