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

Support for custom string formats #119

Closed
dallasanta opened this issue Nov 10, 2023 · 2 comments
Closed

Support for custom string formats #119

dallasanta opened this issue Nov 10, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@dallasanta
Copy link

Describe the feature

According to the OpenAPI specification, string "format" is an open value (https://swagger.io/docs/specification/data-models/data-types/#string)

However, format is an open value, so you can use any formats, even not those defined by the OpenAPI Specification, such as:

That's also backed by the JSON Schema Specification Draft 2020-12](https://tools.ietf.org/html/draft-bhutton-json-schema-00#section-7.2.3)

Implementations MAY support custom format attributes.

The feature request is to support custom "format" fields, not only those defined in the above JSON Schema Specification and implemented on https://github.com/eclipse-vertx/vertx-json-schema/blob/4.4.6/src/main/java/io/vertx/json/schema/impl/Format.java

A regular expression pattern should not ideally be used for that as:

  • Users can find it hard to understand
  • Can't be reused - there's no way to use a $ref for a regular expression pattern in OpenAPI

Use cases

As an organization API provider
I want to be able to create custom string formats
So I can communicate to the API users the expected format
And I can run the correct validation

Contribution

Are you volunteering for implementing this feature? 👍

@dallasanta dallasanta added the enhancement New feature or request label Nov 10, 2023
@pk-work
Copy link
Contributor

pk-work commented May 31, 2024

Is this maybe fixed with #128?

@pk-work pk-work self-assigned this May 31, 2024
@dallasanta
Copy link
Author

dallasanta commented Jun 10, 2024

Yes, that fix and eclipse-vertx/vertx-openapi#51 allow you to specify a custom validator. Thanks for that.

I was think that ideally we could override the default string format from here, for scenarios where we want to further restrict some of the validations, but that should be fine as long as we use custom formats anyway.

Happy for this one to be closed.

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

No branches or pull requests

2 participants