Skip to content

Alias a Required Parameter #3093

@patricker

Description

@patricker

First check

  • [*] I added a very descriptive title to this issue.
  • [*] I used the GitHub search to find a similar issue and didn't find it.
  • [*] I searched the FastAPI documentation, with the integrated search.
  • [*] I already searched in Google "How to X in FastAPI" and didn't find any information.
  • [*] I already read and followed all the tutorial in the docs and didn't find an answer.
  • [*] I already checked if it is not related to FastAPI but to Pydantic.
  • [*] I already checked if it is not related to FastAPI but to Swagger UI.
  • [*] I already checked if it is not related to FastAPI but to ReDoc.
  • [*] After submitting this, I commit to one of:
    • Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there.
    • I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future.
    • Implement a Pull Request for a confirmed bug.

Example

from fastapi import FastAPI, Query

app = FastAPI()

@app.get('/')
def cr_get(fac: int, 
                    d_class: str = Query(None, alias="class"), 
                    d_type: str = Query(None, alias="type")):
    pass

Description

I want all three parameters to be required, but need to alias the last two items.
I do not see a way for Query to handle this. If I use Query then it is identified as an optional parameter automatically. Is there a way around this restriction?

Environment

  • OS: macOS:
  • FastAPI Version 0.63.0
  • Python version: 3.8.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions