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

Include format with Secret types #546

Closed
djlambert opened this issue May 24, 2019 · 7 comments
Closed

Include format with Secret types #546

djlambert opened this issue May 24, 2019 · 7 comments

Comments

@djlambert
Copy link

Feature Request

It'd be nice if SecretStr and SecretBytes included the format attribute with value password to hint UIs to mask the password.

    "secretKey": {
        "title": "Secret Key",
        "type": "string",
        "description": "Secret key",
        "writeOnly": true,
        "format": "password",
        "example": "your secret key"
    },
@samuelcolvin
Copy link
Member

you mean in the schema?

@djlambert
Copy link
Author

Yes, sorry should have specified.

@tiangolo
Copy link
Member

@djlambert they have {"writeOnly": true}. That's what is recommended by the JSON Schema spec for passwords specifically: http://json-schema.org/latest/json-schema-validation.html#rfc.section.10.3

There's no official format of "password" in the specs.

And the writeOnly is supposed to convey the equivalent message. So, I think having an additional, custom password format could misguide developers.

@djlambert
Copy link
Author

It wouldn't be custom, it's in the OpenAPI specs https://swagger.io/specification/#dataTypes

@tiangolo
Copy link
Member

You're right @djlambert.

It's not in JSON Schema but it's indeed in OpenAPI.

I think that deserves a PR.

@Atheuz
Copy link
Contributor

Atheuz commented Apr 23, 2020

Here's a PR: #1424

@Atheuz
Copy link
Contributor

Atheuz commented May 3, 2020

This can be closed due to fix merged in PR #1424

alexdrydew pushed a commit to alexdrydew/pydantic that referenced this issue Dec 23, 2023
* allow partials to call validator

* add function_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants