diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/implementation/ClientModelPropertiesManager.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/implementation/ClientModelPropertiesManager.java index e5792bc64..6c3e16e11 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/implementation/ClientModelPropertiesManager.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/implementation/ClientModelPropertiesManager.java @@ -234,6 +234,24 @@ public final class ClientModelPropertiesManager { } } + // Temporary fix to a larger problem where the discriminator property is defined by a parent model, but not as + // a discriminator. This results in the discriminator property being serialized and deserialized twice as it + // shows up once as a regular property and once as a discriminator property. This will remove the regular + // property from the super properties and indicate that the discriminator came from a parent model. + if (discriminatorProperty != null) { + String serializedDiscriminatorName = discriminatorProperty.getProperty().getSerializedName(); + ClientModelProperty removed; + if ((removed = superRequiredProperties.remove(serializedDiscriminatorName)) != null) { + discriminatorProperty = new ClientModelPropertyWithMetadata(model, removed.newBuilder() + .defaultValue(discriminatorProperty.getProperty().getDefaultValue()).build(), + true); + } else if ((removed = superSetterProperties.remove(serializedDiscriminatorName)) != null) { + discriminatorProperty = new ClientModelPropertyWithMetadata(model, removed.newBuilder() + .defaultValue(discriminatorProperty.getProperty().getDefaultValue()).build(), + true); + } + } + this.hasRequiredProperties = hasRequiredProperties; this.requiredPropertiesCount = requiredProperties.size() + superRequiredProperties.size(); this.setterPropertiesCount = setterProperties.size() + superSetterProperties.size(); diff --git a/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 b/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 index bb0a06c22..8a2e843bf 100644 --- a/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 +++ b/packages/http-client-java/generator/http-client-generator-test/Generate.ps1 @@ -113,13 +113,13 @@ $generateScript = { } } -Set-Location ../../ +Set-Location (Resolve-Path (Join-Path $PSScriptRoot '..' '..')) npm install npm run build npm pack -Set-Location ./generator/http-client-generator-test +Set-Location $PSScriptRoot if (Test-Path node_modules) { diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/DiscriminatorEdgeCasesAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/DiscriminatorEdgeCasesAsyncClient.java new file mode 100644 index 000000000..5a1c5f968 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/DiscriminatorEdgeCasesAsyncClient.java @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.discriminatoredgecases; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.azure.core.util.FluxUtil; +import com.cadl.discriminatoredgecases.implementation.DiscriminatorEdgeCasesClientImpl; +import com.cadl.discriminatoredgecases.models.ChildWithAnotherDiscriminator; +import com.cadl.discriminatoredgecases.models.ChildWithRequiredPropertyAsDiscriminator; +import reactor.core.publisher.Mono; + +/** + * Initializes a new instance of the asynchronous DiscriminatorEdgeCasesClient type. + */ +@ServiceClient(builder = DiscriminatorEdgeCasesClientBuilder.class, isAsync = true) +public final class DiscriminatorEdgeCasesAsyncClient { + @Generated + private final DiscriminatorEdgeCasesClientImpl serviceClient; + + /** + * Initializes an instance of DiscriminatorEdgeCasesAsyncClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DiscriminatorEdgeCasesAsyncClient(DiscriminatorEdgeCasesClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getChildRequiredDiscrim operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     discriminator: String (Required)
+     *     aProperty: String (Required)
+     *     anotherProperty: String (Required)
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getChildRequiredDiscrimWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getChildRequiredDiscrimWithResponseAsync(requestOptions); + } + + /** + * The getChildNewDiscrim operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     discriminator: String (Required)
+     *     aProperty: String (Required)
+     *     differentDiscriminator: String (Required)
+     *     yetAnotherProperty: String (Required)
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getChildNewDiscrimWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getChildNewDiscrimWithResponseAsync(requestOptions); + } + + /** + * The getChildRequiredDiscrim operation. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getChildRequiredDiscrim() { + // Generated convenience method for getChildRequiredDiscrimWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getChildRequiredDiscrimWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ChildWithRequiredPropertyAsDiscriminator.class)); + } + + /** + * The getChildNewDiscrim operation. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getChildNewDiscrim() { + // Generated convenience method for getChildNewDiscrimWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getChildNewDiscrimWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ChildWithAnotherDiscriminator.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/DiscriminatorEdgeCasesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/DiscriminatorEdgeCasesClient.java new file mode 100644 index 000000000..3c3d67418 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/DiscriminatorEdgeCasesClient.java @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.discriminatoredgecases; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.ReturnType; +import com.azure.core.annotation.ServiceClient; +import com.azure.core.annotation.ServiceMethod; +import com.azure.core.exception.ClientAuthenticationException; +import com.azure.core.exception.HttpResponseException; +import com.azure.core.exception.ResourceModifiedException; +import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.rest.RequestOptions; +import com.azure.core.http.rest.Response; +import com.azure.core.util.BinaryData; +import com.cadl.discriminatoredgecases.implementation.DiscriminatorEdgeCasesClientImpl; +import com.cadl.discriminatoredgecases.models.ChildWithAnotherDiscriminator; +import com.cadl.discriminatoredgecases.models.ChildWithRequiredPropertyAsDiscriminator; + +/** + * Initializes a new instance of the synchronous DiscriminatorEdgeCasesClient type. + */ +@ServiceClient(builder = DiscriminatorEdgeCasesClientBuilder.class) +public final class DiscriminatorEdgeCasesClient { + @Generated + private final DiscriminatorEdgeCasesClientImpl serviceClient; + + /** + * Initializes an instance of DiscriminatorEdgeCasesClient class. + * + * @param serviceClient the service client implementation. + */ + @Generated + DiscriminatorEdgeCasesClient(DiscriminatorEdgeCasesClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getChildRequiredDiscrim operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     discriminator: String (Required)
+     *     aProperty: String (Required)
+     *     anotherProperty: String (Required)
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getChildRequiredDiscrimWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getChildRequiredDiscrimWithResponse(requestOptions); + } + + /** + * The getChildNewDiscrim operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     discriminator: String (Required)
+     *     aProperty: String (Required)
+     *     differentDiscriminator: String (Required)
+     *     yetAnotherProperty: String (Required)
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getChildNewDiscrimWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getChildNewDiscrimWithResponse(requestOptions); + } + + /** + * The getChildRequiredDiscrim operation. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ChildWithRequiredPropertyAsDiscriminator getChildRequiredDiscrim() { + // Generated convenience method for getChildRequiredDiscrimWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getChildRequiredDiscrimWithResponse(requestOptions).getValue() + .toObject(ChildWithRequiredPropertyAsDiscriminator.class); + } + + /** + * The getChildNewDiscrim operation. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ChildWithAnotherDiscriminator getChildNewDiscrim() { + // Generated convenience method for getChildNewDiscrimWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getChildNewDiscrimWithResponse(requestOptions).getValue().toObject(ChildWithAnotherDiscriminator.class); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/NamingClientBuilder.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/DiscriminatorEdgeCasesClientBuilder.java similarity index 73% rename from packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/NamingClientBuilder.java rename to packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/DiscriminatorEdgeCasesClientBuilder.java index f1c45ce59..998da21ec 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/NamingClientBuilder.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/DiscriminatorEdgeCasesClientBuilder.java @@ -2,7 +2,7 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com.cadl.naming; +package com.cadl.discriminatoredgecases; import com.azure.core.annotation.Generated; import com.azure.core.annotation.ServiceClientBuilder; @@ -31,18 +31,18 @@ import com.azure.core.util.CoreUtils; import com.azure.core.util.builder.ClientBuilderUtil; import com.azure.core.util.logging.ClientLogger; import com.azure.core.util.serializer.JacksonAdapter; -import com.cadl.naming.implementation.NamingClientImpl; +import com.cadl.discriminatoredgecases.implementation.DiscriminatorEdgeCasesClientImpl; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; /** - * A builder for creating a new instance of the NamingClient type. + * A builder for creating a new instance of the DiscriminatorEdgeCasesClient type. */ -@ServiceClientBuilder(serviceClients = { NamingClient.class, NamingAsyncClient.class }) -public final class NamingClientBuilder implements HttpTrait, - ConfigurationTrait, EndpointTrait { +@ServiceClientBuilder(serviceClients = { DiscriminatorEdgeCasesClient.class, DiscriminatorEdgeCasesAsyncClient.class }) +public final class DiscriminatorEdgeCasesClientBuilder implements HttpTrait, + ConfigurationTrait, EndpointTrait { @Generated private static final String SDK_NAME = "name"; @@ -50,16 +50,17 @@ public final class NamingClientBuilder implements HttpTrait private static final String SDK_VERSION = "version"; @Generated - private static final Map PROPERTIES = CoreUtils.getProperties("cadl-naming.properties"); + private static final Map PROPERTIES + = CoreUtils.getProperties("cadl-discriminatoredgecases.properties"); @Generated private final List pipelinePolicies; /** - * Create an instance of the NamingClientBuilder. + * Create an instance of the DiscriminatorEdgeCasesClientBuilder. */ @Generated - public NamingClientBuilder() { + public DiscriminatorEdgeCasesClientBuilder() { this.pipelinePolicies = new ArrayList<>(); } @@ -74,7 +75,7 @@ public final class NamingClientBuilder implements HttpTrait */ @Generated @Override - public NamingClientBuilder pipeline(HttpPipeline pipeline) { + public DiscriminatorEdgeCasesClientBuilder pipeline(HttpPipeline pipeline) { if (this.pipeline != null && pipeline == null) { LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); } @@ -93,7 +94,7 @@ public final class NamingClientBuilder implements HttpTrait */ @Generated @Override - public NamingClientBuilder httpClient(HttpClient httpClient) { + public DiscriminatorEdgeCasesClientBuilder httpClient(HttpClient httpClient) { this.httpClient = httpClient; return this; } @@ -109,7 +110,7 @@ public final class NamingClientBuilder implements HttpTrait */ @Generated @Override - public NamingClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + public DiscriminatorEdgeCasesClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { this.httpLogOptions = httpLogOptions; return this; } @@ -125,7 +126,7 @@ public final class NamingClientBuilder implements HttpTrait */ @Generated @Override - public NamingClientBuilder clientOptions(ClientOptions clientOptions) { + public DiscriminatorEdgeCasesClientBuilder clientOptions(ClientOptions clientOptions) { this.clientOptions = clientOptions; return this; } @@ -141,7 +142,7 @@ public final class NamingClientBuilder implements HttpTrait */ @Generated @Override - public NamingClientBuilder retryOptions(RetryOptions retryOptions) { + public DiscriminatorEdgeCasesClientBuilder retryOptions(RetryOptions retryOptions) { this.retryOptions = retryOptions; return this; } @@ -151,7 +152,7 @@ public final class NamingClientBuilder implements HttpTrait */ @Generated @Override - public NamingClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { + public DiscriminatorEdgeCasesClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); pipelinePolicies.add(customPolicy); return this; @@ -168,7 +169,7 @@ public final class NamingClientBuilder implements HttpTrait */ @Generated @Override - public NamingClientBuilder configuration(Configuration configuration) { + public DiscriminatorEdgeCasesClientBuilder configuration(Configuration configuration) { this.configuration = configuration; return this; } @@ -184,7 +185,7 @@ public final class NamingClientBuilder implements HttpTrait */ @Generated @Override - public NamingClientBuilder endpoint(String endpoint) { + public DiscriminatorEdgeCasesClientBuilder endpoint(String endpoint) { this.endpoint = endpoint; return this; } @@ -199,25 +200,25 @@ public final class NamingClientBuilder implements HttpTrait * Sets The retry policy that will attempt to retry failed requests, if applicable. * * @param retryPolicy the retryPolicy value. - * @return the NamingClientBuilder. + * @return the DiscriminatorEdgeCasesClientBuilder. */ @Generated - public NamingClientBuilder retryPolicy(RetryPolicy retryPolicy) { + public DiscriminatorEdgeCasesClientBuilder retryPolicy(RetryPolicy retryPolicy) { this.retryPolicy = retryPolicy; return this; } /** - * Builds an instance of NamingClientImpl with the provided parameters. + * Builds an instance of DiscriminatorEdgeCasesClientImpl with the provided parameters. * - * @return an instance of NamingClientImpl. + * @return an instance of DiscriminatorEdgeCasesClientImpl. */ @Generated - private NamingClientImpl buildInnerClient() { + private DiscriminatorEdgeCasesClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - NamingClientImpl client - = new NamingClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); + DiscriminatorEdgeCasesClientImpl client = new DiscriminatorEdgeCasesClientImpl(localPipeline, + JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint); return client; } @@ -264,24 +265,24 @@ public final class NamingClientBuilder implements HttpTrait } /** - * Builds an instance of NamingAsyncClient class. + * Builds an instance of DiscriminatorEdgeCasesAsyncClient class. * - * @return an instance of NamingAsyncClient. + * @return an instance of DiscriminatorEdgeCasesAsyncClient. */ @Generated - public NamingAsyncClient buildAsyncClient() { - return new NamingAsyncClient(buildInnerClient().getNamingOps()); + public DiscriminatorEdgeCasesAsyncClient buildAsyncClient() { + return new DiscriminatorEdgeCasesAsyncClient(buildInnerClient()); } /** - * Builds an instance of NamingClient class. + * Builds an instance of DiscriminatorEdgeCasesClient class. * - * @return an instance of NamingClient. + * @return an instance of DiscriminatorEdgeCasesClient. */ @Generated - public NamingClient buildClient() { - return new NamingClient(buildInnerClient().getNamingOps()); + public DiscriminatorEdgeCasesClient buildClient() { + return new DiscriminatorEdgeCasesClient(buildInnerClient()); } - private static final ClientLogger LOGGER = new ClientLogger(NamingClientBuilder.class); + private static final ClientLogger LOGGER = new ClientLogger(DiscriminatorEdgeCasesClientBuilder.class); } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/implementation/NamingOpsImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/implementation/DiscriminatorEdgeCasesClientImpl.java similarity index 51% rename from packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/implementation/NamingOpsImpl.java rename to packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/implementation/DiscriminatorEdgeCasesClientImpl.java index 5ec21c69f..06e355a19 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/implementation/NamingOpsImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/implementation/DiscriminatorEdgeCasesClientImpl.java @@ -2,16 +2,13 @@ // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. -package com.cadl.naming.implementation; +package com.cadl.discriminatoredgecases.implementation; -import com.azure.core.annotation.BodyParam; import com.azure.core.annotation.ExpectedResponses; import com.azure.core.annotation.Get; import com.azure.core.annotation.HeaderParam; import com.azure.core.annotation.Host; import com.azure.core.annotation.HostParam; -import com.azure.core.annotation.Post; -import com.azure.core.annotation.QueryParam; import com.azure.core.annotation.ReturnType; import com.azure.core.annotation.ServiceInterface; import com.azure.core.annotation.ServiceMethod; @@ -20,217 +17,160 @@ import com.azure.core.exception.ClientAuthenticationException; import com.azure.core.exception.HttpResponseException; import com.azure.core.exception.ResourceModifiedException; import com.azure.core.exception.ResourceNotFoundException; +import com.azure.core.http.HttpPipeline; +import com.azure.core.http.HttpPipelineBuilder; +import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.http.policy.UserAgentPolicy; import com.azure.core.http.rest.RequestOptions; import com.azure.core.http.rest.Response; import com.azure.core.http.rest.RestProxy; import com.azure.core.util.BinaryData; import com.azure.core.util.Context; import com.azure.core.util.FluxUtil; +import com.azure.core.util.serializer.JacksonAdapter; +import com.azure.core.util.serializer.SerializerAdapter; import reactor.core.publisher.Mono; /** - * An instance of this class provides access to all the operations defined in NamingOps. + * Initializes a new instance of the DiscriminatorEdgeCasesClient type. */ -public final class NamingOpsImpl { +public final class DiscriminatorEdgeCasesClientImpl { /** * The proxy service used to perform REST calls. */ - private final NamingOpsService service; + private final DiscriminatorEdgeCasesClientService service; /** - * The service client containing this operation class. + * Service host. */ - private final NamingClientImpl client; + private final String endpoint; /** - * Initializes an instance of NamingOpsImpl. + * Gets Service host. * - * @param client the instance of the service client containing this operation class. + * @return the endpoint value. */ - NamingOpsImpl(NamingClientImpl client) { - this.service - = RestProxy.create(NamingOpsService.class, client.getHttpPipeline(), client.getSerializerAdapter()); - this.client = client; + public String getEndpoint() { + return this.endpoint; } /** - * The interface defining all the services for NamingClientNamingOps to be used by the proxy service to perform REST - * calls. + * The HTTP pipeline to send requests through. + */ + private final HttpPipeline httpPipeline; + + /** + * Gets The HTTP pipeline to send requests through. + * + * @return the httpPipeline value. + */ + public HttpPipeline getHttpPipeline() { + return this.httpPipeline; + } + + /** + * The serializer to serialize an object into a string. + */ + private final SerializerAdapter serializerAdapter; + + /** + * Gets The serializer to serialize an object into a string. + * + * @return the serializerAdapter value. + */ + public SerializerAdapter getSerializerAdapter() { + return this.serializerAdapter; + } + + /** + * Initializes an instance of DiscriminatorEdgeCasesClient client. + * + * @param endpoint Service host. + */ + public DiscriminatorEdgeCasesClientImpl(String endpoint) { + this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), + JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of DiscriminatorEdgeCasesClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public DiscriminatorEdgeCasesClientImpl(HttpPipeline httpPipeline, String endpoint) { + this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint); + } + + /** + * Initializes an instance of DiscriminatorEdgeCasesClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param serializerAdapter The serializer to serialize an object into a string. + * @param endpoint Service host. + */ + public DiscriminatorEdgeCasesClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, + String endpoint) { + this.httpPipeline = httpPipeline; + this.serializerAdapter = serializerAdapter; + this.endpoint = endpoint; + this.service = RestProxy.create(DiscriminatorEdgeCasesClientService.class, this.httpPipeline, + this.getSerializerAdapter()); + } + + /** + * The interface defining all the services for DiscriminatorEdgeCasesClient to be used by the proxy service to + * perform REST calls. */ @Host("{endpoint}") - @ServiceInterface(name = "NamingClientNamingOp") - public interface NamingOpsService { - @Post("/naming") + @ServiceInterface(name = "DiscriminatorEdgeCas") + public interface DiscriminatorEdgeCasesClientService { + @Get("/model/childrequireddiscrim") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> post(@HostParam("endpoint") String endpoint, @QueryParam("name") String name, - @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); - - @Post("/naming") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Response postSync(@HostParam("endpoint") String endpoint, @QueryParam("name") String name, - @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, - @BodyParam("application/json") BinaryData body, RequestOptions requestOptions, Context context); - - @Get("/naming") - @ExpectedResponses({ 200 }) - @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) - @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) - @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) - @UnexpectedResponseExceptionType(HttpResponseException.class) - Mono> getAnonymous(@HostParam("endpoint") String endpoint, + Mono> getChildRequiredDiscrim(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); - @Get("/naming") + @Get("/model/childrequireddiscrim") @ExpectedResponses({ 200 }) @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) @UnexpectedResponseExceptionType(HttpResponseException.class) - Response getAnonymousSync(@HostParam("endpoint") String endpoint, + Response getChildRequiredDiscrimSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/model/childnewdiscrim") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getChildNewDiscrim(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/model/childnewdiscrim") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getChildNewDiscrimSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } /** - * summary of POST op - * - * description of POST op. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
etagStringNosummary of etag header parameter - * - * description of etag header parameter
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
{@code
-     * {
-     *     parameters (Optional): {
-     *         type: String(Type1/Type2) (Required)
-     *     }
-     * }
-     * }
- * + * The getChildRequiredDiscrim operation. *

Response Body Schema

* *
{@code
      * {
-     *     name: String (Required)
-     *     data (Required): {
-     *         data (Required): {
-     *             @data.kind: String (Required)
-     *         }
-     *     }
-     *     type: String(Blob/File) (Required)
-     *     status: String(Running/Completed/Failed) (Required)
-     *     anonymous (Required): {
-     *         last_error (Required): {
-     *             code: String(server_error/rate_limit_exceeded/invalid_prompt) (Required)
-     *         }
-     *     }
-     * }
-     * }
- * - * @param name summary of name query parameter - * - * description of name query parameter. - * @param body The body parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return summary of Response along with {@link Response} on successful completion of {@link Mono}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> postWithResponseAsync(String name, BinaryData body, - RequestOptions requestOptions) { - final String contentType = "application/json"; - final String accept = "application/json"; - return FluxUtil.withContext(context -> service.post(this.client.getEndpoint(), name, contentType, accept, body, - requestOptions, context)); - } - - /** - * summary of POST op - * - * description of POST op. - *

Header Parameters

- * - * - * - * - *
Header Parameters
NameTypeRequiredDescription
etagStringNosummary of etag header parameter - * - * description of etag header parameter
- * You can add these to a request with {@link RequestOptions#addHeader} - *

Request Body Schema

- * - *
{@code
-     * {
-     *     parameters (Optional): {
-     *         type: String(Type1/Type2) (Required)
-     *     }
-     * }
-     * }
- * - *

Response Body Schema

- * - *
{@code
-     * {
-     *     name: String (Required)
-     *     data (Required): {
-     *         data (Required): {
-     *             @data.kind: String (Required)
-     *         }
-     *     }
-     *     type: String(Blob/File) (Required)
-     *     status: String(Running/Completed/Failed) (Required)
-     *     anonymous (Required): {
-     *         last_error (Required): {
-     *             code: String(server_error/rate_limit_exceeded/invalid_prompt) (Required)
-     *         }
-     *     }
-     * }
-     * }
- * - * @param name summary of name query parameter - * - * description of name query parameter. - * @param body The body parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return summary of Response along with {@link Response}. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response postWithResponse(String name, BinaryData body, RequestOptions requestOptions) { - final String contentType = "application/json"; - final String accept = "application/json"; - return service.postSync(this.client.getEndpoint(), name, contentType, accept, body, requestOptions, - Context.NONE); - } - - /** - * The getAnonymous operation. - *

Response Body Schema

- * - *
{@code
-     * {
-     *     name: String (Required)
+     *     discriminator: String (Required)
+     *     aProperty: String (Required)
+     *     anotherProperty: String (Required)
      * }
      * }
* @@ -242,19 +182,21 @@ public final class NamingOpsImpl { * @return the response body along with {@link Response} on successful completion of {@link Mono}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> getAnonymousWithResponseAsync(RequestOptions requestOptions) { + public Mono> getChildRequiredDiscrimWithResponseAsync(RequestOptions requestOptions) { final String accept = "application/json"; - return FluxUtil - .withContext(context -> service.getAnonymous(this.client.getEndpoint(), accept, requestOptions, context)); + return FluxUtil.withContext( + context -> service.getChildRequiredDiscrim(this.getEndpoint(), accept, requestOptions, context)); } /** - * The getAnonymous operation. + * The getChildRequiredDiscrim operation. *

Response Body Schema

* *
{@code
      * {
-     *     name: String (Required)
+     *     discriminator: String (Required)
+     *     aProperty: String (Required)
+     *     anotherProperty: String (Required)
      * }
      * }
* @@ -266,8 +208,61 @@ public final class NamingOpsImpl { * @return the response body along with {@link Response}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response getAnonymousWithResponse(RequestOptions requestOptions) { + public Response getChildRequiredDiscrimWithResponse(RequestOptions requestOptions) { final String accept = "application/json"; - return service.getAnonymousSync(this.client.getEndpoint(), accept, requestOptions, Context.NONE); + return service.getChildRequiredDiscrimSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } + + /** + * The getChildNewDiscrim operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     discriminator: String (Required)
+     *     aProperty: String (Required)
+     *     differentDiscriminator: String (Required)
+     *     yetAnotherProperty: String (Required)
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getChildNewDiscrimWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getChildNewDiscrim(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getChildNewDiscrim operation. + *

Response Body Schema

+ * + *
{@code
+     * {
+     *     discriminator: String (Required)
+     *     aProperty: String (Required)
+     *     differentDiscriminator: String (Required)
+     *     yetAnotherProperty: String (Required)
+     * }
+     * }
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getChildNewDiscrimWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getChildNewDiscrimSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/implementation/package-info.java similarity index 64% rename from packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/implementation/package-info.java rename to packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/implementation/package-info.java index e39e9cae6..07841affa 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/implementation/package-info.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/implementation/package-info.java @@ -4,8 +4,7 @@ /** * - * Package containing the implementations for Naming. - * description of Naming. + * Package containing the implementations for DiscriminatorEdgeCases. * */ -package com.cadl.naming.implementation; +package com.cadl.discriminatoredgecases.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/ChildWithAnotherDiscriminator.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/ChildWithAnotherDiscriminator.java new file mode 100644 index 000000000..dd853c326 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/ChildWithAnotherDiscriminator.java @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.discriminatoredgecases.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The ChildWithAnotherDiscriminator model. + */ +@Immutable +public class ChildWithAnotherDiscriminator extends ParentWithRequiredProperty { + /* + * Discriminator property for ChildWithAnotherDiscriminator. + */ + @Generated + private String differentDiscriminator = "ChildWithAnotherDiscriminator"; + + /* + * The yetAnotherProperty property. + */ + @Generated + private final String yetAnotherProperty; + + /** + * Creates an instance of ChildWithAnotherDiscriminator class. + * + * @param discriminator the discriminator value to set. + * @param aProperty the aProperty value to set. + * @param yetAnotherProperty the yetAnotherProperty value to set. + */ + @Generated + protected ChildWithAnotherDiscriminator(String discriminator, String aProperty, String yetAnotherProperty) { + super(discriminator, aProperty); + this.yetAnotherProperty = yetAnotherProperty; + } + + /** + * Get the differentDiscriminator property: Discriminator property for ChildWithAnotherDiscriminator. + * + * @return the differentDiscriminator value. + */ + @Generated + public String getDifferentDiscriminator() { + return this.differentDiscriminator; + } + + /** + * Get the yetAnotherProperty property: The yetAnotherProperty property. + * + * @return the yetAnotherProperty value. + */ + @Generated + public String getYetAnotherProperty() { + return this.yetAnotherProperty; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("discriminator", getDiscriminator()); + jsonWriter.writeStringField("aProperty", getAProperty()); + jsonWriter.writeStringField("yetAnotherProperty", this.yetAnotherProperty); + jsonWriter.writeStringField("differentDiscriminator", this.differentDiscriminator); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ChildWithAnotherDiscriminator from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ChildWithAnotherDiscriminator if the JsonReader was pointing to an instance of it, or null + * if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ChildWithAnotherDiscriminator. + */ + @Generated + public static ChildWithAnotherDiscriminator fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("differentDiscriminator".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("anotherValue".equals(discriminatorValue)) { + return GrandChildWithAnotherDiscriminator.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static ChildWithAnotherDiscriminator fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminator = null; + String aProperty = null; + String yetAnotherProperty = null; + String differentDiscriminator = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("discriminator".equals(fieldName)) { + discriminator = reader.getString(); + } else if ("aProperty".equals(fieldName)) { + aProperty = reader.getString(); + } else if ("yetAnotherProperty".equals(fieldName)) { + yetAnotherProperty = reader.getString(); + } else if ("differentDiscriminator".equals(fieldName)) { + differentDiscriminator = reader.getString(); + } else { + reader.skipChildren(); + } + } + ChildWithAnotherDiscriminator deserializedChildWithAnotherDiscriminator + = new ChildWithAnotherDiscriminator(discriminator, aProperty, yetAnotherProperty); + deserializedChildWithAnotherDiscriminator.differentDiscriminator = differentDiscriminator; + + return deserializedChildWithAnotherDiscriminator; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/ChildWithRequiredPropertyAsDiscriminator.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/ChildWithRequiredPropertyAsDiscriminator.java new file mode 100644 index 000000000..5f9f0c142 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/ChildWithRequiredPropertyAsDiscriminator.java @@ -0,0 +1,141 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.discriminatoredgecases.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The ChildWithRequiredPropertyAsDiscriminator model. + */ +@Immutable +public class ChildWithRequiredPropertyAsDiscriminator extends ParentWithRequiredProperty { + /* + * Discriminator property for ChildWithRequiredPropertyAsDiscriminator. + */ + @Generated + private String discriminator = "ChildWithRequiredPropertyAsDiscriminator"; + + /* + * The anotherProperty property. + */ + @Generated + private final String anotherProperty; + + /** + * Creates an instance of ChildWithRequiredPropertyAsDiscriminator class. + * + * @param discriminator the discriminator value to set. + * @param aProperty the aProperty value to set. + * @param anotherProperty the anotherProperty value to set. + */ + @Generated + protected ChildWithRequiredPropertyAsDiscriminator(String discriminator, String aProperty, String anotherProperty) { + super(discriminator, aProperty); + this.anotherProperty = anotherProperty; + } + + /** + * Get the discriminator property: Discriminator property for ChildWithRequiredPropertyAsDiscriminator. + * + * @return the discriminator value. + */ + @Generated + @Override + public String getDiscriminator() { + return this.discriminator; + } + + /** + * Get the anotherProperty property: The anotherProperty property. + * + * @return the anotherProperty value. + */ + @Generated + public String getAnotherProperty() { + return this.anotherProperty; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("aProperty", getAProperty()); + jsonWriter.writeStringField("anotherProperty", this.anotherProperty); + jsonWriter.writeStringField("discriminator", this.discriminator); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ChildWithRequiredPropertyAsDiscriminator from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ChildWithRequiredPropertyAsDiscriminator if the JsonReader was pointing to an instance of + * it, or null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ChildWithRequiredPropertyAsDiscriminator. + */ + @Generated + public static ChildWithRequiredPropertyAsDiscriminator fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminatorValue = null; + try (JsonReader readerToUse = reader.bufferObject()) { + readerToUse.nextToken(); // Prepare for reading + while (readerToUse.nextToken() != JsonToken.END_OBJECT) { + String fieldName = readerToUse.getFieldName(); + readerToUse.nextToken(); + if ("discriminator".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("aValue".equals(discriminatorValue)) { + return GrandChildWithRequiredProperty.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Generated + static ChildWithRequiredPropertyAsDiscriminator fromJsonKnownDiscriminator(JsonReader jsonReader) + throws IOException { + return jsonReader.readObject(reader -> { + String aProperty = null; + String anotherProperty = null; + String discriminator = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("aProperty".equals(fieldName)) { + aProperty = reader.getString(); + } else if ("anotherProperty".equals(fieldName)) { + anotherProperty = reader.getString(); + } else if ("discriminator".equals(fieldName)) { + discriminator = reader.getString(); + } else { + reader.skipChildren(); + } + } + ChildWithRequiredPropertyAsDiscriminator deserializedChildWithRequiredPropertyAsDiscriminator + = new ChildWithRequiredPropertyAsDiscriminator(discriminator, aProperty, anotherProperty); + deserializedChildWithRequiredPropertyAsDiscriminator.discriminator = discriminator; + + return deserializedChildWithRequiredPropertyAsDiscriminator; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/GrandChildWithAnotherDiscriminator.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/GrandChildWithAnotherDiscriminator.java new file mode 100644 index 000000000..8cef091a0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/GrandChildWithAnotherDiscriminator.java @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.discriminatoredgecases.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The GrandChildWithAnotherDiscriminator model. + */ +@Immutable +public final class GrandChildWithAnotherDiscriminator extends ChildWithAnotherDiscriminator { + /* + * Discriminator property for ChildWithAnotherDiscriminator. + */ + @Generated + private String differentDiscriminator = "anotherValue"; + + /** + * Creates an instance of GrandChildWithAnotherDiscriminator class. + * + * @param discriminator the discriminator value to set. + * @param aProperty the aProperty value to set. + * @param yetAnotherProperty the yetAnotherProperty value to set. + */ + @Generated + private GrandChildWithAnotherDiscriminator(String discriminator, String aProperty, String yetAnotherProperty) { + super(discriminator, aProperty, yetAnotherProperty); + } + + /** + * Get the differentDiscriminator property: Discriminator property for ChildWithAnotherDiscriminator. + * + * @return the differentDiscriminator value. + */ + @Generated + @Override + public String getDifferentDiscriminator() { + return this.differentDiscriminator; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("discriminator", getDiscriminator()); + jsonWriter.writeStringField("aProperty", getAProperty()); + jsonWriter.writeStringField("yetAnotherProperty", getYetAnotherProperty()); + jsonWriter.writeStringField("differentDiscriminator", this.differentDiscriminator); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GrandChildWithAnotherDiscriminator from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GrandChildWithAnotherDiscriminator if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the GrandChildWithAnotherDiscriminator. + */ + @Generated + public static GrandChildWithAnotherDiscriminator fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminator = null; + String aProperty = null; + String yetAnotherProperty = null; + String differentDiscriminator = "anotherValue"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("discriminator".equals(fieldName)) { + discriminator = reader.getString(); + } else if ("aProperty".equals(fieldName)) { + aProperty = reader.getString(); + } else if ("yetAnotherProperty".equals(fieldName)) { + yetAnotherProperty = reader.getString(); + } else if ("differentDiscriminator".equals(fieldName)) { + differentDiscriminator = reader.getString(); + } else { + reader.skipChildren(); + } + } + GrandChildWithAnotherDiscriminator deserializedGrandChildWithAnotherDiscriminator + = new GrandChildWithAnotherDiscriminator(discriminator, aProperty, yetAnotherProperty); + deserializedGrandChildWithAnotherDiscriminator.differentDiscriminator = differentDiscriminator; + + return deserializedGrandChildWithAnotherDiscriminator; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/GrandChildWithRequiredProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/GrandChildWithRequiredProperty.java new file mode 100644 index 000000000..63c0f8779 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/GrandChildWithRequiredProperty.java @@ -0,0 +1,97 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.discriminatoredgecases.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The GrandChildWithRequiredProperty model. + */ +@Immutable +public final class GrandChildWithRequiredProperty extends ChildWithRequiredPropertyAsDiscriminator { + /* + * Discriminator property for ChildWithRequiredPropertyAsDiscriminator. + */ + @Generated + private String discriminator = "aValue"; + + /** + * Creates an instance of GrandChildWithRequiredProperty class. + * + * @param discriminator the discriminator value to set. + * @param aProperty the aProperty value to set. + * @param anotherProperty the anotherProperty value to set. + */ + @Generated + private GrandChildWithRequiredProperty(String discriminator, String aProperty, String anotherProperty) { + super(discriminator, aProperty, anotherProperty); + } + + /** + * Get the discriminator property: Discriminator property for ChildWithRequiredPropertyAsDiscriminator. + * + * @return the discriminator value. + */ + @Generated + @Override + public String getDiscriminator() { + return this.discriminator; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("aProperty", getAProperty()); + jsonWriter.writeStringField("anotherProperty", getAnotherProperty()); + jsonWriter.writeStringField("discriminator", this.discriminator); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GrandChildWithRequiredProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GrandChildWithRequiredProperty if the JsonReader was pointing to an instance of it, or + * null if it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the GrandChildWithRequiredProperty. + */ + @Generated + public static GrandChildWithRequiredProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String aProperty = null; + String anotherProperty = null; + String discriminator = "aValue"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("aProperty".equals(fieldName)) { + aProperty = reader.getString(); + } else if ("anotherProperty".equals(fieldName)) { + anotherProperty = reader.getString(); + } else if ("discriminator".equals(fieldName)) { + discriminator = reader.getString(); + } else { + reader.skipChildren(); + } + } + GrandChildWithRequiredProperty deserializedGrandChildWithRequiredProperty + = new GrandChildWithRequiredProperty(discriminator, aProperty, anotherProperty); + deserializedGrandChildWithRequiredProperty.discriminator = discriminator; + + return deserializedGrandChildWithRequiredProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/ParentWithRequiredProperty.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/ParentWithRequiredProperty.java new file mode 100644 index 000000000..baa0d41c5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/ParentWithRequiredProperty.java @@ -0,0 +1,105 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.discriminatoredgecases.models; + +import com.azure.core.annotation.Generated; +import com.azure.core.annotation.Immutable; +import com.azure.json.JsonReader; +import com.azure.json.JsonSerializable; +import com.azure.json.JsonToken; +import com.azure.json.JsonWriter; +import java.io.IOException; + +/** + * The ParentWithRequiredProperty model. + */ +@Immutable +public class ParentWithRequiredProperty implements JsonSerializable { + /* + * The discriminator property. + */ + @Generated + private final String discriminator; + + /* + * The aProperty property. + */ + @Generated + private final String aProperty; + + /** + * Creates an instance of ParentWithRequiredProperty class. + * + * @param discriminator the discriminator value to set. + * @param aProperty the aProperty value to set. + */ + @Generated + protected ParentWithRequiredProperty(String discriminator, String aProperty) { + this.discriminator = discriminator; + this.aProperty = aProperty; + } + + /** + * Get the discriminator property: The discriminator property. + * + * @return the discriminator value. + */ + @Generated + public String getDiscriminator() { + return this.discriminator; + } + + /** + * Get the aProperty property: The aProperty property. + * + * @return the aProperty value. + */ + @Generated + public String getAProperty() { + return this.aProperty; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("discriminator", this.discriminator); + jsonWriter.writeStringField("aProperty", this.aProperty); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ParentWithRequiredProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ParentWithRequiredProperty if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. + * @throws IOException If an error occurs while reading the ParentWithRequiredProperty. + */ + @Generated + public static ParentWithRequiredProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String discriminator = null; + String aProperty = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("discriminator".equals(fieldName)) { + discriminator = reader.getString(); + } else if ("aProperty".equals(fieldName)) { + aProperty = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ParentWithRequiredProperty(discriminator, aProperty); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/package-info.java similarity index 66% rename from packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/package-info.java rename to packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/package-info.java index 41c730326..f4ec6f237 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/models/package-info.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/models/package-info.java @@ -4,8 +4,7 @@ /** * - * Package containing the data models for Naming. - * description of Naming. + * Package containing the data models for DiscriminatorEdgeCases. * */ -package com.cadl.naming.models; +package com.cadl.discriminatoredgecases.models; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/package-info.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/package-info.java similarity index 68% rename from packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/package-info.java rename to packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/package-info.java index 12cf7f737..4405d8689 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/naming/package-info.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/com/cadl/discriminatoredgecases/package-info.java @@ -4,8 +4,7 @@ /** * - * Package containing the classes for Naming. - * description of Naming. + * Package containing the classes for DiscriminatorEdgeCases. * */ -package com.cadl.naming; +package com.cadl.discriminatoredgecases; diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-discriminatoredgecases_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-discriminatoredgecases_apiview_properties.json new file mode 100644 index 000000000..f5c21d5f0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/cadl-discriminatoredgecases_apiview_properties.json @@ -0,0 +1,21 @@ +{ + "flavor": "Azure", + "CrossLanguageDefinitionId": { + "com.cadl.discriminatoredgecases.DiscriminatorEdgeCasesAsyncClient": "Cadl.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp", + "com.cadl.discriminatoredgecases.DiscriminatorEdgeCasesAsyncClient.getChildNewDiscrim": "Cadl.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildNewDiscrim", + "com.cadl.discriminatoredgecases.DiscriminatorEdgeCasesAsyncClient.getChildNewDiscrimWithResponse": "Cadl.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildNewDiscrim", + "com.cadl.discriminatoredgecases.DiscriminatorEdgeCasesAsyncClient.getChildRequiredDiscrim": "Cadl.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildRequiredDiscrim", + "com.cadl.discriminatoredgecases.DiscriminatorEdgeCasesAsyncClient.getChildRequiredDiscrimWithResponse": "Cadl.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildRequiredDiscrim", + "com.cadl.discriminatoredgecases.DiscriminatorEdgeCasesClient": "Cadl.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp", + "com.cadl.discriminatoredgecases.DiscriminatorEdgeCasesClient.getChildNewDiscrim": "Cadl.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildNewDiscrim", + "com.cadl.discriminatoredgecases.DiscriminatorEdgeCasesClient.getChildNewDiscrimWithResponse": "Cadl.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildNewDiscrim", + "com.cadl.discriminatoredgecases.DiscriminatorEdgeCasesClient.getChildRequiredDiscrim": "Cadl.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildRequiredDiscrim", + "com.cadl.discriminatoredgecases.DiscriminatorEdgeCasesClient.getChildRequiredDiscrimWithResponse": "Cadl.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildRequiredDiscrim", + "com.cadl.discriminatoredgecases.DiscriminatorEdgeCasesClientBuilder": "Cadl.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp", + "com.cadl.discriminatoredgecases.models.ChildWithAnotherDiscriminator": "Cadl.DiscriminatorEdgeCases.ChildWithAnotherDiscriminator", + "com.cadl.discriminatoredgecases.models.ChildWithRequiredPropertyAsDiscriminator": "Cadl.DiscriminatorEdgeCases.ChildWithRequiredPropertyAsDiscriminator", + "com.cadl.discriminatoredgecases.models.GrandChildWithAnotherDiscriminator": "Cadl.DiscriminatorEdgeCases.GrandChildWithAnotherDiscriminator", + "com.cadl.discriminatoredgecases.models.GrandChildWithRequiredProperty": "Cadl.DiscriminatorEdgeCases.GrandChildWithRequiredProperty", + "com.cadl.discriminatoredgecases.models.ParentWithRequiredProperty": "Cadl.DiscriminatorEdgeCases.ParentWithRequiredProperty" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-naming.properties b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-discriminatoredgecases.properties similarity index 100% rename from packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-naming.properties rename to packages/http-client-java/generator/http-client-generator-test/src/main/resources/cadl-discriminatoredgecases.properties diff --git a/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/discriminatoredgecases/generated/DiscriminatorEdgeCasesClientTestBase.java b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/discriminatoredgecases/generated/DiscriminatorEdgeCasesClientTestBase.java new file mode 100644 index 000000000..440b20306 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/test/java/com/cadl/discriminatoredgecases/generated/DiscriminatorEdgeCasesClientTestBase.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package com.cadl.discriminatoredgecases.generated; + +// The Java test files under 'generated' package are generated for your reference. +// If you wish to modify these files, please copy them out of the 'generated' package, and modify there. +// See https://aka.ms/azsdk/dpg/java/tests for guide on adding a test. + +import com.azure.core.http.HttpClient; +import com.azure.core.http.policy.HttpLogDetailLevel; +import com.azure.core.http.policy.HttpLogOptions; +import com.azure.core.test.TestMode; +import com.azure.core.test.TestProxyTestBase; +import com.azure.core.util.Configuration; +import com.cadl.discriminatoredgecases.DiscriminatorEdgeCasesClient; +import com.cadl.discriminatoredgecases.DiscriminatorEdgeCasesClientBuilder; + +class DiscriminatorEdgeCasesClientTestBase extends TestProxyTestBase { + protected DiscriminatorEdgeCasesClient discriminatorEdgeCasesClient; + + @Override + protected void beforeTest() { + DiscriminatorEdgeCasesClientBuilder discriminatorEdgeCasesClientbuilder + = new DiscriminatorEdgeCasesClientBuilder() + .endpoint(Configuration.getGlobalConfiguration().get("ENDPOINT", "endpoint")) + .httpClient(HttpClient.createDefault()) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BASIC)); + if (getTestMode() == TestMode.PLAYBACK) { + discriminatorEdgeCasesClientbuilder.httpClient(interceptorManager.getPlaybackClient()); + } else if (getTestMode() == TestMode.RECORD) { + discriminatorEdgeCasesClientbuilder.addPolicy(interceptorManager.getRecordPolicy()); + } + discriminatorEdgeCasesClient = discriminatorEdgeCasesClientbuilder.buildClient(); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/tsp/discriminator-edge-cases.tsp b/packages/http-client-java/generator/http-client-generator-test/tsp/discriminator-edge-cases.tsp new file mode 100644 index 000000000..bff3f2f6f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/tsp/discriminator-edge-cases.tsp @@ -0,0 +1,54 @@ +import "@typespec/rest"; +import "@azure-tools/typespec-azure-core"; +import "@azure-tools/typespec-client-generator-core"; + +using TypeSpec.Http; +using Azure.Core; +using Azure.ClientGenerator.Core; + +@service({ + title: "DiscriminatorEdgeCases", +}) +namespace Cadl.DiscriminatorEdgeCases; + +model ParentWithRequiredProperty { + discriminator: string; + aProperty: string; +} + +@discriminator("discriminator") +model ChildWithRequiredPropertyAsDiscriminator extends ParentWithRequiredProperty { + anotherProperty: string; +} + +@discriminator("differentDiscriminator") +model ChildWithAnotherDiscriminator extends ParentWithRequiredProperty { + yetAnotherProperty: string; +} + +model GrandChildWithRequiredProperty extends ChildWithRequiredPropertyAsDiscriminator { + discriminator: "aValue"; +} + +model GrandChildWithAnotherDiscriminator extends ChildWithAnotherDiscriminator { + differentDiscriminator: "anotherValue"; +} + +@client({ + service: Cadl.DiscriminatorEdgeCases, + name: "DiscriminatorEdgeCasesClient", +}) +@route("/model") +interface DiscriminatorEdgeCasesOp { + @get + @route("/childrequireddiscrim") + getChildRequiredDiscrim(): { + @body body: ChildWithRequiredPropertyAsDiscriminator; + }; + + @get + @route("/childnewdiscrim") + getChildNewDiscrim(): { + @body body: ChildWithAnotherDiscriminator; + }; +} diff --git a/packages/http-client-java/generator/http-client-generator/pom.xml b/packages/http-client-java/generator/http-client-generator/pom.xml index 971ee12c0..3bd279843 100644 --- a/packages/http-client-java/generator/http-client-generator/pom.xml +++ b/packages/http-client-java/generator/http-client-generator/pom.xml @@ -65,6 +65,7 @@ ${shade.finalName} true + false ${shade.mainClass}