We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Using OpenAPI maven generator and Feign, but the default encoder doesn't allow OffsetDateTime
Snippets from Open API contract:
/images: post: tags: - image summary: uploadImage operationId: uploadImage requestBody: $ref: '#/components/requestBodies/UploadImageRequest' responses: "201": $ref: '#/components/responses/ImagesResponse' default: $ref: '#/components/responses/ErrorResponse' requestBodies: UploadImageRequest: content: multipart/form-data: schema: $ref: '#/components/schemas/UploadImage' UploadImage: type: object properties: upload_date: type: string format: date-time image: type: string format: binary
I had to create this encoder as workaround to the problem
`import feign.RequestTemplate; import feign.codec.EncodeException; import feign.codec.Encoder;
import java.lang.reflect.Type; import java.time.OffsetDateTime;
public class OffsetDateTimeAwareFormEncoder implements Encoder {
@Override public void encode(Object object, Type bodyType, RequestTemplate template) throws EncodeException { try { new Encoder.Default().encode(object, bodyType, template); } catch (EncodeException e) { if(bodyType == OffsetDateTime.class) { OffsetDateTime offsetDateTime = (OffsetDateTime)object; template.body(offsetDateTime.toString()); } else { throw e; } } }
}`
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Using OpenAPI maven generator and Feign, but the default encoder doesn't allow OffsetDateTime
Snippets from Open API contract:
/images: post: tags: - image summary: uploadImage operationId: uploadImage requestBody: $ref: '#/components/requestBodies/UploadImageRequest' responses: "201": $ref: '#/components/responses/ImagesResponse' default: $ref: '#/components/responses/ErrorResponse' requestBodies: UploadImageRequest: content: multipart/form-data: schema: $ref: '#/components/schemas/UploadImage' UploadImage: type: object properties: upload_date: type: string format: date-time image: type: string format: binary
I had to create this encoder as workaround to the problem
`import feign.RequestTemplate;
import feign.codec.EncodeException;
import feign.codec.Encoder;
import java.lang.reflect.Type;
import java.time.OffsetDateTime;
public class OffsetDateTimeAwareFormEncoder implements Encoder {
}`
The text was updated successfully, but these errors were encountered: