diff --git a/.chronus/changes/java_fix_discriminator_no_subtypes-2026-2-18-19-29-57.md b/.chronus/changes/java_fix_discriminator_no_subtypes-2026-2-18-19-29-57.md new file mode 100644 index 00000000000..4315f4697d3 --- /dev/null +++ b/.chronus/changes/java_fix_discriminator_no_subtypes-2026-2-18-19-29-57.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/http-client-java" +--- + +Fix discriminator property not generated when model has @discriminator but no known subtypes \ No newline at end of file diff --git a/packages/http-client-java/emitter/src/code-model-builder.ts b/packages/http-client-java/emitter/src/code-model-builder.ts index d7af84fcafd..6f66921e0fa 100644 --- a/packages/http-client-java/emitter/src/code-model-builder.ts +++ b/packages/http-client-java/emitter/src/code-model-builder.ts @@ -2829,13 +2829,15 @@ export class CodeModelBuilder { } // discriminator - if (type.discriminatedSubtypes && type.discriminatorProperty) { + if (type.discriminatorProperty) { objectSchema.discriminator = new Discriminator( this.processModelProperty(type.discriminatorProperty), ); - for (const discriminatorValue in type.discriminatedSubtypes) { - const subType = type.discriminatedSubtypes[discriminatorValue]; - this.processSchema(subType, subType.name); + if (type.discriminatedSubtypes) { + for (const discriminatorValue in type.discriminatedSubtypes) { + const subType = type.discriminatedSubtypes[discriminatorValue]; + this.processSchema(subType, subType.name); + } } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/discriminatoredgecases/DiscriminatorEdgeCasesAsyncClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/discriminatoredgecases/DiscriminatorEdgeCasesAsyncClient.java index e73463da429..615aa6128a5 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/discriminatoredgecases/DiscriminatorEdgeCasesAsyncClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/discriminatoredgecases/DiscriminatorEdgeCasesAsyncClient.java @@ -20,6 +20,7 @@ import tsptest.discriminatoredgecases.implementation.DiscriminatorEdgeCasesClientImpl; import tsptest.discriminatoredgecases.models.ChildWithAnotherDiscriminator; import tsptest.discriminatoredgecases.models.ChildWithRequiredPropertyAsDiscriminator; +import tsptest.discriminatoredgecases.models.ModelWithDiscriminatorNoSubtypes; /** * Initializes a new instance of the asynchronous DiscriminatorEdgeCasesClient type. @@ -94,6 +95,32 @@ public Mono> getChildNewDiscrimWithResponse(RequestOptions return this.serviceClient.getChildNewDiscrimWithResponseAsync(requestOptions); } + /** + * The getNoSubtypes operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     name: 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 model with along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNoSubtypesWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNoSubtypesWithResponseAsync(requestOptions); + } + /** * The getChildRequiredDiscrim operation. * @@ -131,4 +158,23 @@ public Mono getChildNewDiscrim() { return getChildNewDiscrimWithResponse(requestOptions).flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(ChildWithAnotherDiscriminator.class)); } + + /** + * The getNoSubtypes 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 model with on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getNoSubtypes() { + // Generated convenience method for getNoSubtypesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNoSubtypesWithResponse(requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(ModelWithDiscriminatorNoSubtypes.class)); + } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/discriminatoredgecases/DiscriminatorEdgeCasesClient.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/discriminatoredgecases/DiscriminatorEdgeCasesClient.java index 1ffb3e582e3..81006ef04e8 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/discriminatoredgecases/DiscriminatorEdgeCasesClient.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/discriminatoredgecases/DiscriminatorEdgeCasesClient.java @@ -18,6 +18,7 @@ import tsptest.discriminatoredgecases.implementation.DiscriminatorEdgeCasesClientImpl; import tsptest.discriminatoredgecases.models.ChildWithAnotherDiscriminator; import tsptest.discriminatoredgecases.models.ChildWithRequiredPropertyAsDiscriminator; +import tsptest.discriminatoredgecases.models.ModelWithDiscriminatorNoSubtypes; /** * Initializes a new instance of the synchronous DiscriminatorEdgeCasesClient type. @@ -92,6 +93,32 @@ public Response getChildNewDiscrimWithResponse(RequestOptions reques return this.serviceClient.getChildNewDiscrimWithResponse(requestOptions); } + /** + * The getNoSubtypes operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     name: 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 model with along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNoSubtypesWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNoSubtypesWithResponse(requestOptions); + } + /** * The getChildRequiredDiscrim operation. * @@ -128,4 +155,22 @@ public ChildWithAnotherDiscriminator getChildNewDiscrim() { RequestOptions requestOptions = new RequestOptions(); return getChildNewDiscrimWithResponse(requestOptions).getValue().toObject(ChildWithAnotherDiscriminator.class); } + + /** + * The getNoSubtypes 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 model with. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ModelWithDiscriminatorNoSubtypes getNoSubtypes() { + // Generated convenience method for getNoSubtypesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNoSubtypesWithResponse(requestOptions).getValue().toObject(ModelWithDiscriminatorNoSubtypes.class); + } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/discriminatoredgecases/implementation/DiscriminatorEdgeCasesClientImpl.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/discriminatoredgecases/implementation/DiscriminatorEdgeCasesClientImpl.java index 9ac447b8517..f76c06ec6ca 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/discriminatoredgecases/implementation/DiscriminatorEdgeCasesClientImpl.java +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/discriminatoredgecases/implementation/DiscriminatorEdgeCasesClientImpl.java @@ -160,6 +160,24 @@ Mono> getChildNewDiscrim(@HostParam("endpoint") String endp @UnexpectedResponseExceptionType(HttpResponseException.class) Response getChildNewDiscrimSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/model/nosubtypes") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Mono> getNoSubtypes(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); + + @Get("/model/nosubtypes") + @ExpectedResponses({ 200 }) + @UnexpectedResponseExceptionType(value = ClientAuthenticationException.class, code = { 401 }) + @UnexpectedResponseExceptionType(value = ResourceNotFoundException.class, code = { 404 }) + @UnexpectedResponseExceptionType(value = ResourceModifiedException.class, code = { 409 }) + @UnexpectedResponseExceptionType(HttpResponseException.class) + Response getNoSubtypesSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions, Context context); } /** @@ -273,4 +291,57 @@ public Response getChildNewDiscrimWithResponse(RequestOptions reques final String accept = "application/json"; return service.getChildNewDiscrimSync(this.getEndpoint(), accept, requestOptions, Context.NONE); } + + /** + * The getNoSubtypes operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     name: 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 model with along with {@link Response} on successful completion of {@link Mono}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getNoSubtypesWithResponseAsync(RequestOptions requestOptions) { + final String accept = "application/json"; + return FluxUtil + .withContext(context -> service.getNoSubtypes(this.getEndpoint(), accept, requestOptions, context)); + } + + /** + * The getNoSubtypes operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     name: 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 model with along with {@link Response}. + */ + @ServiceMethod(returns = ReturnType.SINGLE) + public Response getNoSubtypesWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNoSubtypesSync(this.getEndpoint(), accept, requestOptions, Context.NONE); + } } diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/discriminatoredgecases/models/ModelWithDiscriminatorNoSubtypes.java b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/discriminatoredgecases/models/ModelWithDiscriminatorNoSubtypes.java new file mode 100644 index 00000000000..59c1737d62e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/java/tsptest/discriminatoredgecases/models/ModelWithDiscriminatorNoSubtypes.java @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package tsptest.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; + +/** + * Model with. + */ +@Immutable +public final class ModelWithDiscriminatorNoSubtypes implements JsonSerializable { + /* + * The kind property. + */ + @Generated + private String kind = "ModelWithDiscriminatorNoSubtypes"; + + /* + * The name property. + */ + @Generated + private final String name; + + /** + * Creates an instance of ModelWithDiscriminatorNoSubtypes class. + * + * @param name the name value to set. + */ + @Generated + private ModelWithDiscriminatorNoSubtypes(String name) { + this.name = name; + } + + /** + * Get the kind property: The kind property. + * + * @return the kind value. + */ + @Generated + public String getKind() { + return this.kind; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Generated + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Generated + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("kind", this.kind); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ModelWithDiscriminatorNoSubtypes from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ModelWithDiscriminatorNoSubtypes 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 ModelWithDiscriminatorNoSubtypes. + */ + @Generated + public static ModelWithDiscriminatorNoSubtypes fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String kind = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + ModelWithDiscriminatorNoSubtypes deserializedModelWithDiscriminatorNoSubtypes + = new ModelWithDiscriminatorNoSubtypes(name); + deserializedModelWithDiscriminatorNoSubtypes.kind = kind; + + return deserializedModelWithDiscriminatorNoSubtypes; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-discriminatoredgecases_metadata.json b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-discriminatoredgecases_metadata.json index 10255b975f5..033bf4bc493 100644 --- a/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-discriminatoredgecases_metadata.json +++ b/packages/http-client-java/generator/http-client-generator-test/src/main/resources/META-INF/tsptest-discriminatoredgecases_metadata.json @@ -1 +1 @@ -{"flavor":"Azure","apiVersions":{},"crossLanguageDefinitions":{"tsptest.discriminatoredgecases.DiscriminatorEdgeCasesAsyncClient":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesAsyncClient.getChildNewDiscrim":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildNewDiscrim","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesAsyncClient.getChildNewDiscrimWithResponse":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildNewDiscrim","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesAsyncClient.getChildRequiredDiscrim":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildRequiredDiscrim","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesAsyncClient.getChildRequiredDiscrimWithResponse":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildRequiredDiscrim","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesClient":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesClient.getChildNewDiscrim":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildNewDiscrim","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesClient.getChildNewDiscrimWithResponse":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildNewDiscrim","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesClient.getChildRequiredDiscrim":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildRequiredDiscrim","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesClient.getChildRequiredDiscrimWithResponse":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildRequiredDiscrim","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesClientBuilder":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp","tsptest.discriminatoredgecases.models.ChildWithAnotherDiscriminator":"TspTest.DiscriminatorEdgeCases.ChildWithAnotherDiscriminator","tsptest.discriminatoredgecases.models.ChildWithRequiredPropertyAsDiscriminator":"TspTest.DiscriminatorEdgeCases.ChildWithRequiredPropertyAsDiscriminator","tsptest.discriminatoredgecases.models.GrandChildWithAnotherDiscriminator":"TspTest.DiscriminatorEdgeCases.GrandChildWithAnotherDiscriminator","tsptest.discriminatoredgecases.models.GrandChildWithRequiredProperty":"TspTest.DiscriminatorEdgeCases.GrandChildWithRequiredProperty","tsptest.discriminatoredgecases.models.ParentWithRequiredProperty":"TspTest.DiscriminatorEdgeCases.ParentWithRequiredProperty"},"generatedFiles":["src/main/java/module-info.java","src/main/java/tsptest/discriminatoredgecases/DiscriminatorEdgeCasesAsyncClient.java","src/main/java/tsptest/discriminatoredgecases/DiscriminatorEdgeCasesClient.java","src/main/java/tsptest/discriminatoredgecases/DiscriminatorEdgeCasesClientBuilder.java","src/main/java/tsptest/discriminatoredgecases/implementation/DiscriminatorEdgeCasesClientImpl.java","src/main/java/tsptest/discriminatoredgecases/implementation/package-info.java","src/main/java/tsptest/discriminatoredgecases/models/ChildWithAnotherDiscriminator.java","src/main/java/tsptest/discriminatoredgecases/models/ChildWithRequiredPropertyAsDiscriminator.java","src/main/java/tsptest/discriminatoredgecases/models/GrandChildWithAnotherDiscriminator.java","src/main/java/tsptest/discriminatoredgecases/models/GrandChildWithRequiredProperty.java","src/main/java/tsptest/discriminatoredgecases/models/ParentWithRequiredProperty.java","src/main/java/tsptest/discriminatoredgecases/models/package-info.java","src/main/java/tsptest/discriminatoredgecases/package-info.java"]} \ No newline at end of file +{"flavor":"Azure","apiVersions":{},"crossLanguageDefinitions":{"tsptest.discriminatoredgecases.DiscriminatorEdgeCasesAsyncClient":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesAsyncClient.getChildNewDiscrim":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildNewDiscrim","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesAsyncClient.getChildNewDiscrimWithResponse":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildNewDiscrim","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesAsyncClient.getChildRequiredDiscrim":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildRequiredDiscrim","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesAsyncClient.getChildRequiredDiscrimWithResponse":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildRequiredDiscrim","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesAsyncClient.getNoSubtypes":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getNoSubtypes","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesAsyncClient.getNoSubtypesWithResponse":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getNoSubtypes","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesClient":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesClient.getChildNewDiscrim":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildNewDiscrim","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesClient.getChildNewDiscrimWithResponse":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildNewDiscrim","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesClient.getChildRequiredDiscrim":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildRequiredDiscrim","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesClient.getChildRequiredDiscrimWithResponse":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getChildRequiredDiscrim","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesClient.getNoSubtypes":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getNoSubtypes","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesClient.getNoSubtypesWithResponse":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp.getNoSubtypes","tsptest.discriminatoredgecases.DiscriminatorEdgeCasesClientBuilder":"TspTest.DiscriminatorEdgeCases.DiscriminatorEdgeCasesOp","tsptest.discriminatoredgecases.models.ChildWithAnotherDiscriminator":"TspTest.DiscriminatorEdgeCases.ChildWithAnotherDiscriminator","tsptest.discriminatoredgecases.models.ChildWithRequiredPropertyAsDiscriminator":"TspTest.DiscriminatorEdgeCases.ChildWithRequiredPropertyAsDiscriminator","tsptest.discriminatoredgecases.models.GrandChildWithAnotherDiscriminator":"TspTest.DiscriminatorEdgeCases.GrandChildWithAnotherDiscriminator","tsptest.discriminatoredgecases.models.GrandChildWithRequiredProperty":"TspTest.DiscriminatorEdgeCases.GrandChildWithRequiredProperty","tsptest.discriminatoredgecases.models.ModelWithDiscriminatorNoSubtypes":"TspTest.DiscriminatorEdgeCases.ModelWithDiscriminatorNoSubtypes","tsptest.discriminatoredgecases.models.ParentWithRequiredProperty":"TspTest.DiscriminatorEdgeCases.ParentWithRequiredProperty"},"generatedFiles":["src/main/java/module-info.java","src/main/java/tsptest/discriminatoredgecases/DiscriminatorEdgeCasesAsyncClient.java","src/main/java/tsptest/discriminatoredgecases/DiscriminatorEdgeCasesClient.java","src/main/java/tsptest/discriminatoredgecases/DiscriminatorEdgeCasesClientBuilder.java","src/main/java/tsptest/discriminatoredgecases/implementation/DiscriminatorEdgeCasesClientImpl.java","src/main/java/tsptest/discriminatoredgecases/implementation/package-info.java","src/main/java/tsptest/discriminatoredgecases/models/ChildWithAnotherDiscriminator.java","src/main/java/tsptest/discriminatoredgecases/models/ChildWithRequiredPropertyAsDiscriminator.java","src/main/java/tsptest/discriminatoredgecases/models/GrandChildWithAnotherDiscriminator.java","src/main/java/tsptest/discriminatoredgecases/models/GrandChildWithRequiredProperty.java","src/main/java/tsptest/discriminatoredgecases/models/ModelWithDiscriminatorNoSubtypes.java","src/main/java/tsptest/discriminatoredgecases/models/ParentWithRequiredProperty.java","src/main/java/tsptest/discriminatoredgecases/models/package-info.java","src/main/java/tsptest/discriminatoredgecases/package-info.java"]} \ No newline at end of file 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 index b3cfb94ed8c..bb8982abd9e 100644 --- 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 @@ -32,6 +32,13 @@ model GrandChildWithAnotherDiscriminator extends ChildWithAnotherDiscriminator { differentDiscriminator: "anotherValue"; } +/** Model with @discriminator but no known subtypes. */ +@discriminator("kind") +model ModelWithDiscriminatorNoSubtypes { + kind: string; + name: string; +} + @client({ service: TspTest.DiscriminatorEdgeCases, name: "DiscriminatorEdgeCasesClient", @@ -49,4 +56,10 @@ interface DiscriminatorEdgeCasesOp { getChildNewDiscrim(): { @body body: ChildWithAnotherDiscriminator; }; + + @get + @route("/nosubtypes") + getNoSubtypes(): { + @body body: ModelWithDiscriminatorNoSubtypes; + }; }