Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add label from title #26

Merged
merged 4 commits into from
Jul 15, 2024
Merged

Add label from title #26

merged 4 commits into from
Jul 15, 2024

Conversation

shkangomelet
Copy link
Contributor

@shkangomelet shkangomelet commented Jul 15, 2024

Hello! I'm using your drf-pydantic library to use pydantic model in my django project!

It is very good for cleaning my code, but I found that there is no method to set label in drf_field from drf-pydantic model.

So, I have a request.

What about changing title of pydantic model into label in drf_field? I want to change label field so that I can use it in from drf_yasg.utils import swagger_auto_schema

something like

class DrfPydanticModel(BaseModel):
    test_field: int = Field(..., title="custom title")


@swagger_auto_schema(
    method="post",
    request_body=DrfPydanticModel.drf_serializer,
)

so that I can auto-generate swagger(redoc) page
image

What about changing label of pydantic model as title in drf_field? I want to change label field.
@shkangomelet shkangomelet changed the title Add label from text Add label from title Jul 15, 2024
Copy link

codecov bot commented Jul 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.84%. Comparing base (03bd861) to head (ba6efb2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #26      +/-   ##
==========================================
+ Coverage   98.83%   98.84%   +0.01%     
==========================================
  Files           5        5              
  Lines         171      173       +2     
==========================================
+ Hits          169      171       +2     
  Misses          2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@georgebv
Copy link
Owner

Thank you for the contribution! Can you please add unit test for this and lint the code using ruff?

@shkangomelet
Copy link
Contributor Author

Sure! I did it on 66a7034

@shkangomelet
Copy link
Contributor Author

I added more test case on ba6efb2

@shkangomelet
Copy link
Contributor Author

@georgebv
Copy link
Owner

Looks good, let's merge it. Thank you for providing a reference for how it sets the default label value, I was confused at first.

@georgebv georgebv merged commit 22a5a80 into georgebv:main Jul 15, 2024
11 checks passed
@shkangomelet shkangomelet deleted the patch-1 branch July 15, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants