Skip to content

Commit

Permalink
Update description of fields to include default if default is provided
Browse files Browse the repository at this point in the history
  • Loading branch information
maxachis committed Dec 15, 2024
1 parent bdf4f4e commit fd5a1b5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
10 changes: 1 addition & 9 deletions middleware/primary_resource_logic/locations_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,9 @@
message_response,
multiple_results_response,
)
from middleware.dynamic_request_logic.get_many_logic import get_many
from middleware.dynamic_request_logic.get_related_resource_logic import (
get_related_resource,
GetRelatedResourcesParameters,
)
from middleware.dynamic_request_logic.supporting_classes import MiddlewareParameters
from middleware.enums import Relations
from middleware.flask_response_manager import FlaskResponseManager
from middleware.primary_resource_logic.data_requests import (
get_data_requests_subquery_params,
)

from middleware.schema_and_dto_logic.common_schemas_and_dtos import GetByIDBaseDTO


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
"""

from abc import ABC, abstractmethod
from enum import Enum
from typing import Optional, Type

from flask_restx.reqparse import RequestParser

from flask_restx import fields as restx_fields, Namespace, Model
from marshmallow import fields as marshmallow_fields
from marshmallow import fields as marshmallow_fields, missing
from marshmallow.validate import OneOf

from middleware.schema_and_dto_logic.mappings import (
Expand Down Expand Up @@ -108,6 +109,7 @@ def build_description(self):
self.enum_case()
self.validator_case()
self.list_query_case()
self.default_case()

def enum_case(self):
if isinstance(self.field, marshmallow_fields.Enum):
Expand All @@ -129,6 +131,14 @@ def list_query_case(self):
return
self.description += " \n(Comma-delimited list)"

def default_case(self):

Check warning on line 134 in middleware/schema_and_dto_logic/dynamic_logic/dynamic_schema_documentation_construction.py

View workflow job for this annotation

GitHub Actions / flake8

[flake8] middleware/schema_and_dto_logic/dynamic_logic/dynamic_schema_documentation_construction.py#L134 <102>

Missing docstring in public method
Raw output
./middleware/schema_and_dto_logic/dynamic_logic/dynamic_schema_documentation_construction.py:134:1: D102 Missing docstring in public method
default = self.field.load_default
if default != missing:
# If Enum, get value
if isinstance(default, Enum):
default = default.value
self.description += f" \nDefault: {default}"


class FieldInfo:

Expand Down

0 comments on commit fd5a1b5

Please sign in to comment.