Skip to content

Commit

Permalink
Decouple HttpResponseDecoder from SwaggerMethodParser, Making Jackson…
Browse files Browse the repository at this point in the history
… encoders package private, Java-doc updates (Azure#547)

* Moving protocol/SerializerAdapter, HttpResponseDecoder to serializer package.

* Making all runtime jackson codec types to package private

* Improving HttpRrsponseDecoder so that client can easily create one with specific decoding settings, java-doc updates.
  • Loading branch information
anuchandy authored Feb 17, 2019
1 parent 5739b6f commit 5c4d932
Show file tree
Hide file tree
Showing 63 changed files with 227 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import com.microsoft.azure.v3.AzureEnvironment;
import com.microsoft.azure.v3.AzureEnvironment.Endpoint;
import com.microsoft.rest.v3.annotations.Beta;
import com.microsoft.rest.v3.protocol.SerializerEncoding;
import com.microsoft.rest.v3.serializer.JacksonAdapter;
import com.microsoft.rest.v3.serializer.SerializerEncoding;
import com.microsoft.rest.v3.serializer.jackson.JacksonAdapter;

import java.io.File;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.microsoft.azure.v3.AzureEnvironment;
import com.microsoft.rest.v3.annotations.Beta;
import com.microsoft.rest.v3.serializer.JacksonAdapter;
import com.microsoft.rest.v3.serializer.jackson.JacksonAdapter;
import reactor.core.Exceptions;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import com.microsoft.azure.v3.serializer.AzureJacksonAdapter;
import com.microsoft.rest.v3.annotations.Beta;
import com.microsoft.rest.v3.protocol.SerializerEncoding;
import com.microsoft.rest.v3.serializer.SerializerEncoding;
import reactor.core.publisher.Mono;

import java.io.BufferedReader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import com.microsoft.rest.v3.http.HttpHeaders;
import com.microsoft.rest.v3.http.HttpResponse;
import com.microsoft.rest.v3.protocol.SerializerAdapter;
import com.microsoft.rest.v3.protocol.SerializerEncoding;
import com.microsoft.rest.v3.serializer.JacksonAdapter;
import com.microsoft.rest.v3.serializer.SerializerAdapter;
import com.microsoft.rest.v3.serializer.SerializerEncoding;
import com.microsoft.rest.v3.serializer.jackson.JacksonAdapter;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import reactor.core.publisher.Flux;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import com.microsoft.rest.v3.http.policy.DecodingPolicy;
import com.microsoft.rest.v3.http.policy.RetryPolicy;
import com.microsoft.rest.v3.http.policy.UserAgentPolicy;
import com.microsoft.rest.v3.protocol.SerializerAdapter;
import com.microsoft.rest.v3.protocol.SerializerEncoding;
import com.microsoft.rest.v3.serializer.SerializerAdapter;
import com.microsoft.rest.v3.serializer.SerializerEncoding;
import com.microsoft.rest.v3.util.TypeUtil;
import reactor.core.Exceptions;
import reactor.core.publisher.Flux;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import com.microsoft.rest.v3.ServiceClient;
import com.microsoft.rest.v3.http.HttpPipeline;
import com.microsoft.rest.v3.protocol.SerializerAdapter;
import com.microsoft.rest.v3.serializer.SerializerAdapter;

/**
* The base class for generated Azure service clients.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import com.microsoft.rest.v3.http.ContextData;
import com.microsoft.rest.v3.http.HttpRequest;
import com.microsoft.rest.v3.http.HttpResponse;
import com.microsoft.rest.v3.protocol.HttpResponseDecoder;
import com.microsoft.rest.v3.protocol.SerializerEncoding;
import com.microsoft.rest.v3.serializer.HttpResponseDecoder;
import com.microsoft.rest.v3.serializer.SerializerEncoding;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

package com.microsoft.azure.v3.serializer;

import com.microsoft.rest.v3.protocol.SerializerAdapter;
import com.microsoft.rest.v3.serializer.JacksonAdapter;
import com.microsoft.rest.v3.serializer.SerializerAdapter;
import com.microsoft.rest.v3.serializer.jackson.JacksonAdapter;

/**
* A serialization helper class overriding {@link JacksonAdapter} with extra
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import com.microsoft.rest.v3.http.HttpResponse;
import com.microsoft.rest.v3.http.policy.DecodingPolicy;
import com.microsoft.rest.v3.http.HttpPipelineOptions;
import com.microsoft.rest.v3.protocol.SerializerAdapter;
import com.microsoft.rest.v3.serializer.JacksonAdapter;
import com.microsoft.rest.v3.serializer.SerializerAdapter;
import com.microsoft.rest.v3.serializer.jackson.JacksonAdapter;
import com.microsoft.rest.v3.InvalidReturnTypeException;
import com.microsoft.rest.v3.annotations.DELETE;
import com.microsoft.rest.v3.annotations.ExpectedResponses;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import com.microsoft.rest.v3.http.HttpPipeline;
import com.microsoft.rest.v3.http.policy.DecodingPolicy;
import com.microsoft.rest.v3.http.HttpPipelineOptions;
import com.microsoft.rest.v3.protocol.SerializerAdapter;
import com.microsoft.rest.v3.serializer.JacksonAdapter;
import com.microsoft.rest.v3.serializer.SerializerAdapter;
import com.microsoft.rest.v3.serializer.jackson.JacksonAdapter;
import com.microsoft.rest.v3.annotations.BodyParam;
import com.microsoft.rest.v3.annotations.DELETE;
import com.microsoft.rest.v3.annotations.ExpectedResponses;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import com.microsoft.rest.v3.http.HttpHeaders;
import com.microsoft.rest.v3.http.HttpResponse;
import com.microsoft.rest.v3.protocol.SerializerAdapter;
import com.microsoft.rest.v3.protocol.SerializerEncoding;
import com.microsoft.rest.v3.serializer.JacksonAdapter;
import com.microsoft.rest.v3.serializer.SerializerAdapter;
import com.microsoft.rest.v3.serializer.SerializerEncoding;
import com.microsoft.rest.v3.serializer.jackson.JacksonAdapter;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import reactor.core.publisher.Flux;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* REST response with a strongly-typed content specified.
*
* @param <TBody> The deserialized type of the response body.
* @param <TBody> The deserialized type of the response content.
*/
public final class RestContentResponse<TBody> extends RestResponse<Void, TBody> {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
import com.microsoft.rest.v3.http.HttpPipelineOptions;
import com.microsoft.rest.v3.http.policy.RetryPolicy;
import com.microsoft.rest.v3.http.policy.UserAgentPolicy;
import com.microsoft.rest.v3.protocol.HttpResponseDecoder;
import com.microsoft.rest.v3.protocol.SerializerAdapter;
import com.microsoft.rest.v3.protocol.SerializerEncoding;
import com.microsoft.rest.v3.serializer.JacksonAdapter;
import com.microsoft.rest.v3.serializer.HttpResponseDecoder;
import com.microsoft.rest.v3.serializer.SerializerAdapter;
import com.microsoft.rest.v3.serializer.SerializerEncoding;
import com.microsoft.rest.v3.serializer.jackson.JacksonAdapter;
import com.microsoft.rest.v3.util.FluxUtil;
import com.microsoft.rest.v3.util.TypeUtil;
import io.netty.buffer.ByteBuf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package com.microsoft.rest.v3;

import com.microsoft.rest.v3.http.HttpPipeline;
import com.microsoft.rest.v3.protocol.SerializerAdapter;
import com.microsoft.rest.v3.serializer.SerializerAdapter;

/**
* The base class for REST service clients.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package com.microsoft.rest.v3;

import com.microsoft.rest.v3.annotations.Host;
import com.microsoft.rest.v3.protocol.SerializerAdapter;
import com.microsoft.rest.v3.serializer.SerializerAdapter;

import java.lang.reflect.Method;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
import com.microsoft.rest.v3.http.HttpHeader;
import com.microsoft.rest.v3.http.HttpHeaders;
import com.microsoft.rest.v3.http.HttpMethod;
import com.microsoft.rest.v3.protocol.SerializerAdapter;
import com.microsoft.rest.v3.serializer.HttpResponseDecodeData;
import com.microsoft.rest.v3.serializer.SerializerAdapter;
import com.microsoft.rest.v3.util.TypeUtil;
import com.microsoft.rest.v3.util.escapers.PercentEscaper;
import com.microsoft.rest.v3.util.escapers.UrlEscapers;
Expand All @@ -44,7 +45,7 @@
* The type to parse details of a specific Swagger REST API call from a provided Swagger interface
* method.
*/
public class SwaggerMethodParser {
public class SwaggerMethodParser implements HttpResponseDecodeData {
private final SerializerAdapter serializer;
private final String rawHost;
private final String fullyQualifiedMethodName;
Expand Down Expand Up @@ -207,6 +208,7 @@ public String fullyQualifiedMethodName() {
*
* @return the HTTP method that will be used to complete the Swagger method's request
*/
@Override
public HttpMethod httpMethod() {
return httpMethod;
}
Expand All @@ -219,6 +221,7 @@ public HttpMethod httpMethod() {
* @return the expected HTTP response status codes for this Swagger method or null if all status
* codes less than 400 are allowed.
*/
@Override
public int[] expectedStatusCodes() {
return expectedStatusCodes;
}
Expand Down Expand Up @@ -405,6 +408,7 @@ public Class<? extends RestException> exceptionType() {
* @return the type of body Object that a thrown RestException will contain if the HTTP
* response's status code is not one of the expected status codes
*/
@Override
public Class<?> exceptionBodyType() {
return exceptionBodyType;
}
Expand Down Expand Up @@ -442,6 +446,7 @@ public String bodyContentType() {
*
* @return the return type for the method that this object describes.
*/
@Override
public Type returnType() {
return returnType;
}
Expand All @@ -463,6 +468,7 @@ public Type bodyJavaType() {
*
* @return the type that the raw HTTP response body will be sent as
*/
@Override
public Type returnValueWireType() {
return returnValueWireType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* Annotation for the parameter to be sent as the HTTP Request content.
* Annotation to annotate a parameter to send to a REST endpoint as HTTP Request content.
*
* If the parameter type extends InputStream, this payload is streamed to server through
* "application/octet-stream". Otherwise, the body is serialized first and sent as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.lang.annotation.Target;

/**
* HTTP DELETE method annotation describing the parametrized relative path to an endpoint for resource deletion.
* HTTP DELETE method annotation describing the parametrized relative path to a REST endpoint for resource deletion.
*
* The required value can be either a relative path or an absolute path. When it's
* an absolute path, it must start with a protocol or a parametrized segment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* Annotation to list the HTTP status codes that are expected for a REST API.
* Annotation to annotate list of HTTP status codes that are expected in response from a REST endpoint.
*
* Example:
* {@literal @}ExpectedResponses({200, 201})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.lang.annotation.Target;

/**
* HTTP GET method annotation describing the parametrized relative path to an endpoint for resource retrieval.
* HTTP GET method annotation describing the parametrized relative path to a REST endpoint for resource retrieval.
*
* The required value can be either a relative path or an absolute path. When it's
* an absolute path, it must start with a protocol or a parametrized segment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.lang.annotation.Target;

/**
* HTTP HEAD method annotation describing the parametrized relative path to an endpoint.
* HTTP HEAD method annotation describing the parametrized relative path to a REST endpoint.
*
* The required value can be either a relative path or an absolute path. When it's
* an absolute path, it must start with a protocol or a parametrized segment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* List of static headers sent to the REST endpoint.
* Annotation to annotate list of static headers sent to a REST endpoint.
*
* Headers are comma separated strings, with each in the format of
* "header name: header value1,header value2".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import static java.lang.annotation.ElementType.TYPE;

/**
* Annotation for parametrized host name.
* Annotation for parametrized host name targeting a REST service.
*
* This is the 'host' field or 'x-ms-parameterized-host.hostTemplate' field in
* a Swagger document. parameters are enclosed in {}s, e.g. {accountName}. An
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* A host parameter annotation for replacing parametrized segments in a dynamic {@link Host}.
* Annotation to annotate replacement of parametrized segments in a dynamic {@link Host}.
*
* You provide the value, which should be the same (case sensitive) with
* the parametrized segments in '{}' in the host, unless there's only one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.lang.annotation.Target;

/**
* HTTP PATCH method annotation describing the parametrized relative path to an endpoint for resource patch (update).
* HTTP PATCH method annotation describing the parametrized relative path to a REST endpoint for resource update.
*
* The required value can be either a relative path or an absolute path. When it's
* an absolute path, it must start with a protocol or a parametrized segment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.lang.annotation.Target;

/**
* HTTP POST method annotation describing the parametrized relative path to an endpoint for an action.
* HTTP POST method annotation describing the parametrized relative path to a REST endpoint for an action.
*
* The required value can be either a relative path or an absolute path. When it's
* an absolute path, it must start with a protocol or a parametrized segment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.lang.annotation.Target;

/**
* HTTP PUT method annotation describing the parametrized relative path to an endpoint for resource creation or update.
* HTTP PUT method annotation describing the parametrized relative path to a REST endpoint for resource creation or update.
*
* The required value can be either a relative path or an absolute path. When it's
* an absolute path, it must start with a protocol or a parametrized segment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* Annotation for named replacement in a REST API URL path segment.
* Annotation to annotate replacement for a named path segment in REST endpoint URL.
*
* A parameter that is annotated with PathParam will be ignored if the "uri template"
* does not contain a path segment variable with name {@link PathParam#value()}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* Annotation for query parameters to be appended to REST API Request URI.
* Annotation for query parameters to be appended to a REST API Request URI.
*
* Example#1:
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
* Annotation for the type that will be used to deserialize the return value of a service interface
* method from a network response.
* Annotation for the type that will be used to deserialize the return value of a REST API response.
*/
@Retention(RUNTIME)
@Target(METHOD)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
* Package containing annotation for client side methods that maps to REST APIs.
* Package containing annotations for client side methods that maps to REST APIs.
*/
package com.microsoft.rest.v3.annotations;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

package com.microsoft.rest.v3.http;

import com.microsoft.rest.v3.protocol.HttpResponseDecoder;
import com.microsoft.rest.v3.serializer.HttpResponseDecoder;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import reactor.core.publisher.Flux;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.microsoft.rest.v3.http.HttpPipelineCallContext;
import com.microsoft.rest.v3.http.HttpResponse;
import com.microsoft.rest.v3.http.NextPolicy;
import com.microsoft.rest.v3.protocol.HttpResponseDecoder;
import com.microsoft.rest.v3.serializer.HttpResponseDecoder;
import reactor.core.publisher.Mono;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Package containing HttpPipeline policies.
* Package containing HttpPipelinePolicy interface and it's implementations.
*/
package com.microsoft.rest.v3.http.policy;

Loading

0 comments on commit 5c4d932

Please sign in to comment.