Skip to content

Allow including deprecated into the pydantic model #2476

@bvanelli

Description

@bvanelli

Is your feature request related to a problem? Please describe.

The OpenAPI can declare a deprecated field:

https://swagger.io/docs/specification/v3_0/describing-parameters/#deprecated-parameters

It is also supported on the parser models:

Describe the solution you'd like

I've build a minimal openapi spec with a deprecated field:

openapi: 3.0.4
info:
  title: Sample API
  description: Optional multiline or single-line description
  version: 0.1.9
servers:
  - url: http://api.example.com/v1
    description: Optional server description, e.g. Main (production) server
paths:
  /users:
    get:
      summary: Returns a list of users.
      description: Optional extended description in CommonMark or HTML.
      responses:
        "200": # status code
          description: A JSON array of user names
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string
components:
  schemas:
    Service:
      type: object
      properties:
        location:
          type: string
          description: Location of the service
          example: '400 Street name, City State postcode, Country'
          deprecated: true    # <---------

I would expected the pydantic field to contain the deprecated flag:

class Service(BaseModel):
    location: str = Field(..., description="Location of the service", deprecated=True)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions