-
Notifications
You must be signed in to change notification settings - Fork 16
[WIP] Add support for custom media types #101
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
Conversation
src/main/java/io/vertx/openapi/contract/OpenAPIContractBuilder.java
Outdated
Show resolved
Hide resolved
src/main/java/io/vertx/openapi/contract/OpenAPIContractBuilder.java
Outdated
Show resolved
Hide resolved
src/main/java/io/vertx/openapi/contract/OpenAPIContractBuilder.java
Outdated
Show resolved
Hide resolved
src/main/java/io/vertx/openapi/contract/OpenAPIContractBuilder.java
Outdated
Show resolved
Hide resolved
src/main/java/io/vertx/openapi/contract/OpenAPIContractBuilder.java
Outdated
Show resolved
Hide resolved
src/main/java/io/vertx/openapi/contract/OpenAPIContractBuilder.java
Outdated
Show resolved
Hide resolved
src/main/java/io/vertx/openapi/contract/OpenAPIContractBuilder.java
Outdated
Show resolved
Hide resolved
| * @return The registry. | ||
| */ | ||
| @GenIgnore | ||
| MediaTypeRegistry mediaTypes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| MediaTypeRegistry mediaTypes(); | |
| MediaTypeRegistry getMediaTypeRegistry(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In hindsight I think that this field does not have to exposed here at all.
| static DefaultMediaTypeRegistry createDefault() { | ||
| return new DefaultMediaTypeRegistry() | ||
| .register(MediaTypeRegistration.TEXT_PLAIN) | ||
| .register(MediaTypeRegistration.MULTIPART_FORM_DATA) | ||
| .register(MediaTypeRegistration.APPLICATION_JSON) | ||
| .register(MediaTypeRegistration.APPLICATION_OCTET_STREAM); | ||
| } | ||
|
|
||
| /** | ||
| * Creates an empty registry. | ||
| * | ||
| * @return An empty registry. | ||
| */ | ||
| static DefaultMediaTypeRegistry createEmpty() { | ||
| return new DefaultMediaTypeRegistry(); | ||
| } | ||
|
|
||
| /** | ||
| * Registers a new MediaTypeHandler | ||
| * | ||
| * @param registration The mediatype registration. | ||
| * @return This registry for a fluent interface. | ||
| */ | ||
| DefaultMediaTypeRegistry register(MediaTypeRegistration registration); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep this in DefaultMediaTypeRegistry
| * @param context Whether the analyser is for a request or response. | ||
| * @return A fresh content analyser instance. | ||
| */ | ||
| ContentAnalyser createContentAnalyser(String contentType, Buffer content, ValidationContext context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getContentAnalyser
|
I extracted the builder-part from this PR and requested a new PR: #103 |
4e21944 to
b63d3fe
Compare
|
Will be resolved with #118 |
Motivation:
At the moment it is not possible to use media types that are not included in the static supported mediatypes list in requests and responses. This forces the users to use generic media types where more specific ones exist in their openapi specs.
This pull-request replaces the current static list of mediatypes with a registry that allows the registration of additional mediatypes.
At the moment this is an early draft of the feature and the pull request is used to provide a place for a first review.
Conformance:
The Eclipse Contributor Agreement is signed by me.
The code style will be enforced once this feature reaches a mature state.