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

BaseModel Config support openapi_extra #73

Closed
luolingchun opened this issue May 8, 2023 · 0 comments · Fixed by #76
Closed

BaseModel Config support openapi_extra #73

luolingchun opened this issue May 8, 2023 · 0 comments · Fixed by #76
Labels
enhancement New feature or request
Milestone

Comments

@luolingchun
Copy link
Owner

luolingchun commented May 8, 2023

class BookBody(BaseModel):
    age: Optional[int] = Field(..., ge=2, le=4, description='Age')
    author: str = Field(None, min_length=2, max_length=4, description='Author')

    class Config:
        openapi_extra = {
            "description": "This is post RequestBody",
            "example": {
                "age": 12,
                "author": "author"
            },
            "examples": {
                "example1": {
                    "summary": "example summary1",
                    "description": "example description1",
                    "value": {
                        "age": 24,
                        "author": "author1"
                    }
                },
                "example2": {
                    "summary": "example summary2",
                    "description": "example description2",
                    "value": {
                        "age": 48,
                        "author": "author2"
                    }
                }
            }
        }

DeprecationWarning:
extra_form , extra_body and extra_responses will be deprecated in v3.x ???

@luolingchun luolingchun added the enhancement New feature or request label May 8, 2023
@luolingchun luolingchun added this to the 2.4.0 milestone May 8, 2023
@luolingchun luolingchun changed the title BaseModel Config supoorts openapi_extra BaseModel Config support openapi_extra May 21, 2023
@luolingchun luolingchun mentioned this issue Jun 2, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant