From 27373e76aaa1dcfa540c4309779ec8b83ade9bf8 Mon Sep 17 00:00:00 2001 From: Dapeng Zhang Date: Mon, 13 Jan 2025 16:50:41 +0800 Subject: [PATCH 01/16] [http-client-csharp] the post processor should always keep customized code as root documents (#5481) Fixes #5441 Previously in our generator, we have two instances of `GeneratedCodeWorkspace`: one for the project that is being generated right now (the generated code project), one for the existing part of the generated library (the customized code project). This leads to an issue that in the post processor, only the generated documents are passed into the post processor, therefore the post processor actually does not know about the existence of the customized files. This is not very correct because the generated files must need those customized files to work properly therefore they should be in the same project. This PR refactors this part to change the structure of `GeneratedCodeWorkspace`: now we only create one instance of `GeneratedCodeWorkspace`, and the project inside it will be initialized with shared files and all the customized files in it. In this way, when we get to the post processor, it should be able to access all the necessary documents. --------- Co-authored-by: Wei Hu --- .../src/CSharpGen.cs | 2 +- .../src/CodeModelPlugin.cs | 21 +++++----- .../PostProcessing/GeneratedCodeWorkspace.cs | 42 ++++--------------- .../test/common/Helpers.cs | 36 +++++++++++++++- 4 files changed, 54 insertions(+), 47 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/CSharpGen.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/CSharpGen.cs index df2460f0fa..59d774c875 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/CSharpGen.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/CSharpGen.cs @@ -29,7 +29,7 @@ public async Task ExecuteAsync() var generatedTestOutputPath = CodeModelPlugin.Instance.Configuration.TestGeneratedDirectory; GeneratedCodeWorkspace workspace = await GeneratedCodeWorkspace.Create(); - await CodeModelPlugin.Instance.InitializeSourceInputModelAsync(); + CodeModelPlugin.Instance.SourceInputModel = new SourceInputModel(await workspace.GetCompilationAsync()); var output = CodeModelPlugin.Instance.OutputLibrary; Directory.CreateDirectory(Path.Combine(generatedSourceOutputPath, "Models")); diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/CodeModelPlugin.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/CodeModelPlugin.cs index b03488f93a..2b2a57b91c 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/CodeModelPlugin.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/CodeModelPlugin.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.ComponentModel.Composition; -using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.Generator.CSharp.Input; using Microsoft.Generator.CSharp.Primitives; @@ -61,7 +60,17 @@ protected CodeModelPlugin() // Extensibility points to be implemented by a plugin public virtual TypeFactory TypeFactory { get; } - public virtual SourceInputModel SourceInputModel => _sourceInputModel ?? throw new InvalidOperationException($"SourceInputModel has not been initialized yet"); + + private SourceInputModel? _sourceInputModel; + public virtual SourceInputModel SourceInputModel + { + get => _sourceInputModel ?? throw new InvalidOperationException($"SourceInputModel has not been initialized yet"); + internal set + { + _sourceInputModel = value; + } + } + public virtual string LicenseString => string.Empty; public virtual OutputLibrary OutputLibrary { get; } = new(); public virtual InputLibrary InputLibrary => _inputLibrary; @@ -89,14 +98,6 @@ public void AddSharedSourceDirectory(string sharedSourceDirectory) _sharedSourceDirectories.Add(sharedSourceDirectory); } - private SourceInputModel? _sourceInputModel; - - internal async Task InitializeSourceInputModelAsync() - { - GeneratedCodeWorkspace existingCode = GeneratedCodeWorkspace.CreateExistingCodeProject([Instance.Configuration.ProjectDirectory], Instance.Configuration.ProjectGeneratedDirectory); - _sourceInputModel = new SourceInputModel(await existingCode.GetCompilationAsync()); - } - internal HashSet TypesToKeep { get; } = new(); //TODO consider using TypeProvider so we can have a fully qualified name to filter on //https://github.com/microsoft/typespec/issues/4418 diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/PostProcessing/GeneratedCodeWorkspace.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/PostProcessing/GeneratedCodeWorkspace.cs index bc7242a599..cb2c2fb509 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/PostProcessing/GeneratedCodeWorkspace.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/PostProcessing/GeneratedCodeWorkspace.cs @@ -34,7 +34,6 @@ internal class GeneratedCodeWorkspace private static readonly string[] _sharedFolders = [SharedFolder]; private Project _project; - private Compilation? _compilation; private Dictionary PlainFiles { get; } private GeneratedCodeWorkspace(Project generatedCodeProject) @@ -107,7 +106,7 @@ public async Task AddGeneratedFile(CodeFile codefile) private async Task ProcessDocument(Document document) { var syntaxTree = await document.GetSyntaxTreeAsync(); - var compilation = await GetProjectCompilationAsync(); + var compilation = await GetCompilationAsync(); if (syntaxTree != null) { var semanticModel = compilation.GetSemanticModel(syntaxTree); @@ -143,12 +142,15 @@ private static Project CreateGeneratedCodeProject() internal static async Task Create() { + // prepare the generated code project var projectTask = Interlocked.Exchange(ref _cachedProject, null); - var generatedCodeProject = projectTask != null ? await projectTask : CreateGeneratedCodeProject(); + var project = projectTask != null ? await projectTask : CreateGeneratedCodeProject(); var outputDirectory = CodeModelPlugin.Instance.Configuration.OutputDirectory; var projectDirectory = CodeModelPlugin.Instance.Configuration.ProjectDirectory; + var generatedDirectory = CodeModelPlugin.Instance.Configuration.ProjectGeneratedDirectory; + // add all documents except the documents from the generated directory if (Path.IsPathRooted(projectDirectory) && Path.IsPathRooted(outputDirectory)) { projectDirectory = Path.GetFullPath(projectDirectory); @@ -157,37 +159,15 @@ internal static async Task Create() Directory.CreateDirectory(projectDirectory); Directory.CreateDirectory(outputDirectory); - generatedCodeProject = AddDirectory(generatedCodeProject, projectDirectory, skipPredicate: sourceFile => sourceFile.StartsWith(outputDirectory)); + project = AddDirectory(project, projectDirectory, skipPredicate: sourceFile => sourceFile.StartsWith(generatedDirectory)); } foreach (var sharedSourceFolder in CodeModelPlugin.Instance.SharedSourceDirectories) { - generatedCodeProject = AddDirectory(generatedCodeProject, sharedSourceFolder, folders: _sharedFolders); + project = AddDirectory(project, sharedSourceFolder, folders: _sharedFolders); } - generatedCodeProject = generatedCodeProject.WithParseOptions(new CSharpParseOptions(preprocessorSymbols: new[] { "EXPERIMENTAL" })); - return new GeneratedCodeWorkspace(generatedCodeProject); - } - - internal static GeneratedCodeWorkspace CreateExistingCodeProject(IEnumerable projectDirectories, string generatedDirectory) - { - var workspace = new AdhocWorkspace(); - var newOptionSet = workspace.Options.WithChangedOption(FormattingOptions.NewLine, LanguageNames.CSharp, NewLine); - workspace.TryApplyChanges(workspace.CurrentSolution.WithOptions(newOptionSet)); - Project project = workspace.AddProject("ExistingCode", LanguageNames.CSharp); - - foreach (var projectDirectory in projectDirectories) - { - if (Path.IsPathRooted(projectDirectory)) - { - project = AddDirectory(project, Path.GetFullPath(projectDirectory), skipPredicate: sourceFile => sourceFile.StartsWith(generatedDirectory)); - } - } - - project = project - .AddMetadataReferences(_assemblyMetadataReferences.Value.Concat(CodeModelPlugin.Instance.AdditionalMetadataReferences)) - .WithCompilationOptions(new CSharpCompilationOptions( - OutputKind.DynamicallyLinkedLibrary, metadataReferenceResolver: _metadataReferenceResolver.Value, nullableContextOptions: NullableContextOptions.Disable)); + project = project.WithParseOptions(new CSharpParseOptions(preprocessorSymbols: new[] { "EXPERIMENTAL" })); return new GeneratedCodeWorkspace(project); } @@ -248,11 +228,5 @@ public async Task PostProcessAsync() break; } } - - private async Task GetProjectCompilationAsync() - { - _compilation ??= await _project.GetCompilationAsync(); - return _compilation!; - } } } diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/common/Helpers.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/common/Helpers.cs index 54bd304bc8..d2485ad796 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/common/Helpers.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/test/common/Helpers.cs @@ -1,11 +1,15 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.CompilerServices; using System.Threading.Tasks; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.Formatting; +using NUnit.Framework; namespace Microsoft.Generator.CSharp.Tests.Common { @@ -43,8 +47,36 @@ public static async Task GetCompilationFromDirectoryAsync( { var directory = GetAssetFileOrDirectoryPath(false, parameters, method, filePath); var codeGenAttributeFiles = Path.Combine(_assemblyLocation, "..", "..", "..", "..", "..", "Microsoft.Generator.CSharp.Customization", "src"); - var workspace = GeneratedCodeWorkspace.CreateExistingCodeProject([directory, codeGenAttributeFiles], Path.Combine(directory, "Generated")); - return await workspace.GetCompilationAsync(); + var project = CreateExistingCodeProject([directory, codeGenAttributeFiles], Path.Combine(directory, "Generated")); + var compilation = await project.GetCompilationAsync(); + Assert.IsNotNull(compilation); + return compilation!; + } + + private static Project CreateExistingCodeProject(IEnumerable projectDirectories, string generatedDirectory) + { + var workspace = new AdhocWorkspace(); + var newOptionSet = workspace.Options.WithChangedOption(FormattingOptions.NewLine, LanguageNames.CSharp, "\n"); + workspace.TryApplyChanges(workspace.CurrentSolution.WithOptions(newOptionSet)); + Project project = workspace.AddProject("ExistingCode", LanguageNames.CSharp); + + foreach (var projectDirectory in projectDirectories) + { + if (Path.IsPathRooted(projectDirectory)) + { + project = GeneratedCodeWorkspace.AddDirectory(project, Path.GetFullPath(projectDirectory), skipPredicate: sourceFile => sourceFile.StartsWith(generatedDirectory)); + } + } + + project = project + .AddMetadataReferences([ + MetadataReference.CreateFromFile(typeof(object).Assembly.Location), + ..CodeModelPlugin.Instance.AdditionalMetadataReferences + ]) + .WithCompilationOptions(new CSharpCompilationOptions( + OutputKind.DynamicallyLinkedLibrary, metadataReferenceResolver: new WorkspaceMetadataReferenceResolver(), nullableContextOptions: NullableContextOptions.Disable)); + + return project; } } } From dd36417bb06ead0ec9d4fc544cddcdb24461434a Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 14 Jan 2025 09:40:44 +0800 Subject: [PATCH 02/16] http-client-java, e2e test, use clientcore (#5437) fix https://github.com/Azure/autorest.java/issues/3000 fix https://github.com/Azure/autorest.java/issues/3002 fix https://github.com/Azure/autorest.java/issues/2986 Cases that generated code cannot compile is currently skipped. Cases that not able to pass is disabled. Current result https://specdashboard.z5.web.core.windows.net/ ![image](https://github.com/user-attachments/assets/d14328b4-be18-4536-90f1-ac07a0046f20) --------- Co-authored-by: hongli750210 --- .prettierignore | 1 + cspell.yaml | 1 + .../http-client-java/eng/pipeline/publish.yml | 3 +- .../http-client-java/eng/scripts/Generate.ps1 | 7 +- .../eng/scripts/Test-Packages.ps1 | 16 +- .../Generate.ps1 | 118 + .../Setup.ps1 | 8 + .../Spector-Tests.ps1 | 18 + .../package.json | 32 + .../pom.xml | 77 + .../authentication/apikey/ApiKeyClient.java | 79 + .../apikey/ApiKeyClientBuilder.java | 263 ++ .../authentication/apikey/InvalidAuth.java | 81 + .../implementation/ApiKeyClientImpl.java | 111 + .../apikey/implementation/package-info.java | 7 + .../authentication/apikey/package-info.java | 7 + .../http/custom/CustomClient.java | 79 + .../http/custom/CustomClientBuilder.java | 263 ++ .../http/custom/InvalidAuth.java | 81 + .../implementation/CustomClientImpl.java | 111 + .../custom/implementation/package-info.java | 7 + .../http/custom/package-info.java | 7 + .../java/encode/numeric/NumericClient.java | 179 + .../encode/numeric/NumericClientBuilder.java | 240 ++ .../implementation/NumericClientImpl.java | 64 + .../implementation/PropertiesImpl.java | 180 + .../numeric/implementation/package-info.java | 7 + .../java/encode/numeric/package-info.java | 7 + .../property/SafeintAsStringProperty.java | 82 + .../property/Uint32AsStringProperty.java | 92 + .../property/Uint8AsStringProperty.java | 82 + .../encode/numeric/property/package-info.java | 7 + .../parameters/basic/BasicClientBuilder.java | 250 ++ .../parameters/basic/ExplicitBodyClient.java | 68 + .../parameters/basic/ImplicitBodyClient.java | 70 + .../parameters/basic/explicitbody/User.java | 81 + .../basic/explicitbody/package-info.java | 7 + .../basic/implementation/BasicClientImpl.java | 79 + .../implementation/ExplicitBodiesImpl.java | 79 + .../implementation/ImplicitBodiesImpl.java | 79 + .../basic/implementation/package-info.java | 7 + .../implementation/SimpleRequest.java | 81 + .../implementation/package-info.java | 7 + .../java/parameters/basic/package-info.java | 7 + .../parameters/bodyoptionality/BodyModel.java | 81 + .../BodyOptionalityClient.java | 106 + .../BodyOptionalityClientBuilder.java | 251 ++ .../OptionalExplicitClient.java | 150 + .../BodyOptionalityClientImpl.java | 151 + .../implementation/OptionalExplicitsImpl.java | 128 + .../implementation/package-info.java | 7 + .../bodyoptionality/package-info.java | 7 + .../CollectionFormatClientBuilder.java | 251 ++ .../collectionformat/HeaderClient.java | 58 + .../collectionformat/QueryClient.java | 170 + .../CollectionFormatClientImpl.java | 79 + .../implementation/HeadersImpl.java | 72 + .../implementation/QueriesImpl.java | 164 + .../implementation/package-info.java | 7 + .../collectionformat/package-info.java | 7 + .../java/parameters/spread/AliasClient.java | 302 ++ .../java/parameters/spread/ModelClient.java | 229 ++ .../spread/SpreadClientBuilder.java | 250 ++ .../SpreadAsRequestBodyRequest.java | 81 + .../alias/implementation/package-info.java | 7 + .../spread/implementation/AliasImpl.java | 236 ++ .../spread/implementation/ModelsImpl.java | 209 ++ .../SpreadAsRequestParameterRequest.java | 81 + .../implementation/SpreadClientImpl.java | 79 + .../SpreadCompositeRequestMixRequest.java | 81 + .../SpreadParameterWithInnerAliasRequest.java | 104 + .../SpreadParameterWithInnerModelRequest.java | 82 + .../SpreadWithMultipleParametersRequest.java | 176 + .../spread/implementation/package-info.java | 7 + .../spread/model/BodyParameter.java | 81 + .../parameters/spread/model/package-info.java | 7 + .../java/parameters/spread/package-info.java | 7 + .../ContentNegotiationClientBuilder.java | 251 ++ .../DifferentBodyClient.java | 99 + .../contentnegotiation/SameBodyClient.java | 96 + .../differentbody/PngImageAsJson.java | 81 + .../differentbody/package-info.java | 7 + .../ContentNegotiationClientImpl.java | 79 + .../implementation/DifferentBodiesImpl.java | 104 + .../implementation/SameBodiesImpl.java | 101 + .../implementation/package-info.java | 7 + .../contentnegotiation/package-info.java | 7 + .../payload/jsonmergepatch/InnerModel.java | 179 + .../jsonmergepatch/JsonMergePatchClient.java | 303 ++ .../JsonMergePatchClientBuilder.java | 241 ++ .../java/payload/jsonmergepatch/Resource.java | 316 ++ .../payload/jsonmergepatch/ResourcePatch.java | 389 ++ .../JsonMergePatchClientImpl.java | 307 ++ .../implementation/JsonMergePatchHelper.java | 43 + .../implementation/package-info.java | 7 + .../payload/jsonmergepatch/package-info.java | 7 + .../payload/mediatype/MediaTypeClient.java | 166 + .../mediatype/MediaTypeClientBuilder.java | 241 ++ .../implementation/MediaTypeClientImpl.java | 64 + .../implementation/StringBodiesImpl.java | 160 + .../implementation/package-info.java | 7 + .../java/payload/mediatype/package-info.java | 7 + .../main/java/payload/multipart/Address.java | 81 + .../multipart/BinaryArrayPartsRequest.java | 57 + .../ComplexHttpPartsModelRequest.java | 112 + .../multipart/ComplexPartsRequest.java | 94 + .../multipart/FileOptionalContentType.java | 85 + .../multipart/FileRequiredMetaData.java | 75 + .../multipart/FileSpecificContentType.java | 73 + ...ithHttpPartOptionalContentTypeRequest.java | 38 + ...ithHttpPartRequiredContentTypeRequest.java | 38 + ...ithHttpPartSpecificContentTypeRequest.java | 38 + .../payload/multipart/FormDataClient.java | 288 ++ .../multipart/FormDataHttpPartsClient.java | 74 + .../FormDataHttpPartsContentTypeClient.java | 139 + .../FormDataHttpPartsNonStringClient.java | 65 + .../payload/multipart/JsonPartRequest.java | 56 + .../multipart/MultiBinaryPartsRequest.java | 66 + .../multipart/MultiPartClientBuilder.java | 276 ++ .../payload/multipart/MultiPartRequest.java | 56 + .../payload/multipart/PictureFileDetails.java | 95 + .../multipart/PicturesFileDetails.java | 95 + .../multipart/ProfileImageFileDetails.java | 95 + .../httpparts/nonstring/FloatRequest.java | 38 + .../httpparts/nonstring/package-info.java | 7 + .../implementation/AnonymousModelRequest.java | 39 + .../FormDataHttpPartsContentTypesImpl.java | 117 + .../implementation/FormDataHttpPartsImpl.java | 71 + .../FormDataHttpPartsNonStringsImpl.java | 71 + .../implementation/FormDatasImpl.java | 210 ++ .../implementation/MultiPartClientImpl.java | 109 + .../MultipartFormDataHelper.java | 206 ++ .../implementation/package-info.java | 7 + .../java/payload/multipart/package-info.java | 7 + .../java/payload/pageable/PageableClient.java | 76 + .../pageable/PageableClientBuilder.java | 240 ++ .../src/main/java/payload/pageable/Pet.java | 103 + .../implementation/PageableClientImpl.java | 64 + .../ServerDrivenPaginationsImpl.java | 87 + .../pageable/implementation/package-info.java | 7 + .../java/payload/pageable/package-info.java | 7 + .../serverdrivenpagination/LinkResponse.java | 105 + .../LinkResponseLinks.java | 135 + .../serverdrivenpagination/package-info.java | 7 + .../main/java/routes/InInterfaceClient.java | 54 + .../java/routes/PathParametersClient.java | 113 + ...ParametersLabelExpansionExplodeClient.java | 115 + ...arametersLabelExpansionStandardClient.java | 115 + ...arametersMatrixExpansionExplodeClient.java | 115 + ...rametersMatrixExpansionStandardClient.java | 115 + ...hParametersPathExpansionExplodeClient.java | 115 + ...ParametersPathExpansionStandardClient.java | 115 + ...PathParametersReservedExpansionClient.java | 85 + ...arametersSimpleExpansionExplodeClient.java | 115 + ...rametersSimpleExpansionStandardClient.java | 115 + .../java/routes/QueryParametersClient.java | 113 + ...ametersQueryContinuationExplodeClient.java | 115 + ...metersQueryContinuationStandardClient.java | 115 + ...ParametersQueryExpansionExplodeClient.java | 115 + ...arametersQueryExpansionStandardClient.java | 115 + .../src/main/java/routes/RoutesClient.java | 54 + .../main/java/routes/RoutesClientBuilder.java | 430 +++ .../implementation/InInterfacesImpl.java | 63 + .../implementation/PathParametersImpl.java | 106 + ...hParametersLabelExpansionExplodesImpl.java | 113 + ...ParametersLabelExpansionStandardsImpl.java | 113 + ...ParametersMatrixExpansionExplodesImpl.java | 113 + ...arametersMatrixExpansionStandardsImpl.java | 113 + ...thParametersPathExpansionExplodesImpl.java | 113 + ...hParametersPathExpansionStandardsImpl.java | 113 + .../PathParametersReservedExpansionsImpl.java | 86 + ...ParametersSimpleExpansionExplodesImpl.java | 113 + ...arametersSimpleExpansionStandardsImpl.java | 113 + .../implementation/QueryParametersImpl.java | 103 + ...rametersQueryContinuationExplodesImpl.java | 113 + ...ametersQueryContinuationStandardsImpl.java | 114 + ...yParametersQueryExpansionExplodesImpl.java | 112 + ...ParametersQueryExpansionStandardsImpl.java | 113 + .../implementation/RoutesClientImpl.java | 325 ++ .../routes/implementation/package-info.java | 7 + .../src/main/java/routes/package-info.java | 7 + .../encodedname/json/JsonClient.java | 103 + .../encodedname/json/JsonClientBuilder.java | 240 ++ .../json/implementation/JsonClientImpl.java | 64 + .../json/implementation/PropertiesImpl.java | 108 + .../json/implementation/package-info.java | 7 + .../encodedname/json/package-info.java | 7 + .../json/property/JsonEncodedNameModel.java | 81 + .../json/property/package-info.java | 7 + .../endpoint/notdefined/NotDefinedClient.java | 54 + .../notdefined/NotDefinedClientBuilder.java | 241 ++ .../implementation/NotDefinedClientImpl.java | 89 + .../implementation/package-info.java | 7 + .../endpoint/notdefined/package-info.java | 7 + .../server/path/multiple/MultipleClient.java | 82 + .../path/multiple/MultipleClientBuilder.java | 260 ++ .../path/multiple/MultipleServiceVersion.java | 38 + .../implementation/MultipleClientImpl.java | 123 + .../multiple/implementation/package-info.java | 6 + .../server/path/multiple/package-info.java | 6 + .../java/server/path/single/SingleClient.java | 54 + .../path/single/SingleClientBuilder.java | 240 ++ .../implementation/SingleClientImpl.java | 88 + .../single/implementation/package-info.java | 7 + .../java/server/path/single/package-info.java | 7 + .../notversioned/NotVersionedClient.java | 110 + .../NotVersionedClientBuilder.java | 241 ++ .../NotVersionedClientImpl.java | 131 + .../implementation/package-info.java | 7 + .../versions/notversioned/package-info.java | 7 + .../versions/versioned/VersionedClient.java | 129 + .../versioned/VersionedClientBuilder.java | 261 ++ .../versioned/VersionedServiceVersion.java | 43 + .../implementation/VersionedClientImpl.java | 168 + .../implementation/package-info.java | 7 + .../versions/versioned/package-info.java | 7 + .../specialwords/ModelPropertiesClient.java | 68 + .../main/java/specialwords/ModelsClient.java | 1284 +++++++ .../java/specialwords/OperationsClient.java | 854 +++++ .../java/specialwords/ParametersClient.java | 981 ++++++ .../SpecialWordsClientBuilder.java | 276 ++ .../implementation/ModelPropertiesImpl.java | 79 + .../implementation/ModelsImpl.java | 1071 ++++++ .../implementation/OperationsImpl.java | 639 ++++ .../implementation/ParametersImpl.java | 726 ++++ .../SpecialWordsClientImpl.java | 109 + .../implementation/package-info.java | 44 + .../modelproperties/SameAsModel.java | 81 + .../modelproperties/package-info.java | 44 + .../main/java/specialwords/models/And.java | 81 + .../src/main/java/specialwords/models/As.java | 81 + .../main/java/specialwords/models/Assert.java | 81 + .../main/java/specialwords/models/Async.java | 81 + .../main/java/specialwords/models/Await.java | 81 + .../main/java/specialwords/models/Break.java | 81 + .../java/specialwords/models/ClassModel.java | 81 + .../java/specialwords/models/Constructor.java | 81 + .../java/specialwords/models/Continue.java | 81 + .../main/java/specialwords/models/Def.java | 81 + .../main/java/specialwords/models/Del.java | 81 + .../main/java/specialwords/models/Elif.java | 81 + .../main/java/specialwords/models/Else.java | 81 + .../main/java/specialwords/models/Except.java | 81 + .../main/java/specialwords/models/Exec.java | 81 + .../java/specialwords/models/Finally.java | 81 + .../main/java/specialwords/models/For.java | 81 + .../main/java/specialwords/models/From.java | 81 + .../main/java/specialwords/models/Global.java | 81 + .../src/main/java/specialwords/models/If.java | 81 + .../main/java/specialwords/models/Import.java | 81 + .../src/main/java/specialwords/models/In.java | 81 + .../src/main/java/specialwords/models/Is.java | 81 + .../main/java/specialwords/models/Lambda.java | 81 + .../main/java/specialwords/models/Not.java | 81 + .../src/main/java/specialwords/models/Or.java | 81 + .../main/java/specialwords/models/Pass.java | 81 + .../main/java/specialwords/models/Raise.java | 81 + .../main/java/specialwords/models/Return.java | 81 + .../main/java/specialwords/models/Try.java | 81 + .../main/java/specialwords/models/While.java | 81 + .../main/java/specialwords/models/With.java | 81 + .../main/java/specialwords/models/Yield.java | 81 + .../specialwords/models/package-info.java | 44 + .../main/java/specialwords/package-info.java | 44 + .../java/type/array/ArrayClientBuilder.java | 385 ++ .../java/type/array/BooleanValueClient.java | 103 + .../java/type/array/DatetimeValueClient.java | 104 + .../java/type/array/DurationValueClient.java | 104 + .../java/type/array/Float32ValueClient.java | 103 + .../src/main/java/type/array/InnerModel.java | 117 + .../java/type/array/Int32ValueClient.java | 103 + .../java/type/array/Int64ValueClient.java | 103 + .../java/type/array/ModelValueClient.java | 113 + .../array/NullableBooleanValueClient.java | 103 + .../type/array/NullableFloatValueClient.java | 103 + .../type/array/NullableInt32ValueClient.java | 103 + .../type/array/NullableModelValueClient.java | 113 + .../type/array/NullableStringValueClient.java | 103 + .../java/type/array/StringValueClient.java | 103 + .../java/type/array/UnknownValueClient.java | 103 + .../array/implementation/ArrayClientImpl.java | 259 ++ .../implementation/BooleanValuesImpl.java | 102 + .../implementation/DatetimeValuesImpl.java | 103 + .../implementation/DurationValuesImpl.java | 103 + .../implementation/Float32ValuesImpl.java | 102 + .../array/implementation/Int32ValuesImpl.java | 102 + .../array/implementation/Int64ValuesImpl.java | 102 + .../array/implementation/ModelValuesImpl.java | 113 + .../NullableBooleanValuesImpl.java | 108 + .../NullableFloatValuesImpl.java | 108 + .../NullableInt32ValuesImpl.java | 108 + .../NullableModelValuesImpl.java | 119 + .../NullableStringValuesImpl.java | 108 + .../implementation/StringValuesImpl.java | 102 + .../implementation/UnknownValuesImpl.java | 102 + .../array/implementation/package-info.java | 7 + .../main/java/type/array/package-info.java | 7 + .../type/dictionary/BooleanValueClient.java | 103 + .../type/dictionary/DatetimeValueClient.java | 104 + .../dictionary/DictionaryClientBuilder.java | 353 ++ .../type/dictionary/DurationValueClient.java | 104 + .../type/dictionary/Float32ValueClient.java | 103 + .../main/java/type/dictionary/InnerModel.java | 117 + .../type/dictionary/Int32ValueClient.java | 103 + .../type/dictionary/Int64ValueClient.java | 103 + .../type/dictionary/ModelValueClient.java | 113 + .../dictionary/NullableFloatValueClient.java | 103 + .../dictionary/RecursiveModelValueClient.java | 113 + .../type/dictionary/StringValueClient.java | 103 + .../type/dictionary/UnknownValueClient.java | 103 + .../implementation/BooleanValuesImpl.java | 108 + .../implementation/DatetimeValuesImpl.java | 109 + .../implementation/DictionaryClientImpl.java | 214 ++ .../implementation/DurationValuesImpl.java | 109 + .../implementation/Float32ValuesImpl.java | 108 + .../implementation/Int32ValuesImpl.java | 102 + .../implementation/Int64ValuesImpl.java | 102 + .../implementation/ModelValuesImpl.java | 113 + .../NullableFloatValuesImpl.java | 108 + .../RecursiveModelValuesImpl.java | 119 + .../implementation/StringValuesImpl.java | 108 + .../implementation/UnknownValuesImpl.java | 108 + .../implementation/package-info.java | 7 + .../java/type/dictionary/package-info.java | 7 + .../extensible/DaysOfWeekExtensibleEnum.java | 123 + .../enums/extensible/ExtensibleClient.java | 168 + .../extensible/ExtensibleClientBuilder.java | 241 ++ .../implementation/ExtensibleClientImpl.java | 64 + .../implementation/StringOperationsImpl.java | 161 + .../implementation/package-info.java | 6 + .../type/enums/extensible/package-info.java | 6 + .../java/type/enums/fixed/DaysOfWeekEnum.java | 79 + .../java/type/enums/fixed/FixedClient.java | 135 + .../type/enums/fixed/FixedClientBuilder.java | 240 ++ .../fixed/implementation/FixedClientImpl.java | 64 + .../implementation/StringOperationsImpl.java | 134 + .../fixed/implementation/package-info.java | 6 + .../java/type/enums/fixed/package-info.java | 6 + .../java/type/model/empty/EmptyClient.java | 146 + .../type/model/empty/EmptyClientBuilder.java | 240 ++ .../java/type/model/empty/EmptyInput.java | 57 + .../type/model/empty/EmptyInputOutput.java | 57 + .../java/type/model/empty/EmptyOutput.java | 57 + .../empty/implementation/EmptyClientImpl.java | 173 + .../empty/implementation/package-info.java | 7 + .../java/type/model/empty/package-info.java | 7 + .../inheritance/enumdiscriminator/Cobra.java | 88 + .../inheritance/enumdiscriminator/Dog.java | 130 + .../enumdiscriminator/DogKind.java | 87 + .../EnumDiscriminatorClient.java | 322 ++ .../EnumDiscriminatorClientBuilder.java | 241 ++ .../inheritance/enumdiscriminator/Golden.java | 88 + .../inheritance/enumdiscriminator/Snake.java | 130 + .../enumdiscriminator/SnakeKind.java | 49 + .../EnumDiscriminatorClientImpl.java | 320 ++ .../implementation/package-info.java | 7 + .../enumdiscriminator/package-info.java | 7 + .../inheritance/nesteddiscriminator/Fish.java | 132 + .../nesteddiscriminator/GoblinShark.java | 106 + .../NestedDiscriminatorClient.java | 250 ++ .../NestedDiscriminatorClientBuilder.java | 241 ++ .../nesteddiscriminator/Salmon.java | 190 + .../nesteddiscriminator/SawShark.java | 106 + .../nesteddiscriminator/Shark.java | 133 + .../NestedDiscriminatorClientImpl.java | 259 ++ .../implementation/package-info.java | 7 + .../nesteddiscriminator/package-info.java | 7 + .../inheritance/notdiscriminated/Cat.java | 86 + .../NotDiscriminatedClient.java | 158 + .../NotDiscriminatedClientBuilder.java | 241 ++ .../inheritance/notdiscriminated/Pet.java | 81 + .../inheritance/notdiscriminated/Siamese.java | 91 + .../NotDiscriminatedClientImpl.java | 185 + .../implementation/package-info.java | 7 + .../notdiscriminated/package-info.java | 7 + .../model/inheritance/recursive/Element.java | 92 + .../inheritance/recursive/Extension.java | 98 + .../recursive/RecursiveClient.java | 108 + .../recursive/RecursiveClientBuilder.java | 241 ++ .../implementation/RecursiveClientImpl.java | 140 + .../implementation/package-info.java | 7 + .../inheritance/recursive/package-info.java | 7 + .../inheritance/singlediscriminator/Bird.java | 136 + .../singlediscriminator/Dinosaur.java | 130 + .../singlediscriminator/Eagle.java | 190 + .../singlediscriminator/Goose.java | 88 + .../singlediscriminator/SeaGull.java | 88 + .../SingleDiscriminatorClient.java | 286 ++ .../SingleDiscriminatorClientBuilder.java | 241 ++ .../singlediscriminator/Sparrow.java | 88 + .../inheritance/singlediscriminator/TRex.java | 88 + .../SingleDiscriminatorClientImpl.java | 290 ++ .../implementation/package-info.java | 7 + .../singlediscriminator/package-info.java | 7 + .../type/model/usage/InputOutputRecord.java | 81 + .../java/type/model/usage/InputRecord.java | 81 + .../java/type/model/usage/OutputRecord.java | 81 + .../java/type/model/usage/UsageClient.java | 150 + .../type/model/usage/UsageClientBuilder.java | 240 ++ .../usage/implementation/UsageClientImpl.java | 177 + .../usage/implementation/package-info.java | 7 + .../java/type/model/usage/package-info.java | 7 + .../type/model/visibility/ReadOnlyModel.java | 99 + .../model/visibility/VisibilityClient.java | 377 ++ .../visibility/VisibilityClientBuilder.java | 241 ++ .../model/visibility/VisibilityModel.java | 171 + .../implementation/VisibilityClientImpl.java | 375 ++ .../implementation/package-info.java | 7 + .../type/model/visibility/package-info.java | 7 + .../AdditionalPropertiesClientBuilder.java | 586 ++++ .../DifferentSpreadFloatDerived.java | 102 + .../DifferentSpreadFloatRecord.java | 126 + .../DifferentSpreadModelArrayDerived.java | 105 + .../DifferentSpreadModelArrayRecord.java | 131 + .../DifferentSpreadModelDerived.java | 102 + .../DifferentSpreadModelRecord.java | 127 + .../DifferentSpreadStringDerived.java | 102 + .../DifferentSpreadStringRecord.java | 126 + .../ExtendsDifferentSpreadFloatClient.java | 110 + ...xtendsDifferentSpreadModelArrayClient.java | 122 + .../ExtendsDifferentSpreadModelClient.java | 114 + .../ExtendsDifferentSpreadStringClient.java | 110 + .../ExtendsFloatAdditionalProperties.java | 125 + .../ExtendsFloatClient.java | 108 + .../ExtendsModelAdditionalProperties.java | 125 + ...ExtendsModelArrayAdditionalProperties.java | 130 + .../ExtendsModelArrayClient.java | 120 + .../ExtendsModelClient.java | 112 + .../ExtendsStringAdditionalProperties.java | 125 + .../ExtendsStringClient.java | 108 + .../ExtendsUnknownAdditionalProperties.java | 132 + ...ndsUnknownAdditionalPropertiesDerived.java | 142 + ...nownAdditionalPropertiesDiscriminated.java | 182 + ...itionalPropertiesDiscriminatedDerived.java | 167 + .../ExtendsUnknownClient.java | 108 + .../ExtendsUnknownDerivedClient.java | 112 + .../ExtendsUnknownDiscriminatedClient.java | 110 + .../IsFloatAdditionalProperties.java | 124 + .../additionalproperties/IsFloatClient.java | 108 + .../IsModelAdditionalProperties.java | 125 + .../IsModelArrayAdditionalProperties.java | 129 + .../IsModelArrayClient.java | 120 + .../additionalproperties/IsModelClient.java | 112 + .../IsStringAdditionalProperties.java | 125 + .../additionalproperties/IsStringClient.java | 108 + .../IsUnknownAdditionalProperties.java | 132 + .../IsUnknownAdditionalPropertiesDerived.java | 142 + ...nownAdditionalPropertiesDiscriminated.java | 182 + ...itionalPropertiesDiscriminatedDerived.java | 165 + .../additionalproperties/IsUnknownClient.java | 108 + .../IsUnknownDerivedClient.java | 112 + .../IsUnknownDiscriminatedClient.java | 110 + .../additionalproperties/ModelForRecord.java | 81 + .../MultipleSpreadClient.java | 108 + .../MultipleSpreadRecord.java | 131 + .../SpreadDifferentFloatClient.java | 108 + .../SpreadDifferentModelArrayClient.java | 116 + .../SpreadDifferentModelClient.java | 112 + .../SpreadDifferentStringClient.java | 108 + .../SpreadFloatClient.java | 108 + .../SpreadFloatRecord.java | 124 + .../SpreadModelArrayClient.java | 120 + .../SpreadModelArrayRecord.java | 127 + .../SpreadModelClient.java | 112 + .../SpreadModelRecord.java | 126 + .../SpreadRecordDiscriminatedUnionClient.java | 108 + .../SpreadRecordForDiscriminatedUnion.java | 132 + .../SpreadRecordForNonDiscriminatedUnion.java | 133 + ...SpreadRecordForNonDiscriminatedUnion2.java | 133 + ...SpreadRecordForNonDiscriminatedUnion3.java | 133 + .../SpreadRecordForUnion.java | 131 + ...eadRecordNonDiscriminatedUnion2Client.java | 108 + ...eadRecordNonDiscriminatedUnion3Client.java | 108 + ...readRecordNonDiscriminatedUnionClient.java | 108 + .../SpreadRecordUnionClient.java | 108 + .../SpreadStringClient.java | 108 + .../SpreadStringRecord.java | 124 + .../additionalproperties/WidgetData0.java | 98 + .../additionalproperties/WidgetData1.java | 137 + .../additionalproperties/WidgetData2.java | 98 + .../AdditionalPropertiesClientImpl.java | 529 +++ .../ExtendsDifferentSpreadFloatsImpl.java | 116 + ...ExtendsDifferentSpreadModelArraysImpl.java | 128 + .../ExtendsDifferentSpreadModelsImpl.java | 120 + .../ExtendsDifferentSpreadStringsImpl.java | 116 + .../implementation/ExtendsFloatsImpl.java | 114 + .../ExtendsModelArraysImpl.java | 126 + .../implementation/ExtendsModelsImpl.java | 118 + .../implementation/ExtendsStringsImpl.java | 114 + .../ExtendsUnknownDerivedsImpl.java | 118 + .../ExtendsUnknownDiscriminatedsImpl.java | 116 + .../implementation/ExtendsUnknownsImpl.java | 114 + .../implementation/IsFloatsImpl.java | 114 + .../implementation/IsModelArraysImpl.java | 126 + .../implementation/IsModelsImpl.java | 118 + .../implementation/IsStringsImpl.java | 114 + .../implementation/IsUnknownDerivedsImpl.java | 118 + .../IsUnknownDiscriminatedsImpl.java | 116 + .../implementation/IsUnknownsImpl.java | 114 + .../implementation/MultipleSpreadsImpl.java | 114 + .../SpreadDifferentFloatsImpl.java | 114 + .../SpreadDifferentModelArraysImpl.java | 122 + .../SpreadDifferentModelsImpl.java | 118 + .../SpreadDifferentStringsImpl.java | 114 + .../implementation/SpreadFloatsImpl.java | 114 + .../implementation/SpreadModelArraysImpl.java | 126 + .../implementation/SpreadModelsImpl.java | 118 + .../SpreadRecordDiscriminatedUnionsImpl.java | 114 + ...readRecordNonDiscriminatedUnion2sImpl.java | 114 + ...readRecordNonDiscriminatedUnion3sImpl.java | 114 + ...preadRecordNonDiscriminatedUnionsImpl.java | 114 + .../SpreadRecordUnionsImpl.java | 114 + .../implementation/SpreadStringsImpl.java | 114 + .../implementation/package-info.java | 7 + .../additionalproperties/package-info.java | 7 + .../type/property/nullable/BytesClient.java | 189 + .../type/property/nullable/BytesProperty.java | 181 + .../nullable/CollectionsByteClient.java | 197 ++ .../nullable/CollectionsByteProperty.java | 187 + .../nullable/CollectionsModelClient.java | 205 ++ .../nullable/CollectionsModelProperty.java | 187 + .../nullable/CollectionsStringClient.java | 197 ++ .../nullable/CollectionsStringProperty.java | 187 + .../nullable/DatetimeOperationClient.java | 189 + .../property/nullable/DatetimeProperty.java | 191 + .../nullable/DurationOperationClient.java | 189 + .../property/nullable/DurationProperty.java | 185 + .../type/property/nullable/InnerModel.java | 141 + .../nullable/NullableClientBuilder.java | 308 ++ .../nullable/StringOperationClient.java | 189 + .../property/nullable/StringProperty.java | 181 + .../nullable/implementation/BytesImpl.java | 173 + .../implementation/CollectionsBytesImpl.java | 181 + .../implementation/CollectionsModelsImpl.java | 189 + .../CollectionsStringsImpl.java | 181 + .../DatetimeOperationsImpl.java | 173 + .../DurationOperationsImpl.java | 173 + .../implementation/JsonMergePatchHelper.java | 150 + .../implementation/NullableClientImpl.java | 154 + .../implementation/StringOperationsImpl.java | 173 + .../nullable/implementation/package-info.java | 7 + .../type/property/nullable/package-info.java | 7 + .../optional/BooleanLiteralClient.java | 174 + .../optional/BooleanLiteralProperty.java | 91 + .../BooleanLiteralPropertyProperty.java | 47 + .../type/property/optional/BytesClient.java | 174 + .../type/property/optional/BytesProperty.java | 90 + .../optional/CollectionsByteClient.java | 182 + .../optional/CollectionsByteProperty.java | 92 + .../optional/CollectionsModelClient.java | 190 + .../optional/CollectionsModelProperty.java | 92 + .../optional/DatetimeOperationClient.java | 174 + .../property/optional/DatetimeProperty.java | 94 + .../optional/DurationOperationClient.java | 174 + .../property/optional/DurationProperty.java | 93 + .../property/optional/FloatLiteralClient.java | 174 + .../optional/FloatLiteralProperty.java | 91 + .../FloatLiteralPropertyProperty.java | 47 + .../property/optional/IntLiteralClient.java | 174 + .../property/optional/IntLiteralProperty.java | 90 + .../optional/IntLiteralPropertyProperty.java | 47 + .../optional/OptionalClientBuilder.java | 407 +++ .../property/optional/PlainDateClient.java | 174 + .../property/optional/PlainDateProperty.java | 93 + .../property/optional/PlainTimeClient.java | 174 + .../property/optional/PlainTimeProperty.java | 90 + .../optional/RequiredAndOptionalClient.java | 178 + .../optional/RequiredAndOptionalProperty.java | 117 + .../optional/StringLiteralClient.java | 174 + .../optional/StringLiteralProperty.java | 91 + .../StringLiteralPropertyProperty.java | 49 + .../optional/StringOperationClient.java | 174 + .../property/optional/StringProperty.java | 90 + .../optional/UnionFloatLiteralClient.java | 174 + .../optional/UnionFloatLiteralProperty.java | 91 + .../UnionFloatLiteralPropertyProperty.java | 52 + .../optional/UnionIntLiteralClient.java | 174 + .../optional/UnionIntLiteralProperty.java | 91 + .../UnionIntLiteralPropertyProperty.java | 52 + .../optional/UnionStringLiteralClient.java | 174 + .../optional/UnionStringLiteralProperty.java | 91 + .../UnionStringLiteralPropertyProperty.java | 54 + .../implementation/BooleanLiteralsImpl.java | 169 + .../optional/implementation/BytesImpl.java | 169 + .../implementation/CollectionsBytesImpl.java | 177 + .../implementation/CollectionsModelsImpl.java | 185 + .../DatetimeOperationsImpl.java | 169 + .../DurationOperationsImpl.java | 169 + .../implementation/FloatLiteralsImpl.java | 169 + .../implementation/IntLiteralsImpl.java | 169 + .../implementation/OptionalClientImpl.java | 289 ++ .../implementation/PlainDatesImpl.java | 169 + .../implementation/PlainTimesImpl.java | 169 + .../RequiredAndOptionalsImpl.java | 173 + .../implementation/StringLiteralsImpl.java | 169 + .../implementation/StringOperationsImpl.java | 169 + .../UnionFloatLiteralsImpl.java | 169 + .../implementation/UnionIntLiteralsImpl.java | 169 + .../UnionStringLiteralsImpl.java | 169 + .../optional/implementation/package-info.java | 7 + .../type/property/optional/package-info.java | 7 + .../valuetypes/BooleanLiteralClient.java | 102 + .../valuetypes/BooleanLiteralProperty.java | 75 + .../valuetypes/BooleanOperationClient.java | 102 + .../property/valuetypes/BooleanProperty.java | 81 + .../type/property/valuetypes/BytesClient.java | 102 + .../property/valuetypes/BytesProperty.java | 81 + .../valuetypes/CollectionsIntClient.java | 106 + .../valuetypes/CollectionsIntProperty.java | 82 + .../valuetypes/CollectionsModelClient.java | 110 + .../valuetypes/CollectionsModelProperty.java | 82 + .../valuetypes/CollectionsStringClient.java | 106 + .../valuetypes/CollectionsStringProperty.java | 82 + .../valuetypes/DatetimeOperationClient.java | 102 + .../property/valuetypes/DatetimeProperty.java | 84 + .../property/valuetypes/Decimal128Client.java | 102 + .../valuetypes/Decimal128Property.java | 82 + .../property/valuetypes/DecimalClient.java | 102 + .../property/valuetypes/DecimalProperty.java | 82 + .../valuetypes/DictionaryStringClient.java | 106 + .../valuetypes/DictionaryStringProperty.java | 82 + .../valuetypes/DurationOperationClient.java | 102 + .../property/valuetypes/DurationProperty.java | 83 + .../type/property/valuetypes/EnumClient.java | 102 + .../property/valuetypes/EnumProperty.java | 81 + .../property/valuetypes/ExtendedEnum.java | 87 + .../valuetypes/ExtensibleEnumClient.java | 102 + .../valuetypes/ExtensibleEnumProperty.java | 81 + .../property/valuetypes/FixedInnerEnum.java | 54 + .../valuetypes/FloatLiteralClient.java | 102 + .../valuetypes/FloatLiteralProperty.java | 75 + .../valuetypes/FloatOperationClient.java | 102 + .../property/valuetypes/FloatProperty.java | 81 + .../type/property/valuetypes/InnerEnum.java | 93 + .../type/property/valuetypes/InnerModel.java | 81 + .../type/property/valuetypes/IntClient.java | 102 + .../property/valuetypes/IntLiteralClient.java | 102 + .../valuetypes/IntLiteralProperty.java | 75 + .../type/property/valuetypes/IntProperty.java | 81 + .../type/property/valuetypes/ModelClient.java | 106 + .../property/valuetypes/ModelProperty.java | 81 + .../type/property/valuetypes/NeverClient.java | 100 + .../property/valuetypes/NeverProperty.java | 57 + .../valuetypes/StringLiteralClient.java | 102 + .../valuetypes/StringLiteralProperty.java | 75 + .../valuetypes/StringOperationClient.java | 102 + .../property/valuetypes/StringProperty.java | 81 + .../valuetypes/UnionEnumValueClient.java | 102 + .../valuetypes/UnionEnumValueProperty.java | 75 + .../valuetypes/UnionFloatLiteralClient.java | 102 + .../valuetypes/UnionFloatLiteralProperty.java | 81 + .../UnionFloatLiteralPropertyProperty.java | 52 + .../valuetypes/UnionIntLiteralClient.java | 102 + .../valuetypes/UnionIntLiteralProperty.java | 81 + .../UnionIntLiteralPropertyProperty.java | 52 + .../valuetypes/UnionStringLiteralClient.java | 102 + .../UnionStringLiteralProperty.java | 81 + .../UnionStringLiteralPropertyProperty.java | 54 + .../valuetypes/UnknownArrayClient.java | 102 + .../valuetypes/UnknownArrayProperty.java | 83 + .../valuetypes/UnknownDictClient.java | 102 + .../valuetypes/UnknownDictProperty.java | 83 + .../property/valuetypes/UnknownIntClient.java | 102 + .../valuetypes/UnknownIntProperty.java | 83 + .../valuetypes/UnknownStringClient.java | 102 + .../valuetypes/UnknownStringProperty.java | 83 + .../valuetypes/ValueTypesClientBuilder.java | 551 +++ .../implementation/BooleanLiteralsImpl.java | 108 + .../implementation/BooleanOperationsImpl.java | 108 + .../valuetypes/implementation/BytesImpl.java | 108 + .../implementation/CollectionsIntsImpl.java | 112 + .../implementation/CollectionsModelsImpl.java | 116 + .../CollectionsStringsImpl.java | 112 + .../DatetimeOperationsImpl.java | 108 + .../implementation/Decimal128sImpl.java | 108 + .../implementation/DecimalsImpl.java | 108 + .../implementation/DictionaryStringsImpl.java | 112 + .../DurationOperationsImpl.java | 108 + .../valuetypes/implementation/EnumsImpl.java | 108 + .../implementation/ExtensibleEnumsImpl.java | 108 + .../implementation/FloatLiteralsImpl.java | 108 + .../implementation/FloatOperationsImpl.java | 108 + .../implementation/IntLiteralsImpl.java | 108 + .../valuetypes/implementation/IntsImpl.java | 108 + .../valuetypes/implementation/ModelsImpl.java | 112 + .../valuetypes/implementation/NeversImpl.java | 106 + .../implementation/StringLiteralsImpl.java | 108 + .../implementation/StringOperationsImpl.java | 108 + .../implementation/UnionEnumValuesImpl.java | 108 + .../UnionFloatLiteralsImpl.java | 108 + .../implementation/UnionIntLiteralsImpl.java | 108 + .../UnionStringLiteralsImpl.java | 108 + .../implementation/UnknownArraysImpl.java | 108 + .../implementation/UnknownDictsImpl.java | 108 + .../implementation/UnknownIntsImpl.java | 108 + .../implementation/UnknownStringsImpl.java | 108 + .../implementation/ValueTypesClientImpl.java | 484 +++ .../implementation/package-info.java | 7 + .../property/valuetypes/package-info.java | 7 + .../type/scalar/BooleanOperationClient.java | 98 + .../type/scalar/Decimal128TypeClient.java | 127 + .../type/scalar/Decimal128VerifyClient.java | 102 + .../java/type/scalar/DecimalTypeClient.java | 127 + .../java/type/scalar/DecimalVerifyClient.java | 102 + .../java/type/scalar/ScalarClientBuilder.java | 308 ++ .../type/scalar/StringOperationClient.java | 98 + .../main/java/type/scalar/UnknownClient.java | 98 + .../implementation/BooleanOperationsImpl.java | 97 + .../implementation/Decimal128TypesImpl.java | 126 + .../Decimal128VerifiesImpl.java | 108 + .../implementation/DecimalTypesImpl.java | 126 + .../implementation/DecimalVerifiesImpl.java | 108 + .../implementation/ScalarClientImpl.java | 154 + .../implementation/StringOperationsImpl.java | 97 + .../scalar/implementation/UnknownsImpl.java | 97 + .../scalar/implementation/package-info.java | 6 + .../main/java/type/scalar/package-info.java | 6 + .../src/main/java/type/union/Cat.java | 81 + .../src/main/java/type/union/Dog.java | 81 + .../main/java/type/union/EnumsOnlyCases.java | 103 + .../java/type/union/EnumsOnlyCasesLr.java | 64 + .../java/type/union/EnumsOnlyCasesUd.java | 54 + .../main/java/type/union/EnumsOnlyClient.java | 111 + .../java/type/union/FloatsOnlyClient.java | 105 + .../src/main/java/type/union/GetResponse.java | 81 + .../main/java/type/union/GetResponse1.java | 81 + .../main/java/type/union/GetResponse2.java | 81 + .../main/java/type/union/GetResponse3.java | 81 + .../main/java/type/union/GetResponse4.java | 83 + .../main/java/type/union/GetResponse5.java | 81 + .../main/java/type/union/GetResponse6.java | 81 + .../main/java/type/union/GetResponse7.java | 81 + .../main/java/type/union/GetResponse8.java | 81 + .../main/java/type/union/GetResponse9.java | 81 + .../java/type/union/GetResponseProp1.java | 57 + .../java/type/union/GetResponseProp2.java | 57 + .../java/type/union/GetResponseProp3.java | 93 + .../java/type/union/GetResponseProp4.java | 59 + .../main/java/type/union/IntsOnlyClient.java | 105 + .../java/type/union/MixedLiteralsCases.java | 157 + .../java/type/union/MixedLiteralsClient.java | 115 + .../main/java/type/union/MixedTypesCases.java | 180 + .../java/type/union/MixedTypesClient.java | 121 + .../java/type/union/ModelsOnlyClient.java | 105 + .../java/type/union/StringAndArrayCases.java | 106 + .../java/type/union/StringAndArrayClient.java | 111 + .../type/union/StringExtensibleClient.java | 105 + .../union/StringExtensibleNamedClient.java | 105 + .../union/StringExtensibleNamedUnion.java | 93 + .../java/type/union/StringsOnlyClient.java | 105 + .../java/type/union/UnionClientBuilder.java | 341 ++ .../union/implementation/EnumsOnliesImpl.java | 111 + .../implementation/FloatsOnliesImpl.java | 108 + .../union/implementation/IntsOnliesImpl.java | 102 + .../implementation/MixedLiteralsImpl.java | 118 + .../union/implementation/MixedTypesImpl.java | 124 + .../implementation/ModelsOnliesImpl.java | 108 + .../union/implementation/SendRequest.java | 82 + .../union/implementation/SendRequest1.java | 82 + .../union/implementation/SendRequest2.java | 82 + .../union/implementation/SendRequest3.java | 82 + .../union/implementation/SendRequest4.java | 83 + .../union/implementation/SendRequest5.java | 82 + .../union/implementation/SendRequest6.java | 82 + .../union/implementation/SendRequest7.java | 82 + .../union/implementation/SendRequest8.java | 82 + .../union/implementation/SendRequest9.java | 82 + .../implementation/StringAndArraysImpl.java | 114 + .../StringExtensibleNamedsImpl.java | 108 + .../implementation/StringExtensiblesImpl.java | 108 + .../implementation/StringsOnliesImpl.java | 108 + .../union/implementation/UnionClientImpl.java | 199 ++ .../union/implementation/package-info.java | 7 + .../main/java/type/union/package-info.java | 7 + .../java/versioning/added/AddedClient.java | 136 + .../versioning/added/AddedClientBuilder.java | 289 ++ .../versioning/added/AddedServiceVersion.java | 43 + .../main/java/versioning/added/EnumV1.java | 54 + .../main/java/versioning/added/EnumV2.java | 49 + .../versioning/added/InterfaceV2Client.java | 82 + .../main/java/versioning/added/ModelV1.java | 127 + .../main/java/versioning/added/ModelV2.java | 127 + .../main/java/versioning/added/Versions.java | 54 + .../added/implementation/AddedClientImpl.java | 214 ++ .../implementation/InterfaceV2sImpl.java | 105 + .../added/implementation/package-info.java | 7 + .../java/versioning/added/package-info.java | 7 + .../madeoptional/MadeOptionalClient.java | 107 + .../MadeOptionalClientBuilder.java | 281 ++ .../MadeOptionalServiceVersion.java | 43 + .../versioning/madeoptional/TestModel.java | 116 + .../versioning/madeoptional/Versions.java | 54 + .../MadeOptionalClientImpl.java | 158 + .../implementation/package-info.java | 7 + .../versioning/madeoptional/package-info.java | 7 + .../main/java/versioning/removed/EnumV2.java | 49 + .../main/java/versioning/removed/EnumV3.java | 54 + .../main/java/versioning/removed/ModelV2.java | 127 + .../main/java/versioning/removed/ModelV3.java | 103 + .../versioning/removed/RemovedClient.java | 132 + .../removed/RemovedClientBuilder.java | 280 ++ .../removed/RemovedServiceVersion.java | 48 + .../java/versioning/removed/Versions.java | 59 + .../implementation/RemovedClientImpl.java | 194 + .../removed/implementation/package-info.java | 7 + .../java/versioning/removed/package-info.java | 7 + .../java/versioning/renamedfrom/NewEnum.java | 49 + .../renamedfrom/NewInterfaceClient.java | 82 + .../java/versioning/renamedfrom/NewModel.java | 127 + .../renamedfrom/RenamedFromClient.java | 84 + .../renamedfrom/RenamedFromClientBuilder.java | 291 ++ .../RenamedFromServiceVersion.java | 43 + .../java/versioning/renamedfrom/Versions.java | 54 + .../implementation/NewInterfacesImpl.java | 105 + .../implementation/RenamedFromClientImpl.java | 172 + .../implementation/package-info.java | 7 + .../versioning/renamedfrom/package-info.java | 7 + .../ReturnTypeChangedFromClient.java | 74 + .../ReturnTypeChangedFromClientBuilder.java | 281 ++ .../ReturnTypeChangedFromServiceVersion.java | 43 + .../returntypechangedfrom/Versions.java | 54 + .../ReturnTypeChangedFromClientImpl.java | 146 + .../implementation/package-info.java | 7 + .../returntypechangedfrom/package-info.java | 7 + .../versioning/typechangedfrom/TestModel.java | 103 + .../TypeChangedFromClient.java | 82 + .../TypeChangedFromClientBuilder.java | 281 ++ .../TypeChangedFromServiceVersion.java | 43 + .../versioning/typechangedfrom/Versions.java | 54 + .../TypeChangedFromClientImpl.java | 157 + .../implementation/package-info.java | 7 + .../typechangedfrom/package-info.java | 7 + ...hentication-apikey_apiview_properties.json | 12 + ...cation-http-custom_apiview_properties.json | 12 + .../encode-numeric_apiview_properties.json | 16 + .../parameters-basic_apiview_properties.json | 14 + ...rs-bodyoptionality_apiview_properties.json | 17 + ...s-collectionformat_apiview_properties.json | 20 + .../parameters-spread_apiview_properties.json | 35 + ...contentnegotiation_apiview_properties.json | 17 + ...oad-jsonmergepatch_apiview_properties.json | 16 + .../payload-mediatype_apiview_properties.json | 15 + .../payload-multipart_apiview_properties.json | 52 + .../payload-pageable_apiview_properties.json | 12 + .../META-INF/routes_apiview_properties.json | 115 + ...n-encodedname-json_apiview_properties.json | 12 + ...ndpoint-notdefined_apiview_properties.json | 9 + ...rver-path-multiple_apiview_properties.json | 11 + ...server-path-single_apiview_properties.json | 9 + ...sions-notversioned_apiview_properties.json | 13 + ...versions-versioned_apiview_properties.json | 15 + .../specialwords_apiview_properties.json | 244 ++ .../type-array_apiview_properties.json | 77 + .../type-dictionary_apiview_properties.json | 62 + ...e-enums-extensible_apiview_properties.json | 16 + .../type-enums-fixed_apiview_properties.json | 14 + .../type-model-empty_apiview_properties.json | 16 + ...-enumdiscriminator_apiview_properties.json | 29 + ...esteddiscriminator_apiview_properties.json | 24 + ...e-notdiscriminated_apiview_properties.json | 16 + ...eritance-recursive_apiview_properties.json | 13 + ...inglediscriminator_apiview_properties.json | 28 + .../type-model-usage_apiview_properties.json | 16 + ...e-model-visibility_apiview_properties.json | 23 + ...ditionalproperties_apiview_properties.json | 204 ++ ...-property-nullable_apiview_properties.json | 77 + ...-property-optional_apiview_properties.json | 173 + ...roperty-valuetypes_apiview_properties.json | 187 + .../type-scalar_apiview_properties.json | 45 + .../type-union_apiview_properties.json | 89 + .../versioning-added_apiview_properties.json | 19 + ...oning-madeoptional_apiview_properties.json | 11 + ...versioning-removed_apiview_properties.json | 16 + ...ioning-renamedfrom_apiview_properties.json | 15 + ...urntypechangedfrom_apiview_properties.json | 10 + ...ng-typechangedfrom_apiview_properties.json | 11 + .../authentication/apikey/ApiKeyTests.java | 33 + .../http/custom/CustomAuthTests.java | 33 + .../encode/numeric/StringEncodeTests.java | 23 + .../test/java/org/utils/BinaryDataUtils.java | 20 + .../src/test/java/org/utils/FileUtils.java | 39 + .../parameters/basic/BasicClientTests.java | 18 + .../parameters/bodyoptionality/BodyTests.java | 57 + .../CollectionFormatClientTest.java | 44 + .../java/parameters/spread/SpreadTests.java | 38 + .../contentnegotiation/SharedRouteTests.java | 41 + .../JsonMergePatchClientTest.java | 64 + .../payload/mediatype/MediaTypeTests.java | 23 + .../payload/multipart/MultipartTests.java | 258 ++ .../src/test/java/routes/RouteTests.java | 89 + .../encodedname/json/JsonTests.java | 16 + .../endpoint/notdefined/EndpointTests.java | 14 + .../java/specialwords/ModelClientTest.java | 19 + .../specialwords/ModelPropertyClientTest.java | 17 + .../specialwords/OperationClientTest.java | 16 + .../specialwords/ParameterClientTest.java | 16 + .../test/java/specialwords/ReflectHelper.java | 25 + .../type/array/BooleanValueClientTest.java | 28 + .../type/array/DatetimeValueClientTest.java | 30 + .../type/array/DurationValueClientTest.java | 30 + .../type/array/Float32ValueClientTest.java | 26 + .../java/type/array/Int32ValueClientTest.java | 28 + .../java/type/array/Int64ValueClientTest.java | 27 + .../java/type/array/ModelValueClientTest.java | 31 + .../array/NullableBooleanValueClientTest.java | 27 + .../array/NullableFloatValueClientTest.java | 27 + .../array/NullableInt32ValueClientTest.java | 27 + .../array/NullableModelValueClientTest.java | 33 + .../array/NullableStringValueClientTest.java | 27 + .../type/array/StringValueClientTest.java | 27 + .../type/array/UnknownValueClientTest.java | 46 + .../type/dictionary/BooleanValueTests.java | 30 + .../dictionary/DatetimeValueClientTest.java | 31 + .../dictionary/DurationValueClientTest.java | 31 + .../dictionary/Float32ValueClientTest.java | 28 + .../type/dictionary/Int32ValueClientTest.java | 31 + .../type/dictionary/Int64ValueClientTest.java | 31 + .../type/dictionary/ModelValueClientTest.java | 40 + .../NullableFloatValueClientTests.java | 54 + .../RecursiveModelValueClientTest.java | 44 + .../dictionary/StringValueClientTest.java | 29 + .../dictionary/UnknownValueClientTest.java | 55 + .../extensible/ExtensibleClientTest.java | 40 + .../type/enums/fixed/FixedClientTest.java | 39 + .../type/model/empty/EmptyModelTests.java | 23 + .../inheritance/EnumDiscriminatorTests.java | 35 + .../model/inheritance/InheritanceTests.java | 35 + .../inheritance/NestedDiscriminatorTests.java | 86 + .../inheritance/RecursiveReferenceTests.java | 20 + .../inheritance/SingleDiscriminatorTest.java | 39 + .../model/usage/ModelsUsageClientTest.java | 31 + .../type/model/usage/UsageClientTest.java | 31 + .../model/visibility/AutomaticClientTest.java | 64 + .../additionalproperties/ExtendsTests.java | 229 ++ .../IsFloatClientTest.java | 27 + .../IsModelArrayClientTest.java | 35 + .../IsModelClientTest.java | 30 + .../IsStringClientTest.java | 28 + .../IsUnknownClientTest.java | 75 + .../MultipleSpreadTests.java | 33 + .../additionalproperties/SpreadTests.java | 292 ++ .../property/nullable/BytesClientTest.java | 36 + .../nullable/CollectionsByteClientTest.java | 41 + .../nullable/CollectionsModelClientTest.java | 40 + .../nullable/CollectionsStringClientTest.java | 46 + .../nullable/DatetimeOperationClientTest.java | 40 + .../nullable/DurationOperationClientTest.java | 42 + .../property/nullable/StringClientTests.java | 25 + .../optional/BooleanLiteralClientTests.java | 36 + .../property/optional/BytesClientTest.java | 37 + .../optional/CollectionsByteClientTest.java | 41 + .../optional/CollectionsModelClientTest.java | 45 + .../optional/DatetimeOperationClientTest.java | 39 + .../optional/DurationOperationClientTest.java | 41 + .../optional/FloatLiteralClientTests.java | 36 + .../optional/IntLiteralClientTests.java | 36 + .../optional/PlainDateClientTests.java | 34 + .../optional/PlainTimeClientTests.java | 31 + .../RequiredAndOptionalClientTest.java | 38 + .../optional/StringLiteralClientTests.java | 36 + .../optional/StringOperationClientTest.java | 37 + .../UnionFloatLiteralClientTests.java | 37 + .../optional/UnionIntLiteralClientTests.java | 36 + .../UnionStringLiteralClientTests.java | 36 + .../BooleanOperationClientTest.java | 24 + .../property/valuetypes/BytesClientTest.java | 25 + .../valuetypes/CollectionsIntClientTest.java | 28 + .../CollectionsModelClientTest.java | 31 + .../CollectionsStringClientTest.java | 27 + .../DatetimeOperationClientTest.java | 26 + .../property/valuetypes/DecimalTests.java | 19 + .../DictionaryStringClientTest.java | 31 + .../DurationOperationClientTest.java | 28 + .../property/valuetypes/EnumClientTest.java | 26 + .../property/valuetypes/EnumValueTests.java | 16 + .../valuetypes/ExtensibleEnumClientTest.java | 25 + .../valuetypes/FloatOperationClientTest.java | 24 + .../property/valuetypes/IntClientTest.java | 24 + .../property/valuetypes/LiteralTests.java | 50 + .../property/valuetypes/ModelClientTest.java | 25 + .../property/valuetypes/NeverClientTest.java | 23 + .../valuetypes/StringOperationClientTest.java | 24 + .../type/property/valuetypes/UnionTests.java | 44 + .../property/valuetypes/UnknownTests.java | 59 + .../test/java/type/scalar/DecimalTests.java | 55 + .../test/java/type/scalar/ScalarTests.java | 53 + .../java/type/union/UnionsClientTest.java | 109 + .../org.mockito.plugins.MockMaker | 1 + .../tspconfig.yaml | 9 + .../core/model/clientmodel/ClassType.java | 4 +- .../core/template/ServiceVersionTemplate.java | 3 +- .../GenericMultipartFormDataHelper.java | 4 +- .../http-client-generator-test/package.json | 4 +- packages/http-client-java/generator/pom.xml | 1 + packages/http-client-java/package-lock.json | 3118 ++++++++++++++++- packages/http-client-java/package.json | 1 + 996 files changed, 105811 insertions(+), 131 deletions(-) create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/Generate.ps1 create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/Setup.ps1 create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/Spector-Tests.ps1 create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/package.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/pom.xml create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/ApiKeyClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/ApiKeyClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/InvalidAuth.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/implementation/ApiKeyClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/CustomClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/CustomClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/InvalidAuth.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/implementation/CustomClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/NumericClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/NumericClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/implementation/NumericClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/implementation/PropertiesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/property/SafeintAsStringProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/property/Uint32AsStringProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/property/Uint8AsStringProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/property/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/BasicClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/ExplicitBodyClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/ImplicitBodyClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/explicitbody/User.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/explicitbody/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implementation/BasicClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implementation/ExplicitBodiesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implementation/ImplicitBodiesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implicitbody/implementation/SimpleRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implicitbody/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/BodyModel.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/BodyOptionalityClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/BodyOptionalityClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/OptionalExplicitClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/implementation/BodyOptionalityClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/implementation/OptionalExplicitsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/CollectionFormatClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/HeaderClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/QueryClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/implementation/CollectionFormatClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/implementation/HeadersImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/implementation/QueriesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/AliasClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/ModelClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/SpreadClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/alias/implementation/SpreadAsRequestBodyRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/alias/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/AliasImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/ModelsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadAsRequestParameterRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadCompositeRequestMixRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadParameterWithInnerAliasRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadParameterWithInnerModelRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadWithMultipleParametersRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/model/BodyParameter.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/model/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/ContentNegotiationClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/DifferentBodyClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/SameBodyClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/differentbody/PngImageAsJson.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/differentbody/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/implementation/ContentNegotiationClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/implementation/DifferentBodiesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/implementation/SameBodiesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/InnerModel.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/JsonMergePatchClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/JsonMergePatchClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/Resource.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/ResourcePatch.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/implementation/JsonMergePatchClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/implementation/JsonMergePatchHelper.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/MediaTypeClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/MediaTypeClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/implementation/MediaTypeClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/implementation/StringBodiesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/Address.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/BinaryArrayPartsRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/ComplexHttpPartsModelRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/ComplexPartsRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileOptionalContentType.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileRequiredMetaData.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileSpecificContentType.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileWithHttpPartOptionalContentTypeRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileWithHttpPartRequiredContentTypeRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileWithHttpPartSpecificContentTypeRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FormDataClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FormDataHttpPartsClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FormDataHttpPartsContentTypeClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FormDataHttpPartsNonStringClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/JsonPartRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/MultiBinaryPartsRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/MultiPartClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/MultiPartRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/PictureFileDetails.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/PicturesFileDetails.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/ProfileImageFileDetails.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/formdata/httpparts/nonstring/FloatRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/formdata/httpparts/nonstring/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/AnonymousModelRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/FormDataHttpPartsContentTypesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/FormDataHttpPartsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/FormDataHttpPartsNonStringsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/FormDatasImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/MultiPartClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/MultipartFormDataHelper.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/PageableClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/PageableClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/Pet.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/implementation/PageableClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/implementation/ServerDrivenPaginationsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/serverdrivenpagination/LinkResponse.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/serverdrivenpagination/LinkResponseLinks.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/serverdrivenpagination/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/InInterfaceClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersLabelExpansionExplodeClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersLabelExpansionStandardClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersMatrixExpansionExplodeClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersMatrixExpansionStandardClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersPathExpansionExplodeClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersPathExpansionStandardClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersReservedExpansionClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersSimpleExpansionExplodeClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersSimpleExpansionStandardClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersQueryContinuationExplodeClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersQueryContinuationStandardClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersQueryExpansionExplodeClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersQueryExpansionStandardClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/RoutesClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/RoutesClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/InInterfacesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersLabelExpansionExplodesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersLabelExpansionStandardsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersMatrixExpansionExplodesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersMatrixExpansionStandardsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersPathExpansionExplodesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersPathExpansionStandardsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersReservedExpansionsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersSimpleExpansionExplodesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersSimpleExpansionStandardsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersQueryContinuationExplodesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersQueryContinuationStandardsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersQueryExpansionExplodesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersQueryExpansionStandardsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/RoutesClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/JsonClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/JsonClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/implementation/JsonClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/implementation/PropertiesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/property/JsonEncodedNameModel.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/property/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/NotDefinedClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/NotDefinedClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/implementation/NotDefinedClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/MultipleClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/MultipleClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/MultipleServiceVersion.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/implementation/MultipleClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/SingleClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/SingleClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/implementation/SingleClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/NotVersionedClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/NotVersionedClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/implementation/NotVersionedClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/VersionedClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/VersionedClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/VersionedServiceVersion.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/implementation/VersionedClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/ModelPropertiesClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/ModelsClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/OperationsClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/ParametersClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/SpecialWordsClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/ModelPropertiesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/ModelsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/OperationsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/ParametersImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/SpecialWordsClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/modelproperties/SameAsModel.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/modelproperties/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/And.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/As.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Assert.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Async.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Await.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Break.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/ClassModel.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Constructor.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Continue.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Def.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Del.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Elif.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Else.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Except.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Exec.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Finally.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/For.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/From.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Global.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/If.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Import.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/In.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Is.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Lambda.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Not.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Or.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Pass.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Raise.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Return.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Try.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/While.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/With.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Yield.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/ArrayClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/BooleanValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/DatetimeValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/DurationValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/Float32ValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/InnerModel.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/Int32ValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/Int64ValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/ModelValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableBooleanValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableFloatValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableInt32ValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableModelValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableStringValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/StringValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/UnknownValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/ArrayClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/BooleanValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/DatetimeValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/DurationValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/Float32ValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/Int32ValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/Int64ValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/ModelValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableBooleanValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableFloatValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableInt32ValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableModelValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableStringValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/StringValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/UnknownValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/BooleanValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/DatetimeValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/DictionaryClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/DurationValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/Float32ValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/InnerModel.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/Int32ValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/Int64ValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/ModelValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/NullableFloatValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/RecursiveModelValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/StringValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/UnknownValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/BooleanValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/DatetimeValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/DictionaryClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/DurationValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/Float32ValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/Int32ValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/Int64ValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/ModelValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/NullableFloatValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/RecursiveModelValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/StringValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/UnknownValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/DaysOfWeekExtensibleEnum.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/ExtensibleClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/ExtensibleClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/implementation/ExtensibleClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/implementation/StringOperationsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/DaysOfWeekEnum.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/FixedClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/FixedClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/implementation/FixedClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/implementation/StringOperationsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyInput.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyInputOutput.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyOutput.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/implementation/EmptyClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/Cobra.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/Dog.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/DogKind.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/Golden.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/Snake.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/SnakeKind.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/implementation/EnumDiscriminatorClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/Fish.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/GoblinShark.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/Salmon.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/SawShark.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/Shark.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/implementation/NestedDiscriminatorClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/Cat.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/NotDiscriminatedClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/NotDiscriminatedClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/Pet.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/Siamese.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/implementation/NotDiscriminatedClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/Element.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/Extension.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/RecursiveClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/RecursiveClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/implementation/RecursiveClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Bird.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Dinosaur.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Eagle.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Goose.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SeaGull.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Sparrow.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/TRex.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/InputOutputRecord.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/InputRecord.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/OutputRecord.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/UsageClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/UsageClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/implementation/UsageClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/ReadOnlyModel.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/VisibilityClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/VisibilityClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/VisibilityModel.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/implementation/VisibilityClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/AdditionalPropertiesClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadFloatDerived.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadFloatRecord.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadModelArrayDerived.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadModelArrayRecord.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadModelDerived.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadModelRecord.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadStringDerived.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadStringRecord.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsDifferentSpreadFloatClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsDifferentSpreadModelArrayClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsDifferentSpreadModelClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsDifferentSpreadStringClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsFloatAdditionalProperties.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsFloatClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsModelAdditionalProperties.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsModelArrayAdditionalProperties.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsModelArrayClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsModelClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsStringAdditionalProperties.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsStringClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownAdditionalProperties.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownAdditionalPropertiesDerived.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownAdditionalPropertiesDiscriminated.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownAdditionalPropertiesDiscriminatedDerived.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownDerivedClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownDiscriminatedClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsFloatAdditionalProperties.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsFloatClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsModelAdditionalProperties.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsModelArrayAdditionalProperties.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsModelArrayClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsModelClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsStringAdditionalProperties.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsStringClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownAdditionalProperties.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownAdditionalPropertiesDerived.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownAdditionalPropertiesDiscriminated.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownAdditionalPropertiesDiscriminatedDerived.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownDerivedClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownDiscriminatedClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ModelForRecord.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/MultipleSpreadClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/MultipleSpreadRecord.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadDifferentFloatClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadDifferentModelArrayClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadDifferentModelClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadDifferentStringClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadFloatClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadFloatRecord.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadModelArrayClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadModelArrayRecord.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadModelClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadModelRecord.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordDiscriminatedUnionClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForDiscriminatedUnion.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForNonDiscriminatedUnion.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForNonDiscriminatedUnion2.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForNonDiscriminatedUnion3.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForUnion.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion2Client.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion3Client.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnionClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordUnionClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadStringClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadStringRecord.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/WidgetData0.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/WidgetData1.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/WidgetData2.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/AdditionalPropertiesClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsDifferentSpreadFloatsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelArraysImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsDifferentSpreadStringsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsFloatsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsModelArraysImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsModelsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsStringsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsUnknownDerivedsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsUnknownDiscriminatedsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsUnknownsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsFloatsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsModelArraysImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsModelsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsStringsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsUnknownDerivedsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsUnknownDiscriminatedsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsUnknownsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/MultipleSpreadsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadDifferentFloatsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadDifferentModelArraysImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadDifferentModelsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadDifferentStringsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadFloatsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadModelArraysImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadModelsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordDiscriminatedUnionsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion2sImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion3sImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnionsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordUnionsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadStringsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/BytesClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/BytesProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsByteClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsByteProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsModelClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsModelProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsStringClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsStringProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/DatetimeOperationClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/DatetimeProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/DurationOperationClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/DurationProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/InnerModel.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/NullableClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/StringOperationClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/StringProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/BytesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/CollectionsBytesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/CollectionsModelsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/CollectionsStringsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/DatetimeOperationsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/DurationOperationsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/JsonMergePatchHelper.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/NullableClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/StringOperationsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BooleanLiteralClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BooleanLiteralProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BooleanLiteralPropertyProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BytesClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BytesProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/CollectionsByteClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/CollectionsByteProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/CollectionsModelClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/CollectionsModelProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/DatetimeOperationClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/DatetimeProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/DurationOperationClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/DurationProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/FloatLiteralClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/FloatLiteralProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/FloatLiteralPropertyProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/IntLiteralClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/IntLiteralProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/IntLiteralPropertyProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/OptionalClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/PlainDateClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/PlainDateProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/PlainTimeClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/PlainTimeProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/RequiredAndOptionalClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/RequiredAndOptionalProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringLiteralClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringLiteralProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringLiteralPropertyProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringOperationClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionFloatLiteralClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionFloatLiteralProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionFloatLiteralPropertyProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionIntLiteralClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionIntLiteralProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionIntLiteralPropertyProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionStringLiteralClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionStringLiteralProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionStringLiteralPropertyProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/BooleanLiteralsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/BytesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/CollectionsBytesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/CollectionsModelsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/DatetimeOperationsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/DurationOperationsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/FloatLiteralsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/IntLiteralsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/OptionalClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/PlainDatesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/PlainTimesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/RequiredAndOptionalsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/StringLiteralsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/StringOperationsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/UnionFloatLiteralsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/UnionIntLiteralsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/UnionStringLiteralsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BooleanLiteralClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BooleanLiteralProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BooleanOperationClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BooleanProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BytesClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BytesProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsIntClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsIntProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsModelClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsModelProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsStringClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsStringProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DatetimeOperationClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DatetimeProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/Decimal128Client.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/Decimal128Property.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DecimalClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DecimalProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DictionaryStringClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DictionaryStringProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DurationOperationClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DurationProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/EnumClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/EnumProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ExtendedEnum.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ExtensibleEnumClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ExtensibleEnumProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FixedInnerEnum.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FloatLiteralClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FloatLiteralProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FloatOperationClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FloatProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/InnerEnum.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/InnerModel.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/IntClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/IntLiteralClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/IntLiteralProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/IntProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ModelClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ModelProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/NeverClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/NeverProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/StringLiteralClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/StringLiteralProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/StringOperationClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/StringProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionEnumValueClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionEnumValueProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionFloatLiteralClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionFloatLiteralProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionFloatLiteralPropertyProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionIntLiteralClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionIntLiteralProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionIntLiteralPropertyProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionStringLiteralClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionStringLiteralProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionStringLiteralPropertyProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownArrayClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownArrayProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownDictClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownDictProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownIntClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownIntProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownStringClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownStringProperty.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ValueTypesClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/BooleanLiteralsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/BooleanOperationsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/BytesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/CollectionsIntsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/CollectionsModelsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/CollectionsStringsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/DatetimeOperationsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/Decimal128sImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/DecimalsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/DictionaryStringsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/DurationOperationsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/EnumsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/ExtensibleEnumsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/FloatLiteralsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/FloatOperationsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/IntLiteralsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/IntsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/ModelsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/NeversImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/StringLiteralsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/StringOperationsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnionEnumValuesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnionFloatLiteralsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnionIntLiteralsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnionStringLiteralsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnknownArraysImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnknownDictsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnknownIntsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnknownStringsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/ValueTypesClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/BooleanOperationClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/Decimal128TypeClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/Decimal128VerifyClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/DecimalTypeClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/DecimalVerifyClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/ScalarClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/StringOperationClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/UnknownClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/BooleanOperationsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/Decimal128TypesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/Decimal128VerifiesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/DecimalTypesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/DecimalVerifiesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/ScalarClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/StringOperationsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/UnknownsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/Cat.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/Dog.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/EnumsOnlyCases.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/EnumsOnlyCasesLr.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/EnumsOnlyCasesUd.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/EnumsOnlyClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/FloatsOnlyClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse1.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse2.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse3.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse4.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse5.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse6.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse7.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse8.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse9.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponseProp1.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponseProp2.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponseProp3.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponseProp4.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/IntsOnlyClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/MixedLiteralsCases.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/MixedLiteralsClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/MixedTypesCases.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/MixedTypesClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/ModelsOnlyClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringAndArrayCases.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringAndArrayClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringExtensibleClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringExtensibleNamedClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringExtensibleNamedUnion.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringsOnlyClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/UnionClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/EnumsOnliesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/FloatsOnliesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/IntsOnliesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/MixedLiteralsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/MixedTypesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/ModelsOnliesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest1.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest2.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest3.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest4.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest5.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest6.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest7.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest8.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest9.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/StringAndArraysImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/StringExtensibleNamedsImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/StringExtensiblesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/StringsOnliesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/UnionClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/AddedClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/AddedClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/AddedServiceVersion.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/EnumV1.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/EnumV2.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/InterfaceV2Client.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/ModelV1.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/ModelV2.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/Versions.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/implementation/AddedClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/implementation/InterfaceV2sImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/MadeOptionalClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/MadeOptionalClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/MadeOptionalServiceVersion.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/TestModel.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/Versions.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/implementation/MadeOptionalClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/EnumV2.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/EnumV3.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/ModelV2.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/ModelV3.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/RemovedClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/RemovedClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/RemovedServiceVersion.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/Versions.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/implementation/RemovedClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/NewEnum.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/NewInterfaceClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/NewModel.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/RenamedFromClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/RenamedFromClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/RenamedFromServiceVersion.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/Versions.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/implementation/NewInterfacesImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/implementation/RenamedFromClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/ReturnTypeChangedFromClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/ReturnTypeChangedFromClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/ReturnTypeChangedFromServiceVersion.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/Versions.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/implementation/ReturnTypeChangedFromClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/TestModel.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/TypeChangedFromClient.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/TypeChangedFromClientBuilder.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/TypeChangedFromServiceVersion.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/Versions.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/implementation/TypeChangedFromClientImpl.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/implementation/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/package-info.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/authentication-apikey_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/authentication-http-custom_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/encode-numeric_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-basic_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-bodyoptionality_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-collectionformat_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-spread_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-contentnegotiation_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-jsonmergepatch_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-mediatype_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-multipart_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-pageable_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/routes_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/serialization-encodedname-json_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-endpoint-notdefined_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-path-multiple_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-path-single_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-versions-notversioned_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-versions-versioned_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/specialwords_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-array_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-dictionary_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-enums-extensible_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-enums-fixed_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-empty_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-enumdiscriminator_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-nesteddiscriminator_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-notdiscriminated_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-recursive_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-usage_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-visibility_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-property-additionalproperties_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-property-nullable_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-property-optional_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-property-valuetypes_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-scalar_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-union_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-added_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-madeoptional_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-removed_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-renamedfrom_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-returntypechangedfrom_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-typechangedfrom_apiview_properties.json create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/authentication/apikey/ApiKeyTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/authentication/http/custom/CustomAuthTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/encode/numeric/StringEncodeTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/org/utils/BinaryDataUtils.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/org/utils/FileUtils.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/basic/BasicClientTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/bodyoptionality/BodyTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/collectionformat/CollectionFormatClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/spread/SpreadTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/payload/contentnegotiation/SharedRouteTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/payload/jsonmergepatch/JsonMergePatchClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/payload/mediatype/MediaTypeTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/payload/multipart/MultipartTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/routes/RouteTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/serialization/encodedname/json/JsonTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/server/endpoint/notdefined/EndpointTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/ModelClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/ModelPropertyClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/OperationClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/ParameterClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/ReflectHelper.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/BooleanValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/DatetimeValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/DurationValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/Float32ValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/Int32ValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/Int64ValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/ModelValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableBooleanValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableFloatValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableInt32ValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableModelValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableStringValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/StringValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/UnknownValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/BooleanValueTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/DatetimeValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/DurationValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/Float32ValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/Int32ValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/Int64ValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/ModelValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/NullableFloatValueClientTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/RecursiveModelValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/StringValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/UnknownValueClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/enums/extensible/ExtensibleClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/enums/fixed/FixedClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/empty/EmptyModelTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/EnumDiscriminatorTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/InheritanceTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/NestedDiscriminatorTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/RecursiveReferenceTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/usage/ModelsUsageClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/usage/UsageClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/visibility/AutomaticClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/ExtendsTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsFloatClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsModelArrayClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsModelClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsStringClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsUnknownClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/MultipleSpreadTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/SpreadTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/BytesClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/CollectionsByteClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/CollectionsModelClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/CollectionsStringClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/DatetimeOperationClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/DurationOperationClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/StringClientTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/BooleanLiteralClientTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/BytesClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/CollectionsByteClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/CollectionsModelClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/DatetimeOperationClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/DurationOperationClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/FloatLiteralClientTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/IntLiteralClientTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/PlainDateClientTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/PlainTimeClientTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/RequiredAndOptionalClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/StringLiteralClientTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/StringOperationClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/UnionFloatLiteralClientTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/UnionIntLiteralClientTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/UnionStringLiteralClientTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/BooleanOperationClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/BytesClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/CollectionsIntClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/CollectionsModelClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/CollectionsStringClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/DatetimeOperationClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/DecimalTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/DictionaryStringClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/DurationOperationClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/EnumClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/EnumValueTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/ExtensibleEnumClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/FloatOperationClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/IntClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/LiteralTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/ModelClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/NeverClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/StringOperationClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/UnionTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/UnknownTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/scalar/DecimalTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/scalar/ScalarTests.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/union/UnionsClientTest.java create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker create mode 100644 packages/http-client-java/generator/http-client-generator-clientcore-test/tspconfig.yaml diff --git a/.prettierignore b/.prettierignore index d81e0d264e..c70b91eeb6 100644 --- a/.prettierignore +++ b/.prettierignore @@ -59,3 +59,4 @@ packages/http-client-csharp/generator/TestProjects/**/tspCodeModel.json # auto generated api view properties files packages/http-client-java/generator/http-client-generator-test/src/main/**/*.json +packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/**/*.json diff --git a/cspell.yaml b/cspell.yaml index 97a025dea0..c61e6e1e9b 100644 --- a/cspell.yaml +++ b/cspell.yaml @@ -266,6 +266,7 @@ ignorePaths: - "**/ThirdPartyNotices.txt" - packages/compiler/test/formatter/scenarios/** - packages/http-client-java/generator/http-client-generator-test/** + - packages/http-client-java/generator/http-client-generator-clientcore-test/** - pnpm-lock.yaml - "**/*.mp4" - .git/** diff --git a/packages/http-client-java/eng/pipeline/publish.yml b/packages/http-client-java/eng/pipeline/publish.yml index 2a02c45d83..c5b54aa2d3 100644 --- a/packages/http-client-java/eng/pipeline/publish.yml +++ b/packages/http-client-java/eng/pipeline/publish.yml @@ -17,7 +17,7 @@ extends: parameters: BuildPrereleaseVersion: true UseTypeSpecNext: false - Publish: "public" + Publish: ${{replace(replace('True',eq(variables['Build.SourceBranchName'], 'main'), 'public'),'True','internal')}} PublishDependsOnTest: true PackagePath: /packages/http-client-java EmitterPackageJsonPath: packages/http-client-java/emitter/package.json @@ -30,4 +30,3 @@ extends: LanguageShortName: "java" HasNugetPackages: false CadlRanchName: "@typespec/http-client-java" - EnableCadlRanchReport: false diff --git a/packages/http-client-java/eng/scripts/Generate.ps1 b/packages/http-client-java/eng/scripts/Generate.ps1 index 20164e1695..c29548fb3c 100644 --- a/packages/http-client-java/eng/scripts/Generate.ps1 +++ b/packages/http-client-java/eng/scripts/Generate.ps1 @@ -12,9 +12,12 @@ $env:PATH = "$env:JAVA_HOME\bin;$env:PATH" Invoke "npm run build:generator" Invoke "npm run build:emitter" -$testDir = Join-Path $repoRoot 'test' - $generatorTestDir = Join-Path $repoRoot 'generator/http-client-generator-test' Set-Location $generatorTestDir ./Generate.ps1 Set-Location $PSScriptRoot + +$generatorTestDir = Join-Path $repoRoot 'generator/http-client-generator-clientcore-test' +Set-Location $generatorTestDir +./Generate.ps1 +Set-Location $PSScriptRoot diff --git a/packages/http-client-java/eng/scripts/Test-Packages.ps1 b/packages/http-client-java/eng/scripts/Test-Packages.ps1 index a343502aa8..4996d7da60 100644 --- a/packages/http-client-java/eng/scripts/Test-Packages.ps1 +++ b/packages/http-client-java/eng/scripts/Test-Packages.ps1 @@ -36,12 +36,22 @@ try { try { & ./Setup.ps1 & ./Spector-Tests.ps1 - Set-Location $packageRoot - Write-Host "Spector tests passed" } finally { Pop-Location } + + $generatorTestDir = Join-Path $packageRoot 'generator/http-client-generator-clientcore-test' + Push-Location $generatorTestDir + try { + & ./Setup.ps1 + & ./Spector-Tests.ps1 + } + finally { + Pop-Location + } + + Write-Host "Spector tests passed" } catch { Write-Error "Spector tests failed: $_" @@ -52,7 +62,7 @@ try { if (!(Test-Path $coverageReportDir)) { New-Item -ItemType Directory -Path $coverageReportDir - $sourceFile = Join-Path $packageRoot 'generator/http-client-generator-test/tsp-spector-coverage-java-standard.json' + $sourceFile = Join-Path $packageRoot 'generator/http-client-generator-clientcore-test/tsp-spector-coverage-java-standard.json' $targetFile = Join-Path $coverageReportDir 'tsp-spector-coverage-java-standard.json' Copy-Item $sourceFile -Destination $targetFile } diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/Generate.ps1 b/packages/http-client-java/generator/http-client-generator-clientcore-test/Generate.ps1 new file mode 100644 index 0000000000..db5a852418 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/Generate.ps1 @@ -0,0 +1,118 @@ +# Use case: +# +# The purpose of this script is to compact the steps required to regenerate TypeSpec into a single script. +# +param ( + [int] $Parallelization = [Environment]::ProcessorCount +) + + +$ExitCode = 0 + +if ($Parallelization -lt 1) { + $Parallelization = 1 +} + +Write-Host "Parallelization: $Parallelization" + + +$generateScript = { + $tspFile = $_ + + $tspClientFile = $tspFile -replace 'main.tsp', 'client.tsp' + if (($tspClientFile -match 'client.tsp$') -and (Test-Path $tspClientFile)) { + $tspFile = $tspClientFile + } + + # With TypeSpec code generation being parallelized, we need to make sure that the output directory is unique + # for each test run. We do this by appending a random number to the output directory. + # Without this, we could have multiple runs trying to write to the same directory which introduces race conditions. + $tspOptions = "--option ""@typespec/http-client-java.emitter-output-dir={project-root}/tsp-output/$(Get-Random)""" + if ($tspFile -match "type[\\/]enum[\\/]extensible[\\/]") { + # override namespace for reserved keyword "enum" + $tspOptions += " --option ""@typespec/http-client-java.namespace=type.enums.extensible""" + } elseif ($tspFile -match "type[\\/]enum[\\/]fixed[\\/]") { + # override namespace for reserved keyword "enum" + $tspOptions += " --option ""@typespec/http-client-java.namespace=type.enums.fixed""" + } elseif ($tspFile -match "type[\\/]array" -or $tspFile -match "type[\\/]dictionary") { + # TODO https://github.com/Azure/autorest.java/issues/2964 + # also serve as a test for "use-object-for-unknown" emitter option + $tspOptions += " --option ""@typespec/http-client-java.use-object-for-unknown=true""" + } + + $tspTrace = "--trace import-resolution --trace projection --trace http-client-java" + $tspCommand = "npx --no-install tsp compile $tspFile $tspOptions $tspTrace" + + $timer = [Diagnostics.Stopwatch]::StartNew() + $generateOutput = Invoke-Expression $tspCommand + $timer.Stop() + + $global:ExitCode = $global:ExitCode -bor $LASTEXITCODE + + if ($LASTEXITCODE -ne 0) { + Write-Host " + ======================== + $tspCommand + ======================== + FAILED (Time elapsed: $($timer.ToString())) + $([String]::Join("`n", $generateOutput)) + " + } else { + Write-Host " + ======================== + $tspCommand + ======================== + SUCCEEDED (Time elapsed: $($timer.ToString())) + " + } + + if ($global:ExitCode -ne 0) { + exit $global:ExitCode + } +} + +./Setup.ps1 + +if (Test-Path ./src/main) { + Remove-Item ./src/main -Recurse -Force +} +if (Test-Path ./src/samples) { + Remove-Item ./src/samples -Recurse -Force +} +if (Test-Path ./tsp-output) { + Remove-Item ./tsp-output -Recurse -Force +} + +# generate for http-specs/azure-http-specs test sources +Copy-Item -Path node_modules/@typespec/http-specs/specs -Destination ./ -Recurse -Force +# remove xml tests, emitter has not supported xml model +Remove-Item ./specs/payload/xml -Recurse -Force + +# TokenCredential not in core +Remove-Item ./specs/authentication/oauth2 -Recurse -Force +Remove-Item ./specs/authentication/union -Recurse -Force +# Base64Url not in core +Remove-Item ./specs/encode/bytes -Recurse -Force +# DateTimeRfc1123 is private in beta.1, should now be public in main +Remove-Item ./specs/encode/datetime -Recurse -Force +Remove-Item ./specs/special-headers -Recurse -Force +# JacksonAdapter not in core +Remove-Item ./specs/encode/duration -Recurse -Force + +$job = (Get-ChildItem ./specs -Include "main.tsp","old.tsp" -File -Recurse) | ForEach-Object -Parallel $generateScript -ThrottleLimit $Parallelization -AsJob + +$job | Wait-Job -Timeout 1200 +$job | Receive-Job + +Remove-Item ./specs -Recurse -Force + +Copy-Item -Path ./tsp-output/*/src -Destination ./ -Recurse -Force -Exclude @("module-info.java") + +Remove-Item ./tsp-output -Recurse -Force + +if (Test-Path ./src/main/resources/META-INF/client-structure-service_apiview_properties.json) { + # client structure is generated from multiple client.tsp files and the last one to execute overwrites + # the api view properties file. Because the tests run in parallel, the order is not guaranteed. This + # causes git diff check to fail as the checked in file is not the same as the generated one. + Remove-Item ./src/main/resources/META-INF/client-structure-service_apiview_properties.json -Force +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/Setup.ps1 b/packages/http-client-java/generator/http-client-generator-clientcore-test/Setup.ps1 new file mode 100644 index 0000000000..f72480dd10 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/Setup.ps1 @@ -0,0 +1,8 @@ +# re-build http-client-java +Set-Location (Resolve-Path (Join-Path $PSScriptRoot '..' '..')) + +./Setup.ps1 + +Set-Location $PSScriptRoot + +npm run clean && npm install diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/Spector-Tests.ps1 b/packages/http-client-java/generator/http-client-generator-clientcore-test/Spector-Tests.ps1 new file mode 100644 index 0000000000..2fce786d8c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/Spector-Tests.ps1 @@ -0,0 +1,18 @@ +#Requires -Version 7.0 + +$ErrorActionPreference = 'Stop' +Set-StrictMode -Version 3.0 + +Write-Host "Running Spector tests" + +Write-Host "Starting the Spector server" +npm run spector-start +Write-Host "Compile and run the tests" +mvn clean test --no-transfer-progress -T 1C +if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE +} +Write-Host "Stopping the Spector server" +npm run spector-stop + +Write-Host "Finished running the Spector tests" diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json new file mode 100644 index 0000000000..af076455a1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json @@ -0,0 +1,32 @@ +{ + "name": "@typespec/http-client-java-clientcore-tests", + "version": "0.1.0", + "type": "module", + "scripts": { + "clean": "rimraf ./node_modules/@typespec/http-client-java ./package-lock.json ./tsp-output", + "format": "npm run -s prettier -- --write", + "check-format": "npm run prettier -- --check", + "prettier": "prettier --config ./.prettierrc.yaml **/*.tsp", + "spector-serve": "tsp-spector serve ./node_modules/@typespec/http-specs/specs --coverageFile ./tsp-spector-coverage-java-standard.json", + "spector-start": "tsp-spector server start ./node_modules/@typespec/http-specs/specs --coverageFile ./tsp-spector-coverage-java-standard.json", + "spector-stop": "tsp-spector server stop" + }, + "dependencies": { + "@typespec/http-specs": "0.1.0-alpha.5", + "@typespec/http-client-java": "file:../../typespec-http-client-java-0.1.5.tgz", + "@typespec/http-client-java-tests": "file:" + }, + "overrides": { + "@typespec/compiler": "~0.63.0", + "@typespec/http": "~0.63.0", + "@typespec/rest": "~0.63.0", + "@typespec/versioning": "~0.63.0", + "@typespec/openapi": "~0.63.0", + "@typespec/xml": "~0.63.0", + "@azure-tools/typespec-azure-core": "~0.49.0", + "@azure-tools/typespec-client-generator-core": "~0.49.1", + "@azure-tools/typespec-azure-resource-manager": "~0.49.0", + "@azure-tools/typespec-autorest": "~0.49.0" + }, + "private": true +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/pom.xml b/packages/http-client-java/generator/http-client-generator-clientcore-test/pom.xml new file mode 100644 index 0000000000..614d708908 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/pom.xml @@ -0,0 +1,77 @@ + + 4.0.0 + + com.microsoft.typespec + typespec-java-generator + 1.0.0-beta.1 + + + com.microsoft.typespec + http-client-generator-clientcore-test + jar + + http-client-generator-test + http://maven.apache.org + + + UTF-8 + ../ + + + + + io.clientcore + core + 1.0.0-beta.1 + + + org.junit.jupiter + junit-jupiter-api + 5.11.2 + test + + + io.projectreactor + reactor-test + 3.4.41 + + + org.mockito + mockito-core + 4.11.0 + test + + + + + net.bytebuddy + byte-buddy + 1.15.5 + test + + + net.bytebuddy + byte-buddy-agent + 1.15.5 + test + + + org.slf4j + slf4j-simple + 1.7.36 + + + com.fasterxml.jackson.core + jackson-databind + 2.18.0 + test + + + org.junit.jupiter + junit-jupiter-params + 5.11.2 + test + + + diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/ApiKeyClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/ApiKeyClient.java new file mode 100644 index 0000000000..90cce276bd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/ApiKeyClient.java @@ -0,0 +1,79 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package authentication.apikey; + +import authentication.apikey.implementation.ApiKeyClientImpl; +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; + +/** + * Initializes a new instance of the synchronous ApiKeyClient type. + */ +@ServiceClient(builder = ApiKeyClientBuilder.class) +public final class ApiKeyClient { + @Metadata(generated = true) + private final ApiKeyClientImpl serviceClient; + + /** + * Initializes an instance of ApiKeyClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ApiKeyClient(ApiKeyClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Check whether client is authenticated. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response validWithResponse(RequestOptions requestOptions) { + return this.serviceClient.validWithResponse(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response invalidWithResponse(RequestOptions requestOptions) { + return this.serviceClient.invalidWithResponse(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void valid() { + // Generated convenience method for validWithResponse + RequestOptions requestOptions = new RequestOptions(); + validWithResponse(requestOptions).getValue(); + } + + /** + * Check whether client is authenticated. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void invalid() { + // Generated convenience method for invalidWithResponse + RequestOptions requestOptions = new RequestOptions(); + invalidWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/ApiKeyClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/ApiKeyClientBuilder.java new file mode 100644 index 0000000000..f26d7c1b74 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/ApiKeyClientBuilder.java @@ -0,0 +1,263 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package authentication.apikey; + +import authentication.apikey.implementation.ApiKeyClientImpl; +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.credential.KeyCredential; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.http.pipeline.KeyCredentialPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.KeyCredentialTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * A builder for creating a new instance of the ApiKeyClient type. + */ +@ServiceClientBuilder(serviceClients = { ApiKeyClient.class }) +public final class ApiKeyClientBuilder + implements HttpTrait, ProxyTrait, ConfigurationTrait, + KeyCredentialTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the ApiKeyClientBuilder. + */ + @Metadata(generated = true) + public ApiKeyClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ApiKeyClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ApiKeyClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ApiKeyClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ApiKeyClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ApiKeyClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ApiKeyClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ApiKeyClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ApiKeyClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The KeyCredential used for authentication. + */ + @Metadata(generated = true) + private KeyCredential keyCredential; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ApiKeyClientBuilder credential(KeyCredential keyCredential) { + this.keyCredential = keyCredential; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ApiKeyClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of ApiKeyClientImpl with the provided parameters. + * + * @return an instance of ApiKeyClientImpl. + */ + @Metadata(generated = true) + private ApiKeyClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ApiKeyClientImpl client = new ApiKeyClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + if (keyCredential != null) { + policies.add(new KeyCredentialPolicy("x-ms-api-key", keyCredential, null)); + } + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of ApiKeyClient class. + * + * @return an instance of ApiKeyClient. + */ + @Metadata(generated = true) + public ApiKeyClient buildClient() { + return new ApiKeyClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ApiKeyClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/InvalidAuth.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/InvalidAuth.java new file mode 100644 index 0000000000..bc66cac4a6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/InvalidAuth.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package authentication.apikey; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The InvalidAuth model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class InvalidAuth implements JsonSerializable { + /* + * The error property. + */ + @Metadata(generated = true) + private final String error; + + /** + * Creates an instance of InvalidAuth class. + * + * @param error the error value to set. + */ + @Metadata(generated = true) + private InvalidAuth(String error) { + this.error = error; + } + + /** + * Get the error property: The error property. + * + * @return the error value. + */ + @Metadata(generated = true) + public String getError() { + return this.error; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("error", this.error); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InvalidAuth from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InvalidAuth 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 InvalidAuth. + */ + @Metadata(generated = true) + public static InvalidAuth fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String error = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("error".equals(fieldName)) { + error = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new InvalidAuth(error); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/implementation/ApiKeyClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/implementation/ApiKeyClientImpl.java new file mode 100644 index 0000000000..61eef03e7d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/implementation/ApiKeyClientImpl.java @@ -0,0 +1,111 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package authentication.apikey.implementation; + +import authentication.apikey.InvalidAuth; +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the ApiKeyClient type. + */ +public final class ApiKeyClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ApiKeyClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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; + } + + /** + * Initializes an instance of ApiKeyClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public ApiKeyClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(ApiKeyClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for ApiKeyClient to be used by the proxy service to perform REST calls. + */ + @ServiceInterface(name = "ApiKeyClient", host = "{endpoint}") + public interface ApiKeyClientService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/authentication/api-key/valid", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response validSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/authentication/api-key/invalid", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail(statusCode = { 403 }, exceptionBodyClass = InvalidAuth.class) + @UnexpectedResponseExceptionDetail + Response invalidSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response validWithResponse(RequestOptions requestOptions) { + return service.validSync(this.getEndpoint(), requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response invalidWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.invalidSync(this.getEndpoint(), accept, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/implementation/package-info.java new file mode 100644 index 0000000000..1644016f6e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for ApiKey. + * Illustrates clients generated with ApiKey authentication. + */ +package authentication.apikey.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/package-info.java new file mode 100644 index 0000000000..2ad76c3a07 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/apikey/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for ApiKey. + * Illustrates clients generated with ApiKey authentication. + */ +package authentication.apikey; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/CustomClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/CustomClient.java new file mode 100644 index 0000000000..dde451a5a1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/CustomClient.java @@ -0,0 +1,79 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package authentication.http.custom; + +import authentication.http.custom.implementation.CustomClientImpl; +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; + +/** + * Initializes a new instance of the synchronous CustomClient type. + */ +@ServiceClient(builder = CustomClientBuilder.class) +public final class CustomClient { + @Metadata(generated = true) + private final CustomClientImpl serviceClient; + + /** + * Initializes an instance of CustomClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + CustomClient(CustomClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Check whether client is authenticated. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response validWithResponse(RequestOptions requestOptions) { + return this.serviceClient.validWithResponse(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response invalidWithResponse(RequestOptions requestOptions) { + return this.serviceClient.invalidWithResponse(requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void valid() { + // Generated convenience method for validWithResponse + RequestOptions requestOptions = new RequestOptions(); + validWithResponse(requestOptions).getValue(); + } + + /** + * Check whether client is authenticated. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void invalid() { + // Generated convenience method for invalidWithResponse + RequestOptions requestOptions = new RequestOptions(); + invalidWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/CustomClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/CustomClientBuilder.java new file mode 100644 index 0000000000..c8ede02b16 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/CustomClientBuilder.java @@ -0,0 +1,263 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package authentication.http.custom; + +import authentication.http.custom.implementation.CustomClientImpl; +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.credential.KeyCredential; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.http.pipeline.KeyCredentialPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.KeyCredentialTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * A builder for creating a new instance of the CustomClient type. + */ +@ServiceClientBuilder(serviceClients = { CustomClient.class }) +public final class CustomClientBuilder + implements HttpTrait, ProxyTrait, ConfigurationTrait, + KeyCredentialTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the CustomClientBuilder. + */ + @Metadata(generated = true) + public CustomClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CustomClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CustomClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CustomClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CustomClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CustomClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CustomClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CustomClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CustomClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The KeyCredential used for authentication. + */ + @Metadata(generated = true) + private KeyCredential keyCredential; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CustomClientBuilder credential(KeyCredential keyCredential) { + this.keyCredential = keyCredential; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CustomClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of CustomClientImpl with the provided parameters. + * + * @return an instance of CustomClientImpl. + */ + @Metadata(generated = true) + private CustomClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + CustomClientImpl client = new CustomClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + if (keyCredential != null) { + policies.add(new KeyCredentialPolicy("authorization", keyCredential, "SharedAccessKey")); + } + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of CustomClient class. + * + * @return an instance of CustomClient. + */ + @Metadata(generated = true) + public CustomClient buildClient() { + return new CustomClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(CustomClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/InvalidAuth.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/InvalidAuth.java new file mode 100644 index 0000000000..0d63493977 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/InvalidAuth.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package authentication.http.custom; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The InvalidAuth model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class InvalidAuth implements JsonSerializable { + /* + * The error property. + */ + @Metadata(generated = true) + private final String error; + + /** + * Creates an instance of InvalidAuth class. + * + * @param error the error value to set. + */ + @Metadata(generated = true) + private InvalidAuth(String error) { + this.error = error; + } + + /** + * Get the error property: The error property. + * + * @return the error value. + */ + @Metadata(generated = true) + public String getError() { + return this.error; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("error", this.error); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InvalidAuth from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InvalidAuth 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 InvalidAuth. + */ + @Metadata(generated = true) + public static InvalidAuth fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String error = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("error".equals(fieldName)) { + error = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new InvalidAuth(error); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/implementation/CustomClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/implementation/CustomClientImpl.java new file mode 100644 index 0000000000..9e7301751f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/implementation/CustomClientImpl.java @@ -0,0 +1,111 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package authentication.http.custom.implementation; + +import authentication.http.custom.InvalidAuth; +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the CustomClient type. + */ +public final class CustomClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CustomClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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; + } + + /** + * Initializes an instance of CustomClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public CustomClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(CustomClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for CustomClient to be used by the proxy service to perform REST calls. + */ + @ServiceInterface(name = "CustomClient", host = "{endpoint}") + public interface CustomClientService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/authentication/http/custom/valid", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response validSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/authentication/http/custom/invalid", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail(statusCode = { 403 }, exceptionBodyClass = InvalidAuth.class) + @UnexpectedResponseExceptionDetail + Response invalidSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response validWithResponse(RequestOptions requestOptions) { + return service.validSync(this.getEndpoint(), requestOptions); + } + + /** + * Check whether client is authenticated. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response invalidWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.invalidSync(this.getEndpoint(), accept, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/implementation/package-info.java new file mode 100644 index 0000000000..6b78844f25 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Custom. + * Illustrates clients generated with generic HTTP auth. + */ +package authentication.http.custom.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/package-info.java new file mode 100644 index 0000000000..51131ced09 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/authentication/http/custom/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Custom. + * Illustrates clients generated with generic HTTP auth. + */ +package authentication.http.custom; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/NumericClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/NumericClient.java new file mode 100644 index 0000000000..ce91bb004a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/NumericClient.java @@ -0,0 +1,179 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package encode.numeric; + +import encode.numeric.implementation.PropertiesImpl; +import encode.numeric.property.SafeintAsStringProperty; +import encode.numeric.property.Uint32AsStringProperty; +import encode.numeric.property.Uint8AsStringProperty; +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * Initializes a new instance of the synchronous NumericClient type. + */ +@ServiceClient(builder = NumericClientBuilder.class) +public final class NumericClient { + @Metadata(generated = true) + private final PropertiesImpl serviceClient; + + /** + * Initializes an instance of NumericClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + NumericClient(PropertiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The safeintAsString operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+     * 
+ * + * @param value The value parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response safeintAsStringWithResponse(BinaryData value, + RequestOptions requestOptions) { + return this.serviceClient.safeintAsStringWithResponse(value, requestOptions); + } + + /** + * The uint32AsStringOptional operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: Integer (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: Integer (Optional)
+     * }
+     * }
+     * 
+ * + * @param value The value parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response uint32AsStringOptionalWithResponse(BinaryData value, + RequestOptions requestOptions) { + return this.serviceClient.uint32AsStringOptionalWithResponse(value, requestOptions); + } + + /** + * The uint8AsString operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: int (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: int (Required)
+     * }
+     * }
+     * 
+ * + * @param value The value parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response uint8AsStringWithResponse(BinaryData value, RequestOptions requestOptions) { + return this.serviceClient.uint8AsStringWithResponse(value, requestOptions); + } + + /** + * The safeintAsString operation. + * + * @param value The value parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public SafeintAsStringProperty safeintAsString(SafeintAsStringProperty value) { + // Generated convenience method for safeintAsStringWithResponse + RequestOptions requestOptions = new RequestOptions(); + return safeintAsStringWithResponse(BinaryData.fromObject(value), requestOptions).getValue(); + } + + /** + * The uint32AsStringOptional operation. + * + * @param value The value parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public Uint32AsStringProperty uint32AsStringOptional(Uint32AsStringProperty value) { + // Generated convenience method for uint32AsStringOptionalWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uint32AsStringOptionalWithResponse(BinaryData.fromObject(value), requestOptions).getValue(); + } + + /** + * The uint8AsString operation. + * + * @param value The value parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public Uint8AsStringProperty uint8AsString(Uint8AsStringProperty value) { + // Generated convenience method for uint8AsStringWithResponse + RequestOptions requestOptions = new RequestOptions(); + return uint8AsStringWithResponse(BinaryData.fromObject(value), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/NumericClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/NumericClientBuilder.java new file mode 100644 index 0000000000..aadefd51f8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/NumericClientBuilder.java @@ -0,0 +1,240 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package encode.numeric; + +import encode.numeric.implementation.NumericClientImpl; +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * A builder for creating a new instance of the NumericClient type. + */ +@ServiceClientBuilder(serviceClients = { NumericClient.class }) +public final class NumericClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the NumericClientBuilder. + */ + @Metadata(generated = true) + public NumericClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NumericClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NumericClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NumericClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NumericClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NumericClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NumericClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NumericClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NumericClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NumericClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of NumericClientImpl with the provided parameters. + * + * @return an instance of NumericClientImpl. + */ + @Metadata(generated = true) + private NumericClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + NumericClientImpl client = new NumericClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of NumericClient class. + * + * @return an instance of NumericClient. + */ + @Metadata(generated = true) + public NumericClient buildNumericClient() { + return new NumericClient(buildInnerClient().getProperties()); + } + + private static final ClientLogger LOGGER = new ClientLogger(NumericClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/implementation/NumericClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/implementation/NumericClientImpl.java new file mode 100644 index 0000000000..ea6289a771 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/implementation/NumericClientImpl.java @@ -0,0 +1,64 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package encode.numeric.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the NumericClient type. + */ +public final class NumericClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 PropertiesImpl object to access its operations. + */ + private final PropertiesImpl properties; + + /** + * Gets the PropertiesImpl object to access its operations. + * + * @return the PropertiesImpl object. + */ + public PropertiesImpl getProperties() { + return this.properties; + } + + /** + * Initializes an instance of NumericClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public NumericClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.properties = new PropertiesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/implementation/PropertiesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/implementation/PropertiesImpl.java new file mode 100644 index 0000000000..ba60a22c2c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/implementation/PropertiesImpl.java @@ -0,0 +1,180 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package encode.numeric.implementation; + +import encode.numeric.property.SafeintAsStringProperty; +import encode.numeric.property.Uint32AsStringProperty; +import encode.numeric.property.Uint8AsStringProperty; +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * An instance of this class provides access to all the operations defined in Properties. + */ +public final class PropertiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PropertiesService service; + + /** + * The service client containing this operation class. + */ + private final NumericClientImpl client; + + /** + * Initializes an instance of PropertiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PropertiesImpl(NumericClientImpl client) { + this.service = RestProxy.create(PropertiesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for NumericClientProperties to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "NumericClientPropert", host = "{endpoint}") + public interface PropertiesService { + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/encode/numeric/property/safeint", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response safeintAsStringSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData value, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/encode/numeric/property/uint32", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response uint32AsStringOptionalSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData value, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/encode/numeric/property/uint8", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response uint8AsStringSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData value, RequestOptions requestOptions); + } + + /** + * The safeintAsString operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: long (Required)
+     * }
+     * }
+     * 
+ * + * @param value The value parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response safeintAsStringWithResponse(BinaryData value, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.safeintAsStringSync(this.client.getEndpoint(), contentType, accept, value, requestOptions); + } + + /** + * The uint32AsStringOptional operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: Integer (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: Integer (Optional)
+     * }
+     * }
+     * 
+ * + * @param value The value parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response uint32AsStringOptionalWithResponse(BinaryData value, + RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.uint32AsStringOptionalSync(this.client.getEndpoint(), contentType, accept, value, + requestOptions); + } + + /** + * The uint8AsString operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: int (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     value: int (Required)
+     * }
+     * }
+     * 
+ * + * @param value The value parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response uint8AsStringWithResponse(BinaryData value, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.uint8AsStringSync(this.client.getEndpoint(), contentType, accept, value, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/implementation/package-info.java new file mode 100644 index 0000000000..70d1e0fef6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Numeric. + * Test for encode decorator on integer. + */ +package encode.numeric.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/package-info.java new file mode 100644 index 0000000000..965eeb0da9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Numeric. + * Test for encode decorator on integer. + */ +package encode.numeric; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/property/SafeintAsStringProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/property/SafeintAsStringProperty.java new file mode 100644 index 0000000000..bffafcd768 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/property/SafeintAsStringProperty.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package encode.numeric.property; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.Objects; + +/** + * The SafeintAsStringProperty model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SafeintAsStringProperty implements JsonSerializable { + /* + * The value property. + */ + @Metadata(generated = true) + private final long value; + + /** + * Creates an instance of SafeintAsStringProperty class. + * + * @param value the value value to set. + */ + @Metadata(generated = true) + public SafeintAsStringProperty(long value) { + this.value = value; + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Metadata(generated = true) + public long getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("value", Objects.toString(this.value, null)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SafeintAsStringProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SafeintAsStringProperty 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 SafeintAsStringProperty. + */ + @Metadata(generated = true) + public static SafeintAsStringProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + long value = Long.parseLong("0"); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.getNullable(nonNullReader -> Long.parseLong(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new SafeintAsStringProperty(value); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/property/Uint32AsStringProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/property/Uint32AsStringProperty.java new file mode 100644 index 0000000000..8afe3c7ea7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/property/Uint32AsStringProperty.java @@ -0,0 +1,92 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package encode.numeric.property; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.Objects; + +/** + * The Uint32AsStringProperty model. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class Uint32AsStringProperty implements JsonSerializable { + /* + * The value property. + */ + @Metadata(generated = true) + private Integer value; + + /** + * Creates an instance of Uint32AsStringProperty class. + */ + @Metadata(generated = true) + public Uint32AsStringProperty() { + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Metadata(generated = true) + public Integer getValue() { + return this.value; + } + + /** + * Set the value property: The value property. + * + * @param value the value value to set. + * @return the Uint32AsStringProperty object itself. + */ + @Metadata(generated = true) + public Uint32AsStringProperty setValue(Integer value) { + this.value = value; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("value", Objects.toString(this.value, null)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Uint32AsStringProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Uint32AsStringProperty if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the Uint32AsStringProperty. + */ + @Metadata(generated = true) + public static Uint32AsStringProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Uint32AsStringProperty deserializedUint32AsStringProperty = new Uint32AsStringProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + deserializedUint32AsStringProperty.value + = reader.getNullable(nonNullReader -> Integer.parseInt(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedUint32AsStringProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/property/Uint8AsStringProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/property/Uint8AsStringProperty.java new file mode 100644 index 0000000000..89642f295a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/property/Uint8AsStringProperty.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package encode.numeric.property; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.Objects; + +/** + * The Uint8AsStringProperty model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Uint8AsStringProperty implements JsonSerializable { + /* + * The value property. + */ + @Metadata(generated = true) + private final int value; + + /** + * Creates an instance of Uint8AsStringProperty class. + * + * @param value the value value to set. + */ + @Metadata(generated = true) + public Uint8AsStringProperty(int value) { + this.value = value; + } + + /** + * Get the value property: The value property. + * + * @return the value value. + */ + @Metadata(generated = true) + public int getValue() { + return this.value; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("value", Objects.toString(this.value, null)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Uint8AsStringProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Uint8AsStringProperty 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 Uint8AsStringProperty. + */ + @Metadata(generated = true) + public static Uint8AsStringProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int value = Integer.parseInt("0"); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("value".equals(fieldName)) { + value = reader.getNullable(nonNullReader -> Integer.parseInt(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new Uint8AsStringProperty(value); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/property/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/property/package-info.java new file mode 100644 index 0000000000..aa1202a798 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/encode/numeric/property/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for Numeric. + * Test for encode decorator on integer. + */ +package encode.numeric.property; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/BasicClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/BasicClientBuilder.java new file mode 100644 index 0000000000..a3311e08a8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/BasicClientBuilder.java @@ -0,0 +1,250 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.basic; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import parameters.basic.implementation.BasicClientImpl; + +/** + * A builder for creating a new instance of the BasicClient type. + */ +@ServiceClientBuilder(serviceClients = { ExplicitBodyClient.class, ImplicitBodyClient.class }) +public final class BasicClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the BasicClientBuilder. + */ + @Metadata(generated = true) + public BasicClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BasicClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BasicClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BasicClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BasicClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BasicClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BasicClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BasicClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BasicClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BasicClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of BasicClientImpl with the provided parameters. + * + * @return an instance of BasicClientImpl. + */ + @Metadata(generated = true) + private BasicClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + BasicClientImpl client = new BasicClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of ExplicitBodyClient class. + * + * @return an instance of ExplicitBodyClient. + */ + @Metadata(generated = true) + public ExplicitBodyClient buildExplicitBodyClient() { + return new ExplicitBodyClient(buildInnerClient().getExplicitBodies()); + } + + /** + * Builds an instance of ImplicitBodyClient class. + * + * @return an instance of ImplicitBodyClient. + */ + @Metadata(generated = true) + public ImplicitBodyClient buildImplicitBodyClient() { + return new ImplicitBodyClient(buildInnerClient().getImplicitBodies()); + } + + private static final ClientLogger LOGGER = new ClientLogger(BasicClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/ExplicitBodyClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/ExplicitBodyClient.java new file mode 100644 index 0000000000..d247df5404 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/ExplicitBodyClient.java @@ -0,0 +1,68 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.basic; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import parameters.basic.explicitbody.User; +import parameters.basic.implementation.ExplicitBodiesImpl; + +/** + * Initializes a new instance of the synchronous BasicClient type. + */ +@ServiceClient(builder = BasicClientBuilder.class) +public final class ExplicitBodyClient { + @Metadata(generated = true) + private final ExplicitBodiesImpl serviceClient; + + /** + * Initializes an instance of ExplicitBodyClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ExplicitBodyClient(ExplicitBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The simple operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response simpleWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.simpleWithResponse(body, requestOptions); + } + + /** + * The simple operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void simple(User body) { + // Generated convenience method for simpleWithResponse + RequestOptions requestOptions = new RequestOptions(); + simpleWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/ImplicitBodyClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/ImplicitBodyClient.java new file mode 100644 index 0000000000..a4ba794d39 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/ImplicitBodyClient.java @@ -0,0 +1,70 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.basic; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import parameters.basic.implementation.ImplicitBodiesImpl; +import parameters.basic.implicitbody.implementation.SimpleRequest; + +/** + * Initializes a new instance of the synchronous BasicClient type. + */ +@ServiceClient(builder = BasicClientBuilder.class) +public final class ImplicitBodyClient { + @Metadata(generated = true) + private final ImplicitBodiesImpl serviceClient; + + /** + * Initializes an instance of ImplicitBodyClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ImplicitBodyClient(ImplicitBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The simple operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param simpleRequest The simpleRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response simpleWithResponse(BinaryData simpleRequest, RequestOptions requestOptions) { + return this.serviceClient.simpleWithResponse(simpleRequest, requestOptions); + } + + /** + * The simple operation. + * + * @param name The name parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void simple(String name) { + // Generated convenience method for simpleWithResponse + RequestOptions requestOptions = new RequestOptions(); + SimpleRequest simpleRequestObj = new SimpleRequest(name); + BinaryData simpleRequest = BinaryData.fromObject(simpleRequestObj); + simpleWithResponse(simpleRequest, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/explicitbody/User.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/explicitbody/User.java new file mode 100644 index 0000000000..b993adcff9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/explicitbody/User.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.basic.explicitbody; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * This is a simple model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class User implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of User class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public User(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of User from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of User 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 User. + */ + @Metadata(generated = true) + public static User fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new User(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/explicitbody/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/explicitbody/package-info.java new file mode 100644 index 0000000000..73a831d0ae --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/explicitbody/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for Basic. + * Test for basic parameters cases. + */ +package parameters.basic.explicitbody; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implementation/BasicClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implementation/BasicClientImpl.java new file mode 100644 index 0000000000..331149f99e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implementation/BasicClientImpl.java @@ -0,0 +1,79 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.basic.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the BasicClient type. + */ +public final class BasicClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 ExplicitBodiesImpl object to access its operations. + */ + private final ExplicitBodiesImpl explicitBodies; + + /** + * Gets the ExplicitBodiesImpl object to access its operations. + * + * @return the ExplicitBodiesImpl object. + */ + public ExplicitBodiesImpl getExplicitBodies() { + return this.explicitBodies; + } + + /** + * The ImplicitBodiesImpl object to access its operations. + */ + private final ImplicitBodiesImpl implicitBodies; + + /** + * Gets the ImplicitBodiesImpl object to access its operations. + * + * @return the ImplicitBodiesImpl object. + */ + public ImplicitBodiesImpl getImplicitBodies() { + return this.implicitBodies; + } + + /** + * Initializes an instance of BasicClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public BasicClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.explicitBodies = new ExplicitBodiesImpl(this); + this.implicitBodies = new ImplicitBodiesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implementation/ExplicitBodiesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implementation/ExplicitBodiesImpl.java new file mode 100644 index 0000000000..378a678504 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implementation/ExplicitBodiesImpl.java @@ -0,0 +1,79 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.basic.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * An instance of this class provides access to all the operations defined in ExplicitBodies. + */ +public final class ExplicitBodiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExplicitBodiesService service; + + /** + * The service client containing this operation class. + */ + private final BasicClientImpl client; + + /** + * Initializes an instance of ExplicitBodiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExplicitBodiesImpl(BasicClientImpl client) { + this.service = RestProxy.create(ExplicitBodiesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for BasicClientExplicitBodies to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "BasicClientExplicitB", host = "{endpoint}") + public interface ExplicitBodiesService { + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/parameters/basic/explicit-body/simple", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response simpleSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * The simple operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response simpleWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.simpleSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implementation/ImplicitBodiesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implementation/ImplicitBodiesImpl.java new file mode 100644 index 0000000000..b442631999 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implementation/ImplicitBodiesImpl.java @@ -0,0 +1,79 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.basic.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * An instance of this class provides access to all the operations defined in ImplicitBodies. + */ +public final class ImplicitBodiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ImplicitBodiesService service; + + /** + * The service client containing this operation class. + */ + private final BasicClientImpl client; + + /** + * Initializes an instance of ImplicitBodiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ImplicitBodiesImpl(BasicClientImpl client) { + this.service = RestProxy.create(ImplicitBodiesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for BasicClientImplicitBodies to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "BasicClientImplicitB", host = "{endpoint}") + public interface ImplicitBodiesService { + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/parameters/basic/implicit-body/simple", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response simpleSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData simpleRequest, + RequestOptions requestOptions); + } + + /** + * The simple operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param simpleRequest The simpleRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response simpleWithResponse(BinaryData simpleRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.simpleSync(this.client.getEndpoint(), contentType, simpleRequest, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implementation/package-info.java new file mode 100644 index 0000000000..10c31e84b6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Basic. + * Test for basic parameters cases. + */ +package parameters.basic.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implicitbody/implementation/SimpleRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implicitbody/implementation/SimpleRequest.java new file mode 100644 index 0000000000..70e52daff4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implicitbody/implementation/SimpleRequest.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.basic.implicitbody.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The SimpleRequest model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SimpleRequest implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of SimpleRequest class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public SimpleRequest(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SimpleRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SimpleRequest 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 SimpleRequest. + */ + @Metadata(generated = true) + public static SimpleRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new SimpleRequest(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implicitbody/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implicitbody/implementation/package-info.java new file mode 100644 index 0000000000..b884191917 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/implicitbody/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for Basic. + * Test for basic parameters cases. + */ +package parameters.basic.implicitbody.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/package-info.java new file mode 100644 index 0000000000..13b203e59b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/basic/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Basic. + * Test for basic parameters cases. + */ +package parameters.basic; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/BodyModel.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/BodyModel.java new file mode 100644 index 0000000000..bfb4824a90 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/BodyModel.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyoptionality; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The BodyModel model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class BodyModel implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of BodyModel class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public BodyModel(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BodyModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BodyModel 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 BodyModel. + */ + @Metadata(generated = true) + public static BodyModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new BodyModel(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/BodyOptionalityClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/BodyOptionalityClient.java new file mode 100644 index 0000000000..00f8cbb336 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/BodyOptionalityClient.java @@ -0,0 +1,106 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyoptionality; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import parameters.bodyoptionality.implementation.BodyOptionalityClientImpl; + +/** + * Initializes a new instance of the synchronous BodyOptionalityClient type. + */ +@ServiceClient(builder = BodyOptionalityClientBuilder.class) +public final class BodyOptionalityClient { + @Metadata(generated = true) + private final BodyOptionalityClientImpl serviceClient; + + /** + * Initializes an instance of BodyOptionalityClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + BodyOptionalityClient(BodyOptionalityClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The requiredExplicit operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response requiredExplicitWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.requiredExplicitWithResponse(body, requestOptions); + } + + /** + * The requiredImplicit operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param bodyModel The bodyModel parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response requiredImplicitWithResponse(BinaryData bodyModel, RequestOptions requestOptions) { + return this.serviceClient.requiredImplicitWithResponse(bodyModel, requestOptions); + } + + /** + * The requiredExplicit operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void requiredExplicit(BodyModel body) { + // Generated convenience method for requiredExplicitWithResponse + RequestOptions requestOptions = new RequestOptions(); + requiredExplicitWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The requiredImplicit operation. + * + * @param name The name parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void requiredImplicit(String name) { + // Generated convenience method for requiredImplicitWithResponse + RequestOptions requestOptions = new RequestOptions(); + BodyModel bodyModelObj = new BodyModel(name); + BinaryData bodyModel = BinaryData.fromObject(bodyModelObj); + requiredImplicitWithResponse(bodyModel, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/BodyOptionalityClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/BodyOptionalityClientBuilder.java new file mode 100644 index 0000000000..f581a09c0a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/BodyOptionalityClientBuilder.java @@ -0,0 +1,251 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyoptionality; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import parameters.bodyoptionality.implementation.BodyOptionalityClientImpl; + +/** + * A builder for creating a new instance of the BodyOptionalityClient type. + */ +@ServiceClientBuilder(serviceClients = { BodyOptionalityClient.class, OptionalExplicitClient.class }) +public final class BodyOptionalityClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the BodyOptionalityClientBuilder. + */ + @Metadata(generated = true) + public BodyOptionalityClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BodyOptionalityClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BodyOptionalityClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BodyOptionalityClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BodyOptionalityClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BodyOptionalityClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BodyOptionalityClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BodyOptionalityClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BodyOptionalityClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public BodyOptionalityClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of BodyOptionalityClientImpl with the provided parameters. + * + * @return an instance of BodyOptionalityClientImpl. + */ + @Metadata(generated = true) + private BodyOptionalityClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + BodyOptionalityClientImpl client = new BodyOptionalityClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of BodyOptionalityClient class. + * + * @return an instance of BodyOptionalityClient. + */ + @Metadata(generated = true) + public BodyOptionalityClient buildClient() { + return new BodyOptionalityClient(buildInnerClient()); + } + + /** + * Builds an instance of OptionalExplicitClient class. + * + * @return an instance of OptionalExplicitClient. + */ + @Metadata(generated = true) + public OptionalExplicitClient buildOptionalExplicitClient() { + return new OptionalExplicitClient(buildInnerClient().getOptionalExplicits()); + } + + private static final ClientLogger LOGGER = new ClientLogger(BodyOptionalityClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/OptionalExplicitClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/OptionalExplicitClient.java new file mode 100644 index 0000000000..dbe448502f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/OptionalExplicitClient.java @@ -0,0 +1,150 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyoptionality; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import parameters.bodyoptionality.implementation.OptionalExplicitsImpl; + +/** + * Initializes a new instance of the synchronous BodyOptionalityClient type. + */ +@ServiceClient(builder = BodyOptionalityClientBuilder.class) +public final class OptionalExplicitClient { + @Metadata(generated = true) + private final OptionalExplicitsImpl serviceClient; + + /** + * Initializes an instance of OptionalExplicitClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + OptionalExplicitClient(OptionalExplicitsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The set operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response setWithResponse(RequestOptions requestOptions) { + return this.serviceClient.setWithResponse(requestOptions); + } + + /** + * The omit operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response omitWithResponse(RequestOptions requestOptions) { + return this.serviceClient.omitWithResponse(requestOptions); + } + + /** + * The set operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void set(BodyModel body) { + // Generated convenience method for setWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (body != null) { + requestOptions.setBody(BinaryData.fromObject(body)); + } + setWithResponse(requestOptions).getValue(); + } + + /** + * The set operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void set() { + // Generated convenience method for setWithResponse + RequestOptions requestOptions = new RequestOptions(); + setWithResponse(requestOptions).getValue(); + } + + /** + * The omit operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void omit(BodyModel body) { + // Generated convenience method for omitWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (body != null) { + requestOptions.setBody(BinaryData.fromObject(body)); + } + omitWithResponse(requestOptions).getValue(); + } + + /** + * The omit operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void omit() { + // Generated convenience method for omitWithResponse + RequestOptions requestOptions = new RequestOptions(); + omitWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/implementation/BodyOptionalityClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/implementation/BodyOptionalityClientImpl.java new file mode 100644 index 0000000000..2cd0636f9f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/implementation/BodyOptionalityClientImpl.java @@ -0,0 +1,151 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyoptionality.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * Initializes a new instance of the BodyOptionalityClient type. + */ +public final class BodyOptionalityClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BodyOptionalityClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 OptionalExplicitsImpl object to access its operations. + */ + private final OptionalExplicitsImpl optionalExplicits; + + /** + * Gets the OptionalExplicitsImpl object to access its operations. + * + * @return the OptionalExplicitsImpl object. + */ + public OptionalExplicitsImpl getOptionalExplicits() { + return this.optionalExplicits; + } + + /** + * Initializes an instance of BodyOptionalityClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public BodyOptionalityClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.optionalExplicits = new OptionalExplicitsImpl(this); + this.service = RestProxy.create(BodyOptionalityClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for BodyOptionalityClient to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "BodyOptionalityClien", host = "{endpoint}") + public interface BodyOptionalityClientService { + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/parameters/body-optionality/required-explicit", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response requiredExplicitSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/parameters/body-optionality/required-implicit", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response requiredImplicitSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData bodyModel, + RequestOptions requestOptions); + } + + /** + * The requiredExplicit operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response requiredExplicitWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.requiredExplicitSync(this.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The requiredImplicit operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param bodyModel The bodyModel parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response requiredImplicitWithResponse(BinaryData bodyModel, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.requiredImplicitSync(this.getEndpoint(), contentType, bodyModel, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/implementation/OptionalExplicitsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/implementation/OptionalExplicitsImpl.java new file mode 100644 index 0000000000..5baecbccac --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/implementation/OptionalExplicitsImpl.java @@ -0,0 +1,128 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.bodyoptionality.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpHeaderName; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; + +/** + * An instance of this class provides access to all the operations defined in OptionalExplicits. + */ +public final class OptionalExplicitsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final OptionalExplicitsService service; + + /** + * The service client containing this operation class. + */ + private final BodyOptionalityClientImpl client; + + /** + * Initializes an instance of OptionalExplicitsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OptionalExplicitsImpl(BodyOptionalityClientImpl client) { + this.service = RestProxy.create(OptionalExplicitsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for BodyOptionalityClientOptionalExplicits to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "BodyOptionalityClien", host = "{endpoint}") + public interface OptionalExplicitsService { + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/parameters/body-optionality/optional-explicit/set", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response setSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/parameters/body-optionality/optional-explicit/omit", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response omitSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + } + + /** + * The set operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response setWithResponse(RequestOptions requestOptions) { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"); + } + }); + return service.setSync(this.client.getEndpoint(), requestOptionsLocal); + } + + /** + * The omit operation. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response omitWithResponse(RequestOptions requestOptions) { + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/json"); + } + }); + return service.omitSync(this.client.getEndpoint(), requestOptionsLocal); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/implementation/package-info.java new file mode 100644 index 0000000000..da757cd811 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for BodyOptionality. + * Test describing optionality of the request body. + */ +package parameters.bodyoptionality.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/package-info.java new file mode 100644 index 0000000000..a9a7870e6a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/bodyoptionality/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for BodyOptionality. + * Test describing optionality of the request body. + */ +package parameters.bodyoptionality; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/CollectionFormatClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/CollectionFormatClientBuilder.java new file mode 100644 index 0000000000..496902e6b9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/CollectionFormatClientBuilder.java @@ -0,0 +1,251 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.collectionformat; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import parameters.collectionformat.implementation.CollectionFormatClientImpl; + +/** + * A builder for creating a new instance of the CollectionFormatClient type. + */ +@ServiceClientBuilder(serviceClients = { QueryClient.class, HeaderClient.class }) +public final class CollectionFormatClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the CollectionFormatClientBuilder. + */ + @Metadata(generated = true) + public CollectionFormatClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CollectionFormatClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CollectionFormatClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CollectionFormatClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CollectionFormatClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CollectionFormatClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CollectionFormatClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CollectionFormatClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CollectionFormatClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public CollectionFormatClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of CollectionFormatClientImpl with the provided parameters. + * + * @return an instance of CollectionFormatClientImpl. + */ + @Metadata(generated = true) + private CollectionFormatClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + CollectionFormatClientImpl client = new CollectionFormatClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of QueryClient class. + * + * @return an instance of QueryClient. + */ + @Metadata(generated = true) + public QueryClient buildQueryClient() { + return new QueryClient(buildInnerClient().getQueries()); + } + + /** + * Builds an instance of HeaderClient class. + * + * @return an instance of HeaderClient. + */ + @Metadata(generated = true) + public HeaderClient buildHeaderClient() { + return new HeaderClient(buildInnerClient().getHeaders()); + } + + private static final ClientLogger LOGGER = new ClientLogger(CollectionFormatClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/HeaderClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/HeaderClient.java new file mode 100644 index 0000000000..8e3212c031 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/HeaderClient.java @@ -0,0 +1,58 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.collectionformat; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import parameters.collectionformat.implementation.HeadersImpl; + +/** + * Initializes a new instance of the synchronous CollectionFormatClient type. + */ +@ServiceClient(builder = CollectionFormatClientBuilder.class) +public final class HeaderClient { + @Metadata(generated = true) + private final HeadersImpl serviceClient; + + /** + * Initializes an instance of HeaderClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + HeaderClient(HeadersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response csvWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.csvWithResponse(colors, requestOptions); + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void csv(List colors) { + // Generated convenience method for csvWithResponse + RequestOptions requestOptions = new RequestOptions(); + csvWithResponse(colors, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/QueryClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/QueryClient.java new file mode 100644 index 0000000000..4a31a2f51c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/QueryClient.java @@ -0,0 +1,170 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.collectionformat; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import parameters.collectionformat.implementation.QueriesImpl; + +/** + * Initializes a new instance of the synchronous CollectionFormatClient type. + */ +@ServiceClient(builder = CollectionFormatClientBuilder.class) +public final class QueryClient { + @Metadata(generated = true) + private final QueriesImpl serviceClient; + + /** + * Initializes an instance of QueryClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + QueryClient(QueriesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The multi operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response multiWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.multiWithResponse(colors, requestOptions); + } + + /** + * The ssv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response ssvWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.ssvWithResponse(colors, requestOptions); + } + + /** + * The tsv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response tsvWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.tsvWithResponse(colors, requestOptions); + } + + /** + * The pipes operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response pipesWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.pipesWithResponse(colors, requestOptions); + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response csvWithResponse(List colors, RequestOptions requestOptions) { + return this.serviceClient.csvWithResponse(colors, requestOptions); + } + + /** + * The multi operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void multi(List colors) { + // Generated convenience method for multiWithResponse + RequestOptions requestOptions = new RequestOptions(); + multiWithResponse(colors, requestOptions).getValue(); + } + + /** + * The ssv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void ssv(List colors) { + // Generated convenience method for ssvWithResponse + RequestOptions requestOptions = new RequestOptions(); + ssvWithResponse(colors, requestOptions).getValue(); + } + + /** + * The tsv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void tsv(List colors) { + // Generated convenience method for tsvWithResponse + RequestOptions requestOptions = new RequestOptions(); + tsvWithResponse(colors, requestOptions).getValue(); + } + + /** + * The pipes operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void pipes(List colors) { + // Generated convenience method for pipesWithResponse + RequestOptions requestOptions = new RequestOptions(); + pipesWithResponse(colors, requestOptions).getValue(); + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void csv(List colors) { + // Generated convenience method for csvWithResponse + RequestOptions requestOptions = new RequestOptions(); + csvWithResponse(colors, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/implementation/CollectionFormatClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/implementation/CollectionFormatClientImpl.java new file mode 100644 index 0000000000..e0caabb4ec --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/implementation/CollectionFormatClientImpl.java @@ -0,0 +1,79 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.collectionformat.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the CollectionFormatClient type. + */ +public final class CollectionFormatClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 QueriesImpl object to access its operations. + */ + private final QueriesImpl queries; + + /** + * Gets the QueriesImpl object to access its operations. + * + * @return the QueriesImpl object. + */ + public QueriesImpl getQueries() { + return this.queries; + } + + /** + * The HeadersImpl object to access its operations. + */ + private final HeadersImpl headers; + + /** + * Gets the HeadersImpl object to access its operations. + * + * @return the HeadersImpl object. + */ + public HeadersImpl getHeaders() { + return this.headers; + } + + /** + * Initializes an instance of CollectionFormatClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public CollectionFormatClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.queries = new QueriesImpl(this); + this.headers = new HeadersImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/implementation/HeadersImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/implementation/HeadersImpl.java new file mode 100644 index 0000000000..851d37768e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/implementation/HeadersImpl.java @@ -0,0 +1,72 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.collectionformat.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * An instance of this class provides access to all the operations defined in Headers. + */ +public final class HeadersImpl { + /** + * The proxy service used to perform REST calls. + */ + private final HeadersService service; + + /** + * The service client containing this operation class. + */ + private final CollectionFormatClientImpl client; + + /** + * Initializes an instance of HeadersImpl. + * + * @param client the instance of the service client containing this operation class. + */ + HeadersImpl(CollectionFormatClientImpl client) { + this.service = RestProxy.create(HeadersService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for CollectionFormatClientHeaders to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "CollectionFormatClie", host = "{endpoint}") + public interface HeadersService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/parameters/collection-format/header/csv", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response csvSync(@HostParam("endpoint") String endpoint, @HeaderParam("colors") String colors, + RequestOptions requestOptions); + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response csvWithResponse(List colors, RequestOptions requestOptions) { + String colorsConverted = colors.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.csvSync(this.client.getEndpoint(), colorsConverted, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/implementation/QueriesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/implementation/QueriesImpl.java new file mode 100644 index 0000000000..893a3d50dc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/implementation/QueriesImpl.java @@ -0,0 +1,164 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.collectionformat.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.QueryParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * An instance of this class provides access to all the operations defined in Queries. + */ +public final class QueriesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final QueriesService service; + + /** + * The service client containing this operation class. + */ + private final CollectionFormatClientImpl client; + + /** + * Initializes an instance of QueriesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + QueriesImpl(CollectionFormatClientImpl client) { + this.service = RestProxy.create(QueriesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for CollectionFormatClientQueries to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "CollectionFormatClie", host = "{endpoint}") + public interface QueriesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/parameters/collection-format/query/multi", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response multiSync(@HostParam("endpoint") String endpoint, + @QueryParam(value = "colors", multipleQueryParams = true) List colors, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/parameters/collection-format/query/ssv", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response ssvSync(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/parameters/collection-format/query/tsv", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response tsvSync(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/parameters/collection-format/query/pipes", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response pipesSync(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/parameters/collection-format/query/csv", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response csvSync(@HostParam("endpoint") String endpoint, @QueryParam("colors") String colors, + RequestOptions requestOptions); + } + + /** + * The multi operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response multiWithResponse(List colors, RequestOptions requestOptions) { + List colorsConverted + = colors.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); + return service.multiSync(this.client.getEndpoint(), colorsConverted, requestOptions); + } + + /** + * The ssv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response ssvWithResponse(List colors, RequestOptions requestOptions) { + String colorsConverted = colors.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(" ")); + return service.ssvSync(this.client.getEndpoint(), colorsConverted, requestOptions); + } + + /** + * The tsv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response tsvWithResponse(List colors, RequestOptions requestOptions) { + String colorsConverted = colors.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining("\t")); + return service.tsvSync(this.client.getEndpoint(), colorsConverted, requestOptions); + } + + /** + * The pipes operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response pipesWithResponse(List colors, RequestOptions requestOptions) { + String colorsConverted = colors.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining("|")); + return service.pipesSync(this.client.getEndpoint(), colorsConverted, requestOptions); + } + + /** + * The csv operation. + * + * @param colors Possible values for colors are [blue,red,green]. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response csvWithResponse(List colors, RequestOptions requestOptions) { + String colorsConverted = colors.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.csvSync(this.client.getEndpoint(), colorsConverted, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/implementation/package-info.java new file mode 100644 index 0000000000..93acdf8f82 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for CollectionFormat. + * Test for collectionFormat. + */ +package parameters.collectionformat.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/package-info.java new file mode 100644 index 0000000000..7109374821 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/collectionformat/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for CollectionFormat. + * Test for collectionFormat. + */ +package parameters.collectionformat; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/AliasClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/AliasClient.java new file mode 100644 index 0000000000..dfeeb159bd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/AliasClient.java @@ -0,0 +1,302 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.spread; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; +import parameters.spread.alias.implementation.SpreadAsRequestBodyRequest; +import parameters.spread.implementation.AliasImpl; +import parameters.spread.implementation.SpreadAsRequestParameterRequest; +import parameters.spread.implementation.SpreadParameterWithInnerAliasRequest; +import parameters.spread.implementation.SpreadParameterWithInnerModelRequest; +import parameters.spread.implementation.SpreadWithMultipleParametersRequest; + +/** + * Initializes a new instance of the synchronous SpreadClient type. + */ +@ServiceClient(builder = SpreadClientBuilder.class) +public final class AliasClient { + @Metadata(generated = true) + private final AliasImpl serviceClient; + + /** + * Initializes an instance of AliasClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + AliasClient(AliasImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The spreadAsRequestBody operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param spreadAsRequestBodyRequest The spreadAsRequestBodyRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response spreadAsRequestBodyWithResponse(BinaryData spreadAsRequestBodyRequest, + RequestOptions requestOptions) { + return this.serviceClient.spreadAsRequestBodyWithResponse(spreadAsRequestBodyRequest, requestOptions); + } + + /** + * The spreadParameterWithInnerModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadParameterWithInnerModelRequest The spreadParameterWithInnerModelRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response spreadParameterWithInnerModelWithResponse(String id, String xMsTestHeader, + BinaryData spreadParameterWithInnerModelRequest, RequestOptions requestOptions) { + return this.serviceClient.spreadParameterWithInnerModelWithResponse(id, xMsTestHeader, + spreadParameterWithInnerModelRequest, requestOptions); + } + + /** + * The spreadAsRequestParameter operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadAsRequestParameterRequest The spreadAsRequestParameterRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response spreadAsRequestParameterWithResponse(String id, String xMsTestHeader, + BinaryData spreadAsRequestParameterRequest, RequestOptions requestOptions) { + return this.serviceClient.spreadAsRequestParameterWithResponse(id, xMsTestHeader, + spreadAsRequestParameterRequest, requestOptions); + } + + /** + * The spreadWithMultipleParameters operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredString: String (Required)
+     *     optionalInt: Integer (Optional)
+     *     requiredIntList (Required): [
+     *         int (Required)
+     *     ]
+     *     optionalStringList (Optional): [
+     *         String (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadWithMultipleParametersRequest The spreadWithMultipleParametersRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response spreadWithMultipleParametersWithResponse(String id, String xMsTestHeader, + BinaryData spreadWithMultipleParametersRequest, RequestOptions requestOptions) { + return this.serviceClient.spreadWithMultipleParametersWithResponse(id, xMsTestHeader, + spreadWithMultipleParametersRequest, requestOptions); + } + + /** + * spread an alias with contains another alias property as body. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+     * 
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadParameterWithInnerAliasRequest The spreadParameterWithInnerAliasRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response spreadParameterWithInnerAliasWithResponse(String id, String xMsTestHeader, + BinaryData spreadParameterWithInnerAliasRequest, RequestOptions requestOptions) { + return this.serviceClient.spreadParameterWithInnerAliasWithResponse(id, xMsTestHeader, + spreadParameterWithInnerAliasRequest, requestOptions); + } + + /** + * The spreadAsRequestBody operation. + * + * @param name The name parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void spreadAsRequestBody(String name) { + // Generated convenience method for spreadAsRequestBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadAsRequestBodyRequest spreadAsRequestBodyRequestObj = new SpreadAsRequestBodyRequest(name); + BinaryData spreadAsRequestBodyRequest = BinaryData.fromObject(spreadAsRequestBodyRequestObj); + spreadAsRequestBodyWithResponse(spreadAsRequestBodyRequest, requestOptions).getValue(); + } + + /** + * The spreadParameterWithInnerModel operation. + * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param name The name parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void spreadParameterWithInnerModel(String id, String xMsTestHeader, String name) { + // Generated convenience method for spreadParameterWithInnerModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadParameterWithInnerModelRequest spreadParameterWithInnerModelRequestObj + = new SpreadParameterWithInnerModelRequest(name); + BinaryData spreadParameterWithInnerModelRequest + = BinaryData.fromObject(spreadParameterWithInnerModelRequestObj); + spreadParameterWithInnerModelWithResponse(id, xMsTestHeader, spreadParameterWithInnerModelRequest, + requestOptions).getValue(); + } + + /** + * The spreadAsRequestParameter operation. + * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param name The name parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void spreadAsRequestParameter(String id, String xMsTestHeader, String name) { + // Generated convenience method for spreadAsRequestParameterWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadAsRequestParameterRequest spreadAsRequestParameterRequestObj = new SpreadAsRequestParameterRequest(name); + BinaryData spreadAsRequestParameterRequest = BinaryData.fromObject(spreadAsRequestParameterRequestObj); + spreadAsRequestParameterWithResponse(id, xMsTestHeader, spreadAsRequestParameterRequest, requestOptions) + .getValue(); + } + + /** + * The spreadWithMultipleParameters operation. + * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param requiredString required string. + * @param requiredIntList required int. + * @param optionalInt optional int. + * @param optionalStringList optional string. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void spreadWithMultipleParameters(String id, String xMsTestHeader, String requiredString, + List requiredIntList, Integer optionalInt, List optionalStringList) { + // Generated convenience method for spreadWithMultipleParametersWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadWithMultipleParametersRequest spreadWithMultipleParametersRequestObj + = new SpreadWithMultipleParametersRequest(requiredString, requiredIntList).setOptionalInt(optionalInt) + .setOptionalStringList(optionalStringList); + BinaryData spreadWithMultipleParametersRequest = BinaryData.fromObject(spreadWithMultipleParametersRequestObj); + spreadWithMultipleParametersWithResponse(id, xMsTestHeader, spreadWithMultipleParametersRequest, requestOptions) + .getValue(); + } + + /** + * The spreadWithMultipleParameters operation. + * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param requiredString required string. + * @param requiredIntList required int. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void spreadWithMultipleParameters(String id, String xMsTestHeader, String requiredString, + List requiredIntList) { + // Generated convenience method for spreadWithMultipleParametersWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadWithMultipleParametersRequest spreadWithMultipleParametersRequestObj + = new SpreadWithMultipleParametersRequest(requiredString, requiredIntList); + BinaryData spreadWithMultipleParametersRequest = BinaryData.fromObject(spreadWithMultipleParametersRequestObj); + spreadWithMultipleParametersWithResponse(id, xMsTestHeader, spreadWithMultipleParametersRequest, requestOptions) + .getValue(); + } + + /** + * spread an alias with contains another alias property as body. + * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param name name of the Thing. + * @param age age of the Thing. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void spreadParameterWithInnerAlias(String id, String xMsTestHeader, String name, int age) { + // Generated convenience method for spreadParameterWithInnerAliasWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadParameterWithInnerAliasRequest spreadParameterWithInnerAliasRequestObj + = new SpreadParameterWithInnerAliasRequest(name, age); + BinaryData spreadParameterWithInnerAliasRequest + = BinaryData.fromObject(spreadParameterWithInnerAliasRequestObj); + spreadParameterWithInnerAliasWithResponse(id, xMsTestHeader, spreadParameterWithInnerAliasRequest, + requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/ModelClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/ModelClient.java new file mode 100644 index 0000000000..cae739370c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/ModelClient.java @@ -0,0 +1,229 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.spread; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import parameters.spread.implementation.ModelsImpl; +import parameters.spread.implementation.SpreadCompositeRequestMixRequest; +import parameters.spread.model.BodyParameter; + +/** + * Initializes a new instance of the synchronous SpreadClient type. + */ +@ServiceClient(builder = SpreadClientBuilder.class) +public final class ModelClient { + @Metadata(generated = true) + private final ModelsImpl serviceClient; + + /** + * Initializes an instance of ModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ModelClient(ModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The spreadAsRequestBody operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param bodyParameter The bodyParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response spreadAsRequestBodyWithResponse(BinaryData bodyParameter, RequestOptions requestOptions) { + return this.serviceClient.spreadAsRequestBodyWithResponse(bodyParameter, requestOptions); + } + + /** + * The spreadCompositeRequestOnlyWithBody operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response spreadCompositeRequestOnlyWithBodyWithResponse(BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.spreadCompositeRequestOnlyWithBodyWithResponse(body, requestOptions); + } + + /** + * The spreadCompositeRequestWithoutBody operation. + * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response spreadCompositeRequestWithoutBodyWithResponse(String name, String testHeader, + RequestOptions requestOptions) { + return this.serviceClient.spreadCompositeRequestWithoutBodyWithResponse(name, testHeader, requestOptions); + } + + /** + * The spreadCompositeRequest operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param name The name parameter. + * @param testHeader The testHeader 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 service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response spreadCompositeRequestWithResponse(String name, String testHeader, BinaryData body, + RequestOptions requestOptions) { + return this.serviceClient.spreadCompositeRequestWithResponse(name, testHeader, body, requestOptions); + } + + /** + * The spreadCompositeRequestMix operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     * }
+     * }
+     * 
+ * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param spreadCompositeRequestMixRequest The spreadCompositeRequestMixRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response spreadCompositeRequestMixWithResponse(String name, String testHeader, + BinaryData spreadCompositeRequestMixRequest, RequestOptions requestOptions) { + return this.serviceClient.spreadCompositeRequestMixWithResponse(name, testHeader, + spreadCompositeRequestMixRequest, requestOptions); + } + + /** + * The spreadAsRequestBody operation. + * + * @param name The name parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void spreadAsRequestBody(String name) { + // Generated convenience method for spreadAsRequestBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + BodyParameter bodyParameterObj = new BodyParameter(name); + BinaryData bodyParameter = BinaryData.fromObject(bodyParameterObj); + spreadAsRequestBodyWithResponse(bodyParameter, requestOptions).getValue(); + } + + /** + * The spreadCompositeRequestOnlyWithBody operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void spreadCompositeRequestOnlyWithBody(BodyParameter body) { + // Generated convenience method for spreadCompositeRequestOnlyWithBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + spreadCompositeRequestOnlyWithBodyWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The spreadCompositeRequestWithoutBody operation. + * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void spreadCompositeRequestWithoutBody(String name, String testHeader) { + // Generated convenience method for spreadCompositeRequestWithoutBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + spreadCompositeRequestWithoutBodyWithResponse(name, testHeader, requestOptions).getValue(); + } + + /** + * The spreadCompositeRequest operation. + * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void spreadCompositeRequest(String name, String testHeader, BodyParameter body) { + // Generated convenience method for spreadCompositeRequestWithResponse + RequestOptions requestOptions = new RequestOptions(); + spreadCompositeRequestWithResponse(name, testHeader, BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The spreadCompositeRequestMix operation. + * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param prop The prop parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void spreadCompositeRequestMix(String name, String testHeader, String prop) { + // Generated convenience method for spreadCompositeRequestMixWithResponse + RequestOptions requestOptions = new RequestOptions(); + SpreadCompositeRequestMixRequest spreadCompositeRequestMixRequestObj + = new SpreadCompositeRequestMixRequest(prop); + BinaryData spreadCompositeRequestMixRequest = BinaryData.fromObject(spreadCompositeRequestMixRequestObj); + spreadCompositeRequestMixWithResponse(name, testHeader, spreadCompositeRequestMixRequest, requestOptions) + .getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/SpreadClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/SpreadClientBuilder.java new file mode 100644 index 0000000000..8e26689bd7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/SpreadClientBuilder.java @@ -0,0 +1,250 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.spread; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import parameters.spread.implementation.SpreadClientImpl; + +/** + * A builder for creating a new instance of the SpreadClient type. + */ +@ServiceClientBuilder(serviceClients = { ModelClient.class, AliasClient.class }) +public final class SpreadClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the SpreadClientBuilder. + */ + @Metadata(generated = true) + public SpreadClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpreadClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpreadClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpreadClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpreadClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpreadClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpreadClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpreadClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpreadClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpreadClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of SpreadClientImpl with the provided parameters. + * + * @return an instance of SpreadClientImpl. + */ + @Metadata(generated = true) + private SpreadClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + SpreadClientImpl client = new SpreadClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of ModelClient class. + * + * @return an instance of ModelClient. + */ + @Metadata(generated = true) + public ModelClient buildModelClient() { + return new ModelClient(buildInnerClient().getModels()); + } + + /** + * Builds an instance of AliasClient class. + * + * @return an instance of AliasClient. + */ + @Metadata(generated = true) + public AliasClient buildAliasClient() { + return new AliasClient(buildInnerClient().getAlias()); + } + + private static final ClientLogger LOGGER = new ClientLogger(SpreadClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/alias/implementation/SpreadAsRequestBodyRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/alias/implementation/SpreadAsRequestBodyRequest.java new file mode 100644 index 0000000000..0cd4d2e1bb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/alias/implementation/SpreadAsRequestBodyRequest.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.spread.alias.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The SpreadAsRequestBodyRequest model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SpreadAsRequestBodyRequest implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of SpreadAsRequestBodyRequest class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public SpreadAsRequestBodyRequest(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadAsRequestBodyRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadAsRequestBodyRequest 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 SpreadAsRequestBodyRequest. + */ + @Metadata(generated = true) + public static SpreadAsRequestBodyRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new SpreadAsRequestBodyRequest(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/alias/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/alias/implementation/package-info.java new file mode 100644 index 0000000000..abb8ce34f5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/alias/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for Spread. + * Test for the spread operator. + */ +package parameters.spread.alias.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/AliasImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/AliasImpl.java new file mode 100644 index 0000000000..c13cf38120 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/AliasImpl.java @@ -0,0 +1,236 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.spread.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.PathParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * An instance of this class provides access to all the operations defined in Alias. + */ +public final class AliasImpl { + /** + * The proxy service used to perform REST calls. + */ + private final AliasService service; + + /** + * The service client containing this operation class. + */ + private final SpreadClientImpl client; + + /** + * Initializes an instance of AliasImpl. + * + * @param client the instance of the service client containing this operation class. + */ + AliasImpl(SpreadClientImpl client) { + this.service = RestProxy.create(AliasService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for SpreadClientAlias to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "SpreadClientAlias", host = "{endpoint}") + public interface AliasService { + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/parameters/spread/alias/request-body", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response spreadAsRequestBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadAsRequestBodyRequest, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/parameters/spread/alias/inner-model-parameter/{id}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response spreadParameterWithInnerModelSync(@HostParam("endpoint") String endpoint, + @PathParam("id") String id, @HeaderParam("x-ms-test-header") String xMsTestHeader, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadParameterWithInnerModelRequest, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/parameters/spread/alias/request-parameter/{id}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response spreadAsRequestParameterSync(@HostParam("endpoint") String endpoint, @PathParam("id") String id, + @HeaderParam("x-ms-test-header") String xMsTestHeader, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadAsRequestParameterRequest, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/parameters/spread/alias/multiple-parameters/{id}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response spreadWithMultipleParametersSync(@HostParam("endpoint") String endpoint, + @PathParam("id") String id, @HeaderParam("x-ms-test-header") String xMsTestHeader, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadWithMultipleParametersRequest, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/parameters/spread/alias/inner-alias-parameter/{id}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response spreadParameterWithInnerAliasSync(@HostParam("endpoint") String endpoint, + @PathParam("id") String id, @HeaderParam("x-ms-test-header") String xMsTestHeader, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadParameterWithInnerAliasRequest, + RequestOptions requestOptions); + } + + /** + * The spreadAsRequestBody operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param spreadAsRequestBodyRequest The spreadAsRequestBodyRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response spreadAsRequestBodyWithResponse(BinaryData spreadAsRequestBodyRequest, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadAsRequestBodySync(this.client.getEndpoint(), contentType, spreadAsRequestBodyRequest, + requestOptions); + } + + /** + * The spreadParameterWithInnerModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadParameterWithInnerModelRequest The spreadParameterWithInnerModelRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response spreadParameterWithInnerModelWithResponse(String id, String xMsTestHeader, + BinaryData spreadParameterWithInnerModelRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadParameterWithInnerModelSync(this.client.getEndpoint(), id, xMsTestHeader, contentType, + spreadParameterWithInnerModelRequest, requestOptions); + } + + /** + * The spreadAsRequestParameter operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadAsRequestParameterRequest The spreadAsRequestParameterRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response spreadAsRequestParameterWithResponse(String id, String xMsTestHeader, + BinaryData spreadAsRequestParameterRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadAsRequestParameterSync(this.client.getEndpoint(), id, xMsTestHeader, contentType, + spreadAsRequestParameterRequest, requestOptions); + } + + /** + * The spreadWithMultipleParameters operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredString: String (Required)
+     *     optionalInt: Integer (Optional)
+     *     requiredIntList (Required): [
+     *         int (Required)
+     *     ]
+     *     optionalStringList (Optional): [
+     *         String (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadWithMultipleParametersRequest The spreadWithMultipleParametersRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response spreadWithMultipleParametersWithResponse(String id, String xMsTestHeader, + BinaryData spreadWithMultipleParametersRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadWithMultipleParametersSync(this.client.getEndpoint(), id, xMsTestHeader, contentType, + spreadWithMultipleParametersRequest, requestOptions); + } + + /** + * spread an alias with contains another alias property as body. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+     * 
+ * + * @param id The id parameter. + * @param xMsTestHeader The xMsTestHeader parameter. + * @param spreadParameterWithInnerAliasRequest The spreadParameterWithInnerAliasRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response spreadParameterWithInnerAliasWithResponse(String id, String xMsTestHeader, + BinaryData spreadParameterWithInnerAliasRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadParameterWithInnerAliasSync(this.client.getEndpoint(), id, xMsTestHeader, contentType, + spreadParameterWithInnerAliasRequest, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/ModelsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/ModelsImpl.java new file mode 100644 index 0000000000..12aac88387 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/ModelsImpl.java @@ -0,0 +1,209 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.spread.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.PathParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * An instance of this class provides access to all the operations defined in Models. + */ +public final class ModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ModelsService service; + + /** + * The service client containing this operation class. + */ + private final SpreadClientImpl client; + + /** + * Initializes an instance of ModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ModelsImpl(SpreadClientImpl client) { + this.service = RestProxy.create(ModelsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for SpreadClientModels to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "SpreadClientModels", host = "{endpoint}") + public interface ModelsService { + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/parameters/spread/model/request-body", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response spreadAsRequestBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData bodyParameter, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/parameters/spread/model/composite-request-only-with-body", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response spreadCompositeRequestOnlyWithBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/parameters/spread/model/composite-request-without-body/{name}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response spreadCompositeRequestWithoutBodySync(@HostParam("endpoint") String endpoint, + @PathParam("name") String name, @HeaderParam("test-header") String testHeader, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/parameters/spread/model/composite-request/{name}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response spreadCompositeRequestSync(@HostParam("endpoint") String endpoint, + @PathParam("name") String name, @HeaderParam("test-header") String testHeader, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/parameters/spread/model/composite-request-mix/{name}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response spreadCompositeRequestMixSync(@HostParam("endpoint") String endpoint, + @PathParam("name") String name, @HeaderParam("test-header") String testHeader, + @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData spreadCompositeRequestMixRequest, RequestOptions requestOptions); + } + + /** + * The spreadAsRequestBody operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param bodyParameter The bodyParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response spreadAsRequestBodyWithResponse(BinaryData bodyParameter, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadAsRequestBodySync(this.client.getEndpoint(), contentType, bodyParameter, requestOptions); + } + + /** + * The spreadCompositeRequestOnlyWithBody operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response spreadCompositeRequestOnlyWithBodyWithResponse(BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadCompositeRequestOnlyWithBodySync(this.client.getEndpoint(), contentType, body, + requestOptions); + } + + /** + * The spreadCompositeRequestWithoutBody operation. + * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response spreadCompositeRequestWithoutBodyWithResponse(String name, String testHeader, + RequestOptions requestOptions) { + return service.spreadCompositeRequestWithoutBodySync(this.client.getEndpoint(), name, testHeader, + requestOptions); + } + + /** + * The spreadCompositeRequest operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param name The name parameter. + * @param testHeader The testHeader 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 service returns an error. + * @return the response. + */ + public Response spreadCompositeRequestWithResponse(String name, String testHeader, BinaryData body, + RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadCompositeRequestSync(this.client.getEndpoint(), name, testHeader, contentType, body, + requestOptions); + } + + /** + * The spreadCompositeRequestMix operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     * }
+     * }
+     * 
+ * + * @param name The name parameter. + * @param testHeader The testHeader parameter. + * @param spreadCompositeRequestMixRequest The spreadCompositeRequestMixRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response spreadCompositeRequestMixWithResponse(String name, String testHeader, + BinaryData spreadCompositeRequestMixRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.spreadCompositeRequestMixSync(this.client.getEndpoint(), name, testHeader, contentType, + spreadCompositeRequestMixRequest, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadAsRequestParameterRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadAsRequestParameterRequest.java new file mode 100644 index 0000000000..7a0f99e510 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadAsRequestParameterRequest.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.spread.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The SpreadAsRequestParameterRequest model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SpreadAsRequestParameterRequest implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of SpreadAsRequestParameterRequest class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public SpreadAsRequestParameterRequest(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadAsRequestParameterRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadAsRequestParameterRequest 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 SpreadAsRequestParameterRequest. + */ + @Metadata(generated = true) + public static SpreadAsRequestParameterRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new SpreadAsRequestParameterRequest(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadClientImpl.java new file mode 100644 index 0000000000..0fde6cdf22 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadClientImpl.java @@ -0,0 +1,79 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.spread.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the SpreadClient type. + */ +public final class SpreadClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 ModelsImpl object to access its operations. + */ + private final ModelsImpl models; + + /** + * Gets the ModelsImpl object to access its operations. + * + * @return the ModelsImpl object. + */ + public ModelsImpl getModels() { + return this.models; + } + + /** + * The AliasImpl object to access its operations. + */ + private final AliasImpl alias; + + /** + * Gets the AliasImpl object to access its operations. + * + * @return the AliasImpl object. + */ + public AliasImpl getAlias() { + return this.alias; + } + + /** + * Initializes an instance of SpreadClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public SpreadClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.models = new ModelsImpl(this); + this.alias = new AliasImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadCompositeRequestMixRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadCompositeRequestMixRequest.java new file mode 100644 index 0000000000..5312d8c832 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadCompositeRequestMixRequest.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.spread.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The SpreadCompositeRequestMixRequest model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SpreadCompositeRequestMixRequest implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final String prop; + + /** + * Creates an instance of SpreadCompositeRequestMixRequest class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + public SpreadCompositeRequestMixRequest(String prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public String getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadCompositeRequestMixRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadCompositeRequestMixRequest 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 SpreadCompositeRequestMixRequest. + */ + @Metadata(generated = true) + public static SpreadCompositeRequestMixRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new SpreadCompositeRequestMixRequest(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadParameterWithInnerAliasRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadParameterWithInnerAliasRequest.java new file mode 100644 index 0000000000..56fd08e8d6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadParameterWithInnerAliasRequest.java @@ -0,0 +1,104 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.spread.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The SpreadParameterWithInnerAliasRequest model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SpreadParameterWithInnerAliasRequest + implements JsonSerializable { + /* + * name of the Thing + */ + @Metadata(generated = true) + private final String name; + + /* + * age of the Thing + */ + @Metadata(generated = true) + private final int age; + + /** + * Creates an instance of SpreadParameterWithInnerAliasRequest class. + * + * @param name the name value to set. + * @param age the age value to set. + */ + @Metadata(generated = true) + public SpreadParameterWithInnerAliasRequest(String name, int age) { + this.name = name; + this.age = age; + } + + /** + * Get the name property: name of the Thing. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * Get the age property: age of the Thing. + * + * @return the age value. + */ + @Metadata(generated = true) + public int getAge() { + return this.age; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeIntField("age", this.age); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadParameterWithInnerAliasRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadParameterWithInnerAliasRequest 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 SpreadParameterWithInnerAliasRequest. + */ + @Metadata(generated = true) + public static SpreadParameterWithInnerAliasRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + int age = 0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("age".equals(fieldName)) { + age = reader.getInt(); + } else { + reader.skipChildren(); + } + } + return new SpreadParameterWithInnerAliasRequest(name, age); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadParameterWithInnerModelRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadParameterWithInnerModelRequest.java new file mode 100644 index 0000000000..ccf84d7982 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadParameterWithInnerModelRequest.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.spread.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The SpreadParameterWithInnerModelRequest model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SpreadParameterWithInnerModelRequest + implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of SpreadParameterWithInnerModelRequest class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public SpreadParameterWithInnerModelRequest(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadParameterWithInnerModelRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadParameterWithInnerModelRequest 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 SpreadParameterWithInnerModelRequest. + */ + @Metadata(generated = true) + public static SpreadParameterWithInnerModelRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new SpreadParameterWithInnerModelRequest(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadWithMultipleParametersRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadWithMultipleParametersRequest.java new file mode 100644 index 0000000000..cb6c7bfcd6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/SpreadWithMultipleParametersRequest.java @@ -0,0 +1,176 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.spread.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * The SpreadWithMultipleParametersRequest model. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class SpreadWithMultipleParametersRequest + implements JsonSerializable { + /* + * required string + */ + @Metadata(generated = true) + private final String requiredString; + + /* + * optional int + */ + @Metadata(generated = true) + private Integer optionalInt; + + /* + * required int + */ + @Metadata(generated = true) + private final List requiredIntList; + + /* + * optional string + */ + @Metadata(generated = true) + private List optionalStringList; + + /** + * Creates an instance of SpreadWithMultipleParametersRequest class. + * + * @param requiredString the requiredString value to set. + * @param requiredIntList the requiredIntList value to set. + */ + @Metadata(generated = true) + public SpreadWithMultipleParametersRequest(String requiredString, List requiredIntList) { + this.requiredString = requiredString; + this.requiredIntList = requiredIntList; + } + + /** + * Get the requiredString property: required string. + * + * @return the requiredString value. + */ + @Metadata(generated = true) + public String getRequiredString() { + return this.requiredString; + } + + /** + * Get the optionalInt property: optional int. + * + * @return the optionalInt value. + */ + @Metadata(generated = true) + public Integer getOptionalInt() { + return this.optionalInt; + } + + /** + * Set the optionalInt property: optional int. + * + * @param optionalInt the optionalInt value to set. + * @return the SpreadWithMultipleParametersRequest object itself. + */ + @Metadata(generated = true) + public SpreadWithMultipleParametersRequest setOptionalInt(Integer optionalInt) { + this.optionalInt = optionalInt; + return this; + } + + /** + * Get the requiredIntList property: required int. + * + * @return the requiredIntList value. + */ + @Metadata(generated = true) + public List getRequiredIntList() { + return this.requiredIntList; + } + + /** + * Get the optionalStringList property: optional string. + * + * @return the optionalStringList value. + */ + @Metadata(generated = true) + public List getOptionalStringList() { + return this.optionalStringList; + } + + /** + * Set the optionalStringList property: optional string. + * + * @param optionalStringList the optionalStringList value to set. + * @return the SpreadWithMultipleParametersRequest object itself. + */ + @Metadata(generated = true) + public SpreadWithMultipleParametersRequest setOptionalStringList(List optionalStringList) { + this.optionalStringList = optionalStringList; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredString", this.requiredString); + jsonWriter.writeArrayField("requiredIntList", this.requiredIntList, + (writer, element) -> writer.writeInt(element)); + jsonWriter.writeNumberField("optionalInt", this.optionalInt); + jsonWriter.writeArrayField("optionalStringList", this.optionalStringList, + (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadWithMultipleParametersRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadWithMultipleParametersRequest 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 SpreadWithMultipleParametersRequest. + */ + @Metadata(generated = true) + public static SpreadWithMultipleParametersRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String requiredString = null; + List requiredIntList = null; + Integer optionalInt = null; + List optionalStringList = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredString".equals(fieldName)) { + requiredString = reader.getString(); + } else if ("requiredIntList".equals(fieldName)) { + requiredIntList = reader.readArray(reader1 -> reader1.getInt()); + } else if ("optionalInt".equals(fieldName)) { + optionalInt = reader.getNullable(JsonReader::getInt); + } else if ("optionalStringList".equals(fieldName)) { + optionalStringList = reader.readArray(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + SpreadWithMultipleParametersRequest deserializedSpreadWithMultipleParametersRequest + = new SpreadWithMultipleParametersRequest(requiredString, requiredIntList); + deserializedSpreadWithMultipleParametersRequest.optionalInt = optionalInt; + deserializedSpreadWithMultipleParametersRequest.optionalStringList = optionalStringList; + + return deserializedSpreadWithMultipleParametersRequest; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/package-info.java new file mode 100644 index 0000000000..3695981c9f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Spread. + * Test for the spread operator. + */ +package parameters.spread.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/model/BodyParameter.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/model/BodyParameter.java new file mode 100644 index 0000000000..3d89a9078b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/model/BodyParameter.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package parameters.spread.model; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * This is a simple model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class BodyParameter implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of BodyParameter class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public BodyParameter(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BodyParameter from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BodyParameter 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 BodyParameter. + */ + @Metadata(generated = true) + public static BodyParameter fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new BodyParameter(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/model/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/model/package-info.java new file mode 100644 index 0000000000..d6f1023747 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/model/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for Spread. + * Test for the spread operator. + */ +package parameters.spread.model; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/package-info.java new file mode 100644 index 0000000000..962eacd99c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/parameters/spread/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Spread. + * Test for the spread operator. + */ +package parameters.spread; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/ContentNegotiationClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/ContentNegotiationClientBuilder.java new file mode 100644 index 0000000000..108fa7a3b7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/ContentNegotiationClientBuilder.java @@ -0,0 +1,251 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.contentnegotiation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import payload.contentnegotiation.implementation.ContentNegotiationClientImpl; + +/** + * A builder for creating a new instance of the ContentNegotiationClient type. + */ +@ServiceClientBuilder(serviceClients = { SameBodyClient.class, DifferentBodyClient.class }) +public final class ContentNegotiationClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the ContentNegotiationClientBuilder. + */ + @Metadata(generated = true) + public ContentNegotiationClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ContentNegotiationClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ContentNegotiationClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ContentNegotiationClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ContentNegotiationClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ContentNegotiationClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ContentNegotiationClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ContentNegotiationClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ContentNegotiationClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ContentNegotiationClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of ContentNegotiationClientImpl with the provided parameters. + * + * @return an instance of ContentNegotiationClientImpl. + */ + @Metadata(generated = true) + private ContentNegotiationClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ContentNegotiationClientImpl client = new ContentNegotiationClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of SameBodyClient class. + * + * @return an instance of SameBodyClient. + */ + @Metadata(generated = true) + public SameBodyClient buildSameBodyClient() { + return new SameBodyClient(buildInnerClient().getSameBodies()); + } + + /** + * Builds an instance of DifferentBodyClient class. + * + * @return an instance of DifferentBodyClient. + */ + @Metadata(generated = true) + public DifferentBodyClient buildDifferentBodyClient() { + return new DifferentBodyClient(buildInnerClient().getDifferentBodies()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ContentNegotiationClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/DifferentBodyClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/DifferentBodyClient.java new file mode 100644 index 0000000000..d4370c3e54 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/DifferentBodyClient.java @@ -0,0 +1,99 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.contentnegotiation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import payload.contentnegotiation.differentbody.PngImageAsJson; +import payload.contentnegotiation.implementation.DifferentBodiesImpl; + +/** + * Initializes a new instance of the synchronous ContentNegotiationClient type. + */ +@ServiceClient(builder = ContentNegotiationClientBuilder.class) +public final class DifferentBodyClient { + @Metadata(generated = true) + private final DifferentBodiesImpl serviceClient; + + /** + * Initializes an instance of DifferentBodyClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + DifferentBodyClient(DifferentBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getAvatarAsPng operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response getAvatarAsPngWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAvatarAsPngWithResponse(requestOptions); + } + + /** + * The getAvatarAsJson operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     content: byte[] (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response getAvatarAsJsonWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAvatarAsJsonWithResponse(requestOptions); + } + + /** + * The getAvatarAsPng operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public BinaryData getAvatarAsPng() { + // Generated convenience method for getAvatarAsPngWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAvatarAsPngWithResponse(requestOptions).getValue(); + } + + /** + * The getAvatarAsJson operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public PngImageAsJson getAvatarAsJson() { + // Generated convenience method for getAvatarAsJsonWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAvatarAsJsonWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/SameBodyClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/SameBodyClient.java new file mode 100644 index 0000000000..195913fc6a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/SameBodyClient.java @@ -0,0 +1,96 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.contentnegotiation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import payload.contentnegotiation.implementation.SameBodiesImpl; + +/** + * Initializes a new instance of the synchronous ContentNegotiationClient type. + */ +@ServiceClient(builder = ContentNegotiationClientBuilder.class) +public final class SameBodyClient { + @Metadata(generated = true) + private final SameBodiesImpl serviceClient; + + /** + * Initializes an instance of SameBodyClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + SameBodyClient(SameBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getAvatarAsPng operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response getAvatarAsPngWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAvatarAsPngWithResponse(requestOptions); + } + + /** + * The getAvatarAsJpeg operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response getAvatarAsJpegWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAvatarAsJpegWithResponse(requestOptions); + } + + /** + * The getAvatarAsPng operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public BinaryData getAvatarAsPng() { + // Generated convenience method for getAvatarAsPngWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAvatarAsPngWithResponse(requestOptions).getValue(); + } + + /** + * The getAvatarAsJpeg operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public BinaryData getAvatarAsJpeg() { + // Generated convenience method for getAvatarAsJpegWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAvatarAsJpegWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/differentbody/PngImageAsJson.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/differentbody/PngImageAsJson.java new file mode 100644 index 0000000000..510f07f814 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/differentbody/PngImageAsJson.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.contentnegotiation.differentbody; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The PngImageAsJson model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class PngImageAsJson implements JsonSerializable { + /* + * The content property. + */ + @Metadata(generated = true) + private final byte[] content; + + /** + * Creates an instance of PngImageAsJson class. + * + * @param content the content value to set. + */ + @Metadata(generated = true) + private PngImageAsJson(byte[] content) { + this.content = content; + } + + /** + * Get the content property: The content property. + * + * @return the content value. + */ + @Metadata(generated = true) + public byte[] getContent() { + return this.content; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBinaryField("content", this.content); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PngImageAsJson from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PngImageAsJson 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 PngImageAsJson. + */ + @Metadata(generated = true) + public static PngImageAsJson fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + byte[] content = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("content".equals(fieldName)) { + content = reader.getBinary(); + } else { + reader.skipChildren(); + } + } + return new PngImageAsJson(content); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/differentbody/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/differentbody/package-info.java new file mode 100644 index 0000000000..21321efdb1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/differentbody/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for ContentNegotiation. + * Test describing optionality of the request body. + */ +package payload.contentnegotiation.differentbody; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/implementation/ContentNegotiationClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/implementation/ContentNegotiationClientImpl.java new file mode 100644 index 0000000000..47053945ae --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/implementation/ContentNegotiationClientImpl.java @@ -0,0 +1,79 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.contentnegotiation.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the ContentNegotiationClient type. + */ +public final class ContentNegotiationClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 SameBodiesImpl object to access its operations. + */ + private final SameBodiesImpl sameBodies; + + /** + * Gets the SameBodiesImpl object to access its operations. + * + * @return the SameBodiesImpl object. + */ + public SameBodiesImpl getSameBodies() { + return this.sameBodies; + } + + /** + * The DifferentBodiesImpl object to access its operations. + */ + private final DifferentBodiesImpl differentBodies; + + /** + * Gets the DifferentBodiesImpl object to access its operations. + * + * @return the DifferentBodiesImpl object. + */ + public DifferentBodiesImpl getDifferentBodies() { + return this.differentBodies; + } + + /** + * Initializes an instance of ContentNegotiationClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public ContentNegotiationClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.sameBodies = new SameBodiesImpl(this); + this.differentBodies = new DifferentBodiesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/implementation/DifferentBodiesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/implementation/DifferentBodiesImpl.java new file mode 100644 index 0000000000..2f3f4bf2ce --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/implementation/DifferentBodiesImpl.java @@ -0,0 +1,104 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.contentnegotiation.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import payload.contentnegotiation.differentbody.PngImageAsJson; + +/** + * An instance of this class provides access to all the operations defined in DifferentBodies. + */ +public final class DifferentBodiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DifferentBodiesService service; + + /** + * The service client containing this operation class. + */ + private final ContentNegotiationClientImpl client; + + /** + * Initializes an instance of DifferentBodiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DifferentBodiesImpl(ContentNegotiationClientImpl client) { + this.service = RestProxy.create(DifferentBodiesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ContentNegotiationClientDifferentBodies to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "ContentNegotiationCl", host = "{endpoint}") + public interface DifferentBodiesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/content-negotiation/different-body", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAvatarAsPngSync(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/content-negotiation/different-body", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAvatarAsJsonSync(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions); + } + + /** + * The getAvatarAsPng operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response getAvatarAsPngWithResponse(RequestOptions requestOptions) { + final String accept = "image/png"; + return service.getAvatarAsPngSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The getAvatarAsJson operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     content: byte[] (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response getAvatarAsJsonWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAvatarAsJsonSync(this.client.getEndpoint(), accept, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/implementation/SameBodiesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/implementation/SameBodiesImpl.java new file mode 100644 index 0000000000..f8899137a6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/implementation/SameBodiesImpl.java @@ -0,0 +1,101 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.contentnegotiation.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * An instance of this class provides access to all the operations defined in SameBodies. + */ +public final class SameBodiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SameBodiesService service; + + /** + * The service client containing this operation class. + */ + private final ContentNegotiationClientImpl client; + + /** + * Initializes an instance of SameBodiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SameBodiesImpl(ContentNegotiationClientImpl client) { + this.service = RestProxy.create(SameBodiesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ContentNegotiationClientSameBodies to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ContentNegotiationCl", host = "{endpoint}") + public interface SameBodiesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/content-negotiation/same-body", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAvatarAsPngSync(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/content-negotiation/same-body", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAvatarAsJpegSync(@HostParam("endpoint") String endpoint, + @HeaderParam("accept") String accept, RequestOptions requestOptions); + } + + /** + * The getAvatarAsPng operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response getAvatarAsPngWithResponse(RequestOptions requestOptions) { + final String accept = "image/png"; + return service.getAvatarAsPngSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The getAvatarAsJpeg operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response getAvatarAsJpegWithResponse(RequestOptions requestOptions) { + final String accept = "image/jpeg"; + return service.getAvatarAsJpegSync(this.client.getEndpoint(), accept, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/implementation/package-info.java new file mode 100644 index 0000000000..23028ac85c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for ContentNegotiation. + * Test describing optionality of the request body. + */ +package payload.contentnegotiation.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/package-info.java new file mode 100644 index 0000000000..275a479915 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/contentnegotiation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for ContentNegotiation. + * Test describing optionality of the request body. + */ +package payload.contentnegotiation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/InnerModel.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/InnerModel.java new file mode 100644 index 0000000000..aca9cf7308 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/InnerModel.java @@ -0,0 +1,179 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.jsonmergepatch; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; +import payload.jsonmergepatch.implementation.JsonMergePatchHelper; + +/** + * It is the model used by Resource model. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class InnerModel implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private String name; + + /* + * The description property. + */ + @Metadata(generated = true) + private String description; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Metadata(generated = true) + private final Set updatedProperties = new HashSet<>(); + + @Metadata(generated = true) + private boolean jsonMergePatch; + + @Metadata(generated = true) + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setInnerModelAccessor(new JsonMergePatchHelper.InnerModelAccessor() { + @Override + public InnerModel prepareModelForJsonMergePatch(InnerModel model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(InnerModel model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of InnerModel class. + */ + @Metadata(generated = true) + public InnerModel() { + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * Set the name property: The name property. + * + * @param name the name value to set. + * @return the InnerModel object itself. + */ + @Metadata(generated = true) + public InnerModel setName(String name) { + this.name = name; + this.updatedProperties.add("name"); + return this; + } + + /** + * Get the description property: The description property. + * + * @return the description value. + */ + @Metadata(generated = true) + public String getDescription() { + return this.description; + } + + /** + * Set the description property: The description property. + * + * @param description the description value to set. + * @return the InnerModel object itself. + */ + @Metadata(generated = true) + public InnerModel setDescription(String description) { + this.description = description; + this.updatedProperties.add("description"); + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("description", this.description); + return jsonWriter.writeEndObject(); + } + } + + @Metadata(generated = true) + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("name")) { + if (this.name == null) { + jsonWriter.writeNullField("name"); + } else { + jsonWriter.writeStringField("name", this.name); + } + } + if (updatedProperties.contains("description")) { + if (this.description == null) { + jsonWriter.writeNullField("description"); + } else { + jsonWriter.writeStringField("description", this.description); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InnerModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InnerModel if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IOException If an error occurs while reading the InnerModel. + */ + @Metadata(generated = true) + public static InnerModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + InnerModel deserializedInnerModel = new InnerModel(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + deserializedInnerModel.name = reader.getString(); + } else if ("description".equals(fieldName)) { + deserializedInnerModel.description = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedInnerModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/JsonMergePatchClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/JsonMergePatchClient.java new file mode 100644 index 0000000000..c99278e2bf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/JsonMergePatchClient.java @@ -0,0 +1,303 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.jsonmergepatch; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import payload.jsonmergepatch.implementation.JsonMergePatchClientImpl; +import payload.jsonmergepatch.implementation.JsonMergePatchHelper; + +/** + * Initializes a new instance of the synchronous JsonMergePatchClient type. + */ +@ServiceClient(builder = JsonMergePatchClientBuilder.class) +public final class JsonMergePatchClient { + @Metadata(generated = true) + private final JsonMergePatchClientImpl serviceClient; + + /** + * Initializes an instance of JsonMergePatchClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + JsonMergePatchClient(JsonMergePatchClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Test content-type: application/merge-patch+json with required body. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return details about a resource. + */ + @Metadata(generated = true) + public Response createResourceWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.createResourceWithResponse(body, requestOptions); + } + + /** + * Test content-type: application/merge-patch+json with required body. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return details about a resource. + */ + @Metadata(generated = true) + public Response updateResourceWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.updateResourceWithResponse(body, requestOptions); + } + + /** + * Test content-type: application/merge-patch+json with optional body. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/merge-patch+json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return details about a resource. + */ + @Metadata(generated = true) + public Response updateOptionalResourceWithResponse(RequestOptions requestOptions) { + return this.serviceClient.updateOptionalResourceWithResponse(requestOptions); + } + + /** + * Test content-type: application/merge-patch+json with required body. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return details about a resource. + */ + @Metadata(generated = true) + public Resource createResource(Resource body) { + // Generated convenience method for createResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createResourceWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Test content-type: application/merge-patch+json with required body. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return details about a resource. + */ + @Metadata(generated = true) + public Resource updateResource(ResourcePatch body) { + // Generated convenience method for updateResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getResourcePatchAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getResourcePatchAccessor().prepareModelForJsonMergePatch(body, false); + return updateResourceWithResponse(bodyInBinaryData, requestOptions).getValue(); + } + + /** + * Test content-type: application/merge-patch+json with optional body. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return details about a resource. + */ + @Metadata(generated = true) + public Resource updateOptionalResource(ResourcePatch body) { + // Generated convenience method for updateOptionalResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (body != null) { + JsonMergePatchHelper.getResourcePatchAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getResourcePatchAccessor().prepareModelForJsonMergePatch(body, false); + requestOptions.setBody(bodyInBinaryData); + } + return updateOptionalResourceWithResponse(requestOptions).getValue(); + } + + /** + * Test content-type: application/merge-patch+json with optional body. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return details about a resource. + */ + @Metadata(generated = true) + public Resource updateOptionalResource() { + // Generated convenience method for updateOptionalResourceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return updateOptionalResourceWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/JsonMergePatchClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/JsonMergePatchClientBuilder.java new file mode 100644 index 0000000000..0a3fd08c6e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/JsonMergePatchClientBuilder.java @@ -0,0 +1,241 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.jsonmergepatch; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import payload.jsonmergepatch.implementation.JsonMergePatchClientImpl; + +/** + * A builder for creating a new instance of the JsonMergePatchClient type. + */ +@ServiceClientBuilder(serviceClients = { JsonMergePatchClient.class }) +public final class JsonMergePatchClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the JsonMergePatchClientBuilder. + */ + @Metadata(generated = true) + public JsonMergePatchClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonMergePatchClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonMergePatchClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonMergePatchClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonMergePatchClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonMergePatchClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonMergePatchClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonMergePatchClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonMergePatchClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonMergePatchClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of JsonMergePatchClientImpl with the provided parameters. + * + * @return an instance of JsonMergePatchClientImpl. + */ + @Metadata(generated = true) + private JsonMergePatchClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + JsonMergePatchClientImpl client = new JsonMergePatchClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of JsonMergePatchClient class. + * + * @return an instance of JsonMergePatchClient. + */ + @Metadata(generated = true) + public JsonMergePatchClient buildClient() { + return new JsonMergePatchClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(JsonMergePatchClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/Resource.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/Resource.java new file mode 100644 index 0000000000..82d7e0e8fd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/Resource.java @@ -0,0 +1,316 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.jsonmergepatch; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * Details about a resource. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class Resource implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /* + * The description property. + */ + @Metadata(generated = true) + private String description; + + /* + * The map property. + */ + @Metadata(generated = true) + private Map map; + + /* + * The array property. + */ + @Metadata(generated = true) + private List array; + + /* + * The intValue property. + */ + @Metadata(generated = true) + private Integer intValue; + + /* + * The floatValue property. + */ + @Metadata(generated = true) + private Double floatValue; + + /* + * The innerModel property. + */ + @Metadata(generated = true) + private InnerModel innerModel; + + /* + * The intArray property. + */ + @Metadata(generated = true) + private List intArray; + + /** + * Creates an instance of Resource class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Resource(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * Get the description property: The description property. + * + * @return the description value. + */ + @Metadata(generated = true) + public String getDescription() { + return this.description; + } + + /** + * Set the description property: The description property. + * + * @param description the description value to set. + * @return the Resource object itself. + */ + @Metadata(generated = true) + public Resource setDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the map property: The map property. + * + * @return the map value. + */ + @Metadata(generated = true) + public Map getMap() { + return this.map; + } + + /** + * Set the map property: The map property. + * + * @param map the map value to set. + * @return the Resource object itself. + */ + @Metadata(generated = true) + public Resource setMap(Map map) { + this.map = map; + return this; + } + + /** + * Get the array property: The array property. + * + * @return the array value. + */ + @Metadata(generated = true) + public List getArray() { + return this.array; + } + + /** + * Set the array property: The array property. + * + * @param array the array value to set. + * @return the Resource object itself. + */ + @Metadata(generated = true) + public Resource setArray(List array) { + this.array = array; + return this; + } + + /** + * Get the intValue property: The intValue property. + * + * @return the intValue value. + */ + @Metadata(generated = true) + public Integer getIntValue() { + return this.intValue; + } + + /** + * Set the intValue property: The intValue property. + * + * @param intValue the intValue value to set. + * @return the Resource object itself. + */ + @Metadata(generated = true) + public Resource setIntValue(Integer intValue) { + this.intValue = intValue; + return this; + } + + /** + * Get the floatValue property: The floatValue property. + * + * @return the floatValue value. + */ + @Metadata(generated = true) + public Double getFloatValue() { + return this.floatValue; + } + + /** + * Set the floatValue property: The floatValue property. + * + * @param floatValue the floatValue value to set. + * @return the Resource object itself. + */ + @Metadata(generated = true) + public Resource setFloatValue(Double floatValue) { + this.floatValue = floatValue; + return this; + } + + /** + * Get the innerModel property: The innerModel property. + * + * @return the innerModel value. + */ + @Metadata(generated = true) + public InnerModel getInnerModel() { + return this.innerModel; + } + + /** + * Set the innerModel property: The innerModel property. + * + * @param innerModel the innerModel value to set. + * @return the Resource object itself. + */ + @Metadata(generated = true) + public Resource setInnerModel(InnerModel innerModel) { + this.innerModel = innerModel; + return this; + } + + /** + * Get the intArray property: The intArray property. + * + * @return the intArray value. + */ + @Metadata(generated = true) + public List getIntArray() { + return this.intArray; + } + + /** + * Set the intArray property: The intArray property. + * + * @param intArray the intArray value to set. + * @return the Resource object itself. + */ + @Metadata(generated = true) + public Resource setIntArray(List intArray) { + this.intArray = intArray; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeMapField("map", this.map, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("array", this.array, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeNumberField("intValue", this.intValue); + jsonWriter.writeNumberField("floatValue", this.floatValue); + jsonWriter.writeJsonField("innerModel", this.innerModel); + jsonWriter.writeArrayField("intArray", this.intArray, (writer, element) -> writer.writeInt(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Resource from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Resource 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 Resource. + */ + @Metadata(generated = true) + public static Resource fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String description = null; + Map map = null; + List array = null; + Integer intValue = null; + Double floatValue = null; + InnerModel innerModel = null; + List intArray = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("description".equals(fieldName)) { + description = reader.getString(); + } else if ("map".equals(fieldName)) { + map = reader.readMap(reader1 -> InnerModel.fromJson(reader1)); + } else if ("array".equals(fieldName)) { + array = reader.readArray(reader1 -> InnerModel.fromJson(reader1)); + } else if ("intValue".equals(fieldName)) { + intValue = reader.getNullable(JsonReader::getInt); + } else if ("floatValue".equals(fieldName)) { + floatValue = reader.getNullable(JsonReader::getDouble); + } else if ("innerModel".equals(fieldName)) { + innerModel = InnerModel.fromJson(reader); + } else if ("intArray".equals(fieldName)) { + intArray = reader.readArray(reader1 -> reader1.getInt()); + } else { + reader.skipChildren(); + } + } + Resource deserializedResource = new Resource(name); + deserializedResource.description = description; + deserializedResource.map = map; + deserializedResource.array = array; + deserializedResource.intValue = intValue; + deserializedResource.floatValue = floatValue; + deserializedResource.innerModel = innerModel; + deserializedResource.intArray = intArray; + + return deserializedResource; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/ResourcePatch.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/ResourcePatch.java new file mode 100644 index 0000000000..4fa2902a7b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/ResourcePatch.java @@ -0,0 +1,389 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.jsonmergepatch; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import payload.jsonmergepatch.implementation.JsonMergePatchHelper; + +/** + * Details about a resource for patch operation. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class ResourcePatch implements JsonSerializable { + /* + * The description property. + */ + @Metadata(generated = true) + private String description; + + /* + * The map property. + */ + @Metadata(generated = true) + private Map map; + + /* + * The array property. + */ + @Metadata(generated = true) + private List array; + + /* + * The intValue property. + */ + @Metadata(generated = true) + private Integer intValue; + + /* + * The floatValue property. + */ + @Metadata(generated = true) + private Double floatValue; + + /* + * The innerModel property. + */ + @Metadata(generated = true) + private InnerModel innerModel; + + /* + * The intArray property. + */ + @Metadata(generated = true) + private List intArray; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Metadata(generated = true) + private final Set updatedProperties = new HashSet<>(); + + @Metadata(generated = true) + private boolean jsonMergePatch; + + @Metadata(generated = true) + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setResourcePatchAccessor(new JsonMergePatchHelper.ResourcePatchAccessor() { + @Override + public ResourcePatch prepareModelForJsonMergePatch(ResourcePatch model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(ResourcePatch model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of ResourcePatch class. + */ + @Metadata(generated = true) + public ResourcePatch() { + } + + /** + * Get the description property: The description property. + * + * @return the description value. + */ + @Metadata(generated = true) + public String getDescription() { + return this.description; + } + + /** + * Set the description property: The description property. + * + * @param description the description value to set. + * @return the ResourcePatch object itself. + */ + @Metadata(generated = true) + public ResourcePatch setDescription(String description) { + this.description = description; + this.updatedProperties.add("description"); + return this; + } + + /** + * Get the map property: The map property. + * + * @return the map value. + */ + @Metadata(generated = true) + public Map getMap() { + return this.map; + } + + /** + * Set the map property: The map property. + * + * @param map the map value to set. + * @return the ResourcePatch object itself. + */ + @Metadata(generated = true) + public ResourcePatch setMap(Map map) { + this.map = map; + this.updatedProperties.add("map"); + return this; + } + + /** + * Get the array property: The array property. + * + * @return the array value. + */ + @Metadata(generated = true) + public List getArray() { + return this.array; + } + + /** + * Set the array property: The array property. + * + * @param array the array value to set. + * @return the ResourcePatch object itself. + */ + @Metadata(generated = true) + public ResourcePatch setArray(List array) { + this.array = array; + this.updatedProperties.add("array"); + return this; + } + + /** + * Get the intValue property: The intValue property. + * + * @return the intValue value. + */ + @Metadata(generated = true) + public Integer getIntValue() { + return this.intValue; + } + + /** + * Set the intValue property: The intValue property. + * + * @param intValue the intValue value to set. + * @return the ResourcePatch object itself. + */ + @Metadata(generated = true) + public ResourcePatch setIntValue(Integer intValue) { + this.intValue = intValue; + this.updatedProperties.add("intValue"); + return this; + } + + /** + * Get the floatValue property: The floatValue property. + * + * @return the floatValue value. + */ + @Metadata(generated = true) + public Double getFloatValue() { + return this.floatValue; + } + + /** + * Set the floatValue property: The floatValue property. + * + * @param floatValue the floatValue value to set. + * @return the ResourcePatch object itself. + */ + @Metadata(generated = true) + public ResourcePatch setFloatValue(Double floatValue) { + this.floatValue = floatValue; + this.updatedProperties.add("floatValue"); + return this; + } + + /** + * Get the innerModel property: The innerModel property. + * + * @return the innerModel value. + */ + @Metadata(generated = true) + public InnerModel getInnerModel() { + return this.innerModel; + } + + /** + * Set the innerModel property: The innerModel property. + * + * @param innerModel the innerModel value to set. + * @return the ResourcePatch object itself. + */ + @Metadata(generated = true) + public ResourcePatch setInnerModel(InnerModel innerModel) { + this.innerModel = innerModel; + this.updatedProperties.add("innerModel"); + return this; + } + + /** + * Get the intArray property: The intArray property. + * + * @return the intArray value. + */ + @Metadata(generated = true) + public List getIntArray() { + return this.intArray; + } + + /** + * Set the intArray property: The intArray property. + * + * @param intArray the intArray value to set. + * @return the ResourcePatch object itself. + */ + @Metadata(generated = true) + public ResourcePatch setIntArray(List intArray) { + this.intArray = intArray; + this.updatedProperties.add("intArray"); + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("description", this.description); + jsonWriter.writeMapField("map", this.map, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeArrayField("array", this.array, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeNumberField("intValue", this.intValue); + jsonWriter.writeNumberField("floatValue", this.floatValue); + jsonWriter.writeJsonField("innerModel", this.innerModel); + jsonWriter.writeArrayField("intArray", this.intArray, (writer, element) -> writer.writeInt(element)); + return jsonWriter.writeEndObject(); + } + } + + @Metadata(generated = true) + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("description")) { + if (this.description == null) { + jsonWriter.writeNullField("description"); + } else { + jsonWriter.writeStringField("description", this.description); + } + } + if (updatedProperties.contains("map")) { + if (this.map == null) { + jsonWriter.writeNullField("map"); + } else { + jsonWriter.writeMapField("map", this.map, (writer, element) -> { + if (element != null) { + JsonMergePatchHelper.getInnerModelAccessor().prepareModelForJsonMergePatch(element, true); + writer.writeJson(element); + JsonMergePatchHelper.getInnerModelAccessor().prepareModelForJsonMergePatch(element, false); + } else { + writer.writeNull(); + } + }); + } + } + if (updatedProperties.contains("array")) { + if (this.array == null) { + jsonWriter.writeNullField("array"); + } else { + jsonWriter.writeArrayField("array", this.array, (writer, element) -> writer.writeJson(element)); + } + } + if (updatedProperties.contains("intValue")) { + if (this.intValue == null) { + jsonWriter.writeNullField("intValue"); + } else { + jsonWriter.writeNumberField("intValue", this.intValue); + } + } + if (updatedProperties.contains("floatValue")) { + if (this.floatValue == null) { + jsonWriter.writeNullField("floatValue"); + } else { + jsonWriter.writeNumberField("floatValue", this.floatValue); + } + } + if (updatedProperties.contains("innerModel")) { + if (this.innerModel == null) { + jsonWriter.writeNullField("innerModel"); + } else { + JsonMergePatchHelper.getInnerModelAccessor().prepareModelForJsonMergePatch(this.innerModel, true); + jsonWriter.writeJsonField("innerModel", this.innerModel); + JsonMergePatchHelper.getInnerModelAccessor().prepareModelForJsonMergePatch(this.innerModel, false); + } + } + if (updatedProperties.contains("intArray")) { + if (this.intArray == null) { + jsonWriter.writeNullField("intArray"); + } else { + jsonWriter.writeArrayField("intArray", this.intArray, (writer, element) -> writer.writeInt(element)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ResourcePatch from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ResourcePatch if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ResourcePatch. + */ + @Metadata(generated = true) + public static ResourcePatch fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ResourcePatch deserializedResourcePatch = new ResourcePatch(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("description".equals(fieldName)) { + deserializedResourcePatch.description = reader.getString(); + } else if ("map".equals(fieldName)) { + Map map = reader.readMap(reader1 -> InnerModel.fromJson(reader1)); + deserializedResourcePatch.map = map; + } else if ("array".equals(fieldName)) { + List array = reader.readArray(reader1 -> InnerModel.fromJson(reader1)); + deserializedResourcePatch.array = array; + } else if ("intValue".equals(fieldName)) { + deserializedResourcePatch.intValue = reader.getNullable(JsonReader::getInt); + } else if ("floatValue".equals(fieldName)) { + deserializedResourcePatch.floatValue = reader.getNullable(JsonReader::getDouble); + } else if ("innerModel".equals(fieldName)) { + deserializedResourcePatch.innerModel = InnerModel.fromJson(reader); + } else if ("intArray".equals(fieldName)) { + List intArray = reader.readArray(reader1 -> reader1.getInt()); + deserializedResourcePatch.intArray = intArray; + } else { + reader.skipChildren(); + } + } + + return deserializedResourcePatch; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/implementation/JsonMergePatchClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/implementation/JsonMergePatchClientImpl.java new file mode 100644 index 0000000000..2f4158fc10 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/implementation/JsonMergePatchClientImpl.java @@ -0,0 +1,307 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.jsonmergepatch.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpHeaderName; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.util.binarydata.BinaryData; +import payload.jsonmergepatch.Resource; + +/** + * Initializes a new instance of the JsonMergePatchClient type. + */ +public final class JsonMergePatchClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final JsonMergePatchClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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; + } + + /** + * Initializes an instance of JsonMergePatchClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public JsonMergePatchClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(JsonMergePatchClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for JsonMergePatchClient to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "JsonMergePatchClient", host = "{endpoint}") + public interface JsonMergePatchClientService { + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/json-merge-patch/create/resource", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response createResourceSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PATCH, + path = "/json-merge-patch/update/resource", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response updateResourceSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/merge-patch+json") BinaryData body, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PATCH, + path = "/json-merge-patch/update/resource/optional", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response updateOptionalResourceSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + } + + /** + * Test content-type: application/merge-patch+json with required body. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return details about a resource. + */ + public Response createResourceWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.createResourceSync(this.getEndpoint(), contentType, accept, body, requestOptions); + } + + /** + * Test content-type: application/merge-patch+json with required body. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return details about a resource. + */ + public Response updateResourceWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + final String accept = "application/json"; + return service.updateResourceSync(this.getEndpoint(), contentType, accept, body, requestOptions); + } + + /** + * Test content-type: application/merge-patch+json with optional body. + *

Header Parameters

+ * + * + * + * + *
Header Parameters
NameTypeRequiredDescription
Content-TypeStringNoThe content type. Allowed values: + * "application/merge-patch+json".
+ * You can add these to a request with {@link RequestOptions#addHeader} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     description: String (Optional)
+     *     map (Optional): {
+     *         String (Required): {
+     *             name: String (Optional)
+     *             description: String (Optional)
+     *         }
+     *     }
+     *     array (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     intValue: Integer (Optional)
+     *     floatValue: Double (Optional)
+     *     innerModel (Optional): (recursive schema, see innerModel above)
+     *     intArray (Optional): [
+     *         int (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return details about a resource. + */ + public Response updateOptionalResourceWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + RequestOptions requestOptionsLocal = requestOptions == null ? new RequestOptions() : requestOptions; + requestOptionsLocal.addRequestCallback(requestLocal -> { + if (requestLocal.getBody() != null && requestLocal.getHeaders().get(HttpHeaderName.CONTENT_TYPE) == null) { + requestLocal.getHeaders().set(HttpHeaderName.CONTENT_TYPE, "application/merge-patch+json"); + } + }); + return service.updateOptionalResourceSync(this.getEndpoint(), accept, requestOptionsLocal); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/implementation/JsonMergePatchHelper.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/implementation/JsonMergePatchHelper.java new file mode 100644 index 0000000000..64e667b6f3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/implementation/JsonMergePatchHelper.java @@ -0,0 +1,43 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.jsonmergepatch.implementation; + +import payload.jsonmergepatch.InnerModel; +import payload.jsonmergepatch.ResourcePatch; + +/** + * This is the Helper class to enable json merge patch serialization for a model. + */ +public class JsonMergePatchHelper { + private static InnerModelAccessor innerModelAccessor; + + public interface InnerModelAccessor { + InnerModel prepareModelForJsonMergePatch(InnerModel innerModel, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(InnerModel innerModel); + } + + public static void setInnerModelAccessor(InnerModelAccessor accessor) { + innerModelAccessor = accessor; + } + + public static InnerModelAccessor getInnerModelAccessor() { + return innerModelAccessor; + } + + private static ResourcePatchAccessor resourcePatchAccessor; + + public interface ResourcePatchAccessor { + ResourcePatch prepareModelForJsonMergePatch(ResourcePatch resourcePatch, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(ResourcePatch resourcePatch); + } + + public static void setResourcePatchAccessor(ResourcePatchAccessor accessor) { + resourcePatchAccessor = accessor; + } + + public static ResourcePatchAccessor getResourcePatchAccessor() { + return resourcePatchAccessor; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/implementation/package-info.java new file mode 100644 index 0000000000..c04e0b4bc2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for JsonMergePatch. + * Test for merge-patch+json content-type. + */ +package payload.jsonmergepatch.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/package-info.java new file mode 100644 index 0000000000..dced85e1ca --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/jsonmergepatch/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for JsonMergePatch. + * Test for merge-patch+json content-type. + */ +package payload.jsonmergepatch; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/MediaTypeClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/MediaTypeClient.java new file mode 100644 index 0000000000..03ecadc2ca --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/MediaTypeClient.java @@ -0,0 +1,166 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.mediatype; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import payload.mediatype.implementation.StringBodiesImpl; + +/** + * Initializes a new instance of the synchronous MediaTypeClient type. + */ +@ServiceClient(builder = MediaTypeClientBuilder.class) +public final class MediaTypeClient { + @Metadata(generated = true) + private final StringBodiesImpl serviceClient; + + /** + * Initializes an instance of MediaTypeClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + MediaTypeClient(StringBodiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The sendAsText operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * String
+     * }
+     * 
+ * + * @param text The text parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response sendAsTextWithResponse(BinaryData text, RequestOptions requestOptions) { + return this.serviceClient.sendAsTextWithResponse(text, requestOptions); + } + + /** + * The getAsText operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * String
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a sequence of textual characters. + */ + @Metadata(generated = true) + public Response getAsTextWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAsTextWithResponse(requestOptions); + } + + /** + * The sendAsJson operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * String
+     * }
+     * 
+ * + * @param text The text parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response sendAsJsonWithResponse(BinaryData text, RequestOptions requestOptions) { + return this.serviceClient.sendAsJsonWithResponse(text, requestOptions); + } + + /** + * The getAsJson operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * String
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a sequence of textual characters. + */ + @Metadata(generated = true) + public Response getAsJsonWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAsJsonWithResponse(requestOptions); + } + + /** + * The sendAsText operation. + * + * @param text The text parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void sendAsText(String text) { + // Generated convenience method for sendAsTextWithResponse + RequestOptions requestOptions = new RequestOptions(); + sendAsTextWithResponse(BinaryData.fromString(text), requestOptions).getValue(); + } + + /** + * The getAsText operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a sequence of textual characters. + */ + @Metadata(generated = true) + public String getAsText() { + // Generated convenience method for getAsTextWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAsTextWithResponse(requestOptions).getValue(); + } + + /** + * The sendAsJson operation. + * + * @param text The text parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void sendAsJson(String text) { + // Generated convenience method for sendAsJsonWithResponse + RequestOptions requestOptions = new RequestOptions(); + sendAsJsonWithResponse(BinaryData.fromObject(text), requestOptions).getValue(); + } + + /** + * The getAsJson operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a sequence of textual characters. + */ + @Metadata(generated = true) + public String getAsJson() { + // Generated convenience method for getAsJsonWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAsJsonWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/MediaTypeClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/MediaTypeClientBuilder.java new file mode 100644 index 0000000000..5f8f964750 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/MediaTypeClientBuilder.java @@ -0,0 +1,241 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.mediatype; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import payload.mediatype.implementation.MediaTypeClientImpl; + +/** + * A builder for creating a new instance of the MediaTypeClient type. + */ +@ServiceClientBuilder(serviceClients = { MediaTypeClient.class }) +public final class MediaTypeClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the MediaTypeClientBuilder. + */ + @Metadata(generated = true) + public MediaTypeClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MediaTypeClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MediaTypeClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MediaTypeClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MediaTypeClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MediaTypeClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MediaTypeClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MediaTypeClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MediaTypeClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MediaTypeClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of MediaTypeClientImpl with the provided parameters. + * + * @return an instance of MediaTypeClientImpl. + */ + @Metadata(generated = true) + private MediaTypeClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + MediaTypeClientImpl client = new MediaTypeClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of MediaTypeClient class. + * + * @return an instance of MediaTypeClient. + */ + @Metadata(generated = true) + public MediaTypeClient buildMediaTypeClient() { + return new MediaTypeClient(buildInnerClient().getStringBodies()); + } + + private static final ClientLogger LOGGER = new ClientLogger(MediaTypeClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/implementation/MediaTypeClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/implementation/MediaTypeClientImpl.java new file mode 100644 index 0000000000..ba3bba55ef --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/implementation/MediaTypeClientImpl.java @@ -0,0 +1,64 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.mediatype.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the MediaTypeClient type. + */ +public final class MediaTypeClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 StringBodiesImpl object to access its operations. + */ + private final StringBodiesImpl stringBodies; + + /** + * Gets the StringBodiesImpl object to access its operations. + * + * @return the StringBodiesImpl object. + */ + public StringBodiesImpl getStringBodies() { + return this.stringBodies; + } + + /** + * Initializes an instance of MediaTypeClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public MediaTypeClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.stringBodies = new StringBodiesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/implementation/StringBodiesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/implementation/StringBodiesImpl.java new file mode 100644 index 0000000000..d056ec5134 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/implementation/StringBodiesImpl.java @@ -0,0 +1,160 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.mediatype.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * An instance of this class provides access to all the operations defined in StringBodies. + */ +public final class StringBodiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringBodiesService service; + + /** + * The service client containing this operation class. + */ + private final MediaTypeClientImpl client; + + /** + * Initializes an instance of StringBodiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringBodiesImpl(MediaTypeClientImpl client) { + this.service = RestProxy.create(StringBodiesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for MediaTypeClientStringBodies to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "MediaTypeClientStrin", host = "{endpoint}") + public interface StringBodiesService { + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/payload/media-type/string-body/sendAsText", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response sendAsTextSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("text/plain") BinaryData text, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/payload/media-type/string-body/getAsText", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAsTextSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/payload/media-type/string-body/sendAsJson", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response sendAsJsonSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("application/json") BinaryData text, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/payload/media-type/string-body/getAsJson", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAsJsonSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + } + + /** + * The sendAsText operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * String
+     * }
+     * 
+ * + * @param text The text parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response sendAsTextWithResponse(BinaryData text, RequestOptions requestOptions) { + final String contentType = "text/plain"; + return service.sendAsTextSync(this.client.getEndpoint(), contentType, text, requestOptions); + } + + /** + * The getAsText operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * String
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a sequence of textual characters. + */ + public Response getAsTextWithResponse(RequestOptions requestOptions) { + final String accept = "text/plain"; + return service.getAsTextSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The sendAsJson operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * String
+     * }
+     * 
+ * + * @param text The text parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response sendAsJsonWithResponse(BinaryData text, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendAsJsonSync(this.client.getEndpoint(), contentType, text, requestOptions); + } + + /** + * The getAsJson operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * String
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a sequence of textual characters. + */ + public Response getAsJsonWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAsJsonSync(this.client.getEndpoint(), accept, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/implementation/package-info.java new file mode 100644 index 0000000000..c6c7d34f4c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for MediaType. + * Test the payload with different media types and different types of the payload itself. + */ +package payload.mediatype.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/package-info.java new file mode 100644 index 0000000000..5707c9b8e7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/mediatype/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for MediaType. + * Test the payload with different media types and different types of the payload itself. + */ +package payload.mediatype; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/Address.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/Address.java new file mode 100644 index 0000000000..4d713c64ee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/Address.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Address model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Address implements JsonSerializable
{ + /* + * The city property. + */ + @Metadata(generated = true) + private final String city; + + /** + * Creates an instance of Address class. + * + * @param city the city value to set. + */ + @Metadata(generated = true) + public Address(String city) { + this.city = city; + } + + /** + * Get the city property: The city property. + * + * @return the city value. + */ + @Metadata(generated = true) + public String getCity() { + return this.city; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("city", this.city); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Address from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Address 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 Address. + */ + @Metadata(generated = true) + public static Address fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String city = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("city".equals(fieldName)) { + city = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Address(city); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/BinaryArrayPartsRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/BinaryArrayPartsRequest.java new file mode 100644 index 0000000000..c9ba9a0864 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/BinaryArrayPartsRequest.java @@ -0,0 +1,57 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import java.util.List; + +/** + * The BinaryArrayPartsRequest model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class BinaryArrayPartsRequest { + /* + * The id property. + */ + @Metadata(generated = true) + private final String id; + + /* + * The pictures property. + */ + @Metadata(generated = true) + private final List pictures; + + /** + * Creates an instance of BinaryArrayPartsRequest class. + * + * @param id the id value to set. + * @param pictures the pictures value to set. + */ + @Metadata(generated = true) + public BinaryArrayPartsRequest(String id, List pictures) { + this.id = id; + this.pictures = pictures; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Metadata(generated = true) + public String getId() { + return this.id; + } + + /** + * Get the pictures property: The pictures property. + * + * @return the pictures value. + */ + @Metadata(generated = true) + public List getPictures() { + return this.pictures; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/ComplexHttpPartsModelRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/ComplexHttpPartsModelRequest.java new file mode 100644 index 0000000000..9a2044a21f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/ComplexHttpPartsModelRequest.java @@ -0,0 +1,112 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import java.util.List; + +/** + * The ComplexHttpPartsModelRequest model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class ComplexHttpPartsModelRequest { + /* + * The id property. + */ + @Metadata(generated = true) + private final String id; + + /* + * The address property. + */ + @Metadata(generated = true) + private final Address address; + + /* + * The profileImage property. + */ + @Metadata(generated = true) + private final FileRequiredMetaData profileImage; + + /* + * The previousAddresses property. + */ + @Metadata(generated = true) + private final List
previousAddresses; + + /* + * The pictures property. + */ + @Metadata(generated = true) + private final List pictures; + + /** + * Creates an instance of ComplexHttpPartsModelRequest class. + * + * @param id the id value to set. + * @param address the address value to set. + * @param profileImage the profileImage value to set. + * @param previousAddresses the previousAddresses value to set. + * @param pictures the pictures value to set. + */ + @Metadata(generated = true) + public ComplexHttpPartsModelRequest(String id, Address address, FileRequiredMetaData profileImage, + List
previousAddresses, List pictures) { + this.id = id; + this.address = address; + this.profileImage = profileImage; + this.previousAddresses = previousAddresses; + this.pictures = pictures; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Metadata(generated = true) + public String getId() { + return this.id; + } + + /** + * Get the address property: The address property. + * + * @return the address value. + */ + @Metadata(generated = true) + public Address getAddress() { + return this.address; + } + + /** + * Get the profileImage property: The profileImage property. + * + * @return the profileImage value. + */ + @Metadata(generated = true) + public FileRequiredMetaData getProfileImage() { + return this.profileImage; + } + + /** + * Get the previousAddresses property: The previousAddresses property. + * + * @return the previousAddresses value. + */ + @Metadata(generated = true) + public List
getPreviousAddresses() { + return this.previousAddresses; + } + + /** + * Get the pictures property: The pictures property. + * + * @return the pictures value. + */ + @Metadata(generated = true) + public List getPictures() { + return this.pictures; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/ComplexPartsRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/ComplexPartsRequest.java new file mode 100644 index 0000000000..28e36b334d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/ComplexPartsRequest.java @@ -0,0 +1,94 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import java.util.List; + +/** + * The ComplexPartsRequest model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class ComplexPartsRequest { + /* + * The id property. + */ + @Metadata(generated = true) + private final String id; + + /* + * The address property. + */ + @Metadata(generated = true) + private final Address address; + + /* + * The profileImage property. + */ + @Metadata(generated = true) + private final ProfileImageFileDetails profileImage; + + /* + * The pictures property. + */ + @Metadata(generated = true) + private final List pictures; + + /** + * Creates an instance of ComplexPartsRequest class. + * + * @param id the id value to set. + * @param address the address value to set. + * @param profileImage the profileImage value to set. + * @param pictures the pictures value to set. + */ + @Metadata(generated = true) + public ComplexPartsRequest(String id, Address address, ProfileImageFileDetails profileImage, + List pictures) { + this.id = id; + this.address = address; + this.profileImage = profileImage; + this.pictures = pictures; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Metadata(generated = true) + public String getId() { + return this.id; + } + + /** + * Get the address property: The address property. + * + * @return the address value. + */ + @Metadata(generated = true) + public Address getAddress() { + return this.address; + } + + /** + * Get the profileImage property: The profileImage property. + * + * @return the profileImage value. + */ + @Metadata(generated = true) + public ProfileImageFileDetails getProfileImage() { + return this.profileImage; + } + + /** + * Get the pictures property: The pictures property. + * + * @return the pictures value. + */ + @Metadata(generated = true) + public List getPictures() { + return this.pictures; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileOptionalContentType.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileOptionalContentType.java new file mode 100644 index 0000000000..84e48cf24f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileOptionalContentType.java @@ -0,0 +1,85 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * The file details for the "profileImage" field. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class FileOptionalContentType { + /* + * The content of the file. + */ + @Metadata(generated = true) + private final BinaryData content; + + /* + * The filename of the file. + */ + @Metadata(generated = true) + private final String filename; + + /* + * The content-type of the file. + */ + @Metadata(generated = true) + private String contentType = "application/octet-stream"; + + /** + * Creates an instance of FileOptionalContentType class. + * + * @param content the content value to set. + * @param filename the filename value to set. + */ + @Metadata(generated = true) + public FileOptionalContentType(BinaryData content, String filename) { + this.content = content; + this.filename = filename; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Metadata(generated = true) + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Metadata(generated = true) + public String getFilename() { + return this.filename; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Metadata(generated = true) + public String getContentType() { + return this.contentType; + } + + /** + * Set the contentType property: The content-type of the file. + * + * @param contentType the contentType value to set. + * @return the FileOptionalContentType object itself. + */ + @Metadata(generated = true) + public FileOptionalContentType setContentType(String contentType) { + this.contentType = contentType; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileRequiredMetaData.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileRequiredMetaData.java new file mode 100644 index 0000000000..4f08629229 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileRequiredMetaData.java @@ -0,0 +1,75 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * The file details for the "profileImage" field. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class FileRequiredMetaData { + /* + * The content of the file. + */ + @Metadata(generated = true) + private final BinaryData content; + + /* + * The filename of the file. + */ + @Metadata(generated = true) + private final String filename; + + /* + * The content-type of the file. + */ + @Metadata(generated = true) + private final String contentType; + + /** + * Creates an instance of FileRequiredMetaData class. + * + * @param content the content value to set. + * @param filename the filename value to set. + * @param contentType the contentType value to set. + */ + @Metadata(generated = true) + public FileRequiredMetaData(BinaryData content, String filename, String contentType) { + this.content = content; + this.filename = filename; + this.contentType = contentType; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Metadata(generated = true) + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Metadata(generated = true) + public String getFilename() { + return this.filename; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Metadata(generated = true) + public String getContentType() { + return this.contentType; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileSpecificContentType.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileSpecificContentType.java new file mode 100644 index 0000000000..bd0d164a91 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileSpecificContentType.java @@ -0,0 +1,73 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * The file details for the "profileImage" field. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class FileSpecificContentType { + /* + * The content of the file. + */ + @Metadata(generated = true) + private final BinaryData content; + + /* + * The filename of the file. + */ + @Metadata(generated = true) + private final String filename; + + /* + * The content-type of the file. + */ + @Metadata(generated = true) + private final String contentType = "image/jpg"; + + /** + * Creates an instance of FileSpecificContentType class. + * + * @param content the content value to set. + * @param filename the filename value to set. + */ + @Metadata(generated = true) + public FileSpecificContentType(BinaryData content, String filename) { + this.content = content; + this.filename = filename; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Metadata(generated = true) + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Metadata(generated = true) + public String getFilename() { + return this.filename; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Metadata(generated = true) + public String getContentType() { + return this.contentType; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileWithHttpPartOptionalContentTypeRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileWithHttpPartOptionalContentTypeRequest.java new file mode 100644 index 0000000000..6df1c18e37 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileWithHttpPartOptionalContentTypeRequest.java @@ -0,0 +1,38 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; + +/** + * The FileWithHttpPartOptionalContentTypeRequest model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class FileWithHttpPartOptionalContentTypeRequest { + /* + * The profileImage property. + */ + @Metadata(generated = true) + private final FileOptionalContentType profileImage; + + /** + * Creates an instance of FileWithHttpPartOptionalContentTypeRequest class. + * + * @param profileImage the profileImage value to set. + */ + @Metadata(generated = true) + public FileWithHttpPartOptionalContentTypeRequest(FileOptionalContentType profileImage) { + this.profileImage = profileImage; + } + + /** + * Get the profileImage property: The profileImage property. + * + * @return the profileImage value. + */ + @Metadata(generated = true) + public FileOptionalContentType getProfileImage() { + return this.profileImage; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileWithHttpPartRequiredContentTypeRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileWithHttpPartRequiredContentTypeRequest.java new file mode 100644 index 0000000000..5964363783 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileWithHttpPartRequiredContentTypeRequest.java @@ -0,0 +1,38 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; + +/** + * The FileWithHttpPartRequiredContentTypeRequest model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class FileWithHttpPartRequiredContentTypeRequest { + /* + * The profileImage property. + */ + @Metadata(generated = true) + private final FileRequiredMetaData profileImage; + + /** + * Creates an instance of FileWithHttpPartRequiredContentTypeRequest class. + * + * @param profileImage the profileImage value to set. + */ + @Metadata(generated = true) + public FileWithHttpPartRequiredContentTypeRequest(FileRequiredMetaData profileImage) { + this.profileImage = profileImage; + } + + /** + * Get the profileImage property: The profileImage property. + * + * @return the profileImage value. + */ + @Metadata(generated = true) + public FileRequiredMetaData getProfileImage() { + return this.profileImage; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileWithHttpPartSpecificContentTypeRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileWithHttpPartSpecificContentTypeRequest.java new file mode 100644 index 0000000000..c4ea6ce92b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FileWithHttpPartSpecificContentTypeRequest.java @@ -0,0 +1,38 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; + +/** + * The FileWithHttpPartSpecificContentTypeRequest model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class FileWithHttpPartSpecificContentTypeRequest { + /* + * The profileImage property. + */ + @Metadata(generated = true) + private final FileSpecificContentType profileImage; + + /** + * Creates an instance of FileWithHttpPartSpecificContentTypeRequest class. + * + * @param profileImage the profileImage value to set. + */ + @Metadata(generated = true) + public FileWithHttpPartSpecificContentTypeRequest(FileSpecificContentType profileImage) { + this.profileImage = profileImage; + } + + /** + * Get the profileImage property: The profileImage property. + * + * @return the profileImage value. + */ + @Metadata(generated = true) + public FileSpecificContentType getProfileImage() { + return this.profileImage; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FormDataClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FormDataClient.java new file mode 100644 index 0000000000..ca0d882cbd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FormDataClient.java @@ -0,0 +1,288 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.stream.Collectors; +import payload.multipart.implementation.AnonymousModelRequest; +import payload.multipart.implementation.FormDatasImpl; +import payload.multipart.implementation.MultipartFormDataHelper; + +/** + * Initializes a new instance of the synchronous MultiPartClient type. + */ +@ServiceClient(builder = MultiPartClientBuilder.class) +public final class FormDataClient { + @Metadata(generated = true) + private final FormDatasImpl serviceClient; + + /** + * Initializes an instance of FormDataClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + FormDataClient(FormDatasImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + Response basicWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'basic' is + // 'multipart/form-data' + return this.serviceClient.basicWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for mixed scenarios. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + Response fileArrayAndBasicWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation + // 'fileArrayAndBasic' is 'multipart/form-data' + return this.serviceClient.fileArrayAndBasicWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for scenario contains json part and binary part. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + Response jsonPartWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'jsonPart' is + // 'multipart/form-data' + return this.serviceClient.jsonPartWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + Response binaryArrayPartsWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation + // 'binaryArrayParts' is 'multipart/form-data' + return this.serviceClient.binaryArrayPartsWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + Response multiBinaryPartsWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation + // 'multiBinaryParts' is 'multipart/form-data' + return this.serviceClient.multiBinaryPartsWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + Response checkFileNameAndContentTypeWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation + // 'checkFileNameAndContentType' is 'multipart/form-data' + return this.serviceClient.checkFileNameAndContentTypeWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data. + * + * @param anonymousModelRequest The anonymousModelRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + Response anonymousModelWithResponse(BinaryData anonymousModelRequest, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'anonymousModel' + // is 'multipart/form-data' + return this.serviceClient.anonymousModelWithResponse(anonymousModelRequest, requestOptions); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void basic(MultiPartRequest body) { + // Generated convenience method for basicWithResponse + RequestOptions requestOptions = new RequestOptions(); + basicWithResponse(new MultipartFormDataHelper(requestOptions).serializeTextField("id", body.getId()) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .end() + .getRequestBody(), requestOptions).getValue(); + } + + /** + * Test content-type: multipart/form-data for mixed scenarios. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void fileArrayAndBasic(ComplexPartsRequest body) { + // Generated convenience method for fileArrayAndBasicWithResponse + RequestOptions requestOptions = new RequestOptions(); + fileArrayAndBasicWithResponse(new MultipartFormDataHelper(requestOptions).serializeTextField("id", body.getId()) + .serializeJsonField("address", body.getAddress()) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .serializeFileFields("pictures", + body.getPictures().stream().map(PicturesFileDetails::getContent).collect(Collectors.toList()), + body.getPictures().stream().map(PicturesFileDetails::getContentType).collect(Collectors.toList()), + body.getPictures().stream().map(PicturesFileDetails::getFilename).collect(Collectors.toList())) + .end() + .getRequestBody(), requestOptions).getValue(); + } + + /** + * Test content-type: multipart/form-data for scenario contains json part and binary part. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void jsonPart(JsonPartRequest body) { + // Generated convenience method for jsonPartWithResponse + RequestOptions requestOptions = new RequestOptions(); + jsonPartWithResponse( + new MultipartFormDataHelper(requestOptions).serializeJsonField("address", body.getAddress()) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .end() + .getRequestBody(), + requestOptions).getValue(); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void binaryArrayParts(BinaryArrayPartsRequest body) { + // Generated convenience method for binaryArrayPartsWithResponse + RequestOptions requestOptions = new RequestOptions(); + binaryArrayPartsWithResponse(new MultipartFormDataHelper(requestOptions).serializeTextField("id", body.getId()) + .serializeFileFields("pictures", + body.getPictures().stream().map(PicturesFileDetails::getContent).collect(Collectors.toList()), + body.getPictures().stream().map(PicturesFileDetails::getContentType).collect(Collectors.toList()), + body.getPictures().stream().map(PicturesFileDetails::getFilename).collect(Collectors.toList())) + .end() + .getRequestBody(), requestOptions).getValue(); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void multiBinaryParts(MultiBinaryPartsRequest body) { + // Generated convenience method for multiBinaryPartsWithResponse + RequestOptions requestOptions = new RequestOptions(); + multiBinaryPartsWithResponse(new MultipartFormDataHelper(requestOptions) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .serializeFileField("picture", body.getPicture() == null ? null : body.getPicture().getContent(), + body.getPicture() == null ? null : body.getPicture().getContentType(), + body.getPicture() == null ? null : body.getPicture().getFilename()) + .end() + .getRequestBody(), requestOptions).getValue(); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void checkFileNameAndContentType(MultiPartRequest body) { + // Generated convenience method for checkFileNameAndContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + checkFileNameAndContentTypeWithResponse( + new MultipartFormDataHelper(requestOptions).serializeTextField("id", body.getId()) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .end() + .getRequestBody(), + requestOptions).getValue(); + } + + /** + * Test content-type: multipart/form-data. + * + * @param profileImage The profileImage parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void anonymousModel(ProfileImageFileDetails profileImage) { + // Generated convenience method for anonymousModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + AnonymousModelRequest anonymousModelRequestObj = new AnonymousModelRequest(profileImage); + BinaryData anonymousModelRequest = new MultipartFormDataHelper(requestOptions) + .serializeFileField("profileImage", anonymousModelRequestObj.getProfileImage().getContent(), + anonymousModelRequestObj.getProfileImage().getContentType(), + anonymousModelRequestObj.getProfileImage().getFilename()) + .end() + .getRequestBody(); + anonymousModelWithResponse(anonymousModelRequest, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FormDataHttpPartsClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FormDataHttpPartsClient.java new file mode 100644 index 0000000000..fa3b2c53cd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FormDataHttpPartsClient.java @@ -0,0 +1,74 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.stream.Collectors; +import payload.multipart.implementation.FormDataHttpPartsImpl; +import payload.multipart.implementation.MultipartFormDataHelper; + +/** + * Initializes a new instance of the synchronous MultiPartClient type. + */ +@ServiceClient(builder = MultiPartClientBuilder.class) +public final class FormDataHttpPartsClient { + @Metadata(generated = true) + private final FormDataHttpPartsImpl serviceClient; + + /** + * Initializes an instance of FormDataHttpPartsClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + FormDataHttpPartsClient(FormDataHttpPartsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Test content-type: multipart/form-data for mixed scenarios. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + Response jsonArrayAndFileArrayWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation + // 'jsonArrayAndFileArray' is 'multipart/form-data' + return this.serviceClient.jsonArrayAndFileArrayWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for mixed scenarios. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void jsonArrayAndFileArray(ComplexHttpPartsModelRequest body) { + // Generated convenience method for jsonArrayAndFileArrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + jsonArrayAndFileArrayWithResponse( + new MultipartFormDataHelper(requestOptions).serializeTextField("id", body.getId()) + .serializeJsonField("address", body.getAddress()) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .serializeJsonField("previousAddresses", body.getPreviousAddresses()) + .serializeFileFields("pictures", + body.getPictures().stream().map(FileRequiredMetaData::getContent).collect(Collectors.toList()), + body.getPictures().stream().map(FileRequiredMetaData::getContentType).collect(Collectors.toList()), + body.getPictures().stream().map(FileRequiredMetaData::getFilename).collect(Collectors.toList())) + .end() + .getRequestBody(), + requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FormDataHttpPartsContentTypeClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FormDataHttpPartsContentTypeClient.java new file mode 100644 index 0000000000..d95396ad70 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FormDataHttpPartsContentTypeClient.java @@ -0,0 +1,139 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import payload.multipart.implementation.FormDataHttpPartsContentTypesImpl; +import payload.multipart.implementation.MultipartFormDataHelper; + +/** + * Initializes a new instance of the synchronous MultiPartClient type. + */ +@ServiceClient(builder = MultiPartClientBuilder.class) +public final class FormDataHttpPartsContentTypeClient { + @Metadata(generated = true) + private final FormDataHttpPartsContentTypesImpl serviceClient; + + /** + * Initializes an instance of FormDataHttpPartsContentTypeClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + FormDataHttpPartsContentTypeClient(FormDataHttpPartsContentTypesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + Response imageJpegContentTypeWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation + // 'imageJpegContentType' is 'multipart/form-data' + return this.serviceClient.imageJpegContentTypeWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + Response requiredContentTypeWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation + // 'requiredContentType' is 'multipart/form-data' + return this.serviceClient.requiredContentTypeWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for optional content type. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + Response optionalContentTypeWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation + // 'optionalContentType' is 'multipart/form-data' + return this.serviceClient.optionalContentTypeWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void imageJpegContentType(FileWithHttpPartSpecificContentTypeRequest body) { + // Generated convenience method for imageJpegContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + imageJpegContentTypeWithResponse( + new MultipartFormDataHelper(requestOptions) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .end() + .getRequestBody(), + requestOptions).getValue(); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void requiredContentType(FileWithHttpPartRequiredContentTypeRequest body) { + // Generated convenience method for requiredContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + requiredContentTypeWithResponse( + new MultipartFormDataHelper(requestOptions) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .end() + .getRequestBody(), + requestOptions).getValue(); + } + + /** + * Test content-type: multipart/form-data for optional content type. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void optionalContentType(FileWithHttpPartOptionalContentTypeRequest body) { + // Generated convenience method for optionalContentTypeWithResponse + RequestOptions requestOptions = new RequestOptions(); + optionalContentTypeWithResponse( + new MultipartFormDataHelper(requestOptions) + .serializeFileField("profileImage", body.getProfileImage().getContent(), + body.getProfileImage().getContentType(), body.getProfileImage().getFilename()) + .end() + .getRequestBody(), + requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FormDataHttpPartsNonStringClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FormDataHttpPartsNonStringClient.java new file mode 100644 index 0000000000..ba5c106c2a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/FormDataHttpPartsNonStringClient.java @@ -0,0 +1,65 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import payload.multipart.formdata.httpparts.nonstring.FloatRequest; +import payload.multipart.implementation.FormDataHttpPartsNonStringsImpl; +import payload.multipart.implementation.MultipartFormDataHelper; + +/** + * Initializes a new instance of the synchronous MultiPartClient type. + */ +@ServiceClient(builder = MultiPartClientBuilder.class) +public final class FormDataHttpPartsNonStringClient { + @Metadata(generated = true) + private final FormDataHttpPartsNonStringsImpl serviceClient; + + /** + * Initializes an instance of FormDataHttpPartsNonStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + FormDataHttpPartsNonStringClient(FormDataHttpPartsNonStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Test content-type: multipart/form-data for non string. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + Response floatMethodWithResponse(BinaryData body, RequestOptions requestOptions) { + // Protocol API requires serialization of parts with content-disposition and data, as operation 'float' is + // 'multipart/form-data' + return this.serviceClient.floatMethodWithResponse(body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for non string. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void floatMethod(FloatRequest body) { + // Generated convenience method for floatMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + floatMethodWithResponse(new MultipartFormDataHelper(requestOptions) + .serializeTextField("temperature", String.valueOf(body.getTemperature())) + .end() + .getRequestBody(), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/JsonPartRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/JsonPartRequest.java new file mode 100644 index 0000000000..56ef055c9c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/JsonPartRequest.java @@ -0,0 +1,56 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; + +/** + * The JsonPartRequest model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class JsonPartRequest { + /* + * The address property. + */ + @Metadata(generated = true) + private final Address address; + + /* + * The profileImage property. + */ + @Metadata(generated = true) + private final ProfileImageFileDetails profileImage; + + /** + * Creates an instance of JsonPartRequest class. + * + * @param address the address value to set. + * @param profileImage the profileImage value to set. + */ + @Metadata(generated = true) + public JsonPartRequest(Address address, ProfileImageFileDetails profileImage) { + this.address = address; + this.profileImage = profileImage; + } + + /** + * Get the address property: The address property. + * + * @return the address value. + */ + @Metadata(generated = true) + public Address getAddress() { + return this.address; + } + + /** + * Get the profileImage property: The profileImage property. + * + * @return the profileImage value. + */ + @Metadata(generated = true) + public ProfileImageFileDetails getProfileImage() { + return this.profileImage; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/MultiBinaryPartsRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/MultiBinaryPartsRequest.java new file mode 100644 index 0000000000..1c700f6a78 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/MultiBinaryPartsRequest.java @@ -0,0 +1,66 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; + +/** + * The MultiBinaryPartsRequest model. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class MultiBinaryPartsRequest { + /* + * The profileImage property. + */ + @Metadata(generated = true) + private final ProfileImageFileDetails profileImage; + + /* + * The picture property. + */ + @Metadata(generated = true) + private PictureFileDetails picture; + + /** + * Creates an instance of MultiBinaryPartsRequest class. + * + * @param profileImage the profileImage value to set. + */ + @Metadata(generated = true) + public MultiBinaryPartsRequest(ProfileImageFileDetails profileImage) { + this.profileImage = profileImage; + } + + /** + * Get the profileImage property: The profileImage property. + * + * @return the profileImage value. + */ + @Metadata(generated = true) + public ProfileImageFileDetails getProfileImage() { + return this.profileImage; + } + + /** + * Get the picture property: The picture property. + * + * @return the picture value. + */ + @Metadata(generated = true) + public PictureFileDetails getPicture() { + return this.picture; + } + + /** + * Set the picture property: The picture property. + * + * @param picture the picture value to set. + * @return the MultiBinaryPartsRequest object itself. + */ + @Metadata(generated = true) + public MultiBinaryPartsRequest setPicture(PictureFileDetails picture) { + this.picture = picture; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/MultiPartClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/MultiPartClientBuilder.java new file mode 100644 index 0000000000..05d567a128 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/MultiPartClientBuilder.java @@ -0,0 +1,276 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import payload.multipart.implementation.MultiPartClientImpl; + +/** + * A builder for creating a new instance of the MultiPartClient type. + */ +@ServiceClientBuilder( + serviceClients = { + FormDataClient.class, + FormDataHttpPartsClient.class, + FormDataHttpPartsContentTypeClient.class, + FormDataHttpPartsNonStringClient.class }) +public final class MultiPartClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the MultiPartClientBuilder. + */ + @Metadata(generated = true) + public MultiPartClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultiPartClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultiPartClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultiPartClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultiPartClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultiPartClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultiPartClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultiPartClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultiPartClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultiPartClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of MultiPartClientImpl with the provided parameters. + * + * @return an instance of MultiPartClientImpl. + */ + @Metadata(generated = true) + private MultiPartClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + MultiPartClientImpl client = new MultiPartClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of FormDataClient class. + * + * @return an instance of FormDataClient. + */ + @Metadata(generated = true) + public FormDataClient buildFormDataClient() { + return new FormDataClient(buildInnerClient().getFormDatas()); + } + + /** + * Builds an instance of FormDataHttpPartsClient class. + * + * @return an instance of FormDataHttpPartsClient. + */ + @Metadata(generated = true) + public FormDataHttpPartsClient buildFormDataHttpPartsClient() { + return new FormDataHttpPartsClient(buildInnerClient().getFormDataHttpParts()); + } + + /** + * Builds an instance of FormDataHttpPartsContentTypeClient class. + * + * @return an instance of FormDataHttpPartsContentTypeClient. + */ + @Metadata(generated = true) + public FormDataHttpPartsContentTypeClient buildFormDataHttpPartsContentTypeClient() { + return new FormDataHttpPartsContentTypeClient(buildInnerClient().getFormDataHttpPartsContentTypes()); + } + + /** + * Builds an instance of FormDataHttpPartsNonStringClient class. + * + * @return an instance of FormDataHttpPartsNonStringClient. + */ + @Metadata(generated = true) + public FormDataHttpPartsNonStringClient buildFormDataHttpPartsNonStringClient() { + return new FormDataHttpPartsNonStringClient(buildInnerClient().getFormDataHttpPartsNonStrings()); + } + + private static final ClientLogger LOGGER = new ClientLogger(MultiPartClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/MultiPartRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/MultiPartRequest.java new file mode 100644 index 0000000000..dd739ef349 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/MultiPartRequest.java @@ -0,0 +1,56 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; + +/** + * The MultiPartRequest model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class MultiPartRequest { + /* + * The id property. + */ + @Metadata(generated = true) + private final String id; + + /* + * The profileImage property. + */ + @Metadata(generated = true) + private final ProfileImageFileDetails profileImage; + + /** + * Creates an instance of MultiPartRequest class. + * + * @param id the id value to set. + * @param profileImage the profileImage value to set. + */ + @Metadata(generated = true) + public MultiPartRequest(String id, ProfileImageFileDetails profileImage) { + this.id = id; + this.profileImage = profileImage; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Metadata(generated = true) + public String getId() { + return this.id; + } + + /** + * Get the profileImage property: The profileImage property. + * + * @return the profileImage value. + */ + @Metadata(generated = true) + public ProfileImageFileDetails getProfileImage() { + return this.profileImage; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/PictureFileDetails.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/PictureFileDetails.java new file mode 100644 index 0000000000..49397b6619 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/PictureFileDetails.java @@ -0,0 +1,95 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * The file details for the "picture" field. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class PictureFileDetails { + /* + * The content of the file. + */ + @Metadata(generated = true) + private final BinaryData content; + + /* + * The filename of the file. + */ + @Metadata(generated = true) + private String filename; + + /* + * The content-type of the file. + */ + @Metadata(generated = true) + private String contentType = "application/octet-stream"; + + /** + * Creates an instance of PictureFileDetails class. + * + * @param content the content value to set. + */ + @Metadata(generated = true) + public PictureFileDetails(BinaryData content) { + this.content = content; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Metadata(generated = true) + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Metadata(generated = true) + public String getFilename() { + return this.filename; + } + + /** + * Set the filename property: The filename of the file. + * + * @param filename the filename value to set. + * @return the PictureFileDetails object itself. + */ + @Metadata(generated = true) + public PictureFileDetails setFilename(String filename) { + this.filename = filename; + return this; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Metadata(generated = true) + public String getContentType() { + return this.contentType; + } + + /** + * Set the contentType property: The content-type of the file. + * + * @param contentType the contentType value to set. + * @return the PictureFileDetails object itself. + */ + @Metadata(generated = true) + public PictureFileDetails setContentType(String contentType) { + this.contentType = contentType; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/PicturesFileDetails.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/PicturesFileDetails.java new file mode 100644 index 0000000000..aae4486493 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/PicturesFileDetails.java @@ -0,0 +1,95 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * The file details for the "pictures" field. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class PicturesFileDetails { + /* + * The content of the file. + */ + @Metadata(generated = true) + private final BinaryData content; + + /* + * The filename of the file. + */ + @Metadata(generated = true) + private String filename; + + /* + * The content-type of the file. + */ + @Metadata(generated = true) + private String contentType = "application/octet-stream"; + + /** + * Creates an instance of PicturesFileDetails class. + * + * @param content the content value to set. + */ + @Metadata(generated = true) + public PicturesFileDetails(BinaryData content) { + this.content = content; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Metadata(generated = true) + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Metadata(generated = true) + public String getFilename() { + return this.filename; + } + + /** + * Set the filename property: The filename of the file. + * + * @param filename the filename value to set. + * @return the PicturesFileDetails object itself. + */ + @Metadata(generated = true) + public PicturesFileDetails setFilename(String filename) { + this.filename = filename; + return this; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Metadata(generated = true) + public String getContentType() { + return this.contentType; + } + + /** + * Set the contentType property: The content-type of the file. + * + * @param contentType the contentType value to set. + * @return the PicturesFileDetails object itself. + */ + @Metadata(generated = true) + public PicturesFileDetails setContentType(String contentType) { + this.contentType = contentType; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/ProfileImageFileDetails.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/ProfileImageFileDetails.java new file mode 100644 index 0000000000..82d514ab55 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/ProfileImageFileDetails.java @@ -0,0 +1,95 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * The file details for the "profileImage" field. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class ProfileImageFileDetails { + /* + * The content of the file. + */ + @Metadata(generated = true) + private final BinaryData content; + + /* + * The filename of the file. + */ + @Metadata(generated = true) + private String filename; + + /* + * The content-type of the file. + */ + @Metadata(generated = true) + private String contentType = "application/octet-stream"; + + /** + * Creates an instance of ProfileImageFileDetails class. + * + * @param content the content value to set. + */ + @Metadata(generated = true) + public ProfileImageFileDetails(BinaryData content) { + this.content = content; + } + + /** + * Get the content property: The content of the file. + * + * @return the content value. + */ + @Metadata(generated = true) + public BinaryData getContent() { + return this.content; + } + + /** + * Get the filename property: The filename of the file. + * + * @return the filename value. + */ + @Metadata(generated = true) + public String getFilename() { + return this.filename; + } + + /** + * Set the filename property: The filename of the file. + * + * @param filename the filename value to set. + * @return the ProfileImageFileDetails object itself. + */ + @Metadata(generated = true) + public ProfileImageFileDetails setFilename(String filename) { + this.filename = filename; + return this; + } + + /** + * Get the contentType property: The content-type of the file. + * + * @return the contentType value. + */ + @Metadata(generated = true) + public String getContentType() { + return this.contentType; + } + + /** + * Set the contentType property: The content-type of the file. + * + * @param contentType the contentType value to set. + * @return the ProfileImageFileDetails object itself. + */ + @Metadata(generated = true) + public ProfileImageFileDetails setContentType(String contentType) { + this.contentType = contentType; + return this; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/formdata/httpparts/nonstring/FloatRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/formdata/httpparts/nonstring/FloatRequest.java new file mode 100644 index 0000000000..b6870aeb12 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/formdata/httpparts/nonstring/FloatRequest.java @@ -0,0 +1,38 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart.formdata.httpparts.nonstring; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; + +/** + * The FloatRequest model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class FloatRequest { + /* + * The temperature property. + */ + @Metadata(generated = true) + private final double temperature; + + /** + * Creates an instance of FloatRequest class. + * + * @param temperature the temperature value to set. + */ + @Metadata(generated = true) + public FloatRequest(double temperature) { + this.temperature = temperature; + } + + /** + * Get the temperature property: The temperature property. + * + * @return the temperature value. + */ + @Metadata(generated = true) + public double getTemperature() { + return this.temperature; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/formdata/httpparts/nonstring/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/formdata/httpparts/nonstring/package-info.java new file mode 100644 index 0000000000..42749696da --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/formdata/httpparts/nonstring/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for MultiPart. + * Test for multipart. + */ +package payload.multipart.formdata.httpparts.nonstring; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/AnonymousModelRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/AnonymousModelRequest.java new file mode 100644 index 0000000000..106bf0c888 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/AnonymousModelRequest.java @@ -0,0 +1,39 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import payload.multipart.ProfileImageFileDetails; + +/** + * The AnonymousModelRequest model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class AnonymousModelRequest { + /* + * The profileImage property. + */ + @Metadata(generated = true) + private final ProfileImageFileDetails profileImage; + + /** + * Creates an instance of AnonymousModelRequest class. + * + * @param profileImage the profileImage value to set. + */ + @Metadata(generated = true) + public AnonymousModelRequest(ProfileImageFileDetails profileImage) { + this.profileImage = profileImage; + } + + /** + * Get the profileImage property: The profileImage property. + * + * @return the profileImage value. + */ + @Metadata(generated = true) + public ProfileImageFileDetails getProfileImage() { + return this.profileImage; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/FormDataHttpPartsContentTypesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/FormDataHttpPartsContentTypesImpl.java new file mode 100644 index 0000000000..cdf8fce321 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/FormDataHttpPartsContentTypesImpl.java @@ -0,0 +1,117 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * An instance of this class provides access to all the operations defined in FormDataHttpPartsContentTypes. + */ +public final class FormDataHttpPartsContentTypesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FormDataHttpPartsContentTypesService service; + + /** + * The service client containing this operation class. + */ + private final MultiPartClientImpl client; + + /** + * Initializes an instance of FormDataHttpPartsContentTypesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FormDataHttpPartsContentTypesImpl(MultiPartClientImpl client) { + this.service = RestProxy.create(FormDataHttpPartsContentTypesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for MultiPartClientFormDataHttpPartsContentTypes to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "MultiPartClientFormD", host = "{endpoint}") + public interface FormDataHttpPartsContentTypesService { + // @Multipart not supported by RestProxy + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/multipart/form-data/check-filename-and-specific-content-type-with-httppart", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response imageJpegContentTypeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions); + + // @Multipart not supported by RestProxy + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/multipart/form-data/check-filename-and-required-content-type-with-httppart", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response requiredContentTypeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions); + + // @Multipart not supported by RestProxy + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/multipart/form-data/file-with-http-part-optional-content-type", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response optionalContentTypeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response imageJpegContentTypeWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.imageJpegContentTypeSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response requiredContentTypeWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.requiredContentTypeSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for optional content type. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response optionalContentTypeWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.optionalContentTypeSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/FormDataHttpPartsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/FormDataHttpPartsImpl.java new file mode 100644 index 0000000000..26148e9f71 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/FormDataHttpPartsImpl.java @@ -0,0 +1,71 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * An instance of this class provides access to all the operations defined in FormDataHttpParts. + */ +public final class FormDataHttpPartsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FormDataHttpPartsService service; + + /** + * The service client containing this operation class. + */ + private final MultiPartClientImpl client; + + /** + * Initializes an instance of FormDataHttpPartsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FormDataHttpPartsImpl(MultiPartClientImpl client) { + this.service = RestProxy.create(FormDataHttpPartsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for MultiPartClientFormDataHttpParts to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "MultiPartClientFormD", host = "{endpoint}") + public interface FormDataHttpPartsService { + // @Multipart not supported by RestProxy + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/multipart/form-data/complex-parts-with-httppart", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response jsonArrayAndFileArraySync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Test content-type: multipart/form-data for mixed scenarios. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response jsonArrayAndFileArrayWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.jsonArrayAndFileArraySync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/FormDataHttpPartsNonStringsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/FormDataHttpPartsNonStringsImpl.java new file mode 100644 index 0000000000..173ae924b8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/FormDataHttpPartsNonStringsImpl.java @@ -0,0 +1,71 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * An instance of this class provides access to all the operations defined in FormDataHttpPartsNonStrings. + */ +public final class FormDataHttpPartsNonStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FormDataHttpPartsNonStringsService service; + + /** + * The service client containing this operation class. + */ + private final MultiPartClientImpl client; + + /** + * Initializes an instance of FormDataHttpPartsNonStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FormDataHttpPartsNonStringsImpl(MultiPartClientImpl client) { + this.service = RestProxy.create(FormDataHttpPartsNonStringsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for MultiPartClientFormDataHttpPartsNonStrings to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "MultiPartClientFormD", host = "{endpoint}") + public interface FormDataHttpPartsNonStringsService { + // @Multipart not supported by RestProxy + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/multipart/form-data/non-string-float", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response floatMethodSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Test content-type: multipart/form-data for non string. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response floatMethodWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.floatMethodSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/FormDatasImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/FormDatasImpl.java new file mode 100644 index 0000000000..48f50d2abd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/FormDatasImpl.java @@ -0,0 +1,210 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * An instance of this class provides access to all the operations defined in FormDatas. + */ +public final class FormDatasImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FormDatasService service; + + /** + * The service client containing this operation class. + */ + private final MultiPartClientImpl client; + + /** + * Initializes an instance of FormDatasImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FormDatasImpl(MultiPartClientImpl client) { + this.service = RestProxy.create(FormDatasService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for MultiPartClientFormDatas to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "MultiPartClientFormD", host = "{endpoint}") + public interface FormDatasService { + // @Multipart not supported by RestProxy + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/multipart/form-data/mixed-parts", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response basicSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions); + + // @Multipart not supported by RestProxy + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/multipart/form-data/complex-parts", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response fileArrayAndBasicSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions); + + // @Multipart not supported by RestProxy + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/multipart/form-data/json-part", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response jsonPartSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions); + + // @Multipart not supported by RestProxy + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/multipart/form-data/binary-array-parts", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response binaryArrayPartsSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions); + + // @Multipart not supported by RestProxy + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/multipart/form-data/multi-binary-parts", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response multiBinaryPartsSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions); + + // @Multipart not supported by RestProxy + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/multipart/form-data/check-filename-and-content-type", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response checkFileNameAndContentTypeSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, @BodyParam("multipart/form-data") BinaryData body, + RequestOptions requestOptions); + + // @Multipart not supported by RestProxy + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/multipart/form-data/anonymous-model", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response anonymousModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("content-type") String contentType, + @BodyParam("multipart/form-data") BinaryData anonymousModelRequest, RequestOptions requestOptions); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response basicWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.basicSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for mixed scenarios. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response fileArrayAndBasicWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.fileArrayAndBasicSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for scenario contains json part and binary part. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response jsonPartWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.jsonPartSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response binaryArrayPartsWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.binaryArrayPartsSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Test content-type: multipart/form-data for scenario contains multi binary parts. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response multiBinaryPartsWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.multiBinaryPartsSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Test content-type: multipart/form-data. + * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response checkFileNameAndContentTypeWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.checkFileNameAndContentTypeSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Test content-type: multipart/form-data. + * + * @param anonymousModelRequest The anonymousModelRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response anonymousModelWithResponse(BinaryData anonymousModelRequest, RequestOptions requestOptions) { + final String contentType = "multipart/form-data"; + return service.anonymousModelSync(this.client.getEndpoint(), contentType, anonymousModelRequest, + requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/MultiPartClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/MultiPartClientImpl.java new file mode 100644 index 0000000000..f49c804b48 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/MultiPartClientImpl.java @@ -0,0 +1,109 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the MultiPartClient type. + */ +public final class MultiPartClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 FormDatasImpl object to access its operations. + */ + private final FormDatasImpl formDatas; + + /** + * Gets the FormDatasImpl object to access its operations. + * + * @return the FormDatasImpl object. + */ + public FormDatasImpl getFormDatas() { + return this.formDatas; + } + + /** + * The FormDataHttpPartsImpl object to access its operations. + */ + private final FormDataHttpPartsImpl formDataHttpParts; + + /** + * Gets the FormDataHttpPartsImpl object to access its operations. + * + * @return the FormDataHttpPartsImpl object. + */ + public FormDataHttpPartsImpl getFormDataHttpParts() { + return this.formDataHttpParts; + } + + /** + * The FormDataHttpPartsContentTypesImpl object to access its operations. + */ + private final FormDataHttpPartsContentTypesImpl formDataHttpPartsContentTypes; + + /** + * Gets the FormDataHttpPartsContentTypesImpl object to access its operations. + * + * @return the FormDataHttpPartsContentTypesImpl object. + */ + public FormDataHttpPartsContentTypesImpl getFormDataHttpPartsContentTypes() { + return this.formDataHttpPartsContentTypes; + } + + /** + * The FormDataHttpPartsNonStringsImpl object to access its operations. + */ + private final FormDataHttpPartsNonStringsImpl formDataHttpPartsNonStrings; + + /** + * Gets the FormDataHttpPartsNonStringsImpl object to access its operations. + * + * @return the FormDataHttpPartsNonStringsImpl object. + */ + public FormDataHttpPartsNonStringsImpl getFormDataHttpPartsNonStrings() { + return this.formDataHttpPartsNonStrings; + } + + /** + * Initializes an instance of MultiPartClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public MultiPartClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.formDatas = new FormDatasImpl(this); + this.formDataHttpParts = new FormDataHttpPartsImpl(this); + this.formDataHttpPartsContentTypes = new FormDataHttpPartsContentTypesImpl(this); + this.formDataHttpPartsNonStrings = new FormDataHttpPartsNonStringsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/MultipartFormDataHelper.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/MultipartFormDataHelper.java new file mode 100644 index 0000000000..b5333d2063 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/MultipartFormDataHelper.java @@ -0,0 +1,206 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.multipart.implementation; + +import io.clientcore.core.http.models.HttpHeaderName; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.SequenceInputStream; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.UUID; + +// DO NOT modify this helper class + +public final class MultipartFormDataHelper { + /** + * Line separator for the multipart HTTP request. + */ + private static final String CRLF = "\r\n"; + + private static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; + + /** + * Value to be used as part of the divider for the multipart requests. + */ + private final String boundary; + + /** + * The actual part separator in the request. This is obtained by prepending "--" to the "boundary". + */ + private final String partSeparator; + + /** + * The marker for the ending of a multipart request. This is obtained by post-pending "--" to the "partSeparator". + */ + private final String endMarker; + + /** + * Charset used for encoding the multipart HTTP request. + */ + private final Charset encoderCharset = StandardCharsets.UTF_8; + + private InputStream requestDataStream = new ByteArrayInputStream(new byte[0]); + private long requestLength = 0; + + private RequestOptions requestOptions; + private BinaryData requestBody; + + /** + * Default constructor used in the code. The boundary is a random value. + * + * @param requestOptions the RequestOptions to update + */ + public MultipartFormDataHelper(RequestOptions requestOptions) { + this(requestOptions, UUID.randomUUID().toString().substring(0, 16)); + } + + private MultipartFormDataHelper(RequestOptions requestOptions, String boundary) { + this.requestOptions = requestOptions; + this.boundary = boundary; + this.partSeparator = "--" + boundary; + this.endMarker = this.partSeparator + "--"; + } + + /** + * Gets the multipart HTTP request body. + * + * @return the BinaryData of the multipart HTTP request body + */ + public BinaryData getRequestBody() { + return requestBody; + } + + // text/plain + /** + * Formats a text/plain field for a multipart HTTP request. + * + * @param fieldName the field name + * @param value the value of the text/plain field + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeTextField(String fieldName, String value) { + if (value != null) { + String serialized = partSeparator + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + + "\"" + CRLF + CRLF + value + CRLF; + byte[] data = serialized.getBytes(encoderCharset); + appendBytes(data); + } + return this; + } + + // application/json + /** + * Formats a application/json field for a multipart HTTP request. + * + * @param fieldName the field name + * @param jsonObject the object of the application/json field + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeJsonField(String fieldName, Object jsonObject) { + if (jsonObject != null) { + String serialized + = partSeparator + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + "\"" + CRLF + + "Content-Type: application/json" + CRLF + CRLF + BinaryData.fromObject(jsonObject) + CRLF; + byte[] data = serialized.getBytes(encoderCharset); + appendBytes(data); + } + return this; + } + + /** + * Formats a file field for a multipart HTTP request. + * + * @param fieldName the field name + * @param file the BinaryData of the file + * @param contentType the content-type of the file + * @param filename the filename + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeFileField(String fieldName, BinaryData file, String contentType, + String filename) { + if (file != null) { + if (contentType == null || contentType.isEmpty()) { + contentType = APPLICATION_OCTET_STREAM; + } + writeFileField(fieldName, file, contentType, filename); + } + return this; + } + + /** + * Formats a file field (potentially multiple files) for a multipart HTTP request. + * + * @param fieldName the field name + * @param files the List of BinaryData of the files + * @param contentTypes the List of content-type of the files + * @param filenames the List of filenames + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper serializeFileFields(String fieldName, List files, + List contentTypes, List filenames) { + if (files != null) { + for (int i = 0; i < files.size(); ++i) { + BinaryData file = files.get(i); + String contentType = contentTypes.get(i); + if (contentType == null || contentType.isEmpty()) { + contentType = APPLICATION_OCTET_STREAM; + } + String filename = filenames.get(i); + writeFileField(fieldName, file, contentType, filename); + } + } + return this; + } + + /** + * Ends the serialization of the multipart HTTP request. + * + * @return the MultipartFormDataHelper instance + */ + public MultipartFormDataHelper end() { + byte[] data = endMarker.getBytes(encoderCharset); + appendBytes(data); + + requestBody = BinaryData.fromStream(requestDataStream, requestLength); + + requestOptions.setHeader(HttpHeaderName.CONTENT_TYPE, "multipart/form-data; boundary=" + this.boundary) + .setHeader(HttpHeaderName.CONTENT_LENGTH, String.valueOf(requestLength)); + + return this; + } + + private void writeFileField(String fieldName, BinaryData file, String contentType, String filename) { + String contentDispositionFilename = ""; + if (filename != null && !filename.isEmpty()) { + contentDispositionFilename = "; filename=\"" + escapeName(filename) + "\""; + } + + // Multipart preamble + String fileFieldPreamble + = partSeparator + CRLF + "Content-Disposition: form-data; name=\"" + escapeName(fieldName) + "\"" + + contentDispositionFilename + CRLF + "Content-Type: " + contentType + CRLF + CRLF; + byte[] data = fileFieldPreamble.getBytes(encoderCharset); + appendBytes(data); + + // Writing the file into the request as a byte stream + requestLength += file.getLength(); + requestDataStream = new SequenceInputStream(requestDataStream, file.toStream()); + + // CRLF + data = CRLF.getBytes(encoderCharset); + appendBytes(data); + } + + private void appendBytes(byte[] bytes) { + requestLength += bytes.length; + requestDataStream = new SequenceInputStream(requestDataStream, new ByteArrayInputStream(bytes)); + } + + private static String escapeName(String name) { + return name.replace("\n", "%0A").replace("\r", "%0D").replace("\"", "%22"); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/package-info.java new file mode 100644 index 0000000000..288fdff63b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for MultiPart. + * Test for multipart. + */ +package payload.multipart.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/package-info.java new file mode 100644 index 0000000000..343104c356 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/multipart/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for MultiPart. + * Test for multipart. + */ +package payload.multipart; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/PageableClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/PageableClient.java new file mode 100644 index 0000000000..a2ee430b6e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/PageableClient.java @@ -0,0 +1,76 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.pageable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import payload.pageable.implementation.ServerDrivenPaginationsImpl; +import payload.pageable.serverdrivenpagination.LinkResponse; + +/** + * Initializes a new instance of the synchronous PageableClient type. + */ +@ServiceClient(builder = PageableClientBuilder.class) +public final class PageableClient { + @Metadata(generated = true) + private final ServerDrivenPaginationsImpl serviceClient; + + /** + * Initializes an instance of PageableClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + PageableClient(ServerDrivenPaginationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The link operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     pets (Required): [
+     *          (Required){
+     *             id: String (Required)
+     *             name: String (Required)
+     *         }
+     *     ]
+     *     links (Required): {
+     *         next: String (Optional)
+     *         prev: String (Optional)
+     *         first: String (Optional)
+     *         last: String (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response linkWithResponse(RequestOptions requestOptions) { + return this.serviceClient.linkWithResponse(requestOptions); + } + + /** + * The link operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public LinkResponse link() { + // Generated convenience method for linkWithResponse + RequestOptions requestOptions = new RequestOptions(); + return linkWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/PageableClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/PageableClientBuilder.java new file mode 100644 index 0000000000..e22b123f7e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/PageableClientBuilder.java @@ -0,0 +1,240 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.pageable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import payload.pageable.implementation.PageableClientImpl; + +/** + * A builder for creating a new instance of the PageableClient type. + */ +@ServiceClientBuilder(serviceClients = { PageableClient.class }) +public final class PageableClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the PageableClientBuilder. + */ + @Metadata(generated = true) + public PageableClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public PageableClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public PageableClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public PageableClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public PageableClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public PageableClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public PageableClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public PageableClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public PageableClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public PageableClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of PageableClientImpl with the provided parameters. + * + * @return an instance of PageableClientImpl. + */ + @Metadata(generated = true) + private PageableClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + PageableClientImpl client = new PageableClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of PageableClient class. + * + * @return an instance of PageableClient. + */ + @Metadata(generated = true) + public PageableClient buildPageableClient() { + return new PageableClient(buildInnerClient().getServerDrivenPaginations()); + } + + private static final ClientLogger LOGGER = new ClientLogger(PageableClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/Pet.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/Pet.java new file mode 100644 index 0000000000..44d40f04e4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/Pet.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.pageable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Pet model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Pet implements JsonSerializable { + /* + * The id property. + */ + @Metadata(generated = true) + private final String id; + + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Pet class. + * + * @param id the id value to set. + * @param name the name value to set. + */ + @Metadata(generated = true) + private Pet(String id, String name) { + this.id = id; + this.name = name; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Metadata(generated = true) + public String getId() { + return this.id; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Pet from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Pet 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 Pet. + */ + @Metadata(generated = true) + public static Pet fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Pet(id, name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/implementation/PageableClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/implementation/PageableClientImpl.java new file mode 100644 index 0000000000..69bdcfdb96 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/implementation/PageableClientImpl.java @@ -0,0 +1,64 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.pageable.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the PageableClient type. + */ +public final class PageableClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 ServerDrivenPaginationsImpl object to access its operations. + */ + private final ServerDrivenPaginationsImpl serverDrivenPaginations; + + /** + * Gets the ServerDrivenPaginationsImpl object to access its operations. + * + * @return the ServerDrivenPaginationsImpl object. + */ + public ServerDrivenPaginationsImpl getServerDrivenPaginations() { + return this.serverDrivenPaginations; + } + + /** + * Initializes an instance of PageableClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public PageableClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.serverDrivenPaginations = new ServerDrivenPaginationsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/implementation/ServerDrivenPaginationsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/implementation/ServerDrivenPaginationsImpl.java new file mode 100644 index 0000000000..fdcb1064a0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/implementation/ServerDrivenPaginationsImpl.java @@ -0,0 +1,87 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.pageable.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import payload.pageable.serverdrivenpagination.LinkResponse; + +/** + * An instance of this class provides access to all the operations defined in ServerDrivenPaginations. + */ +public final class ServerDrivenPaginationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ServerDrivenPaginationsService service; + + /** + * The service client containing this operation class. + */ + private final PageableClientImpl client; + + /** + * Initializes an instance of ServerDrivenPaginationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ServerDrivenPaginationsImpl(PageableClientImpl client) { + this.service = RestProxy.create(ServerDrivenPaginationsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for PageableClientServerDrivenPaginations to be used by the proxy service + * to perform REST calls. + */ + @ServiceInterface(name = "PageableClientServer", host = "{endpoint}") + public interface ServerDrivenPaginationsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/payload/pageable/server-driven-pagination/link", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response linkSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + } + + /** + * The link operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     pets (Required): [
+     *          (Required){
+     *             id: String (Required)
+     *             name: String (Required)
+     *         }
+     *     ]
+     *     links (Required): {
+     *         next: String (Optional)
+     *         prev: String (Optional)
+     *         first: String (Optional)
+     *         last: String (Optional)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response linkWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.linkSync(this.client.getEndpoint(), accept, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/implementation/package-info.java new file mode 100644 index 0000000000..8f22934fd2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Pageable. + * Test for pageable payload. + */ +package payload.pageable.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/package-info.java new file mode 100644 index 0000000000..38f4f25699 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Pageable. + * Test for pageable payload. + */ +package payload.pageable; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/serverdrivenpagination/LinkResponse.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/serverdrivenpagination/LinkResponse.java new file mode 100644 index 0000000000..c3be1aba5a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/serverdrivenpagination/LinkResponse.java @@ -0,0 +1,105 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.pageable.serverdrivenpagination; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import payload.pageable.Pet; + +/** + * The LinkResponse model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class LinkResponse implements JsonSerializable { + /* + * The pets property. + */ + @Metadata(generated = true) + private final List pets; + + /* + * The links property. + */ + @Metadata(generated = true) + private final LinkResponseLinks links; + + /** + * Creates an instance of LinkResponse class. + * + * @param pets the pets value to set. + * @param links the links value to set. + */ + @Metadata(generated = true) + private LinkResponse(List pets, LinkResponseLinks links) { + this.pets = pets; + this.links = links; + } + + /** + * Get the pets property: The pets property. + * + * @return the pets value. + */ + @Metadata(generated = true) + public List getPets() { + return this.pets; + } + + /** + * Get the links property: The links property. + * + * @return the links value. + */ + @Metadata(generated = true) + public LinkResponseLinks getLinks() { + return this.links; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("pets", this.pets, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("links", this.links); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LinkResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LinkResponse 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 LinkResponse. + */ + @Metadata(generated = true) + public static LinkResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List pets = null; + LinkResponseLinks links = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("pets".equals(fieldName)) { + pets = reader.readArray(reader1 -> Pet.fromJson(reader1)); + } else if ("links".equals(fieldName)) { + links = LinkResponseLinks.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new LinkResponse(pets, links); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/serverdrivenpagination/LinkResponseLinks.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/serverdrivenpagination/LinkResponseLinks.java new file mode 100644 index 0000000000..98213b47b9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/serverdrivenpagination/LinkResponseLinks.java @@ -0,0 +1,135 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package payload.pageable.serverdrivenpagination; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The LinkResponseLinks model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class LinkResponseLinks implements JsonSerializable { + /* + * The next property. + */ + @Metadata(generated = true) + private String next; + + /* + * The prev property. + */ + @Metadata(generated = true) + private String prev; + + /* + * The first property. + */ + @Metadata(generated = true) + private String first; + + /* + * The last property. + */ + @Metadata(generated = true) + private String last; + + /** + * Creates an instance of LinkResponseLinks class. + */ + @Metadata(generated = true) + private LinkResponseLinks() { + } + + /** + * Get the next property: The next property. + * + * @return the next value. + */ + @Metadata(generated = true) + public String getNext() { + return this.next; + } + + /** + * Get the prev property: The prev property. + * + * @return the prev value. + */ + @Metadata(generated = true) + public String getPrev() { + return this.prev; + } + + /** + * Get the first property: The first property. + * + * @return the first value. + */ + @Metadata(generated = true) + public String getFirst() { + return this.first; + } + + /** + * Get the last property: The last property. + * + * @return the last value. + */ + @Metadata(generated = true) + public String getLast() { + return this.last; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("next", this.next); + jsonWriter.writeStringField("prev", this.prev); + jsonWriter.writeStringField("first", this.first); + jsonWriter.writeStringField("last", this.last); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of LinkResponseLinks from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of LinkResponseLinks if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the LinkResponseLinks. + */ + @Metadata(generated = true) + public static LinkResponseLinks fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + LinkResponseLinks deserializedLinkResponseLinks = new LinkResponseLinks(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("next".equals(fieldName)) { + deserializedLinkResponseLinks.next = reader.getString(); + } else if ("prev".equals(fieldName)) { + deserializedLinkResponseLinks.prev = reader.getString(); + } else if ("first".equals(fieldName)) { + deserializedLinkResponseLinks.first = reader.getString(); + } else if ("last".equals(fieldName)) { + deserializedLinkResponseLinks.last = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedLinkResponseLinks; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/serverdrivenpagination/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/serverdrivenpagination/package-info.java new file mode 100644 index 0000000000..b954bedda3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/payload/pageable/serverdrivenpagination/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for Pageable. + * Test for pageable payload. + */ +package payload.pageable.serverdrivenpagination; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/InInterfaceClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/InInterfaceClient.java new file mode 100644 index 0000000000..1bdeb116c6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/InInterfaceClient.java @@ -0,0 +1,54 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import routes.implementation.InInterfacesImpl; + +/** + * Initializes a new instance of the synchronous RoutesClient type. + */ +@ServiceClient(builder = RoutesClientBuilder.class) +public final class InInterfaceClient { + @Metadata(generated = true) + private final InInterfacesImpl serviceClient; + + /** + * Initializes an instance of InInterfaceClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + InInterfaceClient(InInterfacesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The fixed operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response fixedWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fixedWithResponse(requestOptions); + } + + /** + * The fixed operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void fixed() { + // Generated convenience method for fixedWithResponse + RequestOptions requestOptions = new RequestOptions(); + fixedWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersClient.java new file mode 100644 index 0000000000..7c238ac652 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersClient.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import routes.implementation.PathParametersImpl; + +/** + * Initializes a new instance of the synchronous RoutesClient type. + */ +@ServiceClient(builder = RoutesClientBuilder.class) +public final class PathParametersClient { + @Metadata(generated = true) + private final PathParametersImpl serviceClient; + + /** + * Initializes an instance of PathParametersClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + PathParametersClient(PathParametersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The templateOnly operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response templateOnlyWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.templateOnlyWithResponse(param, requestOptions); + } + + /** + * The explicit operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response explicitWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.explicitWithResponse(param, requestOptions); + } + + /** + * The annotationOnly operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response annotationOnlyWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.annotationOnlyWithResponse(param, requestOptions); + } + + /** + * The templateOnly operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void templateOnly(String param) { + // Generated convenience method for templateOnlyWithResponse + RequestOptions requestOptions = new RequestOptions(); + templateOnlyWithResponse(param, requestOptions).getValue(); + } + + /** + * The explicit operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void explicit(String param) { + // Generated convenience method for explicitWithResponse + RequestOptions requestOptions = new RequestOptions(); + explicitWithResponse(param, requestOptions).getValue(); + } + + /** + * The annotationOnly operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void annotationOnly(String param) { + // Generated convenience method for annotationOnlyWithResponse + RequestOptions requestOptions = new RequestOptions(); + annotationOnlyWithResponse(param, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersLabelExpansionExplodeClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersLabelExpansionExplodeClient.java new file mode 100644 index 0000000000..a7b7e1e56d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersLabelExpansionExplodeClient.java @@ -0,0 +1,115 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import routes.implementation.PathParametersLabelExpansionExplodesImpl; + +/** + * Initializes a new instance of the synchronous RoutesClient type. + */ +@ServiceClient(builder = RoutesClientBuilder.class) +public final class PathParametersLabelExpansionExplodeClient { + @Metadata(generated = true) + private final PathParametersLabelExpansionExplodesImpl serviceClient; + + /** + * Initializes an instance of PathParametersLabelExpansionExplodeClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + PathParametersLabelExpansionExplodeClient(PathParametersLabelExpansionExplodesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.primitiveWithResponse(param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + return this.serviceClient.arrayWithResponse(param, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return this.serviceClient.recordWithResponse(param, requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void primitive(String param) { + // Generated convenience method for primitiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + primitiveWithResponse(param, requestOptions).getValue(); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void array(List param) { + // Generated convenience method for arrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + arrayWithResponse(param, requestOptions).getValue(); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void record(Map param) { + // Generated convenience method for recordWithResponse + RequestOptions requestOptions = new RequestOptions(); + recordWithResponse(param, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersLabelExpansionStandardClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersLabelExpansionStandardClient.java new file mode 100644 index 0000000000..09a5250077 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersLabelExpansionStandardClient.java @@ -0,0 +1,115 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import routes.implementation.PathParametersLabelExpansionStandardsImpl; + +/** + * Initializes a new instance of the synchronous RoutesClient type. + */ +@ServiceClient(builder = RoutesClientBuilder.class) +public final class PathParametersLabelExpansionStandardClient { + @Metadata(generated = true) + private final PathParametersLabelExpansionStandardsImpl serviceClient; + + /** + * Initializes an instance of PathParametersLabelExpansionStandardClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + PathParametersLabelExpansionStandardClient(PathParametersLabelExpansionStandardsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.primitiveWithResponse(param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + return this.serviceClient.arrayWithResponse(param, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return this.serviceClient.recordWithResponse(param, requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void primitive(String param) { + // Generated convenience method for primitiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + primitiveWithResponse(param, requestOptions).getValue(); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void array(List param) { + // Generated convenience method for arrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + arrayWithResponse(param, requestOptions).getValue(); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void record(Map param) { + // Generated convenience method for recordWithResponse + RequestOptions requestOptions = new RequestOptions(); + recordWithResponse(param, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersMatrixExpansionExplodeClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersMatrixExpansionExplodeClient.java new file mode 100644 index 0000000000..15f7b692dc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersMatrixExpansionExplodeClient.java @@ -0,0 +1,115 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import routes.implementation.PathParametersMatrixExpansionExplodesImpl; + +/** + * Initializes a new instance of the synchronous RoutesClient type. + */ +@ServiceClient(builder = RoutesClientBuilder.class) +public final class PathParametersMatrixExpansionExplodeClient { + @Metadata(generated = true) + private final PathParametersMatrixExpansionExplodesImpl serviceClient; + + /** + * Initializes an instance of PathParametersMatrixExpansionExplodeClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + PathParametersMatrixExpansionExplodeClient(PathParametersMatrixExpansionExplodesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.primitiveWithResponse(param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + return this.serviceClient.arrayWithResponse(param, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return this.serviceClient.recordWithResponse(param, requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void primitive(String param) { + // Generated convenience method for primitiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + primitiveWithResponse(param, requestOptions).getValue(); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void array(List param) { + // Generated convenience method for arrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + arrayWithResponse(param, requestOptions).getValue(); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void record(Map param) { + // Generated convenience method for recordWithResponse + RequestOptions requestOptions = new RequestOptions(); + recordWithResponse(param, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersMatrixExpansionStandardClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersMatrixExpansionStandardClient.java new file mode 100644 index 0000000000..a3cbef3ca7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersMatrixExpansionStandardClient.java @@ -0,0 +1,115 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import routes.implementation.PathParametersMatrixExpansionStandardsImpl; + +/** + * Initializes a new instance of the synchronous RoutesClient type. + */ +@ServiceClient(builder = RoutesClientBuilder.class) +public final class PathParametersMatrixExpansionStandardClient { + @Metadata(generated = true) + private final PathParametersMatrixExpansionStandardsImpl serviceClient; + + /** + * Initializes an instance of PathParametersMatrixExpansionStandardClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + PathParametersMatrixExpansionStandardClient(PathParametersMatrixExpansionStandardsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.primitiveWithResponse(param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + return this.serviceClient.arrayWithResponse(param, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return this.serviceClient.recordWithResponse(param, requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void primitive(String param) { + // Generated convenience method for primitiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + primitiveWithResponse(param, requestOptions).getValue(); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void array(List param) { + // Generated convenience method for arrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + arrayWithResponse(param, requestOptions).getValue(); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void record(Map param) { + // Generated convenience method for recordWithResponse + RequestOptions requestOptions = new RequestOptions(); + recordWithResponse(param, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersPathExpansionExplodeClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersPathExpansionExplodeClient.java new file mode 100644 index 0000000000..8520b5b5ea --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersPathExpansionExplodeClient.java @@ -0,0 +1,115 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import routes.implementation.PathParametersPathExpansionExplodesImpl; + +/** + * Initializes a new instance of the synchronous RoutesClient type. + */ +@ServiceClient(builder = RoutesClientBuilder.class) +public final class PathParametersPathExpansionExplodeClient { + @Metadata(generated = true) + private final PathParametersPathExpansionExplodesImpl serviceClient; + + /** + * Initializes an instance of PathParametersPathExpansionExplodeClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + PathParametersPathExpansionExplodeClient(PathParametersPathExpansionExplodesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.primitiveWithResponse(param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + return this.serviceClient.arrayWithResponse(param, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return this.serviceClient.recordWithResponse(param, requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void primitive(String param) { + // Generated convenience method for primitiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + primitiveWithResponse(param, requestOptions).getValue(); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void array(List param) { + // Generated convenience method for arrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + arrayWithResponse(param, requestOptions).getValue(); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void record(Map param) { + // Generated convenience method for recordWithResponse + RequestOptions requestOptions = new RequestOptions(); + recordWithResponse(param, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersPathExpansionStandardClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersPathExpansionStandardClient.java new file mode 100644 index 0000000000..6a0e231c5f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersPathExpansionStandardClient.java @@ -0,0 +1,115 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import routes.implementation.PathParametersPathExpansionStandardsImpl; + +/** + * Initializes a new instance of the synchronous RoutesClient type. + */ +@ServiceClient(builder = RoutesClientBuilder.class) +public final class PathParametersPathExpansionStandardClient { + @Metadata(generated = true) + private final PathParametersPathExpansionStandardsImpl serviceClient; + + /** + * Initializes an instance of PathParametersPathExpansionStandardClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + PathParametersPathExpansionStandardClient(PathParametersPathExpansionStandardsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.primitiveWithResponse(param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + return this.serviceClient.arrayWithResponse(param, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return this.serviceClient.recordWithResponse(param, requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void primitive(String param) { + // Generated convenience method for primitiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + primitiveWithResponse(param, requestOptions).getValue(); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void array(List param) { + // Generated convenience method for arrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + arrayWithResponse(param, requestOptions).getValue(); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void record(Map param) { + // Generated convenience method for recordWithResponse + RequestOptions requestOptions = new RequestOptions(); + recordWithResponse(param, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersReservedExpansionClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersReservedExpansionClient.java new file mode 100644 index 0000000000..1af4d5dc3e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersReservedExpansionClient.java @@ -0,0 +1,85 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import routes.implementation.PathParametersReservedExpansionsImpl; + +/** + * Initializes a new instance of the synchronous RoutesClient type. + */ +@ServiceClient(builder = RoutesClientBuilder.class) +public final class PathParametersReservedExpansionClient { + @Metadata(generated = true) + private final PathParametersReservedExpansionsImpl serviceClient; + + /** + * Initializes an instance of PathParametersReservedExpansionClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + PathParametersReservedExpansionClient(PathParametersReservedExpansionsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The template operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response templateWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.templateWithResponse(param, requestOptions); + } + + /** + * The annotation operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response annotationWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.annotationWithResponse(param, requestOptions); + } + + /** + * The template operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void template(String param) { + // Generated convenience method for templateWithResponse + RequestOptions requestOptions = new RequestOptions(); + templateWithResponse(param, requestOptions).getValue(); + } + + /** + * The annotation operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void annotation(String param) { + // Generated convenience method for annotationWithResponse + RequestOptions requestOptions = new RequestOptions(); + annotationWithResponse(param, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersSimpleExpansionExplodeClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersSimpleExpansionExplodeClient.java new file mode 100644 index 0000000000..1d5716effd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersSimpleExpansionExplodeClient.java @@ -0,0 +1,115 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import routes.implementation.PathParametersSimpleExpansionExplodesImpl; + +/** + * Initializes a new instance of the synchronous RoutesClient type. + */ +@ServiceClient(builder = RoutesClientBuilder.class) +public final class PathParametersSimpleExpansionExplodeClient { + @Metadata(generated = true) + private final PathParametersSimpleExpansionExplodesImpl serviceClient; + + /** + * Initializes an instance of PathParametersSimpleExpansionExplodeClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + PathParametersSimpleExpansionExplodeClient(PathParametersSimpleExpansionExplodesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.primitiveWithResponse(param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + return this.serviceClient.arrayWithResponse(param, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return this.serviceClient.recordWithResponse(param, requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void primitive(String param) { + // Generated convenience method for primitiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + primitiveWithResponse(param, requestOptions).getValue(); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void array(List param) { + // Generated convenience method for arrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + arrayWithResponse(param, requestOptions).getValue(); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void record(Map param) { + // Generated convenience method for recordWithResponse + RequestOptions requestOptions = new RequestOptions(); + recordWithResponse(param, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersSimpleExpansionStandardClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersSimpleExpansionStandardClient.java new file mode 100644 index 0000000000..4a67cff108 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/PathParametersSimpleExpansionStandardClient.java @@ -0,0 +1,115 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import routes.implementation.PathParametersSimpleExpansionStandardsImpl; + +/** + * Initializes a new instance of the synchronous RoutesClient type. + */ +@ServiceClient(builder = RoutesClientBuilder.class) +public final class PathParametersSimpleExpansionStandardClient { + @Metadata(generated = true) + private final PathParametersSimpleExpansionStandardsImpl serviceClient; + + /** + * Initializes an instance of PathParametersSimpleExpansionStandardClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + PathParametersSimpleExpansionStandardClient(PathParametersSimpleExpansionStandardsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.primitiveWithResponse(param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + return this.serviceClient.arrayWithResponse(param, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return this.serviceClient.recordWithResponse(param, requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void primitive(String param) { + // Generated convenience method for primitiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + primitiveWithResponse(param, requestOptions).getValue(); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void array(List param) { + // Generated convenience method for arrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + arrayWithResponse(param, requestOptions).getValue(); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void record(Map param) { + // Generated convenience method for recordWithResponse + RequestOptions requestOptions = new RequestOptions(); + recordWithResponse(param, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersClient.java new file mode 100644 index 0000000000..e1b50dbaef --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersClient.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import routes.implementation.QueryParametersImpl; + +/** + * Initializes a new instance of the synchronous RoutesClient type. + */ +@ServiceClient(builder = RoutesClientBuilder.class) +public final class QueryParametersClient { + @Metadata(generated = true) + private final QueryParametersImpl serviceClient; + + /** + * Initializes an instance of QueryParametersClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + QueryParametersClient(QueryParametersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The templateOnly operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response templateOnlyWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.templateOnlyWithResponse(param, requestOptions); + } + + /** + * The explicit operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response explicitWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.explicitWithResponse(param, requestOptions); + } + + /** + * The annotationOnly operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response annotationOnlyWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.annotationOnlyWithResponse(param, requestOptions); + } + + /** + * The templateOnly operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void templateOnly(String param) { + // Generated convenience method for templateOnlyWithResponse + RequestOptions requestOptions = new RequestOptions(); + templateOnlyWithResponse(param, requestOptions).getValue(); + } + + /** + * The explicit operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void explicit(String param) { + // Generated convenience method for explicitWithResponse + RequestOptions requestOptions = new RequestOptions(); + explicitWithResponse(param, requestOptions).getValue(); + } + + /** + * The annotationOnly operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void annotationOnly(String param) { + // Generated convenience method for annotationOnlyWithResponse + RequestOptions requestOptions = new RequestOptions(); + annotationOnlyWithResponse(param, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersQueryContinuationExplodeClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersQueryContinuationExplodeClient.java new file mode 100644 index 0000000000..3f62fe3e3f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersQueryContinuationExplodeClient.java @@ -0,0 +1,115 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import routes.implementation.QueryParametersQueryContinuationExplodesImpl; + +/** + * Initializes a new instance of the synchronous RoutesClient type. + */ +@ServiceClient(builder = RoutesClientBuilder.class) +public final class QueryParametersQueryContinuationExplodeClient { + @Metadata(generated = true) + private final QueryParametersQueryContinuationExplodesImpl serviceClient; + + /** + * Initializes an instance of QueryParametersQueryContinuationExplodeClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + QueryParametersQueryContinuationExplodeClient(QueryParametersQueryContinuationExplodesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.primitiveWithResponse(param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + return this.serviceClient.arrayWithResponse(param, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return this.serviceClient.recordWithResponse(param, requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void primitive(String param) { + // Generated convenience method for primitiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + primitiveWithResponse(param, requestOptions).getValue(); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void array(List param) { + // Generated convenience method for arrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + arrayWithResponse(param, requestOptions).getValue(); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void record(Map param) { + // Generated convenience method for recordWithResponse + RequestOptions requestOptions = new RequestOptions(); + recordWithResponse(param, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersQueryContinuationStandardClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersQueryContinuationStandardClient.java new file mode 100644 index 0000000000..aa95eb502e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersQueryContinuationStandardClient.java @@ -0,0 +1,115 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import routes.implementation.QueryParametersQueryContinuationStandardsImpl; + +/** + * Initializes a new instance of the synchronous RoutesClient type. + */ +@ServiceClient(builder = RoutesClientBuilder.class) +public final class QueryParametersQueryContinuationStandardClient { + @Metadata(generated = true) + private final QueryParametersQueryContinuationStandardsImpl serviceClient; + + /** + * Initializes an instance of QueryParametersQueryContinuationStandardClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + QueryParametersQueryContinuationStandardClient(QueryParametersQueryContinuationStandardsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.primitiveWithResponse(param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + return this.serviceClient.arrayWithResponse(param, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return this.serviceClient.recordWithResponse(param, requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void primitive(String param) { + // Generated convenience method for primitiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + primitiveWithResponse(param, requestOptions).getValue(); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void array(List param) { + // Generated convenience method for arrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + arrayWithResponse(param, requestOptions).getValue(); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void record(Map param) { + // Generated convenience method for recordWithResponse + RequestOptions requestOptions = new RequestOptions(); + recordWithResponse(param, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersQueryExpansionExplodeClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersQueryExpansionExplodeClient.java new file mode 100644 index 0000000000..ae2f6301e9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersQueryExpansionExplodeClient.java @@ -0,0 +1,115 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import routes.implementation.QueryParametersQueryExpansionExplodesImpl; + +/** + * Initializes a new instance of the synchronous RoutesClient type. + */ +@ServiceClient(builder = RoutesClientBuilder.class) +public final class QueryParametersQueryExpansionExplodeClient { + @Metadata(generated = true) + private final QueryParametersQueryExpansionExplodesImpl serviceClient; + + /** + * Initializes an instance of QueryParametersQueryExpansionExplodeClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + QueryParametersQueryExpansionExplodeClient(QueryParametersQueryExpansionExplodesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.primitiveWithResponse(param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + return this.serviceClient.arrayWithResponse(param, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return this.serviceClient.recordWithResponse(param, requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void primitive(String param) { + // Generated convenience method for primitiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + primitiveWithResponse(param, requestOptions).getValue(); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void array(List param) { + // Generated convenience method for arrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + arrayWithResponse(param, requestOptions).getValue(); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void record(Map param) { + // Generated convenience method for recordWithResponse + RequestOptions requestOptions = new RequestOptions(); + recordWithResponse(param, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersQueryExpansionStandardClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersQueryExpansionStandardClient.java new file mode 100644 index 0000000000..9f64de5dd6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/QueryParametersQueryExpansionStandardClient.java @@ -0,0 +1,115 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import routes.implementation.QueryParametersQueryExpansionStandardsImpl; + +/** + * Initializes a new instance of the synchronous RoutesClient type. + */ +@ServiceClient(builder = RoutesClientBuilder.class) +public final class QueryParametersQueryExpansionStandardClient { + @Metadata(generated = true) + private final QueryParametersQueryExpansionStandardsImpl serviceClient; + + /** + * Initializes an instance of QueryParametersQueryExpansionStandardClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + QueryParametersQueryExpansionStandardClient(QueryParametersQueryExpansionStandardsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return this.serviceClient.primitiveWithResponse(param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + return this.serviceClient.arrayWithResponse(param, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return this.serviceClient.recordWithResponse(param, requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void primitive(String param) { + // Generated convenience method for primitiveWithResponse + RequestOptions requestOptions = new RequestOptions(); + primitiveWithResponse(param, requestOptions).getValue(); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void array(List param) { + // Generated convenience method for arrayWithResponse + RequestOptions requestOptions = new RequestOptions(); + arrayWithResponse(param, requestOptions).getValue(); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void record(Map param) { + // Generated convenience method for recordWithResponse + RequestOptions requestOptions = new RequestOptions(); + recordWithResponse(param, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/RoutesClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/RoutesClient.java new file mode 100644 index 0000000000..282bd7b274 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/RoutesClient.java @@ -0,0 +1,54 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import routes.implementation.RoutesClientImpl; + +/** + * Initializes a new instance of the synchronous RoutesClient type. + */ +@ServiceClient(builder = RoutesClientBuilder.class) +public final class RoutesClient { + @Metadata(generated = true) + private final RoutesClientImpl serviceClient; + + /** + * Initializes an instance of RoutesClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + RoutesClient(RoutesClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The fixed operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response fixedWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fixedWithResponse(requestOptions); + } + + /** + * The fixed operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void fixed() { + // Generated convenience method for fixedWithResponse + RequestOptions requestOptions = new RequestOptions(); + fixedWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/RoutesClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/RoutesClientBuilder.java new file mode 100644 index 0000000000..dcca203748 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/RoutesClientBuilder.java @@ -0,0 +1,430 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import routes.implementation.RoutesClientImpl; + +/** + * A builder for creating a new instance of the RoutesClient type. + */ +@ServiceClientBuilder( + serviceClients = { + RoutesClient.class, + PathParametersClient.class, + PathParametersReservedExpansionClient.class, + PathParametersSimpleExpansionStandardClient.class, + PathParametersSimpleExpansionExplodeClient.class, + PathParametersPathExpansionStandardClient.class, + PathParametersPathExpansionExplodeClient.class, + PathParametersLabelExpansionStandardClient.class, + PathParametersLabelExpansionExplodeClient.class, + PathParametersMatrixExpansionStandardClient.class, + PathParametersMatrixExpansionExplodeClient.class, + QueryParametersClient.class, + QueryParametersQueryExpansionStandardClient.class, + QueryParametersQueryExpansionExplodeClient.class, + QueryParametersQueryContinuationStandardClient.class, + QueryParametersQueryContinuationExplodeClient.class, + InInterfaceClient.class }) +public final class RoutesClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the RoutesClientBuilder. + */ + @Metadata(generated = true) + public RoutesClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RoutesClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RoutesClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RoutesClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RoutesClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RoutesClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RoutesClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RoutesClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RoutesClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RoutesClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of RoutesClientImpl with the provided parameters. + * + * @return an instance of RoutesClientImpl. + */ + @Metadata(generated = true) + private RoutesClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + RoutesClientImpl client = new RoutesClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of RoutesClient class. + * + * @return an instance of RoutesClient. + */ + @Metadata(generated = true) + public RoutesClient buildClient() { + return new RoutesClient(buildInnerClient()); + } + + /** + * Builds an instance of PathParametersClient class. + * + * @return an instance of PathParametersClient. + */ + @Metadata(generated = true) + public PathParametersClient buildPathParametersClient() { + return new PathParametersClient(buildInnerClient().getPathParameters()); + } + + /** + * Builds an instance of PathParametersReservedExpansionClient class. + * + * @return an instance of PathParametersReservedExpansionClient. + */ + @Metadata(generated = true) + public PathParametersReservedExpansionClient buildPathParametersReservedExpansionClient() { + return new PathParametersReservedExpansionClient(buildInnerClient().getPathParametersReservedExpansions()); + } + + /** + * Builds an instance of PathParametersSimpleExpansionStandardClient class. + * + * @return an instance of PathParametersSimpleExpansionStandardClient. + */ + @Metadata(generated = true) + public PathParametersSimpleExpansionStandardClient buildPathParametersSimpleExpansionStandardClient() { + return new PathParametersSimpleExpansionStandardClient( + buildInnerClient().getPathParametersSimpleExpansionStandards()); + } + + /** + * Builds an instance of PathParametersSimpleExpansionExplodeClient class. + * + * @return an instance of PathParametersSimpleExpansionExplodeClient. + */ + @Metadata(generated = true) + public PathParametersSimpleExpansionExplodeClient buildPathParametersSimpleExpansionExplodeClient() { + return new PathParametersSimpleExpansionExplodeClient( + buildInnerClient().getPathParametersSimpleExpansionExplodes()); + } + + /** + * Builds an instance of PathParametersPathExpansionStandardClient class. + * + * @return an instance of PathParametersPathExpansionStandardClient. + */ + @Metadata(generated = true) + public PathParametersPathExpansionStandardClient buildPathParametersPathExpansionStandardClient() { + return new PathParametersPathExpansionStandardClient( + buildInnerClient().getPathParametersPathExpansionStandards()); + } + + /** + * Builds an instance of PathParametersPathExpansionExplodeClient class. + * + * @return an instance of PathParametersPathExpansionExplodeClient. + */ + @Metadata(generated = true) + public PathParametersPathExpansionExplodeClient buildPathParametersPathExpansionExplodeClient() { + return new PathParametersPathExpansionExplodeClient( + buildInnerClient().getPathParametersPathExpansionExplodes()); + } + + /** + * Builds an instance of PathParametersLabelExpansionStandardClient class. + * + * @return an instance of PathParametersLabelExpansionStandardClient. + */ + @Metadata(generated = true) + public PathParametersLabelExpansionStandardClient buildPathParametersLabelExpansionStandardClient() { + return new PathParametersLabelExpansionStandardClient( + buildInnerClient().getPathParametersLabelExpansionStandards()); + } + + /** + * Builds an instance of PathParametersLabelExpansionExplodeClient class. + * + * @return an instance of PathParametersLabelExpansionExplodeClient. + */ + @Metadata(generated = true) + public PathParametersLabelExpansionExplodeClient buildPathParametersLabelExpansionExplodeClient() { + return new PathParametersLabelExpansionExplodeClient( + buildInnerClient().getPathParametersLabelExpansionExplodes()); + } + + /** + * Builds an instance of PathParametersMatrixExpansionStandardClient class. + * + * @return an instance of PathParametersMatrixExpansionStandardClient. + */ + @Metadata(generated = true) + public PathParametersMatrixExpansionStandardClient buildPathParametersMatrixExpansionStandardClient() { + return new PathParametersMatrixExpansionStandardClient( + buildInnerClient().getPathParametersMatrixExpansionStandards()); + } + + /** + * Builds an instance of PathParametersMatrixExpansionExplodeClient class. + * + * @return an instance of PathParametersMatrixExpansionExplodeClient. + */ + @Metadata(generated = true) + public PathParametersMatrixExpansionExplodeClient buildPathParametersMatrixExpansionExplodeClient() { + return new PathParametersMatrixExpansionExplodeClient( + buildInnerClient().getPathParametersMatrixExpansionExplodes()); + } + + /** + * Builds an instance of QueryParametersClient class. + * + * @return an instance of QueryParametersClient. + */ + @Metadata(generated = true) + public QueryParametersClient buildQueryParametersClient() { + return new QueryParametersClient(buildInnerClient().getQueryParameters()); + } + + /** + * Builds an instance of QueryParametersQueryExpansionStandardClient class. + * + * @return an instance of QueryParametersQueryExpansionStandardClient. + */ + @Metadata(generated = true) + public QueryParametersQueryExpansionStandardClient buildQueryParametersQueryExpansionStandardClient() { + return new QueryParametersQueryExpansionStandardClient( + buildInnerClient().getQueryParametersQueryExpansionStandards()); + } + + /** + * Builds an instance of QueryParametersQueryExpansionExplodeClient class. + * + * @return an instance of QueryParametersQueryExpansionExplodeClient. + */ + @Metadata(generated = true) + public QueryParametersQueryExpansionExplodeClient buildQueryParametersQueryExpansionExplodeClient() { + return new QueryParametersQueryExpansionExplodeClient( + buildInnerClient().getQueryParametersQueryExpansionExplodes()); + } + + /** + * Builds an instance of QueryParametersQueryContinuationStandardClient class. + * + * @return an instance of QueryParametersQueryContinuationStandardClient. + */ + @Metadata(generated = true) + public QueryParametersQueryContinuationStandardClient buildQueryParametersQueryContinuationStandardClient() { + return new QueryParametersQueryContinuationStandardClient( + buildInnerClient().getQueryParametersQueryContinuationStandards()); + } + + /** + * Builds an instance of QueryParametersQueryContinuationExplodeClient class. + * + * @return an instance of QueryParametersQueryContinuationExplodeClient. + */ + @Metadata(generated = true) + public QueryParametersQueryContinuationExplodeClient buildQueryParametersQueryContinuationExplodeClient() { + return new QueryParametersQueryContinuationExplodeClient( + buildInnerClient().getQueryParametersQueryContinuationExplodes()); + } + + /** + * Builds an instance of InInterfaceClient class. + * + * @return an instance of InInterfaceClient. + */ + @Metadata(generated = true) + public InInterfaceClient buildInInterfaceClient() { + return new InInterfaceClient(buildInnerClient().getInInterfaces()); + } + + private static final ClientLogger LOGGER = new ClientLogger(RoutesClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/InInterfacesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/InInterfacesImpl.java new file mode 100644 index 0000000000..7f87b48efb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/InInterfacesImpl.java @@ -0,0 +1,63 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; + +/** + * An instance of this class provides access to all the operations defined in InInterfaces. + */ +public final class InInterfacesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final InInterfacesService service; + + /** + * The service client containing this operation class. + */ + private final RoutesClientImpl client; + + /** + * Initializes an instance of InInterfacesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + InInterfacesImpl(RoutesClientImpl client) { + this.service = RestProxy.create(InInterfacesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for RoutesClientInInterfaces to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "RoutesClientInInterf", host = "{endpoint}") + public interface InInterfacesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/in-interface/fixed", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response fixedSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + } + + /** + * The fixed operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response fixedWithResponse(RequestOptions requestOptions) { + return service.fixedSync(this.client.getEndpoint(), requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersImpl.java new file mode 100644 index 0000000000..a44d7db438 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersImpl.java @@ -0,0 +1,106 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.PathParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; + +/** + * An instance of this class provides access to all the operations defined in PathParameters. + */ +public final class PathParametersImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PathParametersService service; + + /** + * The service client containing this operation class. + */ + private final RoutesClientImpl client; + + /** + * Initializes an instance of PathParametersImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PathParametersImpl(RoutesClientImpl client) { + this.service = RestProxy.create(PathParametersService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for RoutesClientPathParameters to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "RoutesClientPathPara", host = "{endpoint}") + public interface PathParametersService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/template-only/{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response templateOnlySync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/explicit/{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response explicitSync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/annotation-only/{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response annotationOnlySync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + } + + /** + * The templateOnly operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response templateOnlyWithResponse(String param, RequestOptions requestOptions) { + return service.templateOnlySync(this.client.getEndpoint(), param, requestOptions); + } + + /** + * The explicit operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response explicitWithResponse(String param, RequestOptions requestOptions) { + return service.explicitSync(this.client.getEndpoint(), param, requestOptions); + } + + /** + * The annotationOnly operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response annotationOnlyWithResponse(String param, RequestOptions requestOptions) { + return service.annotationOnlySync(this.client.getEndpoint(), param, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersLabelExpansionExplodesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersLabelExpansionExplodesImpl.java new file mode 100644 index 0000000000..cec7efd4fc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersLabelExpansionExplodesImpl.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.PathParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * An instance of this class provides access to all the operations defined in PathParametersLabelExpansionExplodes. + */ +public final class PathParametersLabelExpansionExplodesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PathParametersLabelExpansionExplodesService service; + + /** + * The service client containing this operation class. + */ + private final RoutesClientImpl client; + + /** + * Initializes an instance of PathParametersLabelExpansionExplodesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PathParametersLabelExpansionExplodesImpl(RoutesClientImpl client) { + this.service = RestProxy.create(PathParametersLabelExpansionExplodesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for RoutesClientPathParametersLabelExpansionExplodes to be used by the + * proxy service to perform REST calls. + */ + @ServiceInterface(name = "RoutesClientPathPara", host = "{endpoint}") + public interface PathParametersLabelExpansionExplodesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/label/explode/primitive{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response primitiveSync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/label/explode/array{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response arraySync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/label/explode/record{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response recordSync(@HostParam("endpoint") String endpoint, + @PathParam("param") Map param, RequestOptions requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return service.primitiveSync(this.client.getEndpoint(), param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + String paramConverted = param.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.arraySync(this.client.getEndpoint(), paramConverted, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return service.recordSync(this.client.getEndpoint(), param, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersLabelExpansionStandardsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersLabelExpansionStandardsImpl.java new file mode 100644 index 0000000000..502321a2b4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersLabelExpansionStandardsImpl.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.PathParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * An instance of this class provides access to all the operations defined in PathParametersLabelExpansionStandards. + */ +public final class PathParametersLabelExpansionStandardsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PathParametersLabelExpansionStandardsService service; + + /** + * The service client containing this operation class. + */ + private final RoutesClientImpl client; + + /** + * Initializes an instance of PathParametersLabelExpansionStandardsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PathParametersLabelExpansionStandardsImpl(RoutesClientImpl client) { + this.service = RestProxy.create(PathParametersLabelExpansionStandardsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for RoutesClientPathParametersLabelExpansionStandards to be used by the + * proxy service to perform REST calls. + */ + @ServiceInterface(name = "RoutesClientPathPara", host = "{endpoint}") + public interface PathParametersLabelExpansionStandardsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/label/standard/primitive{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response primitiveSync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/label/standard/array{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response arraySync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/label/standard/record{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response recordSync(@HostParam("endpoint") String endpoint, + @PathParam("param") Map param, RequestOptions requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return service.primitiveSync(this.client.getEndpoint(), param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + String paramConverted = param.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.arraySync(this.client.getEndpoint(), paramConverted, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return service.recordSync(this.client.getEndpoint(), param, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersMatrixExpansionExplodesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersMatrixExpansionExplodesImpl.java new file mode 100644 index 0000000000..35a24f2e4f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersMatrixExpansionExplodesImpl.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.PathParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * An instance of this class provides access to all the operations defined in PathParametersMatrixExpansionExplodes. + */ +public final class PathParametersMatrixExpansionExplodesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PathParametersMatrixExpansionExplodesService service; + + /** + * The service client containing this operation class. + */ + private final RoutesClientImpl client; + + /** + * Initializes an instance of PathParametersMatrixExpansionExplodesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PathParametersMatrixExpansionExplodesImpl(RoutesClientImpl client) { + this.service = RestProxy.create(PathParametersMatrixExpansionExplodesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for RoutesClientPathParametersMatrixExpansionExplodes to be used by the + * proxy service to perform REST calls. + */ + @ServiceInterface(name = "RoutesClientPathPara", host = "{endpoint}") + public interface PathParametersMatrixExpansionExplodesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/matrix/explode/primitive{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response primitiveSync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/matrix/explode/array{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response arraySync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/matrix/explode/record{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response recordSync(@HostParam("endpoint") String endpoint, + @PathParam("param") Map param, RequestOptions requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return service.primitiveSync(this.client.getEndpoint(), param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + String paramConverted = param.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.arraySync(this.client.getEndpoint(), paramConverted, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return service.recordSync(this.client.getEndpoint(), param, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersMatrixExpansionStandardsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersMatrixExpansionStandardsImpl.java new file mode 100644 index 0000000000..791b1b0665 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersMatrixExpansionStandardsImpl.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.PathParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * An instance of this class provides access to all the operations defined in PathParametersMatrixExpansionStandards. + */ +public final class PathParametersMatrixExpansionStandardsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PathParametersMatrixExpansionStandardsService service; + + /** + * The service client containing this operation class. + */ + private final RoutesClientImpl client; + + /** + * Initializes an instance of PathParametersMatrixExpansionStandardsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PathParametersMatrixExpansionStandardsImpl(RoutesClientImpl client) { + this.service = RestProxy.create(PathParametersMatrixExpansionStandardsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for RoutesClientPathParametersMatrixExpansionStandards to be used by the + * proxy service to perform REST calls. + */ + @ServiceInterface(name = "RoutesClientPathPara", host = "{endpoint}") + public interface PathParametersMatrixExpansionStandardsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/matrix/standard/primitive{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response primitiveSync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/matrix/standard/array{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response arraySync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/matrix/standard/record{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response recordSync(@HostParam("endpoint") String endpoint, + @PathParam("param") Map param, RequestOptions requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return service.primitiveSync(this.client.getEndpoint(), param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + String paramConverted = param.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.arraySync(this.client.getEndpoint(), paramConverted, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return service.recordSync(this.client.getEndpoint(), param, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersPathExpansionExplodesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersPathExpansionExplodesImpl.java new file mode 100644 index 0000000000..db318b14f8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersPathExpansionExplodesImpl.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.PathParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * An instance of this class provides access to all the operations defined in PathParametersPathExpansionExplodes. + */ +public final class PathParametersPathExpansionExplodesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PathParametersPathExpansionExplodesService service; + + /** + * The service client containing this operation class. + */ + private final RoutesClientImpl client; + + /** + * Initializes an instance of PathParametersPathExpansionExplodesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PathParametersPathExpansionExplodesImpl(RoutesClientImpl client) { + this.service = RestProxy.create(PathParametersPathExpansionExplodesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for RoutesClientPathParametersPathExpansionExplodes to be used by the + * proxy service to perform REST calls. + */ + @ServiceInterface(name = "RoutesClientPathPara", host = "{endpoint}") + public interface PathParametersPathExpansionExplodesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/path/explode/primitive{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response primitiveSync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/path/explode/array{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response arraySync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/path/explode/record{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response recordSync(@HostParam("endpoint") String endpoint, + @PathParam("param") Map param, RequestOptions requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return service.primitiveSync(this.client.getEndpoint(), param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + String paramConverted = param.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.arraySync(this.client.getEndpoint(), paramConverted, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return service.recordSync(this.client.getEndpoint(), param, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersPathExpansionStandardsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersPathExpansionStandardsImpl.java new file mode 100644 index 0000000000..b022392ec7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersPathExpansionStandardsImpl.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.PathParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * An instance of this class provides access to all the operations defined in PathParametersPathExpansionStandards. + */ +public final class PathParametersPathExpansionStandardsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PathParametersPathExpansionStandardsService service; + + /** + * The service client containing this operation class. + */ + private final RoutesClientImpl client; + + /** + * Initializes an instance of PathParametersPathExpansionStandardsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PathParametersPathExpansionStandardsImpl(RoutesClientImpl client) { + this.service = RestProxy.create(PathParametersPathExpansionStandardsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for RoutesClientPathParametersPathExpansionStandards to be used by the + * proxy service to perform REST calls. + */ + @ServiceInterface(name = "RoutesClientPathPara", host = "{endpoint}") + public interface PathParametersPathExpansionStandardsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/path/standard/primitive{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response primitiveSync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/path/standard/array{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response arraySync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/path/standard/record{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response recordSync(@HostParam("endpoint") String endpoint, + @PathParam("param") Map param, RequestOptions requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return service.primitiveSync(this.client.getEndpoint(), param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + String paramConverted = param.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.arraySync(this.client.getEndpoint(), paramConverted, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return service.recordSync(this.client.getEndpoint(), param, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersReservedExpansionsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersReservedExpansionsImpl.java new file mode 100644 index 0000000000..cbcd89332f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersReservedExpansionsImpl.java @@ -0,0 +1,86 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.PathParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; + +/** + * An instance of this class provides access to all the operations defined in PathParametersReservedExpansions. + */ +public final class PathParametersReservedExpansionsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PathParametersReservedExpansionsService service; + + /** + * The service client containing this operation class. + */ + private final RoutesClientImpl client; + + /** + * Initializes an instance of PathParametersReservedExpansionsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PathParametersReservedExpansionsImpl(RoutesClientImpl client) { + this.service = RestProxy.create(PathParametersReservedExpansionsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for RoutesClientPathParametersReservedExpansions to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "RoutesClientPathPara", host = "{endpoint}") + public interface PathParametersReservedExpansionsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/reserved-expansion/template/{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response templateSync(@HostParam("endpoint") String endpoint, + @PathParam(value = "param", encoded = true) String param, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/reserved-expansion/annotation/{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response annotationSync(@HostParam("endpoint") String endpoint, + @PathParam(value = "param", encoded = true) String param, RequestOptions requestOptions); + } + + /** + * The template operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response templateWithResponse(String param, RequestOptions requestOptions) { + return service.templateSync(this.client.getEndpoint(), param, requestOptions); + } + + /** + * The annotation operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response annotationWithResponse(String param, RequestOptions requestOptions) { + return service.annotationSync(this.client.getEndpoint(), param, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersSimpleExpansionExplodesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersSimpleExpansionExplodesImpl.java new file mode 100644 index 0000000000..1372ebec8c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersSimpleExpansionExplodesImpl.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.PathParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * An instance of this class provides access to all the operations defined in PathParametersSimpleExpansionExplodes. + */ +public final class PathParametersSimpleExpansionExplodesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PathParametersSimpleExpansionExplodesService service; + + /** + * The service client containing this operation class. + */ + private final RoutesClientImpl client; + + /** + * Initializes an instance of PathParametersSimpleExpansionExplodesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PathParametersSimpleExpansionExplodesImpl(RoutesClientImpl client) { + this.service = RestProxy.create(PathParametersSimpleExpansionExplodesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for RoutesClientPathParametersSimpleExpansionExplodes to be used by the + * proxy service to perform REST calls. + */ + @ServiceInterface(name = "RoutesClientPathPara", host = "{endpoint}") + public interface PathParametersSimpleExpansionExplodesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/simple/explode/primitive{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response primitiveSync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/simple/explode/array{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response arraySync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/simple/explode/record{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response recordSync(@HostParam("endpoint") String endpoint, + @PathParam("param") Map param, RequestOptions requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return service.primitiveSync(this.client.getEndpoint(), param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + String paramConverted = param.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.arraySync(this.client.getEndpoint(), paramConverted, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return service.recordSync(this.client.getEndpoint(), param, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersSimpleExpansionStandardsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersSimpleExpansionStandardsImpl.java new file mode 100644 index 0000000000..db3ad41a53 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/PathParametersSimpleExpansionStandardsImpl.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.PathParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * An instance of this class provides access to all the operations defined in PathParametersSimpleExpansionStandards. + */ +public final class PathParametersSimpleExpansionStandardsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PathParametersSimpleExpansionStandardsService service; + + /** + * The service client containing this operation class. + */ + private final RoutesClientImpl client; + + /** + * Initializes an instance of PathParametersSimpleExpansionStandardsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PathParametersSimpleExpansionStandardsImpl(RoutesClientImpl client) { + this.service = RestProxy.create(PathParametersSimpleExpansionStandardsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for RoutesClientPathParametersSimpleExpansionStandards to be used by the + * proxy service to perform REST calls. + */ + @ServiceInterface(name = "RoutesClientPathPara", host = "{endpoint}") + public interface PathParametersSimpleExpansionStandardsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/simple/standard/primitive{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response primitiveSync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/simple/standard/array{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response arraySync(@HostParam("endpoint") String endpoint, @PathParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/path/simple/standard/record{param}", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response recordSync(@HostParam("endpoint") String endpoint, + @PathParam("param") Map param, RequestOptions requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return service.primitiveSync(this.client.getEndpoint(), param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + String paramConverted = param.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.arraySync(this.client.getEndpoint(), paramConverted, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return service.recordSync(this.client.getEndpoint(), param, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersImpl.java new file mode 100644 index 0000000000..ed7008f437 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersImpl.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.QueryParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; + +/** + * An instance of this class provides access to all the operations defined in QueryParameters. + */ +public final class QueryParametersImpl { + /** + * The proxy service used to perform REST calls. + */ + private final QueryParametersService service; + + /** + * The service client containing this operation class. + */ + private final RoutesClientImpl client; + + /** + * Initializes an instance of QueryParametersImpl. + * + * @param client the instance of the service client containing this operation class. + */ + QueryParametersImpl(RoutesClientImpl client) { + this.service = RestProxy.create(QueryParametersService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for RoutesClientQueryParameters to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "RoutesClientQueryPar", host = "{endpoint}") + public interface QueryParametersService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/query/template-only", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response templateOnlySync(@HostParam("endpoint") String endpoint, @QueryParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.GET, path = "/routes/query/explicit", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response explicitSync(@HostParam("endpoint") String endpoint, @QueryParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/query/annotation-only", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response annotationOnlySync(@HostParam("endpoint") String endpoint, @QueryParam("param") String param, + RequestOptions requestOptions); + } + + /** + * The templateOnly operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response templateOnlyWithResponse(String param, RequestOptions requestOptions) { + return service.templateOnlySync(this.client.getEndpoint(), param, requestOptions); + } + + /** + * The explicit operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response explicitWithResponse(String param, RequestOptions requestOptions) { + return service.explicitSync(this.client.getEndpoint(), param, requestOptions); + } + + /** + * The annotationOnly operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response annotationOnlyWithResponse(String param, RequestOptions requestOptions) { + return service.annotationOnlySync(this.client.getEndpoint(), param, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersQueryContinuationExplodesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersQueryContinuationExplodesImpl.java new file mode 100644 index 0000000000..1269163b8c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersQueryContinuationExplodesImpl.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.QueryParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * An instance of this class provides access to all the operations defined in QueryParametersQueryContinuationExplodes. + */ +public final class QueryParametersQueryContinuationExplodesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final QueryParametersQueryContinuationExplodesService service; + + /** + * The service client containing this operation class. + */ + private final RoutesClientImpl client; + + /** + * Initializes an instance of QueryParametersQueryContinuationExplodesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + QueryParametersQueryContinuationExplodesImpl(RoutesClientImpl client) { + this.service + = RestProxy.create(QueryParametersQueryContinuationExplodesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for RoutesClientQueryParametersQueryContinuationExplodes to be used by + * the proxy service to perform REST calls. + */ + @ServiceInterface(name = "RoutesClientQueryPar", host = "{endpoint}") + public interface QueryParametersQueryContinuationExplodesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/query/query-continuation/explode/primitive?fixed=true", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response primitiveSync(@HostParam("endpoint") String endpoint, @QueryParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/query/query-continuation/explode/array?fixed=true", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response arraySync(@HostParam("endpoint") String endpoint, + @QueryParam(value = "param", multipleQueryParams = true) List param, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/query/query-continuation/explode/record?fixed=true", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response recordSync(@HostParam("endpoint") String endpoint, + @QueryParam("param") Map param, RequestOptions requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return service.primitiveSync(this.client.getEndpoint(), param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + List paramConverted + = param.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); + return service.arraySync(this.client.getEndpoint(), paramConverted, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return service.recordSync(this.client.getEndpoint(), param, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersQueryContinuationStandardsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersQueryContinuationStandardsImpl.java new file mode 100644 index 0000000000..d19c2bfa59 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersQueryContinuationStandardsImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.QueryParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * An instance of this class provides access to all the operations defined in QueryParametersQueryContinuationStandards. + */ +public final class QueryParametersQueryContinuationStandardsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final QueryParametersQueryContinuationStandardsService service; + + /** + * The service client containing this operation class. + */ + private final RoutesClientImpl client; + + /** + * Initializes an instance of QueryParametersQueryContinuationStandardsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + QueryParametersQueryContinuationStandardsImpl(RoutesClientImpl client) { + this.service + = RestProxy.create(QueryParametersQueryContinuationStandardsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for RoutesClientQueryParametersQueryContinuationStandards to be used by + * the proxy service to perform REST calls. + */ + @ServiceInterface(name = "RoutesClientQueryPar", host = "{endpoint}") + public interface QueryParametersQueryContinuationStandardsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/query/query-continuation/standard/primitive?fixed=true", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response primitiveSync(@HostParam("endpoint") String endpoint, @QueryParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/query/query-continuation/standard/array?fixed=true", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response arraySync(@HostParam("endpoint") String endpoint, @QueryParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/query/query-continuation/standard/record?fixed=true", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response recordSync(@HostParam("endpoint") String endpoint, + @QueryParam("param") Map param, RequestOptions requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return service.primitiveSync(this.client.getEndpoint(), param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + String paramConverted = param.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.arraySync(this.client.getEndpoint(), paramConverted, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return service.recordSync(this.client.getEndpoint(), param, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersQueryExpansionExplodesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersQueryExpansionExplodesImpl.java new file mode 100644 index 0000000000..72f94efed5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersQueryExpansionExplodesImpl.java @@ -0,0 +1,112 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.QueryParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * An instance of this class provides access to all the operations defined in QueryParametersQueryExpansionExplodes. + */ +public final class QueryParametersQueryExpansionExplodesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final QueryParametersQueryExpansionExplodesService service; + + /** + * The service client containing this operation class. + */ + private final RoutesClientImpl client; + + /** + * Initializes an instance of QueryParametersQueryExpansionExplodesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + QueryParametersQueryExpansionExplodesImpl(RoutesClientImpl client) { + this.service = RestProxy.create(QueryParametersQueryExpansionExplodesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for RoutesClientQueryParametersQueryExpansionExplodes to be used by the + * proxy service to perform REST calls. + */ + @ServiceInterface(name = "RoutesClientQueryPar", host = "{endpoint}") + public interface QueryParametersQueryExpansionExplodesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/query/query-expansion/explode/primitive", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response primitiveSync(@HostParam("endpoint") String endpoint, @QueryParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/query/query-expansion/explode/array", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response arraySync(@HostParam("endpoint") String endpoint, + @QueryParam(value = "param", multipleQueryParams = true) List param, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/query/query-expansion/explode/record", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response recordSync(@HostParam("endpoint") String endpoint, + @QueryParam("param") Map param, RequestOptions requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return service.primitiveSync(this.client.getEndpoint(), param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + List paramConverted + = param.stream().map(item -> Objects.toString(item, "")).collect(Collectors.toList()); + return service.arraySync(this.client.getEndpoint(), paramConverted, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return service.recordSync(this.client.getEndpoint(), param, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersQueryExpansionStandardsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersQueryExpansionStandardsImpl.java new file mode 100644 index 0000000000..5127aa2416 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/QueryParametersQueryExpansionStandardsImpl.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.QueryParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * An instance of this class provides access to all the operations defined in QueryParametersQueryExpansionStandards. + */ +public final class QueryParametersQueryExpansionStandardsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final QueryParametersQueryExpansionStandardsService service; + + /** + * The service client containing this operation class. + */ + private final RoutesClientImpl client; + + /** + * Initializes an instance of QueryParametersQueryExpansionStandardsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + QueryParametersQueryExpansionStandardsImpl(RoutesClientImpl client) { + this.service = RestProxy.create(QueryParametersQueryExpansionStandardsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for RoutesClientQueryParametersQueryExpansionStandards to be used by the + * proxy service to perform REST calls. + */ + @ServiceInterface(name = "RoutesClientQueryPar", host = "{endpoint}") + public interface QueryParametersQueryExpansionStandardsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/query/query-expansion/standard/primitive", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response primitiveSync(@HostParam("endpoint") String endpoint, @QueryParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/query/query-expansion/standard/array", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response arraySync(@HostParam("endpoint") String endpoint, @QueryParam("param") String param, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/routes/query/query-expansion/standard/record", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response recordSync(@HostParam("endpoint") String endpoint, + @QueryParam("param") Map param, RequestOptions requestOptions); + } + + /** + * The primitive operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response primitiveWithResponse(String param, RequestOptions requestOptions) { + return service.primitiveSync(this.client.getEndpoint(), param, requestOptions); + } + + /** + * The array operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response arrayWithResponse(List param, RequestOptions requestOptions) { + String paramConverted = param.stream() + .map(paramItemValue -> Objects.toString(paramItemValue, "")) + .collect(Collectors.joining(",")); + return service.arraySync(this.client.getEndpoint(), paramConverted, requestOptions); + } + + /** + * The record operation. + * + * @param param The param parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response recordWithResponse(Map param, RequestOptions requestOptions) { + return service.recordSync(this.client.getEndpoint(), param, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/RoutesClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/RoutesClientImpl.java new file mode 100644 index 0000000000..9e5b8ff921 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/RoutesClientImpl.java @@ -0,0 +1,325 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package routes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the RoutesClient type. + */ +public final class RoutesClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RoutesClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 PathParametersImpl object to access its operations. + */ + private final PathParametersImpl pathParameters; + + /** + * Gets the PathParametersImpl object to access its operations. + * + * @return the PathParametersImpl object. + */ + public PathParametersImpl getPathParameters() { + return this.pathParameters; + } + + /** + * The PathParametersReservedExpansionsImpl object to access its operations. + */ + private final PathParametersReservedExpansionsImpl pathParametersReservedExpansions; + + /** + * Gets the PathParametersReservedExpansionsImpl object to access its operations. + * + * @return the PathParametersReservedExpansionsImpl object. + */ + public PathParametersReservedExpansionsImpl getPathParametersReservedExpansions() { + return this.pathParametersReservedExpansions; + } + + /** + * The PathParametersSimpleExpansionStandardsImpl object to access its operations. + */ + private final PathParametersSimpleExpansionStandardsImpl pathParametersSimpleExpansionStandards; + + /** + * Gets the PathParametersSimpleExpansionStandardsImpl object to access its operations. + * + * @return the PathParametersSimpleExpansionStandardsImpl object. + */ + public PathParametersSimpleExpansionStandardsImpl getPathParametersSimpleExpansionStandards() { + return this.pathParametersSimpleExpansionStandards; + } + + /** + * The PathParametersSimpleExpansionExplodesImpl object to access its operations. + */ + private final PathParametersSimpleExpansionExplodesImpl pathParametersSimpleExpansionExplodes; + + /** + * Gets the PathParametersSimpleExpansionExplodesImpl object to access its operations. + * + * @return the PathParametersSimpleExpansionExplodesImpl object. + */ + public PathParametersSimpleExpansionExplodesImpl getPathParametersSimpleExpansionExplodes() { + return this.pathParametersSimpleExpansionExplodes; + } + + /** + * The PathParametersPathExpansionStandardsImpl object to access its operations. + */ + private final PathParametersPathExpansionStandardsImpl pathParametersPathExpansionStandards; + + /** + * Gets the PathParametersPathExpansionStandardsImpl object to access its operations. + * + * @return the PathParametersPathExpansionStandardsImpl object. + */ + public PathParametersPathExpansionStandardsImpl getPathParametersPathExpansionStandards() { + return this.pathParametersPathExpansionStandards; + } + + /** + * The PathParametersPathExpansionExplodesImpl object to access its operations. + */ + private final PathParametersPathExpansionExplodesImpl pathParametersPathExpansionExplodes; + + /** + * Gets the PathParametersPathExpansionExplodesImpl object to access its operations. + * + * @return the PathParametersPathExpansionExplodesImpl object. + */ + public PathParametersPathExpansionExplodesImpl getPathParametersPathExpansionExplodes() { + return this.pathParametersPathExpansionExplodes; + } + + /** + * The PathParametersLabelExpansionStandardsImpl object to access its operations. + */ + private final PathParametersLabelExpansionStandardsImpl pathParametersLabelExpansionStandards; + + /** + * Gets the PathParametersLabelExpansionStandardsImpl object to access its operations. + * + * @return the PathParametersLabelExpansionStandardsImpl object. + */ + public PathParametersLabelExpansionStandardsImpl getPathParametersLabelExpansionStandards() { + return this.pathParametersLabelExpansionStandards; + } + + /** + * The PathParametersLabelExpansionExplodesImpl object to access its operations. + */ + private final PathParametersLabelExpansionExplodesImpl pathParametersLabelExpansionExplodes; + + /** + * Gets the PathParametersLabelExpansionExplodesImpl object to access its operations. + * + * @return the PathParametersLabelExpansionExplodesImpl object. + */ + public PathParametersLabelExpansionExplodesImpl getPathParametersLabelExpansionExplodes() { + return this.pathParametersLabelExpansionExplodes; + } + + /** + * The PathParametersMatrixExpansionStandardsImpl object to access its operations. + */ + private final PathParametersMatrixExpansionStandardsImpl pathParametersMatrixExpansionStandards; + + /** + * Gets the PathParametersMatrixExpansionStandardsImpl object to access its operations. + * + * @return the PathParametersMatrixExpansionStandardsImpl object. + */ + public PathParametersMatrixExpansionStandardsImpl getPathParametersMatrixExpansionStandards() { + return this.pathParametersMatrixExpansionStandards; + } + + /** + * The PathParametersMatrixExpansionExplodesImpl object to access its operations. + */ + private final PathParametersMatrixExpansionExplodesImpl pathParametersMatrixExpansionExplodes; + + /** + * Gets the PathParametersMatrixExpansionExplodesImpl object to access its operations. + * + * @return the PathParametersMatrixExpansionExplodesImpl object. + */ + public PathParametersMatrixExpansionExplodesImpl getPathParametersMatrixExpansionExplodes() { + return this.pathParametersMatrixExpansionExplodes; + } + + /** + * The QueryParametersImpl object to access its operations. + */ + private final QueryParametersImpl queryParameters; + + /** + * Gets the QueryParametersImpl object to access its operations. + * + * @return the QueryParametersImpl object. + */ + public QueryParametersImpl getQueryParameters() { + return this.queryParameters; + } + + /** + * The QueryParametersQueryExpansionStandardsImpl object to access its operations. + */ + private final QueryParametersQueryExpansionStandardsImpl queryParametersQueryExpansionStandards; + + /** + * Gets the QueryParametersQueryExpansionStandardsImpl object to access its operations. + * + * @return the QueryParametersQueryExpansionStandardsImpl object. + */ + public QueryParametersQueryExpansionStandardsImpl getQueryParametersQueryExpansionStandards() { + return this.queryParametersQueryExpansionStandards; + } + + /** + * The QueryParametersQueryExpansionExplodesImpl object to access its operations. + */ + private final QueryParametersQueryExpansionExplodesImpl queryParametersQueryExpansionExplodes; + + /** + * Gets the QueryParametersQueryExpansionExplodesImpl object to access its operations. + * + * @return the QueryParametersQueryExpansionExplodesImpl object. + */ + public QueryParametersQueryExpansionExplodesImpl getQueryParametersQueryExpansionExplodes() { + return this.queryParametersQueryExpansionExplodes; + } + + /** + * The QueryParametersQueryContinuationStandardsImpl object to access its operations. + */ + private final QueryParametersQueryContinuationStandardsImpl queryParametersQueryContinuationStandards; + + /** + * Gets the QueryParametersQueryContinuationStandardsImpl object to access its operations. + * + * @return the QueryParametersQueryContinuationStandardsImpl object. + */ + public QueryParametersQueryContinuationStandardsImpl getQueryParametersQueryContinuationStandards() { + return this.queryParametersQueryContinuationStandards; + } + + /** + * The QueryParametersQueryContinuationExplodesImpl object to access its operations. + */ + private final QueryParametersQueryContinuationExplodesImpl queryParametersQueryContinuationExplodes; + + /** + * Gets the QueryParametersQueryContinuationExplodesImpl object to access its operations. + * + * @return the QueryParametersQueryContinuationExplodesImpl object. + */ + public QueryParametersQueryContinuationExplodesImpl getQueryParametersQueryContinuationExplodes() { + return this.queryParametersQueryContinuationExplodes; + } + + /** + * The InInterfacesImpl object to access its operations. + */ + private final InInterfacesImpl inInterfaces; + + /** + * Gets the InInterfacesImpl object to access its operations. + * + * @return the InInterfacesImpl object. + */ + public InInterfacesImpl getInInterfaces() { + return this.inInterfaces; + } + + /** + * Initializes an instance of RoutesClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public RoutesClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.pathParameters = new PathParametersImpl(this); + this.pathParametersReservedExpansions = new PathParametersReservedExpansionsImpl(this); + this.pathParametersSimpleExpansionStandards = new PathParametersSimpleExpansionStandardsImpl(this); + this.pathParametersSimpleExpansionExplodes = new PathParametersSimpleExpansionExplodesImpl(this); + this.pathParametersPathExpansionStandards = new PathParametersPathExpansionStandardsImpl(this); + this.pathParametersPathExpansionExplodes = new PathParametersPathExpansionExplodesImpl(this); + this.pathParametersLabelExpansionStandards = new PathParametersLabelExpansionStandardsImpl(this); + this.pathParametersLabelExpansionExplodes = new PathParametersLabelExpansionExplodesImpl(this); + this.pathParametersMatrixExpansionStandards = new PathParametersMatrixExpansionStandardsImpl(this); + this.pathParametersMatrixExpansionExplodes = new PathParametersMatrixExpansionExplodesImpl(this); + this.queryParameters = new QueryParametersImpl(this); + this.queryParametersQueryExpansionStandards = new QueryParametersQueryExpansionStandardsImpl(this); + this.queryParametersQueryExpansionExplodes = new QueryParametersQueryExpansionExplodesImpl(this); + this.queryParametersQueryContinuationStandards = new QueryParametersQueryContinuationStandardsImpl(this); + this.queryParametersQueryContinuationExplodes = new QueryParametersQueryContinuationExplodesImpl(this); + this.inInterfaces = new InInterfacesImpl(this); + this.service = RestProxy.create(RoutesClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for RoutesClient to be used by the proxy service to perform REST calls. + */ + @ServiceInterface(name = "RoutesClient", host = "{endpoint}") + public interface RoutesClientService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/routes/fixed", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response fixedSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + } + + /** + * The fixed operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response fixedWithResponse(RequestOptions requestOptions) { + return service.fixedSync(this.getEndpoint(), requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/package-info.java new file mode 100644 index 0000000000..1625b3e780 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Routes. + * Define scenario in building the http route/uri. + */ +package routes.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/package-info.java new file mode 100644 index 0000000000..bba5069aa6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/routes/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Routes. + * Define scenario in building the http route/uri. + */ +package routes; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/JsonClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/JsonClient.java new file mode 100644 index 0000000000..022b53712f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/JsonClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package serialization.encodedname.json; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import serialization.encodedname.json.implementation.PropertiesImpl; +import serialization.encodedname.json.property.JsonEncodedNameModel; + +/** + * Initializes a new instance of the synchronous JsonClient type. + */ +@ServiceClient(builder = JsonClientBuilder.class) +public final class JsonClient { + @Metadata(generated = true) + private final PropertiesImpl serviceClient; + + /** + * Initializes an instance of JsonClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + JsonClient(PropertiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     wireName: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response sendWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(body, requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     wireName: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void send(JsonEncodedNameModel body) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + sendWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public JsonEncodedNameModel get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/JsonClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/JsonClientBuilder.java new file mode 100644 index 0000000000..d969142be0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/JsonClientBuilder.java @@ -0,0 +1,240 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package serialization.encodedname.json; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import serialization.encodedname.json.implementation.JsonClientImpl; + +/** + * A builder for creating a new instance of the JsonClient type. + */ +@ServiceClientBuilder(serviceClients = { JsonClient.class }) +public final class JsonClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the JsonClientBuilder. + */ + @Metadata(generated = true) + public JsonClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public JsonClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of JsonClientImpl with the provided parameters. + * + * @return an instance of JsonClientImpl. + */ + @Metadata(generated = true) + private JsonClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + JsonClientImpl client = new JsonClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of JsonClient class. + * + * @return an instance of JsonClient. + */ + @Metadata(generated = true) + public JsonClient buildJsonClient() { + return new JsonClient(buildInnerClient().getProperties()); + } + + private static final ClientLogger LOGGER = new ClientLogger(JsonClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/implementation/JsonClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/implementation/JsonClientImpl.java new file mode 100644 index 0000000000..fb0385e3fd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/implementation/JsonClientImpl.java @@ -0,0 +1,64 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package serialization.encodedname.json.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the JsonClient type. + */ +public final class JsonClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 PropertiesImpl object to access its operations. + */ + private final PropertiesImpl properties; + + /** + * Gets the PropertiesImpl object to access its operations. + * + * @return the PropertiesImpl object. + */ + public PropertiesImpl getProperties() { + return this.properties; + } + + /** + * Initializes an instance of JsonClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public JsonClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.properties = new PropertiesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/implementation/PropertiesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/implementation/PropertiesImpl.java new file mode 100644 index 0000000000..5d78d0eb5d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/implementation/PropertiesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package serialization.encodedname.json.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import serialization.encodedname.json.property.JsonEncodedNameModel; + +/** + * An instance of this class provides access to all the operations defined in Properties. + */ +public final class PropertiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PropertiesService service; + + /** + * The service client containing this operation class. + */ + private final JsonClientImpl client; + + /** + * Initializes an instance of PropertiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PropertiesImpl(JsonClientImpl client) { + this.service = RestProxy.create(PropertiesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for JsonClientProperties to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "JsonClientProperties", host = "{endpoint}") + public interface PropertiesService { + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/serialization/encoded-name/json/property", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/serialization/encoded-name/json/property", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     wireName: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response sendWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     wireName: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/implementation/package-info.java new file mode 100644 index 0000000000..86f1b99e71 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Json. + * Projection. + */ +package serialization.encodedname.json.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/package-info.java new file mode 100644 index 0000000000..259776d72d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Json. + * Projection. + */ +package serialization.encodedname.json; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/property/JsonEncodedNameModel.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/property/JsonEncodedNameModel.java new file mode 100644 index 0000000000..990bb1dc87 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/property/JsonEncodedNameModel.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package serialization.encodedname.json.property; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The JsonEncodedNameModel model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class JsonEncodedNameModel implements JsonSerializable { + /* + * Pass in true + */ + @Metadata(generated = true) + private final boolean defaultName; + + /** + * Creates an instance of JsonEncodedNameModel class. + * + * @param defaultName the defaultName value to set. + */ + @Metadata(generated = true) + public JsonEncodedNameModel(boolean defaultName) { + this.defaultName = defaultName; + } + + /** + * Get the defaultName property: Pass in true. + * + * @return the defaultName value. + */ + @Metadata(generated = true) + public boolean isDefaultName() { + return this.defaultName; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("wireName", this.defaultName); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of JsonEncodedNameModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of JsonEncodedNameModel 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 JsonEncodedNameModel. + */ + @Metadata(generated = true) + public static JsonEncodedNameModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean defaultName = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("wireName".equals(fieldName)) { + defaultName = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new JsonEncodedNameModel(defaultName); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/property/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/property/package-info.java new file mode 100644 index 0000000000..73d78c736c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/serialization/encodedname/json/property/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for Json. + * Projection. + */ +package serialization.encodedname.json.property; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/NotDefinedClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/NotDefinedClient.java new file mode 100644 index 0000000000..df0e8bbfe0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/NotDefinedClient.java @@ -0,0 +1,54 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package server.endpoint.notdefined; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import server.endpoint.notdefined.implementation.NotDefinedClientImpl; + +/** + * Initializes a new instance of the synchronous NotDefinedClient type. + */ +@ServiceClient(builder = NotDefinedClientBuilder.class) +public final class NotDefinedClient { + @Metadata(generated = true) + private final NotDefinedClientImpl serviceClient; + + /** + * Initializes an instance of NotDefinedClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + NotDefinedClient(NotDefinedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The valid operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response validWithResponse(RequestOptions requestOptions) { + return this.serviceClient.validWithResponse(requestOptions); + } + + /** + * The valid operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void valid() { + // Generated convenience method for validWithResponse + RequestOptions requestOptions = new RequestOptions(); + validWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/NotDefinedClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/NotDefinedClientBuilder.java new file mode 100644 index 0000000000..4b53d573be --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/NotDefinedClientBuilder.java @@ -0,0 +1,241 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package server.endpoint.notdefined; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import server.endpoint.notdefined.implementation.NotDefinedClientImpl; + +/** + * A builder for creating a new instance of the NotDefinedClient type. + */ +@ServiceClientBuilder(serviceClients = { NotDefinedClient.class }) +public final class NotDefinedClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the NotDefinedClientBuilder. + */ + @Metadata(generated = true) + public NotDefinedClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDefinedClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDefinedClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDefinedClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDefinedClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDefinedClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDefinedClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDefinedClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDefinedClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDefinedClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of NotDefinedClientImpl with the provided parameters. + * + * @return an instance of NotDefinedClientImpl. + */ + @Metadata(generated = true) + private NotDefinedClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + NotDefinedClientImpl client = new NotDefinedClientImpl(localPipeline, this.endpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of NotDefinedClient class. + * + * @return an instance of NotDefinedClient. + */ + @Metadata(generated = true) + public NotDefinedClient buildClient() { + return new NotDefinedClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(NotDefinedClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/implementation/NotDefinedClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/implementation/NotDefinedClientImpl.java new file mode 100644 index 0000000000..0611819fe3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/implementation/NotDefinedClientImpl.java @@ -0,0 +1,89 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package server.endpoint.notdefined.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the NotDefinedClient type. + */ +public final class NotDefinedClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NotDefinedClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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; + } + + /** + * Initializes an instance of NotDefinedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public NotDefinedClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = endpoint; + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(NotDefinedClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for NotDefinedClient to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "NotDefinedClient", host = "{endpoint}") + public interface NotDefinedClientService { + @HttpRequestInformation( + method = HttpMethod.HEAD, + path = "/server/endpoint/not-defined/valid", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response validSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + } + + /** + * The valid operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response validWithResponse(RequestOptions requestOptions) { + return service.validSync(this.getEndpoint(), requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/implementation/package-info.java new file mode 100644 index 0000000000..b61d664376 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for NotDefined. + * Illustrates server doesn't define endpoint. Client should automatically add an endpoint to let user pass in. + */ +package server.endpoint.notdefined.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/package-info.java new file mode 100644 index 0000000000..bd6d77d2b9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/endpoint/notdefined/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for NotDefined. + * Illustrates server doesn't define endpoint. Client should automatically add an endpoint to let user pass in. + */ +package server.endpoint.notdefined; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/MultipleClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/MultipleClient.java new file mode 100644 index 0000000000..8b9ba2d276 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/MultipleClient.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package server.path.multiple; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import server.path.multiple.implementation.MultipleClientImpl; + +/** + * Initializes a new instance of the synchronous MultipleClient type. + */ +@ServiceClient(builder = MultipleClientBuilder.class) +public final class MultipleClient { + @Metadata(generated = true) + private final MultipleClientImpl serviceClient; + + /** + * Initializes an instance of MultipleClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + MultipleClient(MultipleClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The noOperationParams operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response noOperationParamsWithResponse(RequestOptions requestOptions) { + return this.serviceClient.noOperationParamsWithResponse(requestOptions); + } + + /** + * The withOperationPathParam operation. + * + * @param keyword The keyword parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withOperationPathParamWithResponse(String keyword, RequestOptions requestOptions) { + return this.serviceClient.withOperationPathParamWithResponse(keyword, requestOptions); + } + + /** + * The noOperationParams operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void noOperationParams() { + // Generated convenience method for noOperationParamsWithResponse + RequestOptions requestOptions = new RequestOptions(); + noOperationParamsWithResponse(requestOptions).getValue(); + } + + /** + * The withOperationPathParam operation. + * + * @param keyword The keyword parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withOperationPathParam(String keyword) { + // Generated convenience method for withOperationPathParamWithResponse + RequestOptions requestOptions = new RequestOptions(); + withOperationPathParamWithResponse(keyword, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/MultipleClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/MultipleClientBuilder.java new file mode 100644 index 0000000000..f188d53506 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/MultipleClientBuilder.java @@ -0,0 +1,260 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package server.path.multiple; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import server.path.multiple.implementation.MultipleClientImpl; + +/** + * A builder for creating a new instance of the MultipleClient type. + */ +@ServiceClientBuilder(serviceClients = { MultipleClient.class }) +public final class MultipleClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the MultipleClientBuilder. + */ + @Metadata(generated = true) + public MultipleClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultipleClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultipleClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultipleClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultipleClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultipleClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultipleClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultipleClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultipleClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MultipleClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Metadata(generated = true) + private MultipleServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the MultipleClientBuilder. + */ + @Metadata(generated = true) + public MultipleClientBuilder serviceVersion(MultipleServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /** + * Builds an instance of MultipleClientImpl with the provided parameters. + * + * @return an instance of MultipleClientImpl. + */ + @Metadata(generated = true) + private MultipleClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + MultipleServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : MultipleServiceVersion.getLatest(); + MultipleClientImpl client = new MultipleClientImpl(localPipeline, this.endpoint, localServiceVersion); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of MultipleClient class. + * + * @return an instance of MultipleClient. + */ + @Metadata(generated = true) + public MultipleClient buildClient() { + return new MultipleClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(MultipleClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/MultipleServiceVersion.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/MultipleServiceVersion.java new file mode 100644 index 0000000000..82eee89e9d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/MultipleServiceVersion.java @@ -0,0 +1,38 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package server.path.multiple; + +import io.clientcore.core.http.models.ServiceVersion; + +/** + * Service version of MultipleClient. + */ +public enum MultipleServiceVersion implements ServiceVersion { + /** + * Enum value v1.0. + */ + V1_0("v1.0"); + + private final String version; + + MultipleServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link MultipleServiceVersion}. + */ + public static MultipleServiceVersion getLatest() { + return V1_0; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/implementation/MultipleClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/implementation/MultipleClientImpl.java new file mode 100644 index 0000000000..77ecf369ec --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/implementation/MultipleClientImpl.java @@ -0,0 +1,123 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package server.path.multiple.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.PathParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import server.path.multiple.MultipleServiceVersion; + +/** + * Initializes a new instance of the MultipleClient type. + */ +public final class MultipleClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final MultipleClientService service; + + /** + * Pass in http://localhost:3000 for endpoint. + */ + private final String endpoint; + + /** + * Gets Pass in http://localhost:3000 for endpoint. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final MultipleServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public MultipleServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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; + } + + /** + * Initializes an instance of MultipleClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Pass in http://localhost:3000 for endpoint. + * @param serviceVersion Service version. + */ + public MultipleClientImpl(HttpPipeline httpPipeline, String endpoint, MultipleServiceVersion serviceVersion) { + this.endpoint = endpoint; + this.serviceVersion = MultipleServiceVersion.getLatest(); + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(MultipleClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for MultipleClient to be used by the proxy service to perform REST calls. + */ + @ServiceInterface(name = "MultipleClient", host = "{endpoint}/server/path/multiple/{apiVersion}") + public interface MultipleClientService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response noOperationParamsSync(@HostParam("endpoint") String endpoint, + @HostParam("apiVersion") String apiVersion, RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.GET, path = "/{keyword}", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withOperationPathParamSync(@HostParam("endpoint") String endpoint, + @HostParam("apiVersion") String apiVersion, @PathParam("keyword") String keyword, + RequestOptions requestOptions); + } + + /** + * The noOperationParams operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response noOperationParamsWithResponse(RequestOptions requestOptions) { + return service.noOperationParamsSync(this.getEndpoint(), this.getServiceVersion().getVersion(), requestOptions); + } + + /** + * The withOperationPathParam operation. + * + * @param keyword The keyword parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withOperationPathParamWithResponse(String keyword, RequestOptions requestOptions) { + return service.withOperationPathParamSync(this.getEndpoint(), this.getServiceVersion().getVersion(), keyword, + requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/implementation/package-info.java new file mode 100644 index 0000000000..ce05d8bfee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/implementation/package-info.java @@ -0,0 +1,6 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Multiple. + */ +package server.path.multiple.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/package-info.java new file mode 100644 index 0000000000..56cace83a0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/multiple/package-info.java @@ -0,0 +1,6 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Multiple. + */ +package server.path.multiple; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/SingleClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/SingleClient.java new file mode 100644 index 0000000000..345a466dd7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/SingleClient.java @@ -0,0 +1,54 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package server.path.single; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import server.path.single.implementation.SingleClientImpl; + +/** + * Initializes a new instance of the synchronous SingleClient type. + */ +@ServiceClient(builder = SingleClientBuilder.class) +public final class SingleClient { + @Metadata(generated = true) + private final SingleClientImpl serviceClient; + + /** + * Initializes an instance of SingleClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + SingleClient(SingleClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The myOp operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response myOpWithResponse(RequestOptions requestOptions) { + return this.serviceClient.myOpWithResponse(requestOptions); + } + + /** + * The myOp operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void myOp() { + // Generated convenience method for myOpWithResponse + RequestOptions requestOptions = new RequestOptions(); + myOpWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/SingleClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/SingleClientBuilder.java new file mode 100644 index 0000000000..bd8ad953fb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/SingleClientBuilder.java @@ -0,0 +1,240 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package server.path.single; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import server.path.single.implementation.SingleClientImpl; + +/** + * A builder for creating a new instance of the SingleClient type. + */ +@ServiceClientBuilder(serviceClients = { SingleClient.class }) +public final class SingleClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the SingleClientBuilder. + */ + @Metadata(generated = true) + public SingleClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of SingleClientImpl with the provided parameters. + * + * @return an instance of SingleClientImpl. + */ + @Metadata(generated = true) + private SingleClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + SingleClientImpl client = new SingleClientImpl(localPipeline, this.endpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of SingleClient class. + * + * @return an instance of SingleClient. + */ + @Metadata(generated = true) + public SingleClient buildClient() { + return new SingleClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(SingleClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/implementation/SingleClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/implementation/SingleClientImpl.java new file mode 100644 index 0000000000..1b8890c7b9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/implementation/SingleClientImpl.java @@ -0,0 +1,88 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package server.path.single.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the SingleClient type. + */ +public final class SingleClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SingleClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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; + } + + /** + * Initializes an instance of SingleClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + */ + public SingleClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = endpoint; + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(SingleClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for SingleClient to be used by the proxy service to perform REST calls. + */ + @ServiceInterface(name = "SingleClient", host = "{endpoint}") + public interface SingleClientService { + @HttpRequestInformation( + method = HttpMethod.HEAD, + path = "/server/path/single/myOp", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response myOpSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + } + + /** + * The myOp operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response myOpWithResponse(RequestOptions requestOptions) { + return service.myOpSync(this.getEndpoint(), requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/implementation/package-info.java new file mode 100644 index 0000000000..3fb6e6af05 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Single. + * Illustrates server with a single path parameter @server. + */ +package server.path.single.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/package-info.java new file mode 100644 index 0000000000..42ce2ff850 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/path/single/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Single. + * Illustrates server with a single path parameter @server. + */ +package server.path.single; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/NotVersionedClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/NotVersionedClient.java new file mode 100644 index 0000000000..acb618c406 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/NotVersionedClient.java @@ -0,0 +1,110 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package server.versions.notversioned; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import server.versions.notversioned.implementation.NotVersionedClientImpl; + +/** + * Initializes a new instance of the synchronous NotVersionedClient type. + */ +@ServiceClient(builder = NotVersionedClientBuilder.class) +public final class NotVersionedClient { + @Metadata(generated = true) + private final NotVersionedClientImpl serviceClient; + + /** + * Initializes an instance of NotVersionedClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + NotVersionedClient(NotVersionedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withoutApiVersion operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withoutApiVersionWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withoutApiVersionWithResponse(requestOptions); + } + + /** + * The withQueryApiVersion operation. + * + * @param apiVersion The apiVersion parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withQueryApiVersionWithResponse(String apiVersion, RequestOptions requestOptions) { + return this.serviceClient.withQueryApiVersionWithResponse(apiVersion, requestOptions); + } + + /** + * The withPathApiVersion operation. + * + * @param apiVersion The apiVersion parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withPathApiVersionWithResponse(String apiVersion, RequestOptions requestOptions) { + return this.serviceClient.withPathApiVersionWithResponse(apiVersion, requestOptions); + } + + /** + * The withoutApiVersion operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withoutApiVersion() { + // Generated convenience method for withoutApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + withoutApiVersionWithResponse(requestOptions).getValue(); + } + + /** + * The withQueryApiVersion operation. + * + * @param apiVersion The apiVersion parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withQueryApiVersion(String apiVersion) { + // Generated convenience method for withQueryApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + withQueryApiVersionWithResponse(apiVersion, requestOptions).getValue(); + } + + /** + * The withPathApiVersion operation. + * + * @param apiVersion The apiVersion parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withPathApiVersion(String apiVersion) { + // Generated convenience method for withPathApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + withPathApiVersionWithResponse(apiVersion, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/NotVersionedClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/NotVersionedClientBuilder.java new file mode 100644 index 0000000000..2751f51c5d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/NotVersionedClientBuilder.java @@ -0,0 +1,241 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package server.versions.notversioned; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import server.versions.notversioned.implementation.NotVersionedClientImpl; + +/** + * A builder for creating a new instance of the NotVersionedClient type. + */ +@ServiceClientBuilder(serviceClients = { NotVersionedClient.class }) +public final class NotVersionedClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the NotVersionedClientBuilder. + */ + @Metadata(generated = true) + public NotVersionedClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotVersionedClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotVersionedClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotVersionedClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotVersionedClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotVersionedClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotVersionedClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotVersionedClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotVersionedClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotVersionedClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of NotVersionedClientImpl with the provided parameters. + * + * @return an instance of NotVersionedClientImpl. + */ + @Metadata(generated = true) + private NotVersionedClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + NotVersionedClientImpl client = new NotVersionedClientImpl(localPipeline, this.endpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of NotVersionedClient class. + * + * @return an instance of NotVersionedClient. + */ + @Metadata(generated = true) + public NotVersionedClient buildClient() { + return new NotVersionedClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(NotVersionedClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/implementation/NotVersionedClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/implementation/NotVersionedClientImpl.java new file mode 100644 index 0000000000..4b3f646883 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/implementation/NotVersionedClientImpl.java @@ -0,0 +1,131 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package server.versions.notversioned.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.PathParam; +import io.clientcore.core.http.annotation.QueryParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the NotVersionedClient type. + */ +public final class NotVersionedClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NotVersionedClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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; + } + + /** + * Initializes an instance of NotVersionedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + */ + public NotVersionedClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = endpoint; + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(NotVersionedClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for NotVersionedClient to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "NotVersionedClient", host = "{endpoint}") + public interface NotVersionedClientService { + @HttpRequestInformation( + method = HttpMethod.HEAD, + path = "/server/versions/not-versioned/without-api-version", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response withoutApiVersionSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.HEAD, + path = "/server/versions/not-versioned/with-query-api-version", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response withQueryApiVersionSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.HEAD, + path = "/server/versions/not-versioned/with-path-api-version/{apiVersion}", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response withPathApiVersionSync(@HostParam("endpoint") String endpoint, + @PathParam("apiVersion") String apiVersion, RequestOptions requestOptions); + } + + /** + * The withoutApiVersion operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withoutApiVersionWithResponse(RequestOptions requestOptions) { + return service.withoutApiVersionSync(this.getEndpoint(), requestOptions); + } + + /** + * The withQueryApiVersion operation. + * + * @param apiVersion The apiVersion parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withQueryApiVersionWithResponse(String apiVersion, RequestOptions requestOptions) { + return service.withQueryApiVersionSync(this.getEndpoint(), apiVersion, requestOptions); + } + + /** + * The withPathApiVersion operation. + * + * @param apiVersion The apiVersion parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withPathApiVersionWithResponse(String apiVersion, RequestOptions requestOptions) { + return service.withPathApiVersionSync(this.getEndpoint(), apiVersion, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/implementation/package-info.java new file mode 100644 index 0000000000..7e8b86b325 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for NotVersioned. + * Illustrates not-versioned server. + */ +package server.versions.notversioned.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/package-info.java new file mode 100644 index 0000000000..d051621c82 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/notversioned/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for NotVersioned. + * Illustrates not-versioned server. + */ +package server.versions.notversioned; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/VersionedClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/VersionedClient.java new file mode 100644 index 0000000000..6369aacc09 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/VersionedClient.java @@ -0,0 +1,129 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package server.versions.versioned; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import server.versions.versioned.implementation.VersionedClientImpl; + +/** + * Initializes a new instance of the synchronous VersionedClient type. + */ +@ServiceClient(builder = VersionedClientBuilder.class) +public final class VersionedClient { + @Metadata(generated = true) + private final VersionedClientImpl serviceClient; + + /** + * Initializes an instance of VersionedClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + VersionedClient(VersionedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withoutApiVersion operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withoutApiVersionWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withoutApiVersionWithResponse(requestOptions); + } + + /** + * The withQueryApiVersion operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withQueryApiVersionWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryApiVersionWithResponse(requestOptions); + } + + /** + * The withPathApiVersion operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withPathApiVersionWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withPathApiVersionWithResponse(requestOptions); + } + + /** + * The withQueryOldApiVersion operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withQueryOldApiVersionWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withQueryOldApiVersionWithResponse(requestOptions); + } + + /** + * The withoutApiVersion operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withoutApiVersion() { + // Generated convenience method for withoutApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + withoutApiVersionWithResponse(requestOptions).getValue(); + } + + /** + * The withQueryApiVersion operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withQueryApiVersion() { + // Generated convenience method for withQueryApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + withQueryApiVersionWithResponse(requestOptions).getValue(); + } + + /** + * The withPathApiVersion operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withPathApiVersion() { + // Generated convenience method for withPathApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + withPathApiVersionWithResponse(requestOptions).getValue(); + } + + /** + * The withQueryOldApiVersion operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withQueryOldApiVersion() { + // Generated convenience method for withQueryOldApiVersionWithResponse + RequestOptions requestOptions = new RequestOptions(); + withQueryOldApiVersionWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/VersionedClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/VersionedClientBuilder.java new file mode 100644 index 0000000000..c00d2332a8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/VersionedClientBuilder.java @@ -0,0 +1,261 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package server.versions.versioned; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import server.versions.versioned.implementation.VersionedClientImpl; + +/** + * A builder for creating a new instance of the VersionedClient type. + */ +@ServiceClientBuilder(serviceClients = { VersionedClient.class }) +public final class VersionedClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the VersionedClientBuilder. + */ + @Metadata(generated = true) + public VersionedClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VersionedClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VersionedClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VersionedClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VersionedClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VersionedClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VersionedClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VersionedClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VersionedClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VersionedClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Service version + */ + @Metadata(generated = true) + private VersionedServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the VersionedClientBuilder. + */ + @Metadata(generated = true) + public VersionedClientBuilder serviceVersion(VersionedServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /** + * Builds an instance of VersionedClientImpl with the provided parameters. + * + * @return an instance of VersionedClientImpl. + */ + @Metadata(generated = true) + private VersionedClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + VersionedServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : VersionedServiceVersion.getLatest(); + VersionedClientImpl client = new VersionedClientImpl(localPipeline, this.endpoint, localServiceVersion); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of VersionedClient class. + * + * @return an instance of VersionedClient. + */ + @Metadata(generated = true) + public VersionedClient buildClient() { + return new VersionedClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(VersionedClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/VersionedServiceVersion.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/VersionedServiceVersion.java new file mode 100644 index 0000000000..f0496a0ab4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/VersionedServiceVersion.java @@ -0,0 +1,43 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package server.versions.versioned; + +import io.clientcore.core.http.models.ServiceVersion; + +/** + * Service version of VersionedClient. + */ +public enum VersionedServiceVersion implements ServiceVersion { + /** + * Enum value 2021-01-01-preview. + */ + V2021_01_01_PREVIEW("2021-01-01-preview"), + + /** + * Enum value 2022-12-01-preview. + */ + V2022_12_01_PREVIEW("2022-12-01-preview"); + + private final String version; + + VersionedServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link VersionedServiceVersion}. + */ + public static VersionedServiceVersion getLatest() { + return V2022_12_01_PREVIEW; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/implementation/VersionedClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/implementation/VersionedClientImpl.java new file mode 100644 index 0000000000..c9b1c64a54 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/implementation/VersionedClientImpl.java @@ -0,0 +1,168 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package server.versions.versioned.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.PathParam; +import io.clientcore.core.http.annotation.QueryParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import server.versions.versioned.VersionedServiceVersion; + +/** + * Initializes a new instance of the VersionedClient type. + */ +public final class VersionedClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final VersionedClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Service version. + */ + private final VersionedServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public VersionedServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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; + } + + /** + * Initializes an instance of VersionedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param serviceVersion Service version. + */ + public VersionedClientImpl(HttpPipeline httpPipeline, String endpoint, VersionedServiceVersion serviceVersion) { + this.endpoint = endpoint; + this.serviceVersion = VersionedServiceVersion.getLatest(); + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(VersionedClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for VersionedClient to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "VersionedClient", host = "{endpoint}") + public interface VersionedClientService { + @HttpRequestInformation( + method = HttpMethod.HEAD, + path = "/server/versions/versioned/without-api-version", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response withoutApiVersionSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.HEAD, + path = "/server/versions/versioned/with-query-api-version", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response withQueryApiVersionSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.HEAD, + path = "/server/versions/versioned/with-path-api-version/{apiVersion}", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response withPathApiVersionSync(@HostParam("endpoint") String endpoint, + @PathParam("apiVersion") String apiVersion, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.HEAD, + path = "/server/versions/versioned/with-query-old-api-version", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response withQueryOldApiVersionSync(@HostParam("endpoint") String endpoint, + @QueryParam("api-version") String apiVersion, RequestOptions requestOptions); + } + + /** + * The withoutApiVersion operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withoutApiVersionWithResponse(RequestOptions requestOptions) { + return service.withoutApiVersionSync(this.getEndpoint(), requestOptions); + } + + /** + * The withQueryApiVersion operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withQueryApiVersionWithResponse(RequestOptions requestOptions) { + return service.withQueryApiVersionSync(this.getEndpoint(), this.getServiceVersion().getVersion(), + requestOptions); + } + + /** + * The withPathApiVersion operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withPathApiVersionWithResponse(RequestOptions requestOptions) { + return service.withPathApiVersionSync(this.getEndpoint(), this.getServiceVersion().getVersion(), + requestOptions); + } + + /** + * The withQueryOldApiVersion operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withQueryOldApiVersionWithResponse(RequestOptions requestOptions) { + return service.withQueryOldApiVersionSync(this.getEndpoint(), this.getServiceVersion().getVersion(), + requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/implementation/package-info.java new file mode 100644 index 0000000000..a34e0c7c7a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Versioned. + * Illustrates versioned server. + */ +package server.versions.versioned.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/package-info.java new file mode 100644 index 0000000000..1dec2ff7e2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/server/versions/versioned/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Versioned. + * Illustrates versioned server. + */ +package server.versions.versioned; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/ModelPropertiesClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/ModelPropertiesClient.java new file mode 100644 index 0000000000..847410fb28 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/ModelPropertiesClient.java @@ -0,0 +1,68 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import specialwords.implementation.ModelPropertiesImpl; +import specialwords.modelproperties.SameAsModel; + +/** + * Initializes a new instance of the synchronous SpecialWordsClient type. + */ +@ServiceClient(builder = SpecialWordsClientBuilder.class) +public final class ModelPropertiesClient { + @Metadata(generated = true) + private final ModelPropertiesImpl serviceClient; + + /** + * Initializes an instance of ModelPropertiesClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ModelPropertiesClient(ModelPropertiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The sameAsModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     SameAsModel: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response sameAsModelWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.sameAsModelWithResponse(body, requestOptions); + } + + /** + * The sameAsModel operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void sameAsModel(SameAsModel body) { + // Generated convenience method for sameAsModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + sameAsModelWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/ModelsClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/ModelsClient.java new file mode 100644 index 0000000000..9799d187f1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/ModelsClient.java @@ -0,0 +1,1284 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import specialwords.implementation.ModelsImpl; +import specialwords.models.And; +import specialwords.models.As; +import specialwords.models.Assert; +import specialwords.models.Async; +import specialwords.models.Await; +import specialwords.models.Break; +import specialwords.models.ClassModel; +import specialwords.models.Constructor; +import specialwords.models.Continue; +import specialwords.models.Def; +import specialwords.models.Del; +import specialwords.models.Elif; +import specialwords.models.Else; +import specialwords.models.Except; +import specialwords.models.Exec; +import specialwords.models.Finally; +import specialwords.models.For; +import specialwords.models.From; +import specialwords.models.Global; +import specialwords.models.If; +import specialwords.models.Import; +import specialwords.models.In; +import specialwords.models.Is; +import specialwords.models.Lambda; +import specialwords.models.Not; +import specialwords.models.Or; +import specialwords.models.Pass; +import specialwords.models.Raise; +import specialwords.models.Return; +import specialwords.models.Try; +import specialwords.models.While; +import specialwords.models.With; +import specialwords.models.Yield; + +/** + * Initializes a new instance of the synchronous SpecialWordsClient type. + */ +@ServiceClient(builder = SpecialWordsClientBuilder.class) +public final class ModelsClient { + @Metadata(generated = true) + private final ModelsImpl serviceClient; + + /** + * Initializes an instance of ModelsClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ModelsClient(ModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withAnd operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withAndWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withAndWithResponse(body, requestOptions); + } + + /** + * The withAs operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withAsWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withAsWithResponse(body, requestOptions); + } + + /** + * The withAssert operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withAssertWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withAssertWithResponse(body, requestOptions); + } + + /** + * The withAsync operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withAsyncWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withAsyncWithResponse(body, requestOptions); + } + + /** + * The withAwait operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withAwaitWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withAwaitWithResponse(body, requestOptions); + } + + /** + * The withBreak operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withBreakWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withBreakWithResponse(body, requestOptions); + } + + /** + * The withClass operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withClassWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withClassWithResponse(body, requestOptions); + } + + /** + * The withConstructor operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withConstructorWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withConstructorWithResponse(body, requestOptions); + } + + /** + * The withContinue operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withContinueWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withContinueWithResponse(body, requestOptions); + } + + /** + * The withDef operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withDefWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withDefWithResponse(body, requestOptions); + } + + /** + * The withDel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withDelWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withDelWithResponse(body, requestOptions); + } + + /** + * The withElif operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withElifWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withElifWithResponse(body, requestOptions); + } + + /** + * The withElse operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withElseWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withElseWithResponse(body, requestOptions); + } + + /** + * The withExcept operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withExceptWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withExceptWithResponse(body, requestOptions); + } + + /** + * The withExec operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withExecWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withExecWithResponse(body, requestOptions); + } + + /** + * The withFinally operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withFinallyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withFinallyWithResponse(body, requestOptions); + } + + /** + * The withFor operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withForWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withForWithResponse(body, requestOptions); + } + + /** + * The withFrom operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withFromWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withFromWithResponse(body, requestOptions); + } + + /** + * The withGlobal operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withGlobalWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withGlobalWithResponse(body, requestOptions); + } + + /** + * The withIf operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withIfWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withIfWithResponse(body, requestOptions); + } + + /** + * The withImport operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withImportWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withImportWithResponse(body, requestOptions); + } + + /** + * The withIn operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withInWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withInWithResponse(body, requestOptions); + } + + /** + * The withIs operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withIsWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withIsWithResponse(body, requestOptions); + } + + /** + * The withLambda operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withLambdaWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withLambdaWithResponse(body, requestOptions); + } + + /** + * The withNot operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withNotWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withNotWithResponse(body, requestOptions); + } + + /** + * The withOr operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withOrWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withOrWithResponse(body, requestOptions); + } + + /** + * The withPass operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withPassWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withPassWithResponse(body, requestOptions); + } + + /** + * The withRaise operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withRaiseWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withRaiseWithResponse(body, requestOptions); + } + + /** + * The withReturn operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withReturnWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withReturnWithResponse(body, requestOptions); + } + + /** + * The withTry operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withTryWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withTryWithResponse(body, requestOptions); + } + + /** + * The withWhile operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withWhileWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withWhileWithResponse(body, requestOptions); + } + + /** + * The withWith operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withWithWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withWithWithResponse(body, requestOptions); + } + + /** + * The withYield operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withYieldWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.withYieldWithResponse(body, requestOptions); + } + + /** + * The withAnd operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withAnd(And body) { + // Generated convenience method for withAndWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAndWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withAs operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withAs(As body) { + // Generated convenience method for withAsWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAsWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withAssert operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withAssert(Assert body) { + // Generated convenience method for withAssertWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAssertWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withAsync operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withAsync(Async body) { + // Generated convenience method for withAsyncWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAsyncWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withAwait operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withAwait(Await body) { + // Generated convenience method for withAwaitWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAwaitWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withBreak operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withBreak(Break body) { + // Generated convenience method for withBreakWithResponse + RequestOptions requestOptions = new RequestOptions(); + withBreakWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withClass operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withClass(ClassModel body) { + // Generated convenience method for withClassWithResponse + RequestOptions requestOptions = new RequestOptions(); + withClassWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withConstructor operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withConstructor(Constructor body) { + // Generated convenience method for withConstructorWithResponse + RequestOptions requestOptions = new RequestOptions(); + withConstructorWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withContinue operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withContinue(Continue body) { + // Generated convenience method for withContinueWithResponse + RequestOptions requestOptions = new RequestOptions(); + withContinueWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withDef operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withDef(Def body) { + // Generated convenience method for withDefWithResponse + RequestOptions requestOptions = new RequestOptions(); + withDefWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withDel operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withDel(Del body) { + // Generated convenience method for withDelWithResponse + RequestOptions requestOptions = new RequestOptions(); + withDelWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withElif operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withElif(Elif body) { + // Generated convenience method for withElifWithResponse + RequestOptions requestOptions = new RequestOptions(); + withElifWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withElse operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withElse(Else body) { + // Generated convenience method for withElseWithResponse + RequestOptions requestOptions = new RequestOptions(); + withElseWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withExcept operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withExcept(Except body) { + // Generated convenience method for withExceptWithResponse + RequestOptions requestOptions = new RequestOptions(); + withExceptWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withExec operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withExec(Exec body) { + // Generated convenience method for withExecWithResponse + RequestOptions requestOptions = new RequestOptions(); + withExecWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withFinally operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withFinally(Finally body) { + // Generated convenience method for withFinallyWithResponse + RequestOptions requestOptions = new RequestOptions(); + withFinallyWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withFor operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withFor(For body) { + // Generated convenience method for withForWithResponse + RequestOptions requestOptions = new RequestOptions(); + withForWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withFrom operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withFrom(From body) { + // Generated convenience method for withFromWithResponse + RequestOptions requestOptions = new RequestOptions(); + withFromWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withGlobal operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withGlobal(Global body) { + // Generated convenience method for withGlobalWithResponse + RequestOptions requestOptions = new RequestOptions(); + withGlobalWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withIf operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withIf(If body) { + // Generated convenience method for withIfWithResponse + RequestOptions requestOptions = new RequestOptions(); + withIfWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withImport operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withImport(Import body) { + // Generated convenience method for withImportWithResponse + RequestOptions requestOptions = new RequestOptions(); + withImportWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withIn operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withIn(In body) { + // Generated convenience method for withInWithResponse + RequestOptions requestOptions = new RequestOptions(); + withInWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withIs operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withIs(Is body) { + // Generated convenience method for withIsWithResponse + RequestOptions requestOptions = new RequestOptions(); + withIsWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withLambda operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withLambda(Lambda body) { + // Generated convenience method for withLambdaWithResponse + RequestOptions requestOptions = new RequestOptions(); + withLambdaWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withNot operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withNot(Not body) { + // Generated convenience method for withNotWithResponse + RequestOptions requestOptions = new RequestOptions(); + withNotWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withOr operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withOr(Or body) { + // Generated convenience method for withOrWithResponse + RequestOptions requestOptions = new RequestOptions(); + withOrWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withPass operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withPass(Pass body) { + // Generated convenience method for withPassWithResponse + RequestOptions requestOptions = new RequestOptions(); + withPassWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withRaise operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withRaise(Raise body) { + // Generated convenience method for withRaiseWithResponse + RequestOptions requestOptions = new RequestOptions(); + withRaiseWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withReturn operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withReturn(Return body) { + // Generated convenience method for withReturnWithResponse + RequestOptions requestOptions = new RequestOptions(); + withReturnWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withTry operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withTry(Try body) { + // Generated convenience method for withTryWithResponse + RequestOptions requestOptions = new RequestOptions(); + withTryWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withWhile operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withWhile(While body) { + // Generated convenience method for withWhileWithResponse + RequestOptions requestOptions = new RequestOptions(); + withWhileWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withWith operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withWith(With body) { + // Generated convenience method for withWithWithResponse + RequestOptions requestOptions = new RequestOptions(); + withWithWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The withYield operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withYield(Yield body) { + // Generated convenience method for withYieldWithResponse + RequestOptions requestOptions = new RequestOptions(); + withYieldWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/OperationsClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/OperationsClient.java new file mode 100644 index 0000000000..0281f994ab --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/OperationsClient.java @@ -0,0 +1,854 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import specialwords.implementation.OperationsImpl; + +/** + * Initializes a new instance of the synchronous SpecialWordsClient type. + */ +@ServiceClient(builder = SpecialWordsClientBuilder.class) +public final class OperationsClient { + @Metadata(generated = true) + private final OperationsImpl serviceClient; + + /** + * Initializes an instance of OperationsClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + OperationsClient(OperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The and operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response andWithResponse(RequestOptions requestOptions) { + return this.serviceClient.andWithResponse(requestOptions); + } + + /** + * The as operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response asWithResponse(RequestOptions requestOptions) { + return this.serviceClient.asWithResponse(requestOptions); + } + + /** + * The assertMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response assertMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.assertMethodWithResponse(requestOptions); + } + + /** + * The async operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response asyncWithResponse(RequestOptions requestOptions) { + return this.serviceClient.asyncWithResponse(requestOptions); + } + + /** + * The await operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response awaitWithResponse(RequestOptions requestOptions) { + return this.serviceClient.awaitWithResponse(requestOptions); + } + + /** + * The breakMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response breakMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.breakMethodWithResponse(requestOptions); + } + + /** + * The classMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response classMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.classMethodWithResponse(requestOptions); + } + + /** + * The constructor operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response constructorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.constructorWithResponse(requestOptions); + } + + /** + * The continueMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response continueMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.continueMethodWithResponse(requestOptions); + } + + /** + * The def operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response defWithResponse(RequestOptions requestOptions) { + return this.serviceClient.defWithResponse(requestOptions); + } + + /** + * The del operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response delWithResponse(RequestOptions requestOptions) { + return this.serviceClient.delWithResponse(requestOptions); + } + + /** + * The elif operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response elifWithResponse(RequestOptions requestOptions) { + return this.serviceClient.elifWithResponse(requestOptions); + } + + /** + * The elseMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response elseMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.elseMethodWithResponse(requestOptions); + } + + /** + * The except operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response exceptWithResponse(RequestOptions requestOptions) { + return this.serviceClient.exceptWithResponse(requestOptions); + } + + /** + * The exec operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response execWithResponse(RequestOptions requestOptions) { + return this.serviceClient.execWithResponse(requestOptions); + } + + /** + * The finallyMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response finallyMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.finallyMethodWithResponse(requestOptions); + } + + /** + * The forMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response forMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.forMethodWithResponse(requestOptions); + } + + /** + * The from operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response fromWithResponse(RequestOptions requestOptions) { + return this.serviceClient.fromWithResponse(requestOptions); + } + + /** + * The global operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response globalWithResponse(RequestOptions requestOptions) { + return this.serviceClient.globalWithResponse(requestOptions); + } + + /** + * The ifMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response ifMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.ifMethodWithResponse(requestOptions); + } + + /** + * The importMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response importMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.importMethodWithResponse(requestOptions); + } + + /** + * The in operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response inWithResponse(RequestOptions requestOptions) { + return this.serviceClient.inWithResponse(requestOptions); + } + + /** + * The is operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response isWithResponse(RequestOptions requestOptions) { + return this.serviceClient.isWithResponse(requestOptions); + } + + /** + * The lambda operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response lambdaWithResponse(RequestOptions requestOptions) { + return this.serviceClient.lambdaWithResponse(requestOptions); + } + + /** + * The not operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response notWithResponse(RequestOptions requestOptions) { + return this.serviceClient.notWithResponse(requestOptions); + } + + /** + * The or operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response orWithResponse(RequestOptions requestOptions) { + return this.serviceClient.orWithResponse(requestOptions); + } + + /** + * The pass operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response passWithResponse(RequestOptions requestOptions) { + return this.serviceClient.passWithResponse(requestOptions); + } + + /** + * The raise operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response raiseWithResponse(RequestOptions requestOptions) { + return this.serviceClient.raiseWithResponse(requestOptions); + } + + /** + * The returnMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response returnMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.returnMethodWithResponse(requestOptions); + } + + /** + * The tryMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response tryMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.tryMethodWithResponse(requestOptions); + } + + /** + * The whileMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response whileMethodWithResponse(RequestOptions requestOptions) { + return this.serviceClient.whileMethodWithResponse(requestOptions); + } + + /** + * The with operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withWithResponse(RequestOptions requestOptions) { + return this.serviceClient.withWithResponse(requestOptions); + } + + /** + * The yield operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response yieldWithResponse(RequestOptions requestOptions) { + return this.serviceClient.yieldWithResponse(requestOptions); + } + + /** + * The and operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void and() { + // Generated convenience method for andWithResponse + RequestOptions requestOptions = new RequestOptions(); + andWithResponse(requestOptions).getValue(); + } + + /** + * The as operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void as() { + // Generated convenience method for asWithResponse + RequestOptions requestOptions = new RequestOptions(); + asWithResponse(requestOptions).getValue(); + } + + /** + * The assertMethod operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void assertMethod() { + // Generated convenience method for assertMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + assertMethodWithResponse(requestOptions).getValue(); + } + + /** + * The async operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void async() { + // Generated convenience method for asyncWithResponse + RequestOptions requestOptions = new RequestOptions(); + asyncWithResponse(requestOptions).getValue(); + } + + /** + * The await operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void await() { + // Generated convenience method for awaitWithResponse + RequestOptions requestOptions = new RequestOptions(); + awaitWithResponse(requestOptions).getValue(); + } + + /** + * The breakMethod operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void breakMethod() { + // Generated convenience method for breakMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + breakMethodWithResponse(requestOptions).getValue(); + } + + /** + * The classMethod operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void classMethod() { + // Generated convenience method for classMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + classMethodWithResponse(requestOptions).getValue(); + } + + /** + * The constructor operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void constructor() { + // Generated convenience method for constructorWithResponse + RequestOptions requestOptions = new RequestOptions(); + constructorWithResponse(requestOptions).getValue(); + } + + /** + * The continueMethod operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void continueMethod() { + // Generated convenience method for continueMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + continueMethodWithResponse(requestOptions).getValue(); + } + + /** + * The def operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void def() { + // Generated convenience method for defWithResponse + RequestOptions requestOptions = new RequestOptions(); + defWithResponse(requestOptions).getValue(); + } + + /** + * The del operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void del() { + // Generated convenience method for delWithResponse + RequestOptions requestOptions = new RequestOptions(); + delWithResponse(requestOptions).getValue(); + } + + /** + * The elif operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void elif() { + // Generated convenience method for elifWithResponse + RequestOptions requestOptions = new RequestOptions(); + elifWithResponse(requestOptions).getValue(); + } + + /** + * The elseMethod operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void elseMethod() { + // Generated convenience method for elseMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + elseMethodWithResponse(requestOptions).getValue(); + } + + /** + * The except operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void except() { + // Generated convenience method for exceptWithResponse + RequestOptions requestOptions = new RequestOptions(); + exceptWithResponse(requestOptions).getValue(); + } + + /** + * The exec operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void exec() { + // Generated convenience method for execWithResponse + RequestOptions requestOptions = new RequestOptions(); + execWithResponse(requestOptions).getValue(); + } + + /** + * The finallyMethod operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void finallyMethod() { + // Generated convenience method for finallyMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + finallyMethodWithResponse(requestOptions).getValue(); + } + + /** + * The forMethod operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void forMethod() { + // Generated convenience method for forMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + forMethodWithResponse(requestOptions).getValue(); + } + + /** + * The from operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void from() { + // Generated convenience method for fromWithResponse + RequestOptions requestOptions = new RequestOptions(); + fromWithResponse(requestOptions).getValue(); + } + + /** + * The global operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void global() { + // Generated convenience method for globalWithResponse + RequestOptions requestOptions = new RequestOptions(); + globalWithResponse(requestOptions).getValue(); + } + + /** + * The ifMethod operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void ifMethod() { + // Generated convenience method for ifMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + ifMethodWithResponse(requestOptions).getValue(); + } + + /** + * The importMethod operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void importMethod() { + // Generated convenience method for importMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + importMethodWithResponse(requestOptions).getValue(); + } + + /** + * The in operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void in() { + // Generated convenience method for inWithResponse + RequestOptions requestOptions = new RequestOptions(); + inWithResponse(requestOptions).getValue(); + } + + /** + * The is operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void is() { + // Generated convenience method for isWithResponse + RequestOptions requestOptions = new RequestOptions(); + isWithResponse(requestOptions).getValue(); + } + + /** + * The lambda operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void lambda() { + // Generated convenience method for lambdaWithResponse + RequestOptions requestOptions = new RequestOptions(); + lambdaWithResponse(requestOptions).getValue(); + } + + /** + * The not operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void not() { + // Generated convenience method for notWithResponse + RequestOptions requestOptions = new RequestOptions(); + notWithResponse(requestOptions).getValue(); + } + + /** + * The or operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void or() { + // Generated convenience method for orWithResponse + RequestOptions requestOptions = new RequestOptions(); + orWithResponse(requestOptions).getValue(); + } + + /** + * The pass operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void pass() { + // Generated convenience method for passWithResponse + RequestOptions requestOptions = new RequestOptions(); + passWithResponse(requestOptions).getValue(); + } + + /** + * The raise operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void raise() { + // Generated convenience method for raiseWithResponse + RequestOptions requestOptions = new RequestOptions(); + raiseWithResponse(requestOptions).getValue(); + } + + /** + * The returnMethod operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void returnMethod() { + // Generated convenience method for returnMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + returnMethodWithResponse(requestOptions).getValue(); + } + + /** + * The tryMethod operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void tryMethod() { + // Generated convenience method for tryMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + tryMethodWithResponse(requestOptions).getValue(); + } + + /** + * The whileMethod operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void whileMethod() { + // Generated convenience method for whileMethodWithResponse + RequestOptions requestOptions = new RequestOptions(); + whileMethodWithResponse(requestOptions).getValue(); + } + + /** + * The with operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void with() { + // Generated convenience method for withWithResponse + RequestOptions requestOptions = new RequestOptions(); + withWithResponse(requestOptions).getValue(); + } + + /** + * The yield operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void yield() { + // Generated convenience method for yieldWithResponse + RequestOptions requestOptions = new RequestOptions(); + yieldWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/ParametersClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/ParametersClient.java new file mode 100644 index 0000000000..a3160b0c26 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/ParametersClient.java @@ -0,0 +1,981 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import specialwords.implementation.ParametersImpl; + +/** + * Initializes a new instance of the synchronous SpecialWordsClient type. + */ +@ServiceClient(builder = SpecialWordsClientBuilder.class) +public final class ParametersClient { + @Metadata(generated = true) + private final ParametersImpl serviceClient; + + /** + * Initializes an instance of ParametersClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ParametersClient(ParametersImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The withAnd operation. + * + * @param and The and parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withAndWithResponse(String and, RequestOptions requestOptions) { + return this.serviceClient.withAndWithResponse(and, requestOptions); + } + + /** + * The withAs operation. + * + * @param as The as parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withAsWithResponse(String as, RequestOptions requestOptions) { + return this.serviceClient.withAsWithResponse(as, requestOptions); + } + + /** + * The withAssert operation. + * + * @param assertParameter The assertParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withAssertWithResponse(String assertParameter, RequestOptions requestOptions) { + return this.serviceClient.withAssertWithResponse(assertParameter, requestOptions); + } + + /** + * The withAsync operation. + * + * @param async The async parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withAsyncWithResponse(String async, RequestOptions requestOptions) { + return this.serviceClient.withAsyncWithResponse(async, requestOptions); + } + + /** + * The withAwait operation. + * + * @param await The await parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withAwaitWithResponse(String await, RequestOptions requestOptions) { + return this.serviceClient.withAwaitWithResponse(await, requestOptions); + } + + /** + * The withBreak operation. + * + * @param breakParameter The breakParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withBreakWithResponse(String breakParameter, RequestOptions requestOptions) { + return this.serviceClient.withBreakWithResponse(breakParameter, requestOptions); + } + + /** + * The withClass operation. + * + * @param classParameter The classParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withClassWithResponse(String classParameter, RequestOptions requestOptions) { + return this.serviceClient.withClassWithResponse(classParameter, requestOptions); + } + + /** + * The withConstructor operation. + * + * @param constructor The constructor parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withConstructorWithResponse(String constructor, RequestOptions requestOptions) { + return this.serviceClient.withConstructorWithResponse(constructor, requestOptions); + } + + /** + * The withContinue operation. + * + * @param continueParameter The continueParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withContinueWithResponse(String continueParameter, RequestOptions requestOptions) { + return this.serviceClient.withContinueWithResponse(continueParameter, requestOptions); + } + + /** + * The withDef operation. + * + * @param def The def parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withDefWithResponse(String def, RequestOptions requestOptions) { + return this.serviceClient.withDefWithResponse(def, requestOptions); + } + + /** + * The withDel operation. + * + * @param del The del parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withDelWithResponse(String del, RequestOptions requestOptions) { + return this.serviceClient.withDelWithResponse(del, requestOptions); + } + + /** + * The withElif operation. + * + * @param elif The elif parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withElifWithResponse(String elif, RequestOptions requestOptions) { + return this.serviceClient.withElifWithResponse(elif, requestOptions); + } + + /** + * The withElse operation. + * + * @param elseParameter The elseParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withElseWithResponse(String elseParameter, RequestOptions requestOptions) { + return this.serviceClient.withElseWithResponse(elseParameter, requestOptions); + } + + /** + * The withExcept operation. + * + * @param except The except parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withExceptWithResponse(String except, RequestOptions requestOptions) { + return this.serviceClient.withExceptWithResponse(except, requestOptions); + } + + /** + * The withExec operation. + * + * @param exec The exec parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withExecWithResponse(String exec, RequestOptions requestOptions) { + return this.serviceClient.withExecWithResponse(exec, requestOptions); + } + + /** + * The withFinally operation. + * + * @param finallyParameter The finallyParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withFinallyWithResponse(String finallyParameter, RequestOptions requestOptions) { + return this.serviceClient.withFinallyWithResponse(finallyParameter, requestOptions); + } + + /** + * The withFor operation. + * + * @param forParameter The forParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withForWithResponse(String forParameter, RequestOptions requestOptions) { + return this.serviceClient.withForWithResponse(forParameter, requestOptions); + } + + /** + * The withFrom operation. + * + * @param from The from parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withFromWithResponse(String from, RequestOptions requestOptions) { + return this.serviceClient.withFromWithResponse(from, requestOptions); + } + + /** + * The withGlobal operation. + * + * @param global The global parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withGlobalWithResponse(String global, RequestOptions requestOptions) { + return this.serviceClient.withGlobalWithResponse(global, requestOptions); + } + + /** + * The withIf operation. + * + * @param ifParameter The ifParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withIfWithResponse(String ifParameter, RequestOptions requestOptions) { + return this.serviceClient.withIfWithResponse(ifParameter, requestOptions); + } + + /** + * The withImport operation. + * + * @param importParameter The importParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withImportWithResponse(String importParameter, RequestOptions requestOptions) { + return this.serviceClient.withImportWithResponse(importParameter, requestOptions); + } + + /** + * The withIn operation. + * + * @param in The in parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withInWithResponse(String in, RequestOptions requestOptions) { + return this.serviceClient.withInWithResponse(in, requestOptions); + } + + /** + * The withIs operation. + * + * @param is The is parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withIsWithResponse(String is, RequestOptions requestOptions) { + return this.serviceClient.withIsWithResponse(is, requestOptions); + } + + /** + * The withLambda operation. + * + * @param lambda The lambda parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withLambdaWithResponse(String lambda, RequestOptions requestOptions) { + return this.serviceClient.withLambdaWithResponse(lambda, requestOptions); + } + + /** + * The withNot operation. + * + * @param not The not parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withNotWithResponse(String not, RequestOptions requestOptions) { + return this.serviceClient.withNotWithResponse(not, requestOptions); + } + + /** + * The withOr operation. + * + * @param or The or parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withOrWithResponse(String or, RequestOptions requestOptions) { + return this.serviceClient.withOrWithResponse(or, requestOptions); + } + + /** + * The withPass operation. + * + * @param pass The pass parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withPassWithResponse(String pass, RequestOptions requestOptions) { + return this.serviceClient.withPassWithResponse(pass, requestOptions); + } + + /** + * The withRaise operation. + * + * @param raise The raise parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withRaiseWithResponse(String raise, RequestOptions requestOptions) { + return this.serviceClient.withRaiseWithResponse(raise, requestOptions); + } + + /** + * The withReturn operation. + * + * @param returnParameter The returnParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withReturnWithResponse(String returnParameter, RequestOptions requestOptions) { + return this.serviceClient.withReturnWithResponse(returnParameter, requestOptions); + } + + /** + * The withTry operation. + * + * @param tryParameter The tryParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withTryWithResponse(String tryParameter, RequestOptions requestOptions) { + return this.serviceClient.withTryWithResponse(tryParameter, requestOptions); + } + + /** + * The withWhile operation. + * + * @param whileParameter The whileParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withWhileWithResponse(String whileParameter, RequestOptions requestOptions) { + return this.serviceClient.withWhileWithResponse(whileParameter, requestOptions); + } + + /** + * The withWith operation. + * + * @param with The with parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withWithWithResponse(String with, RequestOptions requestOptions) { + return this.serviceClient.withWithWithResponse(with, requestOptions); + } + + /** + * The withYield operation. + * + * @param yield The yield parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withYieldWithResponse(String yield, RequestOptions requestOptions) { + return this.serviceClient.withYieldWithResponse(yield, requestOptions); + } + + /** + * The withCancellationToken operation. + * + * @param cancellationToken The cancellationToken parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response withCancellationTokenWithResponse(String cancellationToken, RequestOptions requestOptions) { + return this.serviceClient.withCancellationTokenWithResponse(cancellationToken, requestOptions); + } + + /** + * The withAnd operation. + * + * @param and The and parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withAnd(String and) { + // Generated convenience method for withAndWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAndWithResponse(and, requestOptions).getValue(); + } + + /** + * The withAs operation. + * + * @param as The as parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withAs(String as) { + // Generated convenience method for withAsWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAsWithResponse(as, requestOptions).getValue(); + } + + /** + * The withAssert operation. + * + * @param assertParameter The assertParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withAssert(String assertParameter) { + // Generated convenience method for withAssertWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAssertWithResponse(assertParameter, requestOptions).getValue(); + } + + /** + * The withAsync operation. + * + * @param async The async parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withAsync(String async) { + // Generated convenience method for withAsyncWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAsyncWithResponse(async, requestOptions).getValue(); + } + + /** + * The withAwait operation. + * + * @param await The await parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withAwait(String await) { + // Generated convenience method for withAwaitWithResponse + RequestOptions requestOptions = new RequestOptions(); + withAwaitWithResponse(await, requestOptions).getValue(); + } + + /** + * The withBreak operation. + * + * @param breakParameter The breakParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withBreak(String breakParameter) { + // Generated convenience method for withBreakWithResponse + RequestOptions requestOptions = new RequestOptions(); + withBreakWithResponse(breakParameter, requestOptions).getValue(); + } + + /** + * The withClass operation. + * + * @param classParameter The classParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withClass(String classParameter) { + // Generated convenience method for withClassWithResponse + RequestOptions requestOptions = new RequestOptions(); + withClassWithResponse(classParameter, requestOptions).getValue(); + } + + /** + * The withConstructor operation. + * + * @param constructor The constructor parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withConstructor(String constructor) { + // Generated convenience method for withConstructorWithResponse + RequestOptions requestOptions = new RequestOptions(); + withConstructorWithResponse(constructor, requestOptions).getValue(); + } + + /** + * The withContinue operation. + * + * @param continueParameter The continueParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withContinue(String continueParameter) { + // Generated convenience method for withContinueWithResponse + RequestOptions requestOptions = new RequestOptions(); + withContinueWithResponse(continueParameter, requestOptions).getValue(); + } + + /** + * The withDef operation. + * + * @param def The def parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withDef(String def) { + // Generated convenience method for withDefWithResponse + RequestOptions requestOptions = new RequestOptions(); + withDefWithResponse(def, requestOptions).getValue(); + } + + /** + * The withDel operation. + * + * @param del The del parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withDel(String del) { + // Generated convenience method for withDelWithResponse + RequestOptions requestOptions = new RequestOptions(); + withDelWithResponse(del, requestOptions).getValue(); + } + + /** + * The withElif operation. + * + * @param elif The elif parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withElif(String elif) { + // Generated convenience method for withElifWithResponse + RequestOptions requestOptions = new RequestOptions(); + withElifWithResponse(elif, requestOptions).getValue(); + } + + /** + * The withElse operation. + * + * @param elseParameter The elseParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withElse(String elseParameter) { + // Generated convenience method for withElseWithResponse + RequestOptions requestOptions = new RequestOptions(); + withElseWithResponse(elseParameter, requestOptions).getValue(); + } + + /** + * The withExcept operation. + * + * @param except The except parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withExcept(String except) { + // Generated convenience method for withExceptWithResponse + RequestOptions requestOptions = new RequestOptions(); + withExceptWithResponse(except, requestOptions).getValue(); + } + + /** + * The withExec operation. + * + * @param exec The exec parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withExec(String exec) { + // Generated convenience method for withExecWithResponse + RequestOptions requestOptions = new RequestOptions(); + withExecWithResponse(exec, requestOptions).getValue(); + } + + /** + * The withFinally operation. + * + * @param finallyParameter The finallyParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withFinally(String finallyParameter) { + // Generated convenience method for withFinallyWithResponse + RequestOptions requestOptions = new RequestOptions(); + withFinallyWithResponse(finallyParameter, requestOptions).getValue(); + } + + /** + * The withFor operation. + * + * @param forParameter The forParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withFor(String forParameter) { + // Generated convenience method for withForWithResponse + RequestOptions requestOptions = new RequestOptions(); + withForWithResponse(forParameter, requestOptions).getValue(); + } + + /** + * The withFrom operation. + * + * @param from The from parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withFrom(String from) { + // Generated convenience method for withFromWithResponse + RequestOptions requestOptions = new RequestOptions(); + withFromWithResponse(from, requestOptions).getValue(); + } + + /** + * The withGlobal operation. + * + * @param global The global parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withGlobal(String global) { + // Generated convenience method for withGlobalWithResponse + RequestOptions requestOptions = new RequestOptions(); + withGlobalWithResponse(global, requestOptions).getValue(); + } + + /** + * The withIf operation. + * + * @param ifParameter The ifParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withIf(String ifParameter) { + // Generated convenience method for withIfWithResponse + RequestOptions requestOptions = new RequestOptions(); + withIfWithResponse(ifParameter, requestOptions).getValue(); + } + + /** + * The withImport operation. + * + * @param importParameter The importParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withImport(String importParameter) { + // Generated convenience method for withImportWithResponse + RequestOptions requestOptions = new RequestOptions(); + withImportWithResponse(importParameter, requestOptions).getValue(); + } + + /** + * The withIn operation. + * + * @param in The in parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withIn(String in) { + // Generated convenience method for withInWithResponse + RequestOptions requestOptions = new RequestOptions(); + withInWithResponse(in, requestOptions).getValue(); + } + + /** + * The withIs operation. + * + * @param is The is parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withIs(String is) { + // Generated convenience method for withIsWithResponse + RequestOptions requestOptions = new RequestOptions(); + withIsWithResponse(is, requestOptions).getValue(); + } + + /** + * The withLambda operation. + * + * @param lambda The lambda parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withLambda(String lambda) { + // Generated convenience method for withLambdaWithResponse + RequestOptions requestOptions = new RequestOptions(); + withLambdaWithResponse(lambda, requestOptions).getValue(); + } + + /** + * The withNot operation. + * + * @param not The not parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withNot(String not) { + // Generated convenience method for withNotWithResponse + RequestOptions requestOptions = new RequestOptions(); + withNotWithResponse(not, requestOptions).getValue(); + } + + /** + * The withOr operation. + * + * @param or The or parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withOr(String or) { + // Generated convenience method for withOrWithResponse + RequestOptions requestOptions = new RequestOptions(); + withOrWithResponse(or, requestOptions).getValue(); + } + + /** + * The withPass operation. + * + * @param pass The pass parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withPass(String pass) { + // Generated convenience method for withPassWithResponse + RequestOptions requestOptions = new RequestOptions(); + withPassWithResponse(pass, requestOptions).getValue(); + } + + /** + * The withRaise operation. + * + * @param raise The raise parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withRaise(String raise) { + // Generated convenience method for withRaiseWithResponse + RequestOptions requestOptions = new RequestOptions(); + withRaiseWithResponse(raise, requestOptions).getValue(); + } + + /** + * The withReturn operation. + * + * @param returnParameter The returnParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withReturn(String returnParameter) { + // Generated convenience method for withReturnWithResponse + RequestOptions requestOptions = new RequestOptions(); + withReturnWithResponse(returnParameter, requestOptions).getValue(); + } + + /** + * The withTry operation. + * + * @param tryParameter The tryParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withTry(String tryParameter) { + // Generated convenience method for withTryWithResponse + RequestOptions requestOptions = new RequestOptions(); + withTryWithResponse(tryParameter, requestOptions).getValue(); + } + + /** + * The withWhile operation. + * + * @param whileParameter The whileParameter parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withWhile(String whileParameter) { + // Generated convenience method for withWhileWithResponse + RequestOptions requestOptions = new RequestOptions(); + withWhileWithResponse(whileParameter, requestOptions).getValue(); + } + + /** + * The withWith operation. + * + * @param with The with parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withWith(String with) { + // Generated convenience method for withWithWithResponse + RequestOptions requestOptions = new RequestOptions(); + withWithWithResponse(with, requestOptions).getValue(); + } + + /** + * The withYield operation. + * + * @param yield The yield parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withYield(String yield) { + // Generated convenience method for withYieldWithResponse + RequestOptions requestOptions = new RequestOptions(); + withYieldWithResponse(yield, requestOptions).getValue(); + } + + /** + * The withCancellationToken operation. + * + * @param cancellationToken The cancellationToken parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void withCancellationToken(String cancellationToken) { + // Generated convenience method for withCancellationTokenWithResponse + RequestOptions requestOptions = new RequestOptions(); + withCancellationTokenWithResponse(cancellationToken, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/SpecialWordsClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/SpecialWordsClientBuilder.java new file mode 100644 index 0000000000..49b4b2683e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/SpecialWordsClientBuilder.java @@ -0,0 +1,276 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import specialwords.implementation.SpecialWordsClientImpl; + +/** + * A builder for creating a new instance of the SpecialWordsClient type. + */ +@ServiceClientBuilder( + serviceClients = { + ModelsClient.class, + ModelPropertiesClient.class, + OperationsClient.class, + ParametersClient.class }) +public final class SpecialWordsClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the SpecialWordsClientBuilder. + */ + @Metadata(generated = true) + public SpecialWordsClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpecialWordsClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpecialWordsClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpecialWordsClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpecialWordsClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpecialWordsClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpecialWordsClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpecialWordsClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpecialWordsClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SpecialWordsClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of SpecialWordsClientImpl with the provided parameters. + * + * @return an instance of SpecialWordsClientImpl. + */ + @Metadata(generated = true) + private SpecialWordsClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + SpecialWordsClientImpl client = new SpecialWordsClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of ModelsClient class. + * + * @return an instance of ModelsClient. + */ + @Metadata(generated = true) + public ModelsClient buildModelsClient() { + return new ModelsClient(buildInnerClient().getModels()); + } + + /** + * Builds an instance of ModelPropertiesClient class. + * + * @return an instance of ModelPropertiesClient. + */ + @Metadata(generated = true) + public ModelPropertiesClient buildModelPropertiesClient() { + return new ModelPropertiesClient(buildInnerClient().getModelProperties()); + } + + /** + * Builds an instance of OperationsClient class. + * + * @return an instance of OperationsClient. + */ + @Metadata(generated = true) + public OperationsClient buildOperationsClient() { + return new OperationsClient(buildInnerClient().getOperations()); + } + + /** + * Builds an instance of ParametersClient class. + * + * @return an instance of ParametersClient. + */ + @Metadata(generated = true) + public ParametersClient buildParametersClient() { + return new ParametersClient(buildInnerClient().getParameters()); + } + + private static final ClientLogger LOGGER = new ClientLogger(SpecialWordsClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/ModelPropertiesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/ModelPropertiesImpl.java new file mode 100644 index 0000000000..6f4e48e28f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/ModelPropertiesImpl.java @@ -0,0 +1,79 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * An instance of this class provides access to all the operations defined in ModelProperties. + */ +public final class ModelPropertiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ModelPropertiesService service; + + /** + * The service client containing this operation class. + */ + private final SpecialWordsClientImpl client; + + /** + * Initializes an instance of ModelPropertiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ModelPropertiesImpl(SpecialWordsClientImpl client) { + this.service = RestProxy.create(ModelPropertiesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for SpecialWordsClientModelProperties to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "SpecialWordsClientMo", host = "{endpoint}") + public interface ModelPropertiesService { + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/model-properties/same-as-model", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response sameAsModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * The sameAsModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     SameAsModel: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response sameAsModelWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sameAsModelSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/ModelsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/ModelsImpl.java new file mode 100644 index 0000000000..365a59ce6d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/ModelsImpl.java @@ -0,0 +1,1071 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * An instance of this class provides access to all the operations defined in Models. + */ +public final class ModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ModelsService service; + + /** + * The service client containing this operation class. + */ + private final SpecialWordsClientImpl client; + + /** + * Initializes an instance of ModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ModelsImpl(SpecialWordsClientImpl client) { + this.service = RestProxy.create(ModelsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for SpecialWordsClientModels to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "SpecialWordsClientMo", host = "{endpoint}") + public interface ModelsService { + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/and", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withAndSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/as", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withAsSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/assert", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withAssertSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/async", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withAsyncSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/await", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withAwaitSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/break", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withBreakSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/class", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withClassSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/constructor", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withConstructorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/continue", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withContinueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/def", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withDefSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/del", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withDelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/elif", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withElifSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/else", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withElseSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/except", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withExceptSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/exec", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withExecSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/finally", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withFinallySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/for", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withForSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/from", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withFromSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/global", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withGlobalSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/if", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withIfSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/import", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withImportSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/in", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withInSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/is", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withIsSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/lambda", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withLambdaSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/not", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withNotSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/or", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withOrSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/pass", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withPassSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/raise", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withRaiseSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/return", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withReturnSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/try", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withTrySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/while", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withWhileSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/with", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withWithSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/special-words/models/yield", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withYieldSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * The withAnd operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withAndWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withAndSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withAs operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withAsWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withAsSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withAssert operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withAssertWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withAssertSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withAsync operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withAsyncWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withAsyncSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withAwait operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withAwaitWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withAwaitSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withBreak operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withBreakWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withBreakSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withClass operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withClassWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withClassSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withConstructor operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withConstructorWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withConstructorSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withContinue operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withContinueWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withContinueSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withDef operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withDefWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withDefSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withDel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withDelWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withDelSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withElif operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withElifWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withElifSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withElse operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withElseWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withElseSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withExcept operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withExceptWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withExceptSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withExec operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withExecWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withExecSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withFinally operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withFinallyWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withFinallySync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withFor operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withForWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withForSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withFrom operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withFromWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withFromSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withGlobal operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withGlobalWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withGlobalSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withIf operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withIfWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withIfSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withImport operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withImportWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withImportSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withIn operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withInWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withInSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withIs operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withIsWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withIsSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withLambda operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withLambdaWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withLambdaSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withNot operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withNotWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withNotSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withOr operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withOrWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withOrSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withPass operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withPassWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withPassSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withRaise operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withRaiseWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withRaiseSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withReturn operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withReturnWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withReturnSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withTry operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withTryWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withTrySync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withWhile operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withWhileWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withWhileSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withWith operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withWithWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withWithSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The withYield operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withYieldWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.withYieldSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/OperationsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/OperationsImpl.java new file mode 100644 index 0000000000..2ceadad226 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/OperationsImpl.java @@ -0,0 +1,639 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; + +/** + * An instance of this class provides access to all the operations defined in Operations. + */ +public final class OperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final OperationsService service; + + /** + * The service client containing this operation class. + */ + private final SpecialWordsClientImpl client; + + /** + * Initializes an instance of OperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + OperationsImpl(SpecialWordsClientImpl client) { + this.service = RestProxy.create(OperationsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for SpecialWordsClientOperations to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "SpecialWordsClientOp", host = "{endpoint}") + public interface OperationsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/and", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response andSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/as", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response asSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/assert", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response assertMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/async", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response asyncSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/await", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response awaitSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/break", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response breakMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/class", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response classMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/constructor", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response constructorSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/continue", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response continueMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/def", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response defSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/del", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response delSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/elif", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response elifSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/else", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response elseMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/except", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response exceptSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/exec", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response execSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/finally", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response finallyMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/for", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response forMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/from", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response fromSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/global", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response globalSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/if", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response ifMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/import", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response importMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/in", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response inSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/is", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response isSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/lambda", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response lambdaSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/not", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response notSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/or", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response orSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/pass", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response passSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/raise", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response raiseSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/return", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response returnMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/try", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response tryMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/while", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response whileMethodSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/with", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/operations/yield", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response yieldSync(@HostParam("endpoint") String endpoint, RequestOptions requestOptions); + } + + /** + * The and operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response andWithResponse(RequestOptions requestOptions) { + return service.andSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The as operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response asWithResponse(RequestOptions requestOptions) { + return service.asSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The assertMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response assertMethodWithResponse(RequestOptions requestOptions) { + return service.assertMethodSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The async operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response asyncWithResponse(RequestOptions requestOptions) { + return service.asyncSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The await operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response awaitWithResponse(RequestOptions requestOptions) { + return service.awaitSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The breakMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response breakMethodWithResponse(RequestOptions requestOptions) { + return service.breakMethodSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The classMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response classMethodWithResponse(RequestOptions requestOptions) { + return service.classMethodSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The constructor operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response constructorWithResponse(RequestOptions requestOptions) { + return service.constructorSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The continueMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response continueMethodWithResponse(RequestOptions requestOptions) { + return service.continueMethodSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The def operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response defWithResponse(RequestOptions requestOptions) { + return service.defSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The del operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response delWithResponse(RequestOptions requestOptions) { + return service.delSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The elif operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response elifWithResponse(RequestOptions requestOptions) { + return service.elifSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The elseMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response elseMethodWithResponse(RequestOptions requestOptions) { + return service.elseMethodSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The except operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response exceptWithResponse(RequestOptions requestOptions) { + return service.exceptSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The exec operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response execWithResponse(RequestOptions requestOptions) { + return service.execSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The finallyMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response finallyMethodWithResponse(RequestOptions requestOptions) { + return service.finallyMethodSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The forMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response forMethodWithResponse(RequestOptions requestOptions) { + return service.forMethodSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The from operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response fromWithResponse(RequestOptions requestOptions) { + return service.fromSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The global operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response globalWithResponse(RequestOptions requestOptions) { + return service.globalSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The ifMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response ifMethodWithResponse(RequestOptions requestOptions) { + return service.ifMethodSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The importMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response importMethodWithResponse(RequestOptions requestOptions) { + return service.importMethodSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The in operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response inWithResponse(RequestOptions requestOptions) { + return service.inSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The is operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response isWithResponse(RequestOptions requestOptions) { + return service.isSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The lambda operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response lambdaWithResponse(RequestOptions requestOptions) { + return service.lambdaSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The not operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response notWithResponse(RequestOptions requestOptions) { + return service.notSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The or operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response orWithResponse(RequestOptions requestOptions) { + return service.orSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The pass operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response passWithResponse(RequestOptions requestOptions) { + return service.passSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The raise operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response raiseWithResponse(RequestOptions requestOptions) { + return service.raiseSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The returnMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response returnMethodWithResponse(RequestOptions requestOptions) { + return service.returnMethodSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The tryMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response tryMethodWithResponse(RequestOptions requestOptions) { + return service.tryMethodSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The whileMethod operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response whileMethodWithResponse(RequestOptions requestOptions) { + return service.whileMethodSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The with operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withWithResponse(RequestOptions requestOptions) { + return service.withSync(this.client.getEndpoint(), requestOptions); + } + + /** + * The yield operation. + * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response yieldWithResponse(RequestOptions requestOptions) { + return service.yieldSync(this.client.getEndpoint(), requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/ParametersImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/ParametersImpl.java new file mode 100644 index 0000000000..aca7d63de5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/ParametersImpl.java @@ -0,0 +1,726 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.QueryParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; + +/** + * An instance of this class provides access to all the operations defined in Parameters. + */ +public final class ParametersImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ParametersService service; + + /** + * The service client containing this operation class. + */ + private final SpecialWordsClientImpl client; + + /** + * Initializes an instance of ParametersImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ParametersImpl(SpecialWordsClientImpl client) { + this.service = RestProxy.create(ParametersService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for SpecialWordsClientParameters to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "SpecialWordsClientPa", host = "{endpoint}") + public interface ParametersService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/and", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withAndSync(@HostParam("endpoint") String endpoint, @QueryParam("and") String and, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/as", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withAsSync(@HostParam("endpoint") String endpoint, @QueryParam("as") String as, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/assert", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withAssertSync(@HostParam("endpoint") String endpoint, + @QueryParam("assert") String assertParameter, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/async", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withAsyncSync(@HostParam("endpoint") String endpoint, @QueryParam("async") String async, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/await", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withAwaitSync(@HostParam("endpoint") String endpoint, @QueryParam("await") String await, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/break", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withBreakSync(@HostParam("endpoint") String endpoint, @QueryParam("break") String breakParameter, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/class", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withClassSync(@HostParam("endpoint") String endpoint, @QueryParam("class") String classParameter, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/constructor", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withConstructorSync(@HostParam("endpoint") String endpoint, + @QueryParam("constructor") String constructor, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/continue", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withContinueSync(@HostParam("endpoint") String endpoint, + @QueryParam("continue") String continueParameter, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/def", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withDefSync(@HostParam("endpoint") String endpoint, @QueryParam("def") String def, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/del", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withDelSync(@HostParam("endpoint") String endpoint, @QueryParam("del") String del, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/elif", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withElifSync(@HostParam("endpoint") String endpoint, @QueryParam("elif") String elif, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/else", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withElseSync(@HostParam("endpoint") String endpoint, @QueryParam("else") String elseParameter, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/except", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withExceptSync(@HostParam("endpoint") String endpoint, @QueryParam("except") String except, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/exec", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withExecSync(@HostParam("endpoint") String endpoint, @QueryParam("exec") String exec, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/finally", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withFinallySync(@HostParam("endpoint") String endpoint, + @QueryParam("finally") String finallyParameter, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/for", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withForSync(@HostParam("endpoint") String endpoint, @QueryParam("for") String forParameter, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/from", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withFromSync(@HostParam("endpoint") String endpoint, @QueryParam("from") String from, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/global", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withGlobalSync(@HostParam("endpoint") String endpoint, @QueryParam("global") String global, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/if", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withIfSync(@HostParam("endpoint") String endpoint, @QueryParam("if") String ifParameter, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/import", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withImportSync(@HostParam("endpoint") String endpoint, + @QueryParam("import") String importParameter, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/in", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withInSync(@HostParam("endpoint") String endpoint, @QueryParam("in") String in, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/is", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withIsSync(@HostParam("endpoint") String endpoint, @QueryParam("is") String is, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/lambda", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withLambdaSync(@HostParam("endpoint") String endpoint, @QueryParam("lambda") String lambda, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/not", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withNotSync(@HostParam("endpoint") String endpoint, @QueryParam("not") String not, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/or", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withOrSync(@HostParam("endpoint") String endpoint, @QueryParam("or") String or, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/pass", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withPassSync(@HostParam("endpoint") String endpoint, @QueryParam("pass") String pass, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/raise", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withRaiseSync(@HostParam("endpoint") String endpoint, @QueryParam("raise") String raise, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/return", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withReturnSync(@HostParam("endpoint") String endpoint, + @QueryParam("return") String returnParameter, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/try", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withTrySync(@HostParam("endpoint") String endpoint, @QueryParam("try") String tryParameter, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/while", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withWhileSync(@HostParam("endpoint") String endpoint, @QueryParam("while") String whileParameter, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/with", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withWithSync(@HostParam("endpoint") String endpoint, @QueryParam("with") String with, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/yield", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withYieldSync(@HostParam("endpoint") String endpoint, @QueryParam("yield") String yield, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/special-words/parameters/cancellationToken", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response withCancellationTokenSync(@HostParam("endpoint") String endpoint, + @QueryParam("cancellationToken") String cancellationToken, RequestOptions requestOptions); + } + + /** + * The withAnd operation. + * + * @param and The and parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withAndWithResponse(String and, RequestOptions requestOptions) { + return service.withAndSync(this.client.getEndpoint(), and, requestOptions); + } + + /** + * The withAs operation. + * + * @param as The as parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withAsWithResponse(String as, RequestOptions requestOptions) { + return service.withAsSync(this.client.getEndpoint(), as, requestOptions); + } + + /** + * The withAssert operation. + * + * @param assertParameter The assertParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withAssertWithResponse(String assertParameter, RequestOptions requestOptions) { + return service.withAssertSync(this.client.getEndpoint(), assertParameter, requestOptions); + } + + /** + * The withAsync operation. + * + * @param async The async parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withAsyncWithResponse(String async, RequestOptions requestOptions) { + return service.withAsyncSync(this.client.getEndpoint(), async, requestOptions); + } + + /** + * The withAwait operation. + * + * @param await The await parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withAwaitWithResponse(String await, RequestOptions requestOptions) { + return service.withAwaitSync(this.client.getEndpoint(), await, requestOptions); + } + + /** + * The withBreak operation. + * + * @param breakParameter The breakParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withBreakWithResponse(String breakParameter, RequestOptions requestOptions) { + return service.withBreakSync(this.client.getEndpoint(), breakParameter, requestOptions); + } + + /** + * The withClass operation. + * + * @param classParameter The classParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withClassWithResponse(String classParameter, RequestOptions requestOptions) { + return service.withClassSync(this.client.getEndpoint(), classParameter, requestOptions); + } + + /** + * The withConstructor operation. + * + * @param constructor The constructor parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withConstructorWithResponse(String constructor, RequestOptions requestOptions) { + return service.withConstructorSync(this.client.getEndpoint(), constructor, requestOptions); + } + + /** + * The withContinue operation. + * + * @param continueParameter The continueParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withContinueWithResponse(String continueParameter, RequestOptions requestOptions) { + return service.withContinueSync(this.client.getEndpoint(), continueParameter, requestOptions); + } + + /** + * The withDef operation. + * + * @param def The def parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withDefWithResponse(String def, RequestOptions requestOptions) { + return service.withDefSync(this.client.getEndpoint(), def, requestOptions); + } + + /** + * The withDel operation. + * + * @param del The del parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withDelWithResponse(String del, RequestOptions requestOptions) { + return service.withDelSync(this.client.getEndpoint(), del, requestOptions); + } + + /** + * The withElif operation. + * + * @param elif The elif parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withElifWithResponse(String elif, RequestOptions requestOptions) { + return service.withElifSync(this.client.getEndpoint(), elif, requestOptions); + } + + /** + * The withElse operation. + * + * @param elseParameter The elseParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withElseWithResponse(String elseParameter, RequestOptions requestOptions) { + return service.withElseSync(this.client.getEndpoint(), elseParameter, requestOptions); + } + + /** + * The withExcept operation. + * + * @param except The except parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withExceptWithResponse(String except, RequestOptions requestOptions) { + return service.withExceptSync(this.client.getEndpoint(), except, requestOptions); + } + + /** + * The withExec operation. + * + * @param exec The exec parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withExecWithResponse(String exec, RequestOptions requestOptions) { + return service.withExecSync(this.client.getEndpoint(), exec, requestOptions); + } + + /** + * The withFinally operation. + * + * @param finallyParameter The finallyParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withFinallyWithResponse(String finallyParameter, RequestOptions requestOptions) { + return service.withFinallySync(this.client.getEndpoint(), finallyParameter, requestOptions); + } + + /** + * The withFor operation. + * + * @param forParameter The forParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withForWithResponse(String forParameter, RequestOptions requestOptions) { + return service.withForSync(this.client.getEndpoint(), forParameter, requestOptions); + } + + /** + * The withFrom operation. + * + * @param from The from parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withFromWithResponse(String from, RequestOptions requestOptions) { + return service.withFromSync(this.client.getEndpoint(), from, requestOptions); + } + + /** + * The withGlobal operation. + * + * @param global The global parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withGlobalWithResponse(String global, RequestOptions requestOptions) { + return service.withGlobalSync(this.client.getEndpoint(), global, requestOptions); + } + + /** + * The withIf operation. + * + * @param ifParameter The ifParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withIfWithResponse(String ifParameter, RequestOptions requestOptions) { + return service.withIfSync(this.client.getEndpoint(), ifParameter, requestOptions); + } + + /** + * The withImport operation. + * + * @param importParameter The importParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withImportWithResponse(String importParameter, RequestOptions requestOptions) { + return service.withImportSync(this.client.getEndpoint(), importParameter, requestOptions); + } + + /** + * The withIn operation. + * + * @param in The in parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withInWithResponse(String in, RequestOptions requestOptions) { + return service.withInSync(this.client.getEndpoint(), in, requestOptions); + } + + /** + * The withIs operation. + * + * @param is The is parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withIsWithResponse(String is, RequestOptions requestOptions) { + return service.withIsSync(this.client.getEndpoint(), is, requestOptions); + } + + /** + * The withLambda operation. + * + * @param lambda The lambda parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withLambdaWithResponse(String lambda, RequestOptions requestOptions) { + return service.withLambdaSync(this.client.getEndpoint(), lambda, requestOptions); + } + + /** + * The withNot operation. + * + * @param not The not parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withNotWithResponse(String not, RequestOptions requestOptions) { + return service.withNotSync(this.client.getEndpoint(), not, requestOptions); + } + + /** + * The withOr operation. + * + * @param or The or parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withOrWithResponse(String or, RequestOptions requestOptions) { + return service.withOrSync(this.client.getEndpoint(), or, requestOptions); + } + + /** + * The withPass operation. + * + * @param pass The pass parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withPassWithResponse(String pass, RequestOptions requestOptions) { + return service.withPassSync(this.client.getEndpoint(), pass, requestOptions); + } + + /** + * The withRaise operation. + * + * @param raise The raise parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withRaiseWithResponse(String raise, RequestOptions requestOptions) { + return service.withRaiseSync(this.client.getEndpoint(), raise, requestOptions); + } + + /** + * The withReturn operation. + * + * @param returnParameter The returnParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withReturnWithResponse(String returnParameter, RequestOptions requestOptions) { + return service.withReturnSync(this.client.getEndpoint(), returnParameter, requestOptions); + } + + /** + * The withTry operation. + * + * @param tryParameter The tryParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withTryWithResponse(String tryParameter, RequestOptions requestOptions) { + return service.withTrySync(this.client.getEndpoint(), tryParameter, requestOptions); + } + + /** + * The withWhile operation. + * + * @param whileParameter The whileParameter parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withWhileWithResponse(String whileParameter, RequestOptions requestOptions) { + return service.withWhileSync(this.client.getEndpoint(), whileParameter, requestOptions); + } + + /** + * The withWith operation. + * + * @param with The with parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withWithWithResponse(String with, RequestOptions requestOptions) { + return service.withWithSync(this.client.getEndpoint(), with, requestOptions); + } + + /** + * The withYield operation. + * + * @param yield The yield parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withYieldWithResponse(String yield, RequestOptions requestOptions) { + return service.withYieldSync(this.client.getEndpoint(), yield, requestOptions); + } + + /** + * The withCancellationToken operation. + * + * @param cancellationToken The cancellationToken parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response withCancellationTokenWithResponse(String cancellationToken, RequestOptions requestOptions) { + return service.withCancellationTokenSync(this.client.getEndpoint(), cancellationToken, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/SpecialWordsClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/SpecialWordsClientImpl.java new file mode 100644 index 0000000000..edb8baf2c9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/SpecialWordsClientImpl.java @@ -0,0 +1,109 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the SpecialWordsClient type. + */ +public final class SpecialWordsClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 ModelsImpl object to access its operations. + */ + private final ModelsImpl models; + + /** + * Gets the ModelsImpl object to access its operations. + * + * @return the ModelsImpl object. + */ + public ModelsImpl getModels() { + return this.models; + } + + /** + * The ModelPropertiesImpl object to access its operations. + */ + private final ModelPropertiesImpl modelProperties; + + /** + * Gets the ModelPropertiesImpl object to access its operations. + * + * @return the ModelPropertiesImpl object. + */ + public ModelPropertiesImpl getModelProperties() { + return this.modelProperties; + } + + /** + * The OperationsImpl object to access its operations. + */ + private final OperationsImpl operations; + + /** + * Gets the OperationsImpl object to access its operations. + * + * @return the OperationsImpl object. + */ + public OperationsImpl getOperations() { + return this.operations; + } + + /** + * The ParametersImpl object to access its operations. + */ + private final ParametersImpl parameters; + + /** + * Gets the ParametersImpl object to access its operations. + * + * @return the ParametersImpl object. + */ + public ParametersImpl getParameters() { + return this.parameters; + } + + /** + * Initializes an instance of SpecialWordsClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public SpecialWordsClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.models = new ModelsImpl(this); + this.modelProperties = new ModelPropertiesImpl(this); + this.operations = new OperationsImpl(this); + this.parameters = new ParametersImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/package-info.java new file mode 100644 index 0000000000..78c3bd3c66 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/implementation/package-info.java @@ -0,0 +1,44 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for SpecialWords. + * Scenarios to verify that reserved words can be used in service and generators will handle it appropriately. + * + * Current list of special words + * ```txt + * and + * as + * assert + * async + * await + * break + * class + * constructor + * continue + * def + * del + * elif + * else + * except + * exec + * finally + * for + * from + * global + * if + * import + * in + * is + * lambda + * not + * or + * pass + * raise + * return + * try + * while + * with + * yield + * ```. + */ +package specialwords.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/modelproperties/SameAsModel.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/modelproperties/SameAsModel.java new file mode 100644 index 0000000000..9caf72227e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/modelproperties/SameAsModel.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.modelproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The SameAsModel model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SameAsModel implements JsonSerializable { + /* + * The SameAsModel property. + */ + @Metadata(generated = true) + private final String sameAsModel; + + /** + * Creates an instance of SameAsModel class. + * + * @param sameAsModel the sameAsModel value to set. + */ + @Metadata(generated = true) + public SameAsModel(String sameAsModel) { + this.sameAsModel = sameAsModel; + } + + /** + * Get the sameAsModel property: The SameAsModel property. + * + * @return the sameAsModel value. + */ + @Metadata(generated = true) + public String getSameAsModel() { + return this.sameAsModel; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("SameAsModel", this.sameAsModel); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SameAsModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SameAsModel 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 SameAsModel. + */ + @Metadata(generated = true) + public static SameAsModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String sameAsModel = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("SameAsModel".equals(fieldName)) { + sameAsModel = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new SameAsModel(sameAsModel); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/modelproperties/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/modelproperties/package-info.java new file mode 100644 index 0000000000..7effe8e27e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/modelproperties/package-info.java @@ -0,0 +1,44 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for SpecialWords. + * Scenarios to verify that reserved words can be used in service and generators will handle it appropriately. + * + * Current list of special words + * ```txt + * and + * as + * assert + * async + * await + * break + * class + * constructor + * continue + * def + * del + * elif + * else + * except + * exec + * finally + * for + * from + * global + * if + * import + * in + * is + * lambda + * not + * or + * pass + * raise + * return + * try + * while + * with + * yield + * ```. + */ +package specialwords.modelproperties; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/And.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/And.java new file mode 100644 index 0000000000..51b720968d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/And.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The And model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class And implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of And class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public And(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of And from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of And 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 And. + */ + @Metadata(generated = true) + public static And fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new And(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/As.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/As.java new file mode 100644 index 0000000000..81983cb13b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/As.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The As model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class As implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of As class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public As(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of As from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of As 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 As. + */ + @Metadata(generated = true) + public static As fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new As(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Assert.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Assert.java new file mode 100644 index 0000000000..d159be5561 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Assert.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Assert model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Assert implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Assert class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Assert(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Assert from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Assert 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 Assert. + */ + @Metadata(generated = true) + public static Assert fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Assert(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Async.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Async.java new file mode 100644 index 0000000000..f9c58d6b15 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Async.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Async model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Async implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Async class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Async(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Async from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Async 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 Async. + */ + @Metadata(generated = true) + public static Async fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Async(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Await.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Await.java new file mode 100644 index 0000000000..46c5ae3398 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Await.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Await model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Await implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Await class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Await(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Await from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Await 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 Await. + */ + @Metadata(generated = true) + public static Await fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Await(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Break.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Break.java new file mode 100644 index 0000000000..08dd03c1d0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Break.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Break model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Break implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Break class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Break(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Break from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Break 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 Break. + */ + @Metadata(generated = true) + public static Break fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Break(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/ClassModel.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/ClassModel.java new file mode 100644 index 0000000000..9ab699e400 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/ClassModel.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The ClassModel model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class ClassModel implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of ClassModel class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public ClassModel(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ClassModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ClassModel 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 ClassModel. + */ + @Metadata(generated = true) + public static ClassModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ClassModel(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Constructor.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Constructor.java new file mode 100644 index 0000000000..e696d4b17b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Constructor.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Constructor model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Constructor implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Constructor class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Constructor(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Constructor from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Constructor 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 Constructor. + */ + @Metadata(generated = true) + public static Constructor fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Constructor(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Continue.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Continue.java new file mode 100644 index 0000000000..572d3339e7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Continue.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Continue model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Continue implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Continue class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Continue(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Continue from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Continue 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 Continue. + */ + @Metadata(generated = true) + public static Continue fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Continue(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Def.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Def.java new file mode 100644 index 0000000000..9f91c4ed22 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Def.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Def model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Def implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Def class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Def(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Def from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Def 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 Def. + */ + @Metadata(generated = true) + public static Def fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Def(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Del.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Del.java new file mode 100644 index 0000000000..d63b10e8fb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Del.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Del model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Del implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Del class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Del(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Del from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Del 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 Del. + */ + @Metadata(generated = true) + public static Del fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Del(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Elif.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Elif.java new file mode 100644 index 0000000000..45521d1a6a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Elif.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Elif model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Elif implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Elif class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Elif(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Elif from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Elif 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 Elif. + */ + @Metadata(generated = true) + public static Elif fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Elif(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Else.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Else.java new file mode 100644 index 0000000000..a43c56d78e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Else.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Else model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Else implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Else class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Else(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Else from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Else 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 Else. + */ + @Metadata(generated = true) + public static Else fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Else(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Except.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Except.java new file mode 100644 index 0000000000..46e915c014 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Except.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Except model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Except implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Except class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Except(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Except from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Except 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 Except. + */ + @Metadata(generated = true) + public static Except fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Except(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Exec.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Exec.java new file mode 100644 index 0000000000..fdd13ec18b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Exec.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Exec model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Exec implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Exec class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Exec(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Exec from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Exec 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 Exec. + */ + @Metadata(generated = true) + public static Exec fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Exec(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Finally.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Finally.java new file mode 100644 index 0000000000..de642bd40b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Finally.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Finally model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Finally implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Finally class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Finally(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Finally from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Finally 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 Finally. + */ + @Metadata(generated = true) + public static Finally fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Finally(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/For.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/For.java new file mode 100644 index 0000000000..cd8b96af1d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/For.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The For model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class For implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of For class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public For(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of For from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of For 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 For. + */ + @Metadata(generated = true) + public static For fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new For(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/From.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/From.java new file mode 100644 index 0000000000..7d87a58b5a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/From.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The From model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class From implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of From class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public From(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of From from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of From 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 From. + */ + @Metadata(generated = true) + public static From fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new From(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Global.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Global.java new file mode 100644 index 0000000000..b589f609ee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Global.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Global model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Global implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Global class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Global(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Global from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Global 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 Global. + */ + @Metadata(generated = true) + public static Global fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Global(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/If.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/If.java new file mode 100644 index 0000000000..ed8e8c7c0e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/If.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The If model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class If implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of If class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public If(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of If from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of If 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 If. + */ + @Metadata(generated = true) + public static If fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new If(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Import.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Import.java new file mode 100644 index 0000000000..97ccc5ddb3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Import.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Import model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Import implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Import class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Import(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Import from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Import 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 Import. + */ + @Metadata(generated = true) + public static Import fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Import(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/In.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/In.java new file mode 100644 index 0000000000..c3290d9df0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/In.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The In model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class In implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of In class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public In(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of In from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of In 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 In. + */ + @Metadata(generated = true) + public static In fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new In(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Is.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Is.java new file mode 100644 index 0000000000..eea6a362d0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Is.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Is model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Is implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Is class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Is(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Is from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Is 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 Is. + */ + @Metadata(generated = true) + public static Is fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Is(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Lambda.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Lambda.java new file mode 100644 index 0000000000..96d297715c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Lambda.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Lambda model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Lambda implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Lambda class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Lambda(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Lambda from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Lambda 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 Lambda. + */ + @Metadata(generated = true) + public static Lambda fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Lambda(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Not.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Not.java new file mode 100644 index 0000000000..5f537f9ea3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Not.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Not model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Not implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Not class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Not(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Not from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Not 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 Not. + */ + @Metadata(generated = true) + public static Not fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Not(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Or.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Or.java new file mode 100644 index 0000000000..1681c68bfc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Or.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Or model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Or implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Or class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Or(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Or from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Or 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 Or. + */ + @Metadata(generated = true) + public static Or fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Or(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Pass.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Pass.java new file mode 100644 index 0000000000..0820605581 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Pass.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Pass model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Pass implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Pass class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Pass(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Pass from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Pass 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 Pass. + */ + @Metadata(generated = true) + public static Pass fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Pass(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Raise.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Raise.java new file mode 100644 index 0000000000..5756cac1ca --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Raise.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Raise model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Raise implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Raise class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Raise(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Raise from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Raise 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 Raise. + */ + @Metadata(generated = true) + public static Raise fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Raise(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Return.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Return.java new file mode 100644 index 0000000000..411bc82f8f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Return.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Return model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Return implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Return class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Return(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Return from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Return 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 Return. + */ + @Metadata(generated = true) + public static Return fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Return(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Try.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Try.java new file mode 100644 index 0000000000..2b5dfd9c0d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Try.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Try model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Try implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Try class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Try(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Try from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Try 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 Try. + */ + @Metadata(generated = true) + public static Try fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Try(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/While.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/While.java new file mode 100644 index 0000000000..116b711ee9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/While.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The While model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class While implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of While class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public While(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of While from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of While 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 While. + */ + @Metadata(generated = true) + public static While fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new While(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/With.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/With.java new file mode 100644 index 0000000000..62d5ed2259 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/With.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The With model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class With implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of With class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public With(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of With from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of With 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 With. + */ + @Metadata(generated = true) + public static With fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new With(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Yield.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Yield.java new file mode 100644 index 0000000000..75802f1e45 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/Yield.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package specialwords.models; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Yield model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Yield implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Yield class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Yield(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Yield from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Yield 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 Yield. + */ + @Metadata(generated = true) + public static Yield fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Yield(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/package-info.java new file mode 100644 index 0000000000..b86aea6a66 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/models/package-info.java @@ -0,0 +1,44 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the data models for SpecialWords. + * Scenarios to verify that reserved words can be used in service and generators will handle it appropriately. + * + * Current list of special words + * ```txt + * and + * as + * assert + * async + * await + * break + * class + * constructor + * continue + * def + * del + * elif + * else + * except + * exec + * finally + * for + * from + * global + * if + * import + * in + * is + * lambda + * not + * or + * pass + * raise + * return + * try + * while + * with + * yield + * ```. + */ +package specialwords.models; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/package-info.java new file mode 100644 index 0000000000..2644497da9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/specialwords/package-info.java @@ -0,0 +1,44 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for SpecialWords. + * Scenarios to verify that reserved words can be used in service and generators will handle it appropriately. + * + * Current list of special words + * ```txt + * and + * as + * assert + * async + * await + * break + * class + * constructor + * continue + * def + * del + * elif + * else + * except + * exec + * finally + * for + * from + * global + * if + * import + * in + * is + * lambda + * not + * or + * pass + * raise + * return + * try + * while + * with + * yield + * ```. + */ +package specialwords; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/ArrayClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/ArrayClientBuilder.java new file mode 100644 index 0000000000..e2d479a965 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/ArrayClientBuilder.java @@ -0,0 +1,385 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.array.implementation.ArrayClientImpl; + +/** + * A builder for creating a new instance of the ArrayClient type. + */ +@ServiceClientBuilder( + serviceClients = { + Int32ValueClient.class, + Int64ValueClient.class, + BooleanValueClient.class, + StringValueClient.class, + Float32ValueClient.class, + DatetimeValueClient.class, + DurationValueClient.class, + UnknownValueClient.class, + ModelValueClient.class, + NullableFloatValueClient.class, + NullableInt32ValueClient.class, + NullableBooleanValueClient.class, + NullableStringValueClient.class, + NullableModelValueClient.class }) +public final class ArrayClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the ArrayClientBuilder. + */ + @Metadata(generated = true) + public ArrayClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ArrayClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ArrayClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ArrayClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ArrayClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ArrayClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ArrayClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ArrayClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ArrayClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ArrayClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of ArrayClientImpl with the provided parameters. + * + * @return an instance of ArrayClientImpl. + */ + @Metadata(generated = true) + private ArrayClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ArrayClientImpl client = new ArrayClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of Int32ValueClient class. + * + * @return an instance of Int32ValueClient. + */ + @Metadata(generated = true) + public Int32ValueClient buildInt32ValueClient() { + return new Int32ValueClient(buildInnerClient().getInt32Values()); + } + + /** + * Builds an instance of Int64ValueClient class. + * + * @return an instance of Int64ValueClient. + */ + @Metadata(generated = true) + public Int64ValueClient buildInt64ValueClient() { + return new Int64ValueClient(buildInnerClient().getInt64Values()); + } + + /** + * Builds an instance of BooleanValueClient class. + * + * @return an instance of BooleanValueClient. + */ + @Metadata(generated = true) + public BooleanValueClient buildBooleanValueClient() { + return new BooleanValueClient(buildInnerClient().getBooleanValues()); + } + + /** + * Builds an instance of StringValueClient class. + * + * @return an instance of StringValueClient. + */ + @Metadata(generated = true) + public StringValueClient buildStringValueClient() { + return new StringValueClient(buildInnerClient().getStringValues()); + } + + /** + * Builds an instance of Float32ValueClient class. + * + * @return an instance of Float32ValueClient. + */ + @Metadata(generated = true) + public Float32ValueClient buildFloat32ValueClient() { + return new Float32ValueClient(buildInnerClient().getFloat32Values()); + } + + /** + * Builds an instance of DatetimeValueClient class. + * + * @return an instance of DatetimeValueClient. + */ + @Metadata(generated = true) + public DatetimeValueClient buildDatetimeValueClient() { + return new DatetimeValueClient(buildInnerClient().getDatetimeValues()); + } + + /** + * Builds an instance of DurationValueClient class. + * + * @return an instance of DurationValueClient. + */ + @Metadata(generated = true) + public DurationValueClient buildDurationValueClient() { + return new DurationValueClient(buildInnerClient().getDurationValues()); + } + + /** + * Builds an instance of UnknownValueClient class. + * + * @return an instance of UnknownValueClient. + */ + @Metadata(generated = true) + public UnknownValueClient buildUnknownValueClient() { + return new UnknownValueClient(buildInnerClient().getUnknownValues()); + } + + /** + * Builds an instance of ModelValueClient class. + * + * @return an instance of ModelValueClient. + */ + @Metadata(generated = true) + public ModelValueClient buildModelValueClient() { + return new ModelValueClient(buildInnerClient().getModelValues()); + } + + /** + * Builds an instance of NullableFloatValueClient class. + * + * @return an instance of NullableFloatValueClient. + */ + @Metadata(generated = true) + public NullableFloatValueClient buildNullableFloatValueClient() { + return new NullableFloatValueClient(buildInnerClient().getNullableFloatValues()); + } + + /** + * Builds an instance of NullableInt32ValueClient class. + * + * @return an instance of NullableInt32ValueClient. + */ + @Metadata(generated = true) + public NullableInt32ValueClient buildNullableInt32ValueClient() { + return new NullableInt32ValueClient(buildInnerClient().getNullableInt32Values()); + } + + /** + * Builds an instance of NullableBooleanValueClient class. + * + * @return an instance of NullableBooleanValueClient. + */ + @Metadata(generated = true) + public NullableBooleanValueClient buildNullableBooleanValueClient() { + return new NullableBooleanValueClient(buildInnerClient().getNullableBooleanValues()); + } + + /** + * Builds an instance of NullableStringValueClient class. + * + * @return an instance of NullableStringValueClient. + */ + @Metadata(generated = true) + public NullableStringValueClient buildNullableStringValueClient() { + return new NullableStringValueClient(buildInnerClient().getNullableStringValues()); + } + + /** + * Builds an instance of NullableModelValueClient class. + * + * @return an instance of NullableModelValueClient. + */ + @Metadata(generated = true) + public NullableModelValueClient buildNullableModelValueClient() { + return new NullableModelValueClient(buildInnerClient().getNullableModelValues()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ArrayClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/BooleanValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/BooleanValueClient.java new file mode 100644 index 0000000000..0cdd4636cb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/BooleanValueClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; +import type.array.implementation.BooleanValuesImpl; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class BooleanValueClient { + @Metadata(generated = true) + private final BooleanValuesImpl serviceClient; + + /** + * Initializes an instance of BooleanValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + BooleanValueClient(BooleanValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     boolean (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     boolean (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/DatetimeValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/DatetimeValueClient.java new file mode 100644 index 0000000000..139519f56c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/DatetimeValueClient.java @@ -0,0 +1,104 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.time.OffsetDateTime; +import java.util.List; +import type.array.implementation.DatetimeValuesImpl; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class DatetimeValueClient { + @Metadata(generated = true) + private final DatetimeValuesImpl serviceClient; + + /** + * Initializes an instance of DatetimeValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + DatetimeValueClient(DatetimeValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     OffsetDateTime (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     OffsetDateTime (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/DurationValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/DurationValueClient.java new file mode 100644 index 0000000000..5c2ef86669 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/DurationValueClient.java @@ -0,0 +1,104 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.time.Duration; +import java.util.List; +import type.array.implementation.DurationValuesImpl; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class DurationValueClient { + @Metadata(generated = true) + private final DurationValuesImpl serviceClient; + + /** + * Initializes an instance of DurationValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + DurationValueClient(DurationValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     Duration (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     Duration (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/Float32ValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/Float32ValueClient.java new file mode 100644 index 0000000000..27c97c5a73 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/Float32ValueClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; +import type.array.implementation.Float32ValuesImpl; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class Float32ValueClient { + @Metadata(generated = true) + private final Float32ValuesImpl serviceClient; + + /** + * Initializes an instance of Float32ValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + Float32ValueClient(Float32ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     double (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     double (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/InnerModel.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/InnerModel.java new file mode 100644 index 0000000000..f164a4c93a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/InnerModel.java @@ -0,0 +1,117 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Array inner model. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class InnerModel implements JsonSerializable { + /* + * Required string property + */ + @Metadata(generated = true) + private final String property; + + /* + * The children property. + */ + @Metadata(generated = true) + private List children; + + /** + * Creates an instance of InnerModel class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public InnerModel(String property) { + this.property = property; + } + + /** + * Get the property property: Required string property. + * + * @return the property value. + */ + @Metadata(generated = true) + public String getProperty() { + return this.property; + } + + /** + * Get the children property: The children property. + * + * @return the children value. + */ + @Metadata(generated = true) + public List getChildren() { + return this.children; + } + + /** + * Set the children property: The children property. + * + * @param children the children value to set. + * @return the InnerModel object itself. + */ + @Metadata(generated = true) + public InnerModel setChildren(List children) { + this.children = children; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property); + jsonWriter.writeArrayField("children", this.children, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InnerModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InnerModel 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 InnerModel. + */ + @Metadata(generated = true) + public static InnerModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String property = null; + List children = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getString(); + } else if ("children".equals(fieldName)) { + children = reader.readArray(reader1 -> InnerModel.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + InnerModel deserializedInnerModel = new InnerModel(property); + deserializedInnerModel.children = children; + + return deserializedInnerModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/Int32ValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/Int32ValueClient.java new file mode 100644 index 0000000000..a2ea01217d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/Int32ValueClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; +import type.array.implementation.Int32ValuesImpl; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class Int32ValueClient { + @Metadata(generated = true) + private final Int32ValuesImpl serviceClient; + + /** + * Initializes an instance of Int32ValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + Int32ValueClient(Int32ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/Int64ValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/Int64ValueClient.java new file mode 100644 index 0000000000..7be17f6730 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/Int64ValueClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; +import type.array.implementation.Int64ValuesImpl; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class Int64ValueClient { + @Metadata(generated = true) + private final Int64ValuesImpl serviceClient; + + /** + * Initializes an instance of Int64ValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + Int64ValueClient(Int64ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     long (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     long (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/ModelValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/ModelValueClient.java new file mode 100644 index 0000000000..53f101b0ce --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/ModelValueClient.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; +import type.array.implementation.ModelValuesImpl; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class ModelValueClient { + @Metadata(generated = true) + private final ModelValuesImpl serviceClient; + + /** + * Initializes an instance of ModelValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ModelValueClient(ModelValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableBooleanValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableBooleanValueClient.java new file mode 100644 index 0000000000..e17e2ade05 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableBooleanValueClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; +import type.array.implementation.NullableBooleanValuesImpl; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class NullableBooleanValueClient { + @Metadata(generated = true) + private final NullableBooleanValuesImpl serviceClient; + + /** + * Initializes an instance of NullableBooleanValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + NullableBooleanValueClient(NullableBooleanValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     boolean (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     boolean (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableFloatValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableFloatValueClient.java new file mode 100644 index 0000000000..61c12ecc05 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableFloatValueClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; +import type.array.implementation.NullableFloatValuesImpl; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class NullableFloatValueClient { + @Metadata(generated = true) + private final NullableFloatValuesImpl serviceClient; + + /** + * Initializes an instance of NullableFloatValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + NullableFloatValueClient(NullableFloatValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     double (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     double (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableInt32ValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableInt32ValueClient.java new file mode 100644 index 0000000000..16f5db1d07 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableInt32ValueClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; +import type.array.implementation.NullableInt32ValuesImpl; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class NullableInt32ValueClient { + @Metadata(generated = true) + private final NullableInt32ValuesImpl serviceClient; + + /** + * Initializes an instance of NullableInt32ValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + NullableInt32ValueClient(NullableInt32ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableModelValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableModelValueClient.java new file mode 100644 index 0000000000..25308841f2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableModelValueClient.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; +import type.array.implementation.NullableModelValuesImpl; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class NullableModelValueClient { + @Metadata(generated = true) + private final NullableModelValuesImpl serviceClient; + + /** + * Initializes an instance of NullableModelValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + NullableModelValueClient(NullableModelValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableStringValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableStringValueClient.java new file mode 100644 index 0000000000..980a51fc6d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/NullableStringValueClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; +import type.array.implementation.NullableStringValuesImpl; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class NullableStringValueClient { + @Metadata(generated = true) + private final NullableStringValuesImpl serviceClient; + + /** + * Initializes an instance of NullableStringValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + NullableStringValueClient(NullableStringValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     String (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     String (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/StringValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/StringValueClient.java new file mode 100644 index 0000000000..f387154241 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/StringValueClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; +import type.array.implementation.StringValuesImpl; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class StringValueClient { + @Metadata(generated = true) + private final StringValuesImpl serviceClient; + + /** + * Initializes an instance of StringValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + StringValueClient(StringValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     String (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     String (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/UnknownValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/UnknownValueClient.java new file mode 100644 index 0000000000..826a8ef6eb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/UnknownValueClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; +import type.array.implementation.UnknownValuesImpl; + +/** + * Initializes a new instance of the synchronous ArrayClient type. + */ +@ServiceClient(builder = ArrayClientBuilder.class) +public final class UnknownValueClient { + @Metadata(generated = true) + private final UnknownValuesImpl serviceClient; + + /** + * Initializes an instance of UnknownValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + UnknownValueClient(UnknownValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     Object (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     Object (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public List get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(List body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/ArrayClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/ArrayClientImpl.java new file mode 100644 index 0000000000..45588e290d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/ArrayClientImpl.java @@ -0,0 +1,259 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the ArrayClient type. + */ +public final class ArrayClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 Int32ValuesImpl object to access its operations. + */ + private final Int32ValuesImpl int32Values; + + /** + * Gets the Int32ValuesImpl object to access its operations. + * + * @return the Int32ValuesImpl object. + */ + public Int32ValuesImpl getInt32Values() { + return this.int32Values; + } + + /** + * The Int64ValuesImpl object to access its operations. + */ + private final Int64ValuesImpl int64Values; + + /** + * Gets the Int64ValuesImpl object to access its operations. + * + * @return the Int64ValuesImpl object. + */ + public Int64ValuesImpl getInt64Values() { + return this.int64Values; + } + + /** + * The BooleanValuesImpl object to access its operations. + */ + private final BooleanValuesImpl booleanValues; + + /** + * Gets the BooleanValuesImpl object to access its operations. + * + * @return the BooleanValuesImpl object. + */ + public BooleanValuesImpl getBooleanValues() { + return this.booleanValues; + } + + /** + * The StringValuesImpl object to access its operations. + */ + private final StringValuesImpl stringValues; + + /** + * Gets the StringValuesImpl object to access its operations. + * + * @return the StringValuesImpl object. + */ + public StringValuesImpl getStringValues() { + return this.stringValues; + } + + /** + * The Float32ValuesImpl object to access its operations. + */ + private final Float32ValuesImpl float32Values; + + /** + * Gets the Float32ValuesImpl object to access its operations. + * + * @return the Float32ValuesImpl object. + */ + public Float32ValuesImpl getFloat32Values() { + return this.float32Values; + } + + /** + * The DatetimeValuesImpl object to access its operations. + */ + private final DatetimeValuesImpl datetimeValues; + + /** + * Gets the DatetimeValuesImpl object to access its operations. + * + * @return the DatetimeValuesImpl object. + */ + public DatetimeValuesImpl getDatetimeValues() { + return this.datetimeValues; + } + + /** + * The DurationValuesImpl object to access its operations. + */ + private final DurationValuesImpl durationValues; + + /** + * Gets the DurationValuesImpl object to access its operations. + * + * @return the DurationValuesImpl object. + */ + public DurationValuesImpl getDurationValues() { + return this.durationValues; + } + + /** + * The UnknownValuesImpl object to access its operations. + */ + private final UnknownValuesImpl unknownValues; + + /** + * Gets the UnknownValuesImpl object to access its operations. + * + * @return the UnknownValuesImpl object. + */ + public UnknownValuesImpl getUnknownValues() { + return this.unknownValues; + } + + /** + * The ModelValuesImpl object to access its operations. + */ + private final ModelValuesImpl modelValues; + + /** + * Gets the ModelValuesImpl object to access its operations. + * + * @return the ModelValuesImpl object. + */ + public ModelValuesImpl getModelValues() { + return this.modelValues; + } + + /** + * The NullableFloatValuesImpl object to access its operations. + */ + private final NullableFloatValuesImpl nullableFloatValues; + + /** + * Gets the NullableFloatValuesImpl object to access its operations. + * + * @return the NullableFloatValuesImpl object. + */ + public NullableFloatValuesImpl getNullableFloatValues() { + return this.nullableFloatValues; + } + + /** + * The NullableInt32ValuesImpl object to access its operations. + */ + private final NullableInt32ValuesImpl nullableInt32Values; + + /** + * Gets the NullableInt32ValuesImpl object to access its operations. + * + * @return the NullableInt32ValuesImpl object. + */ + public NullableInt32ValuesImpl getNullableInt32Values() { + return this.nullableInt32Values; + } + + /** + * The NullableBooleanValuesImpl object to access its operations. + */ + private final NullableBooleanValuesImpl nullableBooleanValues; + + /** + * Gets the NullableBooleanValuesImpl object to access its operations. + * + * @return the NullableBooleanValuesImpl object. + */ + public NullableBooleanValuesImpl getNullableBooleanValues() { + return this.nullableBooleanValues; + } + + /** + * The NullableStringValuesImpl object to access its operations. + */ + private final NullableStringValuesImpl nullableStringValues; + + /** + * Gets the NullableStringValuesImpl object to access its operations. + * + * @return the NullableStringValuesImpl object. + */ + public NullableStringValuesImpl getNullableStringValues() { + return this.nullableStringValues; + } + + /** + * The NullableModelValuesImpl object to access its operations. + */ + private final NullableModelValuesImpl nullableModelValues; + + /** + * Gets the NullableModelValuesImpl object to access its operations. + * + * @return the NullableModelValuesImpl object. + */ + public NullableModelValuesImpl getNullableModelValues() { + return this.nullableModelValues; + } + + /** + * Initializes an instance of ArrayClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public ArrayClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.int32Values = new Int32ValuesImpl(this); + this.int64Values = new Int64ValuesImpl(this); + this.booleanValues = new BooleanValuesImpl(this); + this.stringValues = new StringValuesImpl(this); + this.float32Values = new Float32ValuesImpl(this); + this.datetimeValues = new DatetimeValuesImpl(this); + this.durationValues = new DurationValuesImpl(this); + this.unknownValues = new UnknownValuesImpl(this); + this.modelValues = new ModelValuesImpl(this); + this.nullableFloatValues = new NullableFloatValuesImpl(this); + this.nullableInt32Values = new NullableInt32ValuesImpl(this); + this.nullableBooleanValues = new NullableBooleanValuesImpl(this); + this.nullableStringValues = new NullableStringValuesImpl(this); + this.nullableModelValues = new NullableModelValuesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/BooleanValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/BooleanValuesImpl.java new file mode 100644 index 0000000000..07c840e3d7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/BooleanValuesImpl.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; + +/** + * An instance of this class provides access to all the operations defined in BooleanValues. + */ +public final class BooleanValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BooleanValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of BooleanValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BooleanValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(BooleanValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientBooleanValues to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "ArrayClientBooleanVa", host = "{endpoint}") + public interface BooleanValuesService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/array/boolean", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.PUT, path = "/type/array/boolean", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     boolean (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     boolean (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/DatetimeValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/DatetimeValuesImpl.java new file mode 100644 index 0000000000..6744ea8ab1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/DatetimeValuesImpl.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.time.OffsetDateTime; +import java.util.List; + +/** + * An instance of this class provides access to all the operations defined in DatetimeValues. + */ +public final class DatetimeValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DatetimeValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of DatetimeValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DatetimeValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(DatetimeValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientDatetimeValues to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "ArrayClientDatetimeV", host = "{endpoint}") + public interface DatetimeValuesService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/array/datetime", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.PUT, path = "/type/array/datetime", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     OffsetDateTime (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     OffsetDateTime (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/DurationValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/DurationValuesImpl.java new file mode 100644 index 0000000000..f62c5a2375 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/DurationValuesImpl.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.time.Duration; +import java.util.List; + +/** + * An instance of this class provides access to all the operations defined in DurationValues. + */ +public final class DurationValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DurationValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of DurationValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DurationValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(DurationValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientDurationValues to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "ArrayClientDurationV", host = "{endpoint}") + public interface DurationValuesService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/array/duration", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.PUT, path = "/type/array/duration", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     Duration (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     Duration (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/Float32ValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/Float32ValuesImpl.java new file mode 100644 index 0000000000..e6be95b346 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/Float32ValuesImpl.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; + +/** + * An instance of this class provides access to all the operations defined in Float32Values. + */ +public final class Float32ValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Float32ValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of Float32ValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Float32ValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(Float32ValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientFloat32Values to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "ArrayClientFloat32Va", host = "{endpoint}") + public interface Float32ValuesService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/array/float32", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.PUT, path = "/type/array/float32", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     double (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     double (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/Int32ValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/Int32ValuesImpl.java new file mode 100644 index 0000000000..d0a5553311 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/Int32ValuesImpl.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; + +/** + * An instance of this class provides access to all the operations defined in Int32Values. + */ +public final class Int32ValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Int32ValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of Int32ValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Int32ValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(Int32ValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientInt32Values to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "ArrayClientInt32Valu", host = "{endpoint}") + public interface Int32ValuesService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/array/int32", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.PUT, path = "/type/array/int32", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/Int64ValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/Int64ValuesImpl.java new file mode 100644 index 0000000000..970e8b3334 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/Int64ValuesImpl.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; + +/** + * An instance of this class provides access to all the operations defined in Int64Values. + */ +public final class Int64ValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Int64ValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of Int64ValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Int64ValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(Int64ValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientInt64Values to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "ArrayClientInt64Valu", host = "{endpoint}") + public interface Int64ValuesService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/array/int64", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.PUT, path = "/type/array/int64", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     long (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     long (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/ModelValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/ModelValuesImpl.java new file mode 100644 index 0000000000..622a995e6a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/ModelValuesImpl.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; +import type.array.InnerModel; + +/** + * An instance of this class provides access to all the operations defined in ModelValues. + */ +public final class ModelValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ModelValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of ModelValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ModelValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(ModelValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientModelValues to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "ArrayClientModelValu", host = "{endpoint}") + public interface ModelValuesService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/array/model", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.PUT, path = "/type/array/model", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableBooleanValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableBooleanValuesImpl.java new file mode 100644 index 0000000000..ab7fb98da7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableBooleanValuesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; + +/** + * An instance of this class provides access to all the operations defined in NullableBooleanValues. + */ +public final class NullableBooleanValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NullableBooleanValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of NullableBooleanValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NullableBooleanValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(NullableBooleanValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientNullableBooleanValues to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ArrayClientNullableB", host = "{endpoint}") + public interface NullableBooleanValuesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/array/nullable-boolean", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/array/nullable-boolean", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     boolean (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     boolean (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableFloatValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableFloatValuesImpl.java new file mode 100644 index 0000000000..636fbf2696 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableFloatValuesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; + +/** + * An instance of this class provides access to all the operations defined in NullableFloatValues. + */ +public final class NullableFloatValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NullableFloatValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of NullableFloatValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NullableFloatValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(NullableFloatValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientNullableFloatValues to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ArrayClientNullableF", host = "{endpoint}") + public interface NullableFloatValuesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/array/nullable-float", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/array/nullable-float", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     double (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     double (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableInt32ValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableInt32ValuesImpl.java new file mode 100644 index 0000000000..e0ea48f9ae --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableInt32ValuesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; + +/** + * An instance of this class provides access to all the operations defined in NullableInt32Values. + */ +public final class NullableInt32ValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NullableInt32ValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of NullableInt32ValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NullableInt32ValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(NullableInt32ValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientNullableInt32Values to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ArrayClientNullableI", host = "{endpoint}") + public interface NullableInt32ValuesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/array/nullable-int32", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/array/nullable-int32", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     int (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableModelValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableModelValuesImpl.java new file mode 100644 index 0000000000..38e86bffd3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableModelValuesImpl.java @@ -0,0 +1,119 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; +import type.array.InnerModel; + +/** + * An instance of this class provides access to all the operations defined in NullableModelValues. + */ +public final class NullableModelValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NullableModelValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of NullableModelValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NullableModelValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(NullableModelValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientNullableModelValues to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ArrayClientNullableM", host = "{endpoint}") + public interface NullableModelValuesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/array/nullable-model", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/array/nullable-model", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *      (Required){
+     *         property: String (Required)
+     *         children (Optional): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableStringValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableStringValuesImpl.java new file mode 100644 index 0000000000..99fb9f60d1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/NullableStringValuesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; + +/** + * An instance of this class provides access to all the operations defined in NullableStringValues. + */ +public final class NullableStringValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NullableStringValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of NullableStringValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NullableStringValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(NullableStringValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientNullableStringValues to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ArrayClientNullableS", host = "{endpoint}") + public interface NullableStringValuesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/array/nullable-string", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/array/nullable-string", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     String (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     String (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/StringValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/StringValuesImpl.java new file mode 100644 index 0000000000..bbf2f090f0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/StringValuesImpl.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; + +/** + * An instance of this class provides access to all the operations defined in StringValues. + */ +public final class StringValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of StringValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(StringValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientStringValues to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "ArrayClientStringVal", host = "{endpoint}") + public interface StringValuesService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/array/string", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.PUT, path = "/type/array/string", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     String (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     String (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/UnknownValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/UnknownValuesImpl.java new file mode 100644 index 0000000000..d62c9e1bdf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/UnknownValuesImpl.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.array.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.List; + +/** + * An instance of this class provides access to all the operations defined in UnknownValues. + */ +public final class UnknownValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnknownValuesService service; + + /** + * The service client containing this operation class. + */ + private final ArrayClientImpl client; + + /** + * Initializes an instance of UnknownValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnknownValuesImpl(ArrayClientImpl client) { + this.service = RestProxy.create(UnknownValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ArrayClientUnknownValues to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "ArrayClientUnknownVa", host = "{endpoint}") + public interface UnknownValuesService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/array/unknown", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.PUT, path = "/type/array/unknown", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     Object (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * [
+     *     Object (Required)
+     * ]
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/package-info.java new file mode 100644 index 0000000000..169b8dbb76 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Array. + * Illustrates various types of arrays. + */ +package type.array.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/package-info.java new file mode 100644 index 0000000000..7fb788a941 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/array/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Array. + * Illustrates various types of arrays. + */ +package type.array; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/BooleanValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/BooleanValueClient.java new file mode 100644 index 0000000000..03d2f32a91 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/BooleanValueClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; +import type.dictionary.implementation.BooleanValuesImpl; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class BooleanValueClient { + @Metadata(generated = true) + private final BooleanValuesImpl serviceClient; + + /** + * Initializes an instance of BooleanValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + BooleanValueClient(BooleanValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/DatetimeValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/DatetimeValueClient.java new file mode 100644 index 0000000000..4b177f7ea9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/DatetimeValueClient.java @@ -0,0 +1,104 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.time.OffsetDateTime; +import java.util.Map; +import type.dictionary.implementation.DatetimeValuesImpl; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class DatetimeValueClient { + @Metadata(generated = true) + private final DatetimeValuesImpl serviceClient; + + /** + * Initializes an instance of DatetimeValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + DatetimeValueClient(DatetimeValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/DictionaryClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/DictionaryClientBuilder.java new file mode 100644 index 0000000000..f2579f7acf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/DictionaryClientBuilder.java @@ -0,0 +1,353 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.dictionary.implementation.DictionaryClientImpl; + +/** + * A builder for creating a new instance of the DictionaryClient type. + */ +@ServiceClientBuilder( + serviceClients = { + Int32ValueClient.class, + Int64ValueClient.class, + BooleanValueClient.class, + StringValueClient.class, + Float32ValueClient.class, + DatetimeValueClient.class, + DurationValueClient.class, + UnknownValueClient.class, + ModelValueClient.class, + RecursiveModelValueClient.class, + NullableFloatValueClient.class }) +public final class DictionaryClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the DictionaryClientBuilder. + */ + @Metadata(generated = true) + public DictionaryClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public DictionaryClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public DictionaryClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public DictionaryClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public DictionaryClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public DictionaryClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public DictionaryClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public DictionaryClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public DictionaryClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public DictionaryClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of DictionaryClientImpl with the provided parameters. + * + * @return an instance of DictionaryClientImpl. + */ + @Metadata(generated = true) + private DictionaryClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + DictionaryClientImpl client = new DictionaryClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of Int32ValueClient class. + * + * @return an instance of Int32ValueClient. + */ + @Metadata(generated = true) + public Int32ValueClient buildInt32ValueClient() { + return new Int32ValueClient(buildInnerClient().getInt32Values()); + } + + /** + * Builds an instance of Int64ValueClient class. + * + * @return an instance of Int64ValueClient. + */ + @Metadata(generated = true) + public Int64ValueClient buildInt64ValueClient() { + return new Int64ValueClient(buildInnerClient().getInt64Values()); + } + + /** + * Builds an instance of BooleanValueClient class. + * + * @return an instance of BooleanValueClient. + */ + @Metadata(generated = true) + public BooleanValueClient buildBooleanValueClient() { + return new BooleanValueClient(buildInnerClient().getBooleanValues()); + } + + /** + * Builds an instance of StringValueClient class. + * + * @return an instance of StringValueClient. + */ + @Metadata(generated = true) + public StringValueClient buildStringValueClient() { + return new StringValueClient(buildInnerClient().getStringValues()); + } + + /** + * Builds an instance of Float32ValueClient class. + * + * @return an instance of Float32ValueClient. + */ + @Metadata(generated = true) + public Float32ValueClient buildFloat32ValueClient() { + return new Float32ValueClient(buildInnerClient().getFloat32Values()); + } + + /** + * Builds an instance of DatetimeValueClient class. + * + * @return an instance of DatetimeValueClient. + */ + @Metadata(generated = true) + public DatetimeValueClient buildDatetimeValueClient() { + return new DatetimeValueClient(buildInnerClient().getDatetimeValues()); + } + + /** + * Builds an instance of DurationValueClient class. + * + * @return an instance of DurationValueClient. + */ + @Metadata(generated = true) + public DurationValueClient buildDurationValueClient() { + return new DurationValueClient(buildInnerClient().getDurationValues()); + } + + /** + * Builds an instance of UnknownValueClient class. + * + * @return an instance of UnknownValueClient. + */ + @Metadata(generated = true) + public UnknownValueClient buildUnknownValueClient() { + return new UnknownValueClient(buildInnerClient().getUnknownValues()); + } + + /** + * Builds an instance of ModelValueClient class. + * + * @return an instance of ModelValueClient. + */ + @Metadata(generated = true) + public ModelValueClient buildModelValueClient() { + return new ModelValueClient(buildInnerClient().getModelValues()); + } + + /** + * Builds an instance of RecursiveModelValueClient class. + * + * @return an instance of RecursiveModelValueClient. + */ + @Metadata(generated = true) + public RecursiveModelValueClient buildRecursiveModelValueClient() { + return new RecursiveModelValueClient(buildInnerClient().getRecursiveModelValues()); + } + + /** + * Builds an instance of NullableFloatValueClient class. + * + * @return an instance of NullableFloatValueClient. + */ + @Metadata(generated = true) + public NullableFloatValueClient buildNullableFloatValueClient() { + return new NullableFloatValueClient(buildInnerClient().getNullableFloatValues()); + } + + private static final ClientLogger LOGGER = new ClientLogger(DictionaryClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/DurationValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/DurationValueClient.java new file mode 100644 index 0000000000..96d4b5b2ca --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/DurationValueClient.java @@ -0,0 +1,104 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.time.Duration; +import java.util.Map; +import type.dictionary.implementation.DurationValuesImpl; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class DurationValueClient { + @Metadata(generated = true) + private final DurationValuesImpl serviceClient; + + /** + * Initializes an instance of DurationValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + DurationValueClient(DurationValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: Duration (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: Duration (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/Float32ValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/Float32ValueClient.java new file mode 100644 index 0000000000..4ec906ad2e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/Float32ValueClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; +import type.dictionary.implementation.Float32ValuesImpl; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class Float32ValueClient { + @Metadata(generated = true) + private final Float32ValuesImpl serviceClient; + + /** + * Initializes an instance of Float32ValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + Float32ValueClient(Float32ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: double (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: double (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/InnerModel.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/InnerModel.java new file mode 100644 index 0000000000..1f38d598ec --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/InnerModel.java @@ -0,0 +1,117 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Dictionary inner model. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class InnerModel implements JsonSerializable { + /* + * Required string property + */ + @Metadata(generated = true) + private final String property; + + /* + * The children property. + */ + @Metadata(generated = true) + private Map children; + + /** + * Creates an instance of InnerModel class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public InnerModel(String property) { + this.property = property; + } + + /** + * Get the property property: Required string property. + * + * @return the property value. + */ + @Metadata(generated = true) + public String getProperty() { + return this.property; + } + + /** + * Get the children property: The children property. + * + * @return the children value. + */ + @Metadata(generated = true) + public Map getChildren() { + return this.children; + } + + /** + * Set the children property: The children property. + * + * @param children the children value to set. + * @return the InnerModel object itself. + */ + @Metadata(generated = true) + public InnerModel setChildren(Map children) { + this.children = children; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property); + jsonWriter.writeMapField("children", this.children, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InnerModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InnerModel 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 InnerModel. + */ + @Metadata(generated = true) + public static InnerModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String property = null; + Map children = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getString(); + } else if ("children".equals(fieldName)) { + children = reader.readMap(reader1 -> InnerModel.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + InnerModel deserializedInnerModel = new InnerModel(property); + deserializedInnerModel.children = children; + + return deserializedInnerModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/Int32ValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/Int32ValueClient.java new file mode 100644 index 0000000000..39153bc654 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/Int32ValueClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; +import type.dictionary.implementation.Int32ValuesImpl; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class Int32ValueClient { + @Metadata(generated = true) + private final Int32ValuesImpl serviceClient; + + /** + * Initializes an instance of Int32ValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + Int32ValueClient(Int32ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: int (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/Int64ValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/Int64ValueClient.java new file mode 100644 index 0000000000..fbb7ce11f5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/Int64ValueClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; +import type.dictionary.implementation.Int64ValuesImpl; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class Int64ValueClient { + @Metadata(generated = true) + private final Int64ValuesImpl serviceClient; + + /** + * Initializes an instance of Int64ValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + Int64ValueClient(Int64ValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: long (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: long (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/ModelValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/ModelValueClient.java new file mode 100644 index 0000000000..401b9aa304 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/ModelValueClient.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; +import type.dictionary.implementation.ModelValuesImpl; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class ModelValueClient { + @Metadata(generated = true) + private final ModelValuesImpl serviceClient; + + /** + * Initializes an instance of ModelValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ModelValueClient(ModelValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/NullableFloatValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/NullableFloatValueClient.java new file mode 100644 index 0000000000..9ecbe481e4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/NullableFloatValueClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; +import type.dictionary.implementation.NullableFloatValuesImpl; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class NullableFloatValueClient { + @Metadata(generated = true) + private final NullableFloatValuesImpl serviceClient; + + /** + * Initializes an instance of NullableFloatValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + NullableFloatValueClient(NullableFloatValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: Double (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: Double (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/RecursiveModelValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/RecursiveModelValueClient.java new file mode 100644 index 0000000000..af446f0864 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/RecursiveModelValueClient.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; +import type.dictionary.implementation.RecursiveModelValuesImpl; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class RecursiveModelValueClient { + @Metadata(generated = true) + private final RecursiveModelValuesImpl serviceClient; + + /** + * Initializes an instance of RecursiveModelValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + RecursiveModelValueClient(RecursiveModelValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/StringValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/StringValueClient.java new file mode 100644 index 0000000000..2d96fc2efd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/StringValueClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; +import type.dictionary.implementation.StringValuesImpl; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class StringValueClient { + @Metadata(generated = true) + private final StringValuesImpl serviceClient; + + /** + * Initializes an instance of StringValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + StringValueClient(StringValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/UnknownValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/UnknownValueClient.java new file mode 100644 index 0000000000..4387626a9f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/UnknownValueClient.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; +import type.dictionary.implementation.UnknownValuesImpl; + +/** + * Initializes a new instance of the synchronous DictionaryClient type. + */ +@ServiceClient(builder = DictionaryClientBuilder.class) +public final class UnknownValueClient { + @Metadata(generated = true) + private final UnknownValuesImpl serviceClient; + + /** + * Initializes an instance of UnknownValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + UnknownValueClient(UnknownValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: Object (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: Object (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public Map get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The put operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(Map body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/BooleanValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/BooleanValuesImpl.java new file mode 100644 index 0000000000..f40352a455 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/BooleanValuesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; + +/** + * An instance of this class provides access to all the operations defined in BooleanValues. + */ +public final class BooleanValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BooleanValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of BooleanValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BooleanValuesImpl(DictionaryClientImpl client) { + this.service = RestProxy.create(BooleanValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientBooleanValues to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "DictionaryClientBool", host = "{endpoint}") + public interface BooleanValuesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/dictionary/boolean", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/dictionary/boolean", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/DatetimeValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/DatetimeValuesImpl.java new file mode 100644 index 0000000000..bf0536de84 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/DatetimeValuesImpl.java @@ -0,0 +1,109 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.time.OffsetDateTime; +import java.util.Map; + +/** + * An instance of this class provides access to all the operations defined in DatetimeValues. + */ +public final class DatetimeValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DatetimeValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of DatetimeValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DatetimeValuesImpl(DictionaryClientImpl client) { + this.service = RestProxy.create(DatetimeValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientDatetimeValues to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "DictionaryClientDate", host = "{endpoint}") + public interface DatetimeValuesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/dictionary/datetime", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/dictionary/datetime", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/DictionaryClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/DictionaryClientImpl.java new file mode 100644 index 0000000000..9d608b9630 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/DictionaryClientImpl.java @@ -0,0 +1,214 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the DictionaryClient type. + */ +public final class DictionaryClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 Int32ValuesImpl object to access its operations. + */ + private final Int32ValuesImpl int32Values; + + /** + * Gets the Int32ValuesImpl object to access its operations. + * + * @return the Int32ValuesImpl object. + */ + public Int32ValuesImpl getInt32Values() { + return this.int32Values; + } + + /** + * The Int64ValuesImpl object to access its operations. + */ + private final Int64ValuesImpl int64Values; + + /** + * Gets the Int64ValuesImpl object to access its operations. + * + * @return the Int64ValuesImpl object. + */ + public Int64ValuesImpl getInt64Values() { + return this.int64Values; + } + + /** + * The BooleanValuesImpl object to access its operations. + */ + private final BooleanValuesImpl booleanValues; + + /** + * Gets the BooleanValuesImpl object to access its operations. + * + * @return the BooleanValuesImpl object. + */ + public BooleanValuesImpl getBooleanValues() { + return this.booleanValues; + } + + /** + * The StringValuesImpl object to access its operations. + */ + private final StringValuesImpl stringValues; + + /** + * Gets the StringValuesImpl object to access its operations. + * + * @return the StringValuesImpl object. + */ + public StringValuesImpl getStringValues() { + return this.stringValues; + } + + /** + * The Float32ValuesImpl object to access its operations. + */ + private final Float32ValuesImpl float32Values; + + /** + * Gets the Float32ValuesImpl object to access its operations. + * + * @return the Float32ValuesImpl object. + */ + public Float32ValuesImpl getFloat32Values() { + return this.float32Values; + } + + /** + * The DatetimeValuesImpl object to access its operations. + */ + private final DatetimeValuesImpl datetimeValues; + + /** + * Gets the DatetimeValuesImpl object to access its operations. + * + * @return the DatetimeValuesImpl object. + */ + public DatetimeValuesImpl getDatetimeValues() { + return this.datetimeValues; + } + + /** + * The DurationValuesImpl object to access its operations. + */ + private final DurationValuesImpl durationValues; + + /** + * Gets the DurationValuesImpl object to access its operations. + * + * @return the DurationValuesImpl object. + */ + public DurationValuesImpl getDurationValues() { + return this.durationValues; + } + + /** + * The UnknownValuesImpl object to access its operations. + */ + private final UnknownValuesImpl unknownValues; + + /** + * Gets the UnknownValuesImpl object to access its operations. + * + * @return the UnknownValuesImpl object. + */ + public UnknownValuesImpl getUnknownValues() { + return this.unknownValues; + } + + /** + * The ModelValuesImpl object to access its operations. + */ + private final ModelValuesImpl modelValues; + + /** + * Gets the ModelValuesImpl object to access its operations. + * + * @return the ModelValuesImpl object. + */ + public ModelValuesImpl getModelValues() { + return this.modelValues; + } + + /** + * The RecursiveModelValuesImpl object to access its operations. + */ + private final RecursiveModelValuesImpl recursiveModelValues; + + /** + * Gets the RecursiveModelValuesImpl object to access its operations. + * + * @return the RecursiveModelValuesImpl object. + */ + public RecursiveModelValuesImpl getRecursiveModelValues() { + return this.recursiveModelValues; + } + + /** + * The NullableFloatValuesImpl object to access its operations. + */ + private final NullableFloatValuesImpl nullableFloatValues; + + /** + * Gets the NullableFloatValuesImpl object to access its operations. + * + * @return the NullableFloatValuesImpl object. + */ + public NullableFloatValuesImpl getNullableFloatValues() { + return this.nullableFloatValues; + } + + /** + * Initializes an instance of DictionaryClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public DictionaryClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.int32Values = new Int32ValuesImpl(this); + this.int64Values = new Int64ValuesImpl(this); + this.booleanValues = new BooleanValuesImpl(this); + this.stringValues = new StringValuesImpl(this); + this.float32Values = new Float32ValuesImpl(this); + this.datetimeValues = new DatetimeValuesImpl(this); + this.durationValues = new DurationValuesImpl(this); + this.unknownValues = new UnknownValuesImpl(this); + this.modelValues = new ModelValuesImpl(this); + this.recursiveModelValues = new RecursiveModelValuesImpl(this); + this.nullableFloatValues = new NullableFloatValuesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/DurationValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/DurationValuesImpl.java new file mode 100644 index 0000000000..ace12512b2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/DurationValuesImpl.java @@ -0,0 +1,109 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.time.Duration; +import java.util.Map; + +/** + * An instance of this class provides access to all the operations defined in DurationValues. + */ +public final class DurationValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DurationValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of DurationValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DurationValuesImpl(DictionaryClientImpl client) { + this.service = RestProxy.create(DurationValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientDurationValues to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "DictionaryClientDura", host = "{endpoint}") + public interface DurationValuesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/dictionary/duration", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/dictionary/duration", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: Duration (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: Duration (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/Float32ValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/Float32ValuesImpl.java new file mode 100644 index 0000000000..3e3a98f482 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/Float32ValuesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; + +/** + * An instance of this class provides access to all the operations defined in Float32Values. + */ +public final class Float32ValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Float32ValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of Float32ValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Float32ValuesImpl(DictionaryClientImpl client) { + this.service = RestProxy.create(Float32ValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientFloat32Values to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "DictionaryClientFloa", host = "{endpoint}") + public interface Float32ValuesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/dictionary/float32", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/dictionary/float32", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: double (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: double (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/Int32ValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/Int32ValuesImpl.java new file mode 100644 index 0000000000..79b2e97cbe --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/Int32ValuesImpl.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; + +/** + * An instance of this class provides access to all the operations defined in Int32Values. + */ +public final class Int32ValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Int32ValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of Int32ValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Int32ValuesImpl(DictionaryClientImpl client) { + this.service = RestProxy.create(Int32ValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientInt32Values to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "DictionaryClientInt3", host = "{endpoint}") + public interface Int32ValuesService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/dictionary/int32", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.PUT, path = "/type/dictionary/int32", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: int (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/Int64ValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/Int64ValuesImpl.java new file mode 100644 index 0000000000..61cd98fe2e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/Int64ValuesImpl.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; + +/** + * An instance of this class provides access to all the operations defined in Int64Values. + */ +public final class Int64ValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Int64ValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of Int64ValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Int64ValuesImpl(DictionaryClientImpl client) { + this.service = RestProxy.create(Int64ValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientInt64Values to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "DictionaryClientInt6", host = "{endpoint}") + public interface Int64ValuesService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/dictionary/int64", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.PUT, path = "/type/dictionary/int64", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: long (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: long (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/ModelValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/ModelValuesImpl.java new file mode 100644 index 0000000000..378035cddf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/ModelValuesImpl.java @@ -0,0 +1,113 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; +import type.dictionary.InnerModel; + +/** + * An instance of this class provides access to all the operations defined in ModelValues. + */ +public final class ModelValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ModelValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of ModelValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ModelValuesImpl(DictionaryClientImpl client) { + this.service = RestProxy.create(ModelValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientModelValues to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "DictionaryClientMode", host = "{endpoint}") + public interface ModelValuesService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/dictionary/model", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.PUT, path = "/type/dictionary/model", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/NullableFloatValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/NullableFloatValuesImpl.java new file mode 100644 index 0000000000..9eb7868488 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/NullableFloatValuesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; + +/** + * An instance of this class provides access to all the operations defined in NullableFloatValues. + */ +public final class NullableFloatValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NullableFloatValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of NullableFloatValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NullableFloatValuesImpl(DictionaryClientImpl client) { + this.service = RestProxy.create(NullableFloatValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientNullableFloatValues to be used by the proxy service + * to perform REST calls. + */ + @ServiceInterface(name = "DictionaryClientNull", host = "{endpoint}") + public interface NullableFloatValuesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/dictionary/nullable-float", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/dictionary/nullable-float", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: Double (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: Double (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/RecursiveModelValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/RecursiveModelValuesImpl.java new file mode 100644 index 0000000000..268f34698d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/RecursiveModelValuesImpl.java @@ -0,0 +1,119 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; +import type.dictionary.InnerModel; + +/** + * An instance of this class provides access to all the operations defined in RecursiveModelValues. + */ +public final class RecursiveModelValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RecursiveModelValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of RecursiveModelValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + RecursiveModelValuesImpl(DictionaryClientImpl client) { + this.service = RestProxy.create(RecursiveModelValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientRecursiveModelValues to be used by the proxy service + * to perform REST calls. + */ + @ServiceInterface(name = "DictionaryClientRecu", host = "{endpoint}") + public interface RecursiveModelValuesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/dictionary/model/recursive", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/dictionary/model/recursive", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String (Required): {
+     *         property: String (Required)
+     *         children (Optional): {
+     *             String (Required): (recursive schema, see String above)
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/StringValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/StringValuesImpl.java new file mode 100644 index 0000000000..c6b8c1bab5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/StringValuesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; + +/** + * An instance of this class provides access to all the operations defined in StringValues. + */ +public final class StringValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of StringValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringValuesImpl(DictionaryClientImpl client) { + this.service = RestProxy.create(StringValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientStringValues to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "DictionaryClientStri", host = "{endpoint}") + public interface StringValuesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/dictionary/string", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/dictionary/string", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/UnknownValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/UnknownValuesImpl.java new file mode 100644 index 0000000000..174146d75e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/UnknownValuesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.dictionary.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; + +/** + * An instance of this class provides access to all the operations defined in UnknownValues. + */ +public final class UnknownValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnknownValuesService service; + + /** + * The service client containing this operation class. + */ + private final DictionaryClientImpl client; + + /** + * Initializes an instance of UnknownValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnknownValuesImpl(DictionaryClientImpl client) { + this.service = RestProxy.create(UnknownValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for DictionaryClientUnknownValues to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "DictionaryClientUnkn", host = "{endpoint}") + public interface UnknownValuesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/dictionary/unknown", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/dictionary/unknown", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: Object (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     String: Object (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/package-info.java new file mode 100644 index 0000000000..00a8f9de44 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Dictionary. + * Illustrates various of dictionaries. + */ +package type.dictionary.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/package-info.java new file mode 100644 index 0000000000..fff9dff84d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/dictionary/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Dictionary. + * Illustrates various of dictionaries. + */ +package type.dictionary; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/DaysOfWeekExtensibleEnum.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/DaysOfWeekExtensibleEnum.java new file mode 100644 index 0000000000..5d80480ef6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/DaysOfWeekExtensibleEnum.java @@ -0,0 +1,123 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.enums.extensible; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.util.ExpandableEnum; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; + +/** + * Days of the week. + */ +public final class DaysOfWeekExtensibleEnum implements ExpandableEnum { + private static final Map VALUES = new ConcurrentHashMap<>(); + + private static final Function NEW_INSTANCE = DaysOfWeekExtensibleEnum::new; + + /** + * Monday. + */ + @Metadata(generated = true) + public static final DaysOfWeekExtensibleEnum MONDAY = fromValue("Monday"); + + /** + * Tuesday. + */ + @Metadata(generated = true) + public static final DaysOfWeekExtensibleEnum TUESDAY = fromValue("Tuesday"); + + /** + * Wednesday. + */ + @Metadata(generated = true) + public static final DaysOfWeekExtensibleEnum WEDNESDAY = fromValue("Wednesday"); + + /** + * Thursday. + */ + @Metadata(generated = true) + public static final DaysOfWeekExtensibleEnum THURSDAY = fromValue("Thursday"); + + /** + * Friday. + */ + @Metadata(generated = true) + public static final DaysOfWeekExtensibleEnum FRIDAY = fromValue("Friday"); + + /** + * Saturday. + */ + @Metadata(generated = true) + public static final DaysOfWeekExtensibleEnum SATURDAY = fromValue("Saturday"); + + /** + * Sunday. + */ + @Metadata(generated = true) + public static final DaysOfWeekExtensibleEnum SUNDAY = fromValue("Sunday"); + + private final String value; + + private DaysOfWeekExtensibleEnum(String value) { + this.value = value; + } + + /** + * Creates or finds a DaysOfWeekExtensibleEnum. + * + * @param value a value to look for. + * @return the corresponding DaysOfWeekExtensibleEnum. + * @throws IllegalArgumentException if value is null. + */ + @Metadata(generated = true) + public static DaysOfWeekExtensibleEnum fromValue(String value) { + if (value == null) { + throw new IllegalArgumentException("'value' cannot be null."); + } + return VALUES.computeIfAbsent(value, NEW_INSTANCE); + } + + /** + * Gets known DaysOfWeekExtensibleEnum values. + * + * @return Known DaysOfWeekExtensibleEnum values. + */ + @Metadata(generated = true) + public static Collection values() { + return new ArrayList<>(VALUES.values()); + } + + /** + * Gets the value of the DaysOfWeekExtensibleEnum instance. + * + * @return the value of the DaysOfWeekExtensibleEnum instance. + */ + @Metadata(generated = true) + @Override + public String getValue() { + return this.value; + } + + @Metadata(generated = true) + @Override + public String toString() { + return Objects.toString(this.value); + } + + @Metadata(generated = true) + @Override + public boolean equals(Object obj) { + return this == obj; + } + + @Metadata(generated = true) + @Override + public int hashCode() { + return Objects.hashCode(this.value); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/ExtensibleClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/ExtensibleClient.java new file mode 100644 index 0000000000..c1af1d7ebe --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/ExtensibleClient.java @@ -0,0 +1,168 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.enums.extensible; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.enums.extensible.implementation.StringOperationsImpl; + +/** + * Initializes a new instance of the synchronous ExtensibleClient type. + */ +@ServiceClient(builder = ExtensibleClientBuilder.class) +public final class ExtensibleClient { + @Metadata(generated = true) + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of ExtensibleClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ExtensibleClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getKnownValue operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * String(Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return days of the week. + */ + @Metadata(generated = true) + public Response getKnownValueWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getKnownValueWithResponse(requestOptions); + } + + /** + * The getUnknownValue operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * String(Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return days of the week. + */ + @Metadata(generated = true) + public Response getUnknownValueWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getUnknownValueWithResponse(requestOptions); + } + + /** + * The putKnownValue operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * String(Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putKnownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putKnownValueWithResponse(body, requestOptions); + } + + /** + * The putUnknownValue operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * String(Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putUnknownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putUnknownValueWithResponse(body, requestOptions); + } + + /** + * The getKnownValue operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return days of the week. + */ + @Metadata(generated = true) + public DaysOfWeekExtensibleEnum getKnownValue() { + // Generated convenience method for getKnownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getKnownValueWithResponse(requestOptions).getValue(); + } + + /** + * The getUnknownValue operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return days of the week. + */ + @Metadata(generated = true) + public DaysOfWeekExtensibleEnum getUnknownValue() { + // Generated convenience method for getUnknownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getUnknownValueWithResponse(requestOptions).getValue(); + } + + /** + * The putKnownValue operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putKnownValue(DaysOfWeekExtensibleEnum body) { + // Generated convenience method for putKnownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + putKnownValueWithResponse(BinaryData.fromObject(body == null ? null : body.getValue()), requestOptions) + .getValue(); + } + + /** + * The putUnknownValue operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putUnknownValue(DaysOfWeekExtensibleEnum body) { + // Generated convenience method for putUnknownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + putUnknownValueWithResponse(BinaryData.fromObject(body == null ? null : body.getValue()), requestOptions) + .getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/ExtensibleClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/ExtensibleClientBuilder.java new file mode 100644 index 0000000000..d4b0983950 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/ExtensibleClientBuilder.java @@ -0,0 +1,241 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.enums.extensible; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.enums.extensible.implementation.ExtensibleClientImpl; + +/** + * A builder for creating a new instance of the ExtensibleClient type. + */ +@ServiceClientBuilder(serviceClients = { ExtensibleClient.class }) +public final class ExtensibleClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the ExtensibleClientBuilder. + */ + @Metadata(generated = true) + public ExtensibleClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ExtensibleClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ExtensibleClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ExtensibleClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ExtensibleClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ExtensibleClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ExtensibleClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ExtensibleClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ExtensibleClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ExtensibleClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of ExtensibleClientImpl with the provided parameters. + * + * @return an instance of ExtensibleClientImpl. + */ + @Metadata(generated = true) + private ExtensibleClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ExtensibleClientImpl client = new ExtensibleClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of ExtensibleClient class. + * + * @return an instance of ExtensibleClient. + */ + @Metadata(generated = true) + public ExtensibleClient buildExtensibleClient() { + return new ExtensibleClient(buildInnerClient().getStringOperations()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ExtensibleClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/implementation/ExtensibleClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/implementation/ExtensibleClientImpl.java new file mode 100644 index 0000000000..10dfffe731 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/implementation/ExtensibleClientImpl.java @@ -0,0 +1,64 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.enums.extensible.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the ExtensibleClient type. + */ +public final class ExtensibleClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 StringOperationsImpl object to access its operations. + */ + private final StringOperationsImpl stringOperations; + + /** + * Gets the StringOperationsImpl object to access its operations. + * + * @return the StringOperationsImpl object. + */ + public StringOperationsImpl getStringOperations() { + return this.stringOperations; + } + + /** + * Initializes an instance of ExtensibleClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public ExtensibleClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.stringOperations = new StringOperationsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/implementation/StringOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/implementation/StringOperationsImpl.java new file mode 100644 index 0000000000..b0b2ec9145 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/implementation/StringOperationsImpl.java @@ -0,0 +1,161 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.enums.extensible.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.enums.extensible.DaysOfWeekExtensibleEnum; + +/** + * An instance of this class provides access to all the operations defined in StringOperations. + */ +public final class StringOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringOperationsService service; + + /** + * The service client containing this operation class. + */ + private final ExtensibleClientImpl client; + + /** + * Initializes an instance of StringOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringOperationsImpl(ExtensibleClientImpl client) { + this.service = RestProxy.create(StringOperationsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ExtensibleClientStringOperations to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ExtensibleClientStri", host = "{endpoint}") + public interface StringOperationsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/enum/extensible/string/known-value", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getKnownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/enum/extensible/string/unknown-value", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getUnknownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/enum/extensible/string/known-value", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putKnownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/enum/extensible/string/unknown-value", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putUnknownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * The getKnownValue operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * String(Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return days of the week. + */ + public Response getKnownValueWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getKnownValueSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The getUnknownValue operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * String(Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return days of the week. + */ + public Response getUnknownValueWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getUnknownValueSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The putKnownValue operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * String(Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putKnownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putKnownValueSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The putUnknownValue operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * String(Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putUnknownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putUnknownValueSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/implementation/package-info.java new file mode 100644 index 0000000000..1128779ec1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/implementation/package-info.java @@ -0,0 +1,6 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Extensible. + */ +package type.enums.extensible.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/package-info.java new file mode 100644 index 0000000000..883e743b6d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/extensible/package-info.java @@ -0,0 +1,6 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Extensible. + */ +package type.enums.extensible; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/DaysOfWeekEnum.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/DaysOfWeekEnum.java new file mode 100644 index 0000000000..1fe4c405aa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/DaysOfWeekEnum.java @@ -0,0 +1,79 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.enums.fixed; + +/** + * Days of the week. + */ +public enum DaysOfWeekEnum { + /** + * Monday. + */ + MONDAY("Monday"), + + /** + * Tuesday. + */ + TUESDAY("Tuesday"), + + /** + * Wednesday. + */ + WEDNESDAY("Wednesday"), + + /** + * Thursday. + */ + THURSDAY("Thursday"), + + /** + * Friday. + */ + FRIDAY("Friday"), + + /** + * Saturday. + */ + SATURDAY("Saturday"), + + /** + * Sunday. + */ + SUNDAY("Sunday"); + + /** + * The actual serialized value for a DaysOfWeekEnum instance. + */ + private final String value; + + DaysOfWeekEnum(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a DaysOfWeekEnum instance. + * + * @param value the serialized value to parse. + * @return the parsed DaysOfWeekEnum object, or null if unable to parse. + */ + public static DaysOfWeekEnum fromString(String value) { + if (value == null) { + return null; + } + DaysOfWeekEnum[] items = DaysOfWeekEnum.values(); + for (DaysOfWeekEnum item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/FixedClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/FixedClient.java new file mode 100644 index 0000000000..54dccf71fa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/FixedClient.java @@ -0,0 +1,135 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.enums.fixed; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.enums.fixed.implementation.StringOperationsImpl; + +/** + * Initializes a new instance of the synchronous FixedClient type. + */ +@ServiceClient(builder = FixedClientBuilder.class) +public final class FixedClient { + @Metadata(generated = true) + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of FixedClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + FixedClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * getKnownValue. + *

Response Body Schema

+ * + *
+     * {@code
+     * String(Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return days of the week. + */ + @Metadata(generated = true) + public Response getKnownValueWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getKnownValueWithResponse(requestOptions); + } + + /** + * putKnownValue. + *

Request Body Schema

+ * + *
+     * {@code
+     * String(Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
+     * }
+     * 
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putKnownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putKnownValueWithResponse(body, requestOptions); + } + + /** + * putUnknownValue. + *

Request Body Schema

+ * + *
+     * {@code
+     * String(Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
+     * }
+     * 
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putUnknownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putUnknownValueWithResponse(body, requestOptions); + } + + /** + * getKnownValue. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return days of the week. + */ + @Metadata(generated = true) + public DaysOfWeekEnum getKnownValue() { + // Generated convenience method for getKnownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getKnownValueWithResponse(requestOptions).getValue(); + } + + /** + * putKnownValue. + * + * @param body _. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putKnownValue(DaysOfWeekEnum body) { + // Generated convenience method for putKnownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + putKnownValueWithResponse(BinaryData.fromObject(body == null ? null : body.toString()), requestOptions) + .getValue(); + } + + /** + * putUnknownValue. + * + * @param body _. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putUnknownValue(DaysOfWeekEnum body) { + // Generated convenience method for putUnknownValueWithResponse + RequestOptions requestOptions = new RequestOptions(); + putUnknownValueWithResponse(BinaryData.fromObject(body == null ? null : body.toString()), requestOptions) + .getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/FixedClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/FixedClientBuilder.java new file mode 100644 index 0000000000..653d5ddbd9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/FixedClientBuilder.java @@ -0,0 +1,240 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.enums.fixed; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.enums.fixed.implementation.FixedClientImpl; + +/** + * A builder for creating a new instance of the FixedClient type. + */ +@ServiceClientBuilder(serviceClients = { FixedClient.class }) +public final class FixedClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the FixedClientBuilder. + */ + @Metadata(generated = true) + public FixedClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public FixedClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public FixedClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public FixedClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public FixedClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public FixedClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public FixedClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public FixedClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public FixedClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public FixedClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of FixedClientImpl with the provided parameters. + * + * @return an instance of FixedClientImpl. + */ + @Metadata(generated = true) + private FixedClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + FixedClientImpl client = new FixedClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of FixedClient class. + * + * @return an instance of FixedClient. + */ + @Metadata(generated = true) + public FixedClient buildFixedClient() { + return new FixedClient(buildInnerClient().getStringOperations()); + } + + private static final ClientLogger LOGGER = new ClientLogger(FixedClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/implementation/FixedClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/implementation/FixedClientImpl.java new file mode 100644 index 0000000000..6d3bf50e90 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/implementation/FixedClientImpl.java @@ -0,0 +1,64 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.enums.fixed.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the FixedClient type. + */ +public final class FixedClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 StringOperationsImpl object to access its operations. + */ + private final StringOperationsImpl stringOperations; + + /** + * Gets the StringOperationsImpl object to access its operations. + * + * @return the StringOperationsImpl object. + */ + public StringOperationsImpl getStringOperations() { + return this.stringOperations; + } + + /** + * Initializes an instance of FixedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public FixedClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.stringOperations = new StringOperationsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/implementation/StringOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/implementation/StringOperationsImpl.java new file mode 100644 index 0000000000..1ed2fbbda8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/implementation/StringOperationsImpl.java @@ -0,0 +1,134 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.enums.fixed.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.enums.fixed.DaysOfWeekEnum; + +/** + * An instance of this class provides access to all the operations defined in StringOperations. + */ +public final class StringOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringOperationsService service; + + /** + * The service client containing this operation class. + */ + private final FixedClientImpl client; + + /** + * Initializes an instance of StringOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringOperationsImpl(FixedClientImpl client) { + this.service = RestProxy.create(StringOperationsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for FixedClientStringOperations to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "FixedClientStringOpe", host = "{endpoint}") + public interface StringOperationsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/enum/fixed/string/known-value", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getKnownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/enum/fixed/string/known-value", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putKnownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/enum/fixed/string/unknown-value", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putUnknownValueSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * getKnownValue. + *

Response Body Schema

+ * + *
+     * {@code
+     * String(Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return days of the week. + */ + public Response getKnownValueWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getKnownValueSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * putKnownValue. + *

Request Body Schema

+ * + *
+     * {@code
+     * String(Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
+     * }
+     * 
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putKnownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putKnownValueSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * putUnknownValue. + *

Request Body Schema

+ * + *
+     * {@code
+     * String(Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
+     * }
+     * 
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putUnknownValueWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putUnknownValueSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/implementation/package-info.java new file mode 100644 index 0000000000..c7b6dae4b6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/implementation/package-info.java @@ -0,0 +1,6 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Fixed. + */ +package type.enums.fixed.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/package-info.java new file mode 100644 index 0000000000..adec0cfe9d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/enums/fixed/package-info.java @@ -0,0 +1,6 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Fixed. + */ +package type.enums.fixed; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyClient.java new file mode 100644 index 0000000000..243344e36f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyClient.java @@ -0,0 +1,146 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.empty; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.model.empty.implementation.EmptyClientImpl; + +/** + * Initializes a new instance of the synchronous EmptyClient type. + */ +@ServiceClient(builder = EmptyClientBuilder.class) +public final class EmptyClient { + @Metadata(generated = true) + private final EmptyClientImpl serviceClient; + + /** + * Initializes an instance of EmptyClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + EmptyClient(EmptyClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The putEmpty operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putEmptyWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putEmptyWithResponse(input, requestOptions); + } + + /** + * The getEmpty operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return empty model used in operation return type. + */ + @Metadata(generated = true) + public Response getEmptyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getEmptyWithResponse(requestOptions); + } + + /** + * The postRoundTripEmpty operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return empty model used in both parameter and return type. + */ + @Metadata(generated = true) + public Response postRoundTripEmptyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.postRoundTripEmptyWithResponse(body, requestOptions); + } + + /** + * The putEmpty operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putEmpty(EmptyInput input) { + // Generated convenience method for putEmptyWithResponse + RequestOptions requestOptions = new RequestOptions(); + putEmptyWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The getEmpty operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return empty model used in operation return type. + */ + @Metadata(generated = true) + public EmptyOutput getEmpty() { + // Generated convenience method for getEmptyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getEmptyWithResponse(requestOptions).getValue(); + } + + /** + * The postRoundTripEmpty operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return empty model used in both parameter and return type. + */ + @Metadata(generated = true) + public EmptyInputOutput postRoundTripEmpty(EmptyInputOutput body) { + // Generated convenience method for postRoundTripEmptyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return postRoundTripEmptyWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyClientBuilder.java new file mode 100644 index 0000000000..dde3e5be94 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyClientBuilder.java @@ -0,0 +1,240 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.empty; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.model.empty.implementation.EmptyClientImpl; + +/** + * A builder for creating a new instance of the EmptyClient type. + */ +@ServiceClientBuilder(serviceClients = { EmptyClient.class }) +public final class EmptyClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the EmptyClientBuilder. + */ + @Metadata(generated = true) + public EmptyClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EmptyClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EmptyClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EmptyClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EmptyClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EmptyClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EmptyClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EmptyClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EmptyClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EmptyClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of EmptyClientImpl with the provided parameters. + * + * @return an instance of EmptyClientImpl. + */ + @Metadata(generated = true) + private EmptyClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + EmptyClientImpl client = new EmptyClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of EmptyClient class. + * + * @return an instance of EmptyClient. + */ + @Metadata(generated = true) + public EmptyClient buildClient() { + return new EmptyClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(EmptyClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyInput.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyInput.java new file mode 100644 index 0000000000..cff897aef1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyInput.java @@ -0,0 +1,57 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.empty; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Empty model used in operation parameters. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class EmptyInput implements JsonSerializable { + /** + * Creates an instance of EmptyInput class. + */ + @Metadata(generated = true) + public EmptyInput() { + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EmptyInput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EmptyInput if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IOException If an error occurs while reading the EmptyInput. + */ + @Metadata(generated = true) + public static EmptyInput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EmptyInput deserializedEmptyInput = new EmptyInput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedEmptyInput; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyInputOutput.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyInputOutput.java new file mode 100644 index 0000000000..e0b2f847e7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyInputOutput.java @@ -0,0 +1,57 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.empty; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Empty model used in both parameter and return type. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class EmptyInputOutput implements JsonSerializable { + /** + * Creates an instance of EmptyInputOutput class. + */ + @Metadata(generated = true) + public EmptyInputOutput() { + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EmptyInputOutput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EmptyInputOutput if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the EmptyInputOutput. + */ + @Metadata(generated = true) + public static EmptyInputOutput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EmptyInputOutput deserializedEmptyInputOutput = new EmptyInputOutput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedEmptyInputOutput; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyOutput.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyOutput.java new file mode 100644 index 0000000000..3441d177b8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/EmptyOutput.java @@ -0,0 +1,57 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.empty; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Empty model used in operation return type. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class EmptyOutput implements JsonSerializable { + /** + * Creates an instance of EmptyOutput class. + */ + @Metadata(generated = true) + private EmptyOutput() { + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EmptyOutput from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EmptyOutput if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the EmptyOutput. + */ + @Metadata(generated = true) + public static EmptyOutput fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EmptyOutput deserializedEmptyOutput = new EmptyOutput(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedEmptyOutput; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/implementation/EmptyClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/implementation/EmptyClientImpl.java new file mode 100644 index 0000000000..c3a2eae6c0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/implementation/EmptyClientImpl.java @@ -0,0 +1,173 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.empty.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.util.binarydata.BinaryData; +import type.model.empty.EmptyInputOutput; +import type.model.empty.EmptyOutput; + +/** + * Initializes a new instance of the EmptyClient type. + */ +public final class EmptyClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final EmptyClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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; + } + + /** + * Initializes an instance of EmptyClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public EmptyClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(EmptyClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for EmptyClient to be used by the proxy service to perform REST calls. + */ + @ServiceInterface(name = "EmptyClient", host = "{endpoint}") + public interface EmptyClientService { + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/model/empty/alone", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putEmptySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/empty/alone", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getEmptySync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/type/model/empty/round-trip", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response postRoundTripEmptySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The putEmpty operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putEmptyWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putEmptySync(this.getEndpoint(), contentType, input, requestOptions); + } + + /** + * The getEmpty operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return empty model used in operation return type. + */ + public Response getEmptyWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getEmptySync(this.getEndpoint(), accept, requestOptions); + } + + /** + * The postRoundTripEmpty operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return empty model used in both parameter and return type. + */ + public Response postRoundTripEmptyWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.postRoundTripEmptySync(this.getEndpoint(), contentType, accept, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/implementation/package-info.java new file mode 100644 index 0000000000..082706a5b1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Empty. + * Illustrates usage of empty model used in operation's parameters and responses. + */ +package type.model.empty.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/package-info.java new file mode 100644 index 0000000000..9bb760dc94 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/empty/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Empty. + * Illustrates usage of empty model used in operation's parameters and responses. + */ +package type.model.empty; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/Cobra.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/Cobra.java new file mode 100644 index 0000000000..5dd634f6ff --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/Cobra.java @@ -0,0 +1,88 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.enumdiscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Cobra model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Cobra extends Snake { + /* + * discriminator property + */ + @Metadata(generated = true) + private SnakeKind kind = SnakeKind.COBRA; + + /** + * Creates an instance of Cobra class. + * + * @param length the length value to set. + */ + @Metadata(generated = true) + public Cobra(int length) { + super(length); + } + + /** + * Get the kind property: discriminator property. + * + * @return the kind value. + */ + @Metadata(generated = true) + @Override + public SnakeKind getKind() { + return this.kind; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("length", getLength()); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Cobra from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Cobra 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 Cobra. + */ + @Metadata(generated = true) + public static Cobra fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int length = 0; + SnakeKind kind = SnakeKind.COBRA; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("length".equals(fieldName)) { + length = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = SnakeKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + Cobra deserializedCobra = new Cobra(length); + deserializedCobra.kind = kind; + + return deserializedCobra; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/Dog.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/Dog.java new file mode 100644 index 0000000000..f16c5739c3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/Dog.java @@ -0,0 +1,130 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.enumdiscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Test extensible enum type for discriminator. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public class Dog implements JsonSerializable { + /* + * discriminator property + */ + @Metadata(generated = true) + private DogKind kind = DogKind.fromValue("Dog"); + + /* + * Weight of the dog + */ + @Metadata(generated = true) + private final int weight; + + /** + * Creates an instance of Dog class. + * + * @param weight the weight value to set. + */ + @Metadata(generated = true) + public Dog(int weight) { + this.weight = weight; + } + + /** + * Get the kind property: discriminator property. + * + * @return the kind value. + */ + @Metadata(generated = true) + public DogKind getKind() { + return this.kind; + } + + /** + * Get the weight property: Weight of the dog. + * + * @return the weight value. + */ + @Metadata(generated = true) + public int getWeight() { + return this.weight; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("weight", this.weight); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.getValue()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Dog from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Dog 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 Dog. + */ + @Metadata(generated = true) + public static Dog 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 ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("golden".equals(discriminatorValue)) { + return Golden.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Metadata(generated = true) + static Dog fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int weight = 0; + DogKind kind = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("weight".equals(fieldName)) { + weight = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = DogKind.fromValue(reader.getString()); + } else { + reader.skipChildren(); + } + } + Dog deserializedDog = new Dog(weight); + deserializedDog.kind = kind; + + return deserializedDog; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/DogKind.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/DogKind.java new file mode 100644 index 0000000000..cfacb73911 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/DogKind.java @@ -0,0 +1,87 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.enumdiscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.util.ExpandableEnum; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; + +/** + * extensible enum type for discriminator. + */ +public final class DogKind implements ExpandableEnum { + private static final Map VALUES = new ConcurrentHashMap<>(); + + private static final Function NEW_INSTANCE = DogKind::new; + + /** + * Species golden. + */ + @Metadata(generated = true) + public static final DogKind GOLDEN = fromValue("golden"); + + private final String value; + + private DogKind(String value) { + this.value = value; + } + + /** + * Creates or finds a DogKind. + * + * @param value a value to look for. + * @return the corresponding DogKind. + * @throws IllegalArgumentException if value is null. + */ + @Metadata(generated = true) + public static DogKind fromValue(String value) { + if (value == null) { + throw new IllegalArgumentException("'value' cannot be null."); + } + return VALUES.computeIfAbsent(value, NEW_INSTANCE); + } + + /** + * Gets known DogKind values. + * + * @return Known DogKind values. + */ + @Metadata(generated = true) + public static Collection values() { + return new ArrayList<>(VALUES.values()); + } + + /** + * Gets the value of the DogKind instance. + * + * @return the value of the DogKind instance. + */ + @Metadata(generated = true) + @Override + public String getValue() { + return this.value; + } + + @Metadata(generated = true) + @Override + public String toString() { + return Objects.toString(this.value); + } + + @Metadata(generated = true) + @Override + public boolean equals(Object obj) { + return this == obj; + } + + @Metadata(generated = true) + @Override + public int hashCode() { + return Objects.hashCode(this.value); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClient.java new file mode 100644 index 0000000000..885ebcd508 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClient.java @@ -0,0 +1,322 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.enumdiscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.model.inheritance.enumdiscriminator.implementation.EnumDiscriminatorClientImpl; + +/** + * Initializes a new instance of the synchronous EnumDiscriminatorClient type. + */ +@ServiceClient(builder = EnumDiscriminatorClientBuilder.class) +public final class EnumDiscriminatorClient { + @Metadata(generated = true) + private final EnumDiscriminatorClientImpl serviceClient; + + /** + * Initializes an instance of EnumDiscriminatorClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + EnumDiscriminatorClient(EnumDiscriminatorClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Receive model with extensible enum discriminator type. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return test extensible enum type for discriminator. + */ + @Metadata(generated = true) + public Response getExtensibleModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getExtensibleModelWithResponse(requestOptions); + } + + /** + * Send model with extensible enum discriminator type. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input Dog to create. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putExtensibleModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putExtensibleModelWithResponse(input, requestOptions); + } + + /** + * Get a model omitting the discriminator. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a model omitting the discriminator. + */ + @Metadata(generated = true) + public Response getExtensibleModelMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getExtensibleModelMissingDiscriminatorWithResponse(requestOptions); + } + + /** + * Get a model containing discriminator value never defined. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a model containing discriminator value never defined. + */ + @Metadata(generated = true) + public Response getExtensibleModelWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getExtensibleModelWrongDiscriminatorWithResponse(requestOptions); + } + + /** + * Receive model with fixed enum discriminator type. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return test fixed enum type for discriminator. + */ + @Metadata(generated = true) + public Response getFixedModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getFixedModelWithResponse(requestOptions); + } + + /** + * Send model with fixed enum discriminator type. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input Snake to create. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putFixedModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putFixedModelWithResponse(input, requestOptions); + } + + /** + * Get a model omitting the discriminator. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a model omitting the discriminator. + */ + @Metadata(generated = true) + public Response getFixedModelMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getFixedModelMissingDiscriminatorWithResponse(requestOptions); + } + + /** + * Get a model containing discriminator value never defined. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a model containing discriminator value never defined. + */ + @Metadata(generated = true) + public Response getFixedModelWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getFixedModelWrongDiscriminatorWithResponse(requestOptions); + } + + /** + * Receive model with extensible enum discriminator type. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return test extensible enum type for discriminator. + */ + @Metadata(generated = true) + public Dog getExtensibleModel() { + // Generated convenience method for getExtensibleModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getExtensibleModelWithResponse(requestOptions).getValue(); + } + + /** + * Send model with extensible enum discriminator type. + * + * @param input Dog to create. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putExtensibleModel(Dog input) { + // Generated convenience method for putExtensibleModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putExtensibleModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * Get a model omitting the discriminator. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a model omitting the discriminator. + */ + @Metadata(generated = true) + public Dog getExtensibleModelMissingDiscriminator() { + // Generated convenience method for getExtensibleModelMissingDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getExtensibleModelMissingDiscriminatorWithResponse(requestOptions).getValue(); + } + + /** + * Get a model containing discriminator value never defined. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a model containing discriminator value never defined. + */ + @Metadata(generated = true) + public Dog getExtensibleModelWrongDiscriminator() { + // Generated convenience method for getExtensibleModelWrongDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getExtensibleModelWrongDiscriminatorWithResponse(requestOptions).getValue(); + } + + /** + * Receive model with fixed enum discriminator type. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return test fixed enum type for discriminator. + */ + @Metadata(generated = true) + public Snake getFixedModel() { + // Generated convenience method for getFixedModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getFixedModelWithResponse(requestOptions).getValue(); + } + + /** + * Send model with fixed enum discriminator type. + * + * @param input Snake to create. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putFixedModel(Snake input) { + // Generated convenience method for putFixedModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putFixedModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * Get a model omitting the discriminator. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a model omitting the discriminator. + */ + @Metadata(generated = true) + public Snake getFixedModelMissingDiscriminator() { + // Generated convenience method for getFixedModelMissingDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getFixedModelMissingDiscriminatorWithResponse(requestOptions).getValue(); + } + + /** + * Get a model containing discriminator value never defined. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a model containing discriminator value never defined. + */ + @Metadata(generated = true) + public Snake getFixedModelWrongDiscriminator() { + // Generated convenience method for getFixedModelWrongDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getFixedModelWrongDiscriminatorWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClientBuilder.java new file mode 100644 index 0000000000..34f5371061 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/EnumDiscriminatorClientBuilder.java @@ -0,0 +1,241 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.enumdiscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.model.inheritance.enumdiscriminator.implementation.EnumDiscriminatorClientImpl; + +/** + * A builder for creating a new instance of the EnumDiscriminatorClient type. + */ +@ServiceClientBuilder(serviceClients = { EnumDiscriminatorClient.class }) +public final class EnumDiscriminatorClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the EnumDiscriminatorClientBuilder. + */ + @Metadata(generated = true) + public EnumDiscriminatorClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EnumDiscriminatorClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EnumDiscriminatorClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EnumDiscriminatorClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EnumDiscriminatorClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EnumDiscriminatorClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EnumDiscriminatorClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EnumDiscriminatorClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EnumDiscriminatorClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public EnumDiscriminatorClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of EnumDiscriminatorClientImpl with the provided parameters. + * + * @return an instance of EnumDiscriminatorClientImpl. + */ + @Metadata(generated = true) + private EnumDiscriminatorClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + EnumDiscriminatorClientImpl client = new EnumDiscriminatorClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of EnumDiscriminatorClient class. + * + * @return an instance of EnumDiscriminatorClient. + */ + @Metadata(generated = true) + public EnumDiscriminatorClient buildClient() { + return new EnumDiscriminatorClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(EnumDiscriminatorClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/Golden.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/Golden.java new file mode 100644 index 0000000000..7182989666 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/Golden.java @@ -0,0 +1,88 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.enumdiscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Golden dog model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Golden extends Dog { + /* + * discriminator property + */ + @Metadata(generated = true) + private DogKind kind = DogKind.GOLDEN; + + /** + * Creates an instance of Golden class. + * + * @param weight the weight value to set. + */ + @Metadata(generated = true) + public Golden(int weight) { + super(weight); + } + + /** + * Get the kind property: discriminator property. + * + * @return the kind value. + */ + @Metadata(generated = true) + @Override + public DogKind getKind() { + return this.kind; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("weight", getWeight()); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.getValue()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Golden from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Golden 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 Golden. + */ + @Metadata(generated = true) + public static Golden fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int weight = 0; + DogKind kind = DogKind.GOLDEN; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("weight".equals(fieldName)) { + weight = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = DogKind.fromValue(reader.getString()); + } else { + reader.skipChildren(); + } + } + Golden deserializedGolden = new Golden(weight); + deserializedGolden.kind = kind; + + return deserializedGolden; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/Snake.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/Snake.java new file mode 100644 index 0000000000..b12a5cbe36 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/Snake.java @@ -0,0 +1,130 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.enumdiscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Test fixed enum type for discriminator. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public class Snake implements JsonSerializable { + /* + * discriminator property + */ + @Metadata(generated = true) + private SnakeKind kind; + + /* + * Length of the snake + */ + @Metadata(generated = true) + private final int length; + + /** + * Creates an instance of Snake class. + * + * @param length the length value to set. + */ + @Metadata(generated = true) + public Snake(int length) { + this.length = length; + } + + /** + * Get the kind property: discriminator property. + * + * @return the kind value. + */ + @Metadata(generated = true) + public SnakeKind getKind() { + return this.kind; + } + + /** + * Get the length property: Length of the snake. + * + * @return the length value. + */ + @Metadata(generated = true) + public int getLength() { + return this.length; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("length", this.length); + jsonWriter.writeStringField("kind", this.kind == null ? null : this.kind.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Snake from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Snake 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 Snake. + */ + @Metadata(generated = true) + public static Snake 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 ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("cobra".equals(discriminatorValue)) { + return Cobra.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Metadata(generated = true) + static Snake fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int length = 0; + SnakeKind kind = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("length".equals(fieldName)) { + length = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = SnakeKind.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + Snake deserializedSnake = new Snake(length); + deserializedSnake.kind = kind; + + return deserializedSnake; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/SnakeKind.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/SnakeKind.java new file mode 100644 index 0000000000..c6a2f11290 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/SnakeKind.java @@ -0,0 +1,49 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.enumdiscriminator; + +/** + * fixed enum type for discriminator. + */ +public enum SnakeKind { + /** + * Species cobra. + */ + COBRA("cobra"); + + /** + * The actual serialized value for a SnakeKind instance. + */ + private final String value; + + SnakeKind(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a SnakeKind instance. + * + * @param value the serialized value to parse. + * @return the parsed SnakeKind object, or null if unable to parse. + */ + public static SnakeKind fromString(String value) { + if (value == null) { + return null; + } + SnakeKind[] items = SnakeKind.values(); + for (SnakeKind item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/implementation/EnumDiscriminatorClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/implementation/EnumDiscriminatorClientImpl.java new file mode 100644 index 0000000000..db3c37a2c7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/implementation/EnumDiscriminatorClientImpl.java @@ -0,0 +1,320 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.enumdiscriminator.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.util.binarydata.BinaryData; +import type.model.inheritance.enumdiscriminator.Dog; +import type.model.inheritance.enumdiscriminator.Snake; + +/** + * Initializes a new instance of the EnumDiscriminatorClient type. + */ +public final class EnumDiscriminatorClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final EnumDiscriminatorClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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; + } + + /** + * Initializes an instance of EnumDiscriminatorClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public EnumDiscriminatorClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(EnumDiscriminatorClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for EnumDiscriminatorClient to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "EnumDiscriminatorCli", host = "{endpoint}") + public interface EnumDiscriminatorClientService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/enum-discriminator/extensible-enum", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getExtensibleModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/model/inheritance/enum-discriminator/extensible-enum", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putExtensibleModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/enum-discriminator/extensible-enum/missingdiscriminator", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getExtensibleModelMissingDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/enum-discriminator/extensible-enum/wrongdiscriminator", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getExtensibleModelWrongDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/enum-discriminator/fixed-enum", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getFixedModelSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/model/inheritance/enum-discriminator/fixed-enum", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putFixedModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/enum-discriminator/fixed-enum/missingdiscriminator", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getFixedModelMissingDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/enum-discriminator/fixed-enum/wrongdiscriminator", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getFixedModelWrongDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + } + + /** + * Receive model with extensible enum discriminator type. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return test extensible enum type for discriminator. + */ + public Response getExtensibleModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getExtensibleModelSync(this.getEndpoint(), accept, requestOptions); + } + + /** + * Send model with extensible enum discriminator type. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input Dog to create. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putExtensibleModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putExtensibleModelSync(this.getEndpoint(), contentType, input, requestOptions); + } + + /** + * Get a model omitting the discriminator. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a model omitting the discriminator. + */ + public Response getExtensibleModelMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getExtensibleModelMissingDiscriminatorSync(this.getEndpoint(), accept, requestOptions); + } + + /** + * Get a model containing discriminator value never defined. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(golden) (Required)
+     *     weight: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a model containing discriminator value never defined. + */ + public Response getExtensibleModelWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getExtensibleModelWrongDiscriminatorSync(this.getEndpoint(), accept, requestOptions); + } + + /** + * Receive model with fixed enum discriminator type. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return test fixed enum type for discriminator. + */ + public Response getFixedModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getFixedModelSync(this.getEndpoint(), accept, requestOptions); + } + + /** + * Send model with fixed enum discriminator type. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input Snake to create. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putFixedModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putFixedModelSync(this.getEndpoint(), contentType, input, requestOptions); + } + + /** + * Get a model omitting the discriminator. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a model omitting the discriminator. + */ + public Response getFixedModelMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getFixedModelMissingDiscriminatorSync(this.getEndpoint(), accept, requestOptions); + } + + /** + * Get a model containing discriminator value never defined. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String(cobra) (Required)
+     *     length: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a model containing discriminator value never defined. + */ + public Response getFixedModelWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getFixedModelWrongDiscriminatorSync(this.getEndpoint(), accept, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/implementation/package-info.java new file mode 100644 index 0000000000..cfdeff5098 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for EnumDiscriminator. + * Illustrates inheritance with enum discriminator. + */ +package type.model.inheritance.enumdiscriminator.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/package-info.java new file mode 100644 index 0000000000..621acc1dab --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/enumdiscriminator/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for EnumDiscriminator. + * Illustrates inheritance with enum discriminator. + */ +package type.model.inheritance.enumdiscriminator; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/Fish.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/Fish.java new file mode 100644 index 0000000000..b014b85b53 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/Fish.java @@ -0,0 +1,132 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.nesteddiscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * This is base model for polymorphic multiple levels inheritance with a discriminator. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public class Fish implements JsonSerializable { + /* + * Discriminator property for Fish. + */ + @Metadata(generated = true) + private String kind = "Fish"; + + /* + * The age property. + */ + @Metadata(generated = true) + private final int age; + + /** + * Creates an instance of Fish class. + * + * @param age the age value to set. + */ + @Metadata(generated = true) + public Fish(int age) { + this.age = age; + } + + /** + * Get the kind property: Discriminator property for Fish. + * + * @return the kind value. + */ + @Metadata(generated = true) + public String getKind() { + return this.kind; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + @Metadata(generated = true) + public int getAge() { + return this.age; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("age", this.age); + jsonWriter.writeStringField("kind", this.kind); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Fish from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Fish 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 Fish. + */ + @Metadata(generated = true) + public static Fish 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 ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("shark".equals(discriminatorValue)) { + return Shark.fromJson(readerToUse.reset()); + } else if ("salmon".equals(discriminatorValue)) { + return Salmon.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Metadata(generated = true) + static Fish fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int age = 0; + String kind = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + age = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + Fish deserializedFish = new Fish(age); + deserializedFish.kind = kind; + + return deserializedFish; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/GoblinShark.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/GoblinShark.java new file mode 100644 index 0000000000..a3d75a2dc9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/GoblinShark.java @@ -0,0 +1,106 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.nesteddiscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The third level model GoblinShark in polymorphic multiple levels inheritance. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class GoblinShark extends Shark { + /* + * Discriminator property for Fish. + */ + @Metadata(generated = true) + private String kind = "shark"; + + /* + * The sharktype property. + */ + @Metadata(generated = true) + private String sharktype = "goblin"; + + /** + * Creates an instance of GoblinShark class. + * + * @param age the age value to set. + */ + @Metadata(generated = true) + public GoblinShark(int age) { + super(age); + } + + /** + * Get the kind property: Discriminator property for Fish. + * + * @return the kind value. + */ + @Metadata(generated = true) + @Override + public String getKind() { + return this.kind; + } + + /** + * Get the sharktype property: The sharktype property. + * + * @return the sharktype value. + */ + @Metadata(generated = true) + @Override + public String getSharktype() { + return this.sharktype; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeIntField("age", getAge()); + jsonWriter.writeStringField("sharktype", this.sharktype); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GoblinShark from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GoblinShark 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 GoblinShark. + */ + @Metadata(generated = true) + public static GoblinShark fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int age = 0; + String sharktype = "goblin"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + age = reader.getInt(); + } else if ("sharktype".equals(fieldName)) { + sharktype = reader.getString(); + } else { + reader.skipChildren(); + } + } + GoblinShark deserializedGoblinShark = new GoblinShark(age); + deserializedGoblinShark.sharktype = sharktype; + + return deserializedGoblinShark; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClient.java new file mode 100644 index 0000000000..eb461313ec --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClient.java @@ -0,0 +1,250 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.nesteddiscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.model.inheritance.nesteddiscriminator.implementation.NestedDiscriminatorClientImpl; + +/** + * Initializes a new instance of the synchronous NestedDiscriminatorClient type. + */ +@ServiceClient(builder = NestedDiscriminatorClientBuilder.class) +public final class NestedDiscriminatorClient { + @Metadata(generated = true) + private final NestedDiscriminatorClientImpl serviceClient; + + /** + * Initializes an instance of NestedDiscriminatorClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + NestedDiscriminatorClient(NestedDiscriminatorClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @Metadata(generated = true) + public Response getModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getModelWithResponse(requestOptions); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putModelWithResponse(input, requestOptions); + } + + /** + * The getRecursiveModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @Metadata(generated = true) + public Response getRecursiveModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getRecursiveModelWithResponse(requestOptions); + } + + /** + * The putRecursiveModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putRecursiveModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putRecursiveModelWithResponse(input, requestOptions); + } + + /** + * The getMissingDiscriminator operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @Metadata(generated = true) + public Response getMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getMissingDiscriminatorWithResponse(requestOptions); + } + + /** + * The getWrongDiscriminator operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @Metadata(generated = true) + public Response getWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWrongDiscriminatorWithResponse(requestOptions); + } + + /** + * The getModel operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @Metadata(generated = true) + public Fish getModel() { + // Generated convenience method for getModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getModelWithResponse(requestOptions).getValue(); + } + + /** + * The putModel operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putModel(Fish input) { + // Generated convenience method for putModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The getRecursiveModel operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @Metadata(generated = true) + public Fish getRecursiveModel() { + // Generated convenience method for getRecursiveModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getRecursiveModelWithResponse(requestOptions).getValue(); + } + + /** + * The putRecursiveModel operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putRecursiveModel(Fish input) { + // Generated convenience method for putRecursiveModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putRecursiveModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The getMissingDiscriminator operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @Metadata(generated = true) + public Fish getMissingDiscriminator() { + // Generated convenience method for getMissingDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getMissingDiscriminatorWithResponse(requestOptions).getValue(); + } + + /** + * The getWrongDiscriminator operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + @Metadata(generated = true) + public Fish getWrongDiscriminator() { + // Generated convenience method for getWrongDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWrongDiscriminatorWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClientBuilder.java new file mode 100644 index 0000000000..1f6ed3bfaf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/NestedDiscriminatorClientBuilder.java @@ -0,0 +1,241 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.nesteddiscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.model.inheritance.nesteddiscriminator.implementation.NestedDiscriminatorClientImpl; + +/** + * A builder for creating a new instance of the NestedDiscriminatorClient type. + */ +@ServiceClientBuilder(serviceClients = { NestedDiscriminatorClient.class }) +public final class NestedDiscriminatorClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the NestedDiscriminatorClientBuilder. + */ + @Metadata(generated = true) + public NestedDiscriminatorClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NestedDiscriminatorClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NestedDiscriminatorClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NestedDiscriminatorClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NestedDiscriminatorClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NestedDiscriminatorClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NestedDiscriminatorClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NestedDiscriminatorClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NestedDiscriminatorClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NestedDiscriminatorClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of NestedDiscriminatorClientImpl with the provided parameters. + * + * @return an instance of NestedDiscriminatorClientImpl. + */ + @Metadata(generated = true) + private NestedDiscriminatorClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + NestedDiscriminatorClientImpl client = new NestedDiscriminatorClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of NestedDiscriminatorClient class. + * + * @return an instance of NestedDiscriminatorClient. + */ + @Metadata(generated = true) + public NestedDiscriminatorClient buildClient() { + return new NestedDiscriminatorClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(NestedDiscriminatorClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/Salmon.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/Salmon.java new file mode 100644 index 0000000000..86326500ef --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/Salmon.java @@ -0,0 +1,190 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.nesteddiscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * The second level model in polymorphic multiple levels inheritance which contains references to other polymorphic + * instances. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class Salmon extends Fish { + /* + * Discriminator property for Fish. + */ + @Metadata(generated = true) + private String kind = "salmon"; + + /* + * The friends property. + */ + @Metadata(generated = true) + private List friends; + + /* + * The hate property. + */ + @Metadata(generated = true) + private Map hate; + + /* + * The partner property. + */ + @Metadata(generated = true) + private Fish partner; + + /** + * Creates an instance of Salmon class. + * + * @param age the age value to set. + */ + @Metadata(generated = true) + public Salmon(int age) { + super(age); + } + + /** + * Get the kind property: Discriminator property for Fish. + * + * @return the kind value. + */ + @Metadata(generated = true) + @Override + public String getKind() { + return this.kind; + } + + /** + * Get the friends property: The friends property. + * + * @return the friends value. + */ + @Metadata(generated = true) + public List getFriends() { + return this.friends; + } + + /** + * Set the friends property: The friends property. + * + * @param friends the friends value to set. + * @return the Salmon object itself. + */ + @Metadata(generated = true) + public Salmon setFriends(List friends) { + this.friends = friends; + return this; + } + + /** + * Get the hate property: The hate property. + * + * @return the hate value. + */ + @Metadata(generated = true) + public Map getHate() { + return this.hate; + } + + /** + * Set the hate property: The hate property. + * + * @param hate the hate value to set. + * @return the Salmon object itself. + */ + @Metadata(generated = true) + public Salmon setHate(Map hate) { + this.hate = hate; + return this; + } + + /** + * Get the partner property: The partner property. + * + * @return the partner value. + */ + @Metadata(generated = true) + public Fish getPartner() { + return this.partner; + } + + /** + * Set the partner property: The partner property. + * + * @param partner the partner value to set. + * @return the Salmon object itself. + */ + @Metadata(generated = true) + public Salmon setPartner(Fish partner) { + this.partner = partner; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("age", getAge()); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeArrayField("friends", this.friends, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeMapField("hate", this.hate, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("partner", this.partner); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Salmon from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Salmon 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 Salmon. + */ + @Metadata(generated = true) + public static Salmon fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int age = 0; + String kind = "salmon"; + List friends = null; + Map hate = null; + Fish partner = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + age = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else if ("friends".equals(fieldName)) { + friends = reader.readArray(reader1 -> Fish.fromJson(reader1)); + } else if ("hate".equals(fieldName)) { + hate = reader.readMap(reader1 -> Fish.fromJson(reader1)); + } else if ("partner".equals(fieldName)) { + partner = Fish.fromJson(reader); + } else { + reader.skipChildren(); + } + } + Salmon deserializedSalmon = new Salmon(age); + deserializedSalmon.kind = kind; + deserializedSalmon.friends = friends; + deserializedSalmon.hate = hate; + deserializedSalmon.partner = partner; + + return deserializedSalmon; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/SawShark.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/SawShark.java new file mode 100644 index 0000000000..a15023e691 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/SawShark.java @@ -0,0 +1,106 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.nesteddiscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The third level model SawShark in polymorphic multiple levels inheritance. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SawShark extends Shark { + /* + * Discriminator property for Fish. + */ + @Metadata(generated = true) + private String kind = "shark"; + + /* + * The sharktype property. + */ + @Metadata(generated = true) + private String sharktype = "saw"; + + /** + * Creates an instance of SawShark class. + * + * @param age the age value to set. + */ + @Metadata(generated = true) + public SawShark(int age) { + super(age); + } + + /** + * Get the kind property: Discriminator property for Fish. + * + * @return the kind value. + */ + @Metadata(generated = true) + @Override + public String getKind() { + return this.kind; + } + + /** + * Get the sharktype property: The sharktype property. + * + * @return the sharktype value. + */ + @Metadata(generated = true) + @Override + public String getSharktype() { + return this.sharktype; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeIntField("age", getAge()); + jsonWriter.writeStringField("sharktype", this.sharktype); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SawShark from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SawShark 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 SawShark. + */ + @Metadata(generated = true) + public static SawShark fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int age = 0; + String sharktype = "saw"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + age = reader.getInt(); + } else if ("sharktype".equals(fieldName)) { + sharktype = reader.getString(); + } else { + reader.skipChildren(); + } + } + SawShark deserializedSawShark = new SawShark(age); + deserializedSawShark.sharktype = sharktype; + + return deserializedSawShark; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/Shark.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/Shark.java new file mode 100644 index 0000000000..dad1291a3a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/Shark.java @@ -0,0 +1,133 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.nesteddiscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The second level model in polymorphic multiple levels inheritance and it defines a new discriminator. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public class Shark extends Fish { + /* + * Discriminator property for Fish. + */ + @Metadata(generated = true) + private String kind = "shark"; + + /* + * The sharktype property. + */ + @Metadata(generated = true) + private String sharktype = "shark"; + + /** + * Creates an instance of Shark class. + * + * @param age the age value to set. + */ + @Metadata(generated = true) + public Shark(int age) { + super(age); + } + + /** + * Get the kind property: Discriminator property for Fish. + * + * @return the kind value. + */ + @Metadata(generated = true) + @Override + public String getKind() { + return this.kind; + } + + /** + * Get the sharktype property: The sharktype property. + * + * @return the sharktype value. + */ + @Metadata(generated = true) + public String getSharktype() { + return this.sharktype; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeIntField("age", getAge()); + jsonWriter.writeStringField("sharktype", this.sharktype); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Shark from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Shark 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 Shark. + */ + @Metadata(generated = true) + public static Shark 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 ("sharktype".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("saw".equals(discriminatorValue)) { + return SawShark.fromJson(readerToUse.reset()); + } else if ("goblin".equals(discriminatorValue)) { + return GoblinShark.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Metadata(generated = true) + static Shark fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int age = 0; + String sharktype = "shark"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("age".equals(fieldName)) { + age = reader.getInt(); + } else if ("sharktype".equals(fieldName)) { + sharktype = reader.getString(); + } else { + reader.skipChildren(); + } + } + Shark deserializedShark = new Shark(age); + deserializedShark.sharktype = sharktype; + + return deserializedShark; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/implementation/NestedDiscriminatorClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/implementation/NestedDiscriminatorClientImpl.java new file mode 100644 index 0000000000..3511fc97e1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/implementation/NestedDiscriminatorClientImpl.java @@ -0,0 +1,259 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.nesteddiscriminator.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.util.binarydata.BinaryData; +import type.model.inheritance.nesteddiscriminator.Fish; + +/** + * Initializes a new instance of the NestedDiscriminatorClient type. + */ +public final class NestedDiscriminatorClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NestedDiscriminatorClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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; + } + + /** + * Initializes an instance of NestedDiscriminatorClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public NestedDiscriminatorClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(NestedDiscriminatorClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for NestedDiscriminatorClient to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "NestedDiscriminatorC", host = "{endpoint}") + public interface NestedDiscriminatorClientService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/nested-discriminator/model", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getModelSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/model/inheritance/nested-discriminator/model", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/nested-discriminator/recursivemodel", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getRecursiveModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/model/inheritance/nested-discriminator/recursivemodel", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putRecursiveModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/nested-discriminator/missingdiscriminator", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getMissingDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/nested-discriminator/wrongdiscriminator", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getWrongDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + } + + /** + * The getModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + public Response getModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getModelSync(this.getEndpoint(), accept, requestOptions); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putModelSync(this.getEndpoint(), contentType, input, requestOptions); + } + + /** + * The getRecursiveModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + public Response getRecursiveModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getRecursiveModelSync(this.getEndpoint(), accept, requestOptions); + } + + /** + * The putRecursiveModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putRecursiveModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putRecursiveModelSync(this.getEndpoint(), contentType, input, requestOptions); + } + + /** + * The getMissingDiscriminator operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + public Response getMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getMissingDiscriminatorSync(this.getEndpoint(), accept, requestOptions); + } + + /** + * The getWrongDiscriminator operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     age: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return this is base model for polymorphic multiple levels inheritance with a discriminator. + */ + public Response getWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getWrongDiscriminatorSync(this.getEndpoint(), accept, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/implementation/package-info.java new file mode 100644 index 0000000000..17431c38e7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for NestedDiscriminator. + * Illustrates multiple level inheritance with multiple discriminators. + */ +package type.model.inheritance.nesteddiscriminator.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/package-info.java new file mode 100644 index 0000000000..ab74170178 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/nesteddiscriminator/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for NestedDiscriminator. + * Illustrates multiple level inheritance with multiple discriminators. + */ +package type.model.inheritance.nesteddiscriminator; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/Cat.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/Cat.java new file mode 100644 index 0000000000..b07c5377cb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/Cat.java @@ -0,0 +1,86 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.notdiscriminated; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The second level model in the normal multiple levels inheritance. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public class Cat extends Pet { + /* + * The age property. + */ + @Metadata(generated = true) + private final int age; + + /** + * Creates an instance of Cat class. + * + * @param name the name value to set. + * @param age the age value to set. + */ + @Metadata(generated = true) + public Cat(String name, int age) { + super(name); + this.age = age; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + @Metadata(generated = true) + public int getAge() { + return this.age; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", getName()); + jsonWriter.writeIntField("age", this.age); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Cat from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Cat 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 Cat. + */ + @Metadata(generated = true) + public static Cat fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + int age = 0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("age".equals(fieldName)) { + age = reader.getInt(); + } else { + reader.skipChildren(); + } + } + return new Cat(name, age); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/NotDiscriminatedClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/NotDiscriminatedClient.java new file mode 100644 index 0000000000..0d11ea43b1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/NotDiscriminatedClient.java @@ -0,0 +1,158 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.notdiscriminated; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.model.inheritance.notdiscriminated.implementation.NotDiscriminatedClientImpl; + +/** + * Initializes a new instance of the synchronous NotDiscriminatedClient type. + */ +@ServiceClient(builder = NotDiscriminatedClientBuilder.class) +public final class NotDiscriminatedClient { + @Metadata(generated = true) + private final NotDiscriminatedClientImpl serviceClient; + + /** + * Initializes an instance of NotDiscriminatedClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + NotDiscriminatedClient(NotDiscriminatedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The postValid operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response postValidWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.postValidWithResponse(input, requestOptions); + } + + /** + * The getValid operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the third level model in the normal multiple levels inheritance. + */ + @Metadata(generated = true) + public Response getValidWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getValidWithResponse(requestOptions); + } + + /** + * The putValid operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the third level model in the normal multiple levels inheritance. + */ + @Metadata(generated = true) + public Response putValidWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putValidWithResponse(input, requestOptions); + } + + /** + * The postValid operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void postValid(Siamese input) { + // Generated convenience method for postValidWithResponse + RequestOptions requestOptions = new RequestOptions(); + postValidWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The getValid operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the third level model in the normal multiple levels inheritance. + */ + @Metadata(generated = true) + public Siamese getValid() { + // Generated convenience method for getValidWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getValidWithResponse(requestOptions).getValue(); + } + + /** + * The putValid operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the third level model in the normal multiple levels inheritance. + */ + @Metadata(generated = true) + public Siamese putValid(Siamese input) { + // Generated convenience method for putValidWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putValidWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/NotDiscriminatedClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/NotDiscriminatedClientBuilder.java new file mode 100644 index 0000000000..367c4a8602 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/NotDiscriminatedClientBuilder.java @@ -0,0 +1,241 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.notdiscriminated; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.model.inheritance.notdiscriminated.implementation.NotDiscriminatedClientImpl; + +/** + * A builder for creating a new instance of the NotDiscriminatedClient type. + */ +@ServiceClientBuilder(serviceClients = { NotDiscriminatedClient.class }) +public final class NotDiscriminatedClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the NotDiscriminatedClientBuilder. + */ + @Metadata(generated = true) + public NotDiscriminatedClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDiscriminatedClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDiscriminatedClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDiscriminatedClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDiscriminatedClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDiscriminatedClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDiscriminatedClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDiscriminatedClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDiscriminatedClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NotDiscriminatedClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of NotDiscriminatedClientImpl with the provided parameters. + * + * @return an instance of NotDiscriminatedClientImpl. + */ + @Metadata(generated = true) + private NotDiscriminatedClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + NotDiscriminatedClientImpl client = new NotDiscriminatedClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of NotDiscriminatedClient class. + * + * @return an instance of NotDiscriminatedClient. + */ + @Metadata(generated = true) + public NotDiscriminatedClient buildClient() { + return new NotDiscriminatedClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(NotDiscriminatedClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/Pet.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/Pet.java new file mode 100644 index 0000000000..5d727d5eb7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/Pet.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.notdiscriminated; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * This is base model for not-discriminated normal multiple levels inheritance. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public class Pet implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Pet class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Pet(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Pet from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Pet 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 Pet. + */ + @Metadata(generated = true) + public static Pet fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Pet(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/Siamese.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/Siamese.java new file mode 100644 index 0000000000..694d789505 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/Siamese.java @@ -0,0 +1,91 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.notdiscriminated; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The third level model in the normal multiple levels inheritance. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Siamese extends Cat { + /* + * The smart property. + */ + @Metadata(generated = true) + private final boolean smart; + + /** + * Creates an instance of Siamese class. + * + * @param name the name value to set. + * @param age the age value to set. + * @param smart the smart value to set. + */ + @Metadata(generated = true) + public Siamese(String name, int age, boolean smart) { + super(name, age); + this.smart = smart; + } + + /** + * Get the smart property: The smart property. + * + * @return the smart value. + */ + @Metadata(generated = true) + public boolean isSmart() { + return this.smart; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", getName()); + jsonWriter.writeIntField("age", getAge()); + jsonWriter.writeBooleanField("smart", this.smart); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Siamese from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Siamese 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 Siamese. + */ + @Metadata(generated = true) + public static Siamese fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + int age = 0; + boolean smart = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("age".equals(fieldName)) { + age = reader.getInt(); + } else if ("smart".equals(fieldName)) { + smart = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new Siamese(name, age, smart); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/implementation/NotDiscriminatedClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/implementation/NotDiscriminatedClientImpl.java new file mode 100644 index 0000000000..73ef7b384c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/implementation/NotDiscriminatedClientImpl.java @@ -0,0 +1,185 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.notdiscriminated.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.util.binarydata.BinaryData; +import type.model.inheritance.notdiscriminated.Siamese; + +/** + * Initializes a new instance of the NotDiscriminatedClient type. + */ +public final class NotDiscriminatedClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NotDiscriminatedClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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; + } + + /** + * Initializes an instance of NotDiscriminatedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public NotDiscriminatedClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(NotDiscriminatedClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for NotDiscriminatedClient to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "NotDiscriminatedClie", host = "{endpoint}") + public interface NotDiscriminatedClientService { + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/type/model/inheritance/not-discriminated/valid", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response postValidSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/not-discriminated/valid", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getValidSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/model/inheritance/not-discriminated/valid", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response putValidSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData input, RequestOptions requestOptions); + } + + /** + * The postValid operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response postValidWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.postValidSync(this.getEndpoint(), contentType, input, requestOptions); + } + + /** + * The getValid operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the third level model in the normal multiple levels inheritance. + */ + public Response getValidWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getValidSync(this.getEndpoint(), accept, requestOptions); + } + + /** + * The putValid operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *     age: int (Required)
+     *     smart: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the third level model in the normal multiple levels inheritance. + */ + public Response putValidWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.putValidSync(this.getEndpoint(), contentType, accept, input, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/implementation/package-info.java new file mode 100644 index 0000000000..06aa545315 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for NotDiscriminated. + * Illustrates not-discriminated inheritance model. + */ +package type.model.inheritance.notdiscriminated.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/package-info.java new file mode 100644 index 0000000000..6c99568e86 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/notdiscriminated/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for NotDiscriminated. + * Illustrates not-discriminated inheritance model. + */ +package type.model.inheritance.notdiscriminated; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/Element.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/Element.java new file mode 100644 index 0000000000..0b40ac1093 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/Element.java @@ -0,0 +1,92 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.recursive; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * element. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public class Element implements JsonSerializable { + /* + * The extension property. + */ + @Metadata(generated = true) + private List extension; + + /** + * Creates an instance of Element class. + */ + @Metadata(generated = true) + public Element() { + } + + /** + * Get the extension property: The extension property. + * + * @return the extension value. + */ + @Metadata(generated = true) + public List getExtension() { + return this.extension; + } + + /** + * Set the extension property: The extension property. + * + * @param extension the extension value to set. + * @return the Element object itself. + */ + @Metadata(generated = true) + public Element setExtension(List extension) { + this.extension = extension; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("extension", this.extension, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Element from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Element if the JsonReader was pointing to an instance of it, or null if it was pointing to + * JSON null. + * @throws IOException If an error occurs while reading the Element. + */ + @Metadata(generated = true) + public static Element fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Element deserializedElement = new Element(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("extension".equals(fieldName)) { + List extension = reader.readArray(reader1 -> Extension.fromJson(reader1)); + deserializedElement.extension = extension; + } else { + reader.skipChildren(); + } + } + + return deserializedElement; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/Extension.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/Extension.java new file mode 100644 index 0000000000..2fc50a25ab --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/Extension.java @@ -0,0 +1,98 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.recursive; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * extension. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class Extension extends Element { + /* + * The level property. + */ + @Metadata(generated = true) + private final int level; + + /** + * Creates an instance of Extension class. + * + * @param level the level value to set. + */ + @Metadata(generated = true) + public Extension(int level) { + this.level = level; + } + + /** + * Get the level property: The level property. + * + * @return the level value. + */ + @Metadata(generated = true) + public int getLevel() { + return this.level; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public Extension setExtension(List extension) { + super.setExtension(extension); + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("extension", getExtension(), (writer, element) -> writer.writeJson(element)); + jsonWriter.writeIntField("level", this.level); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Extension from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Extension 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 Extension. + */ + @Metadata(generated = true) + public static Extension fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List extension = null; + int level = 0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("extension".equals(fieldName)) { + extension = reader.readArray(reader1 -> Extension.fromJson(reader1)); + } else if ("level".equals(fieldName)) { + level = reader.getInt(); + } else { + reader.skipChildren(); + } + } + Extension deserializedExtension = new Extension(level); + deserializedExtension.setExtension(extension); + + return deserializedExtension; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/RecursiveClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/RecursiveClient.java new file mode 100644 index 0000000000..89edd309d1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/RecursiveClient.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.recursive; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.model.inheritance.recursive.implementation.RecursiveClientImpl; + +/** + * Initializes a new instance of the synchronous RecursiveClient type. + */ +@ServiceClient(builder = RecursiveClientBuilder.class) +public final class RecursiveClient { + @Metadata(generated = true) + private final RecursiveClientImpl serviceClient; + + /** + * Initializes an instance of RecursiveClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + RecursiveClient(RecursiveClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     extension (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     level: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(input, requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     extension (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     level: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return extension. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The put operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(Extension input) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return extension. + */ + @Metadata(generated = true) + public Extension get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/RecursiveClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/RecursiveClientBuilder.java new file mode 100644 index 0000000000..f4020cd176 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/RecursiveClientBuilder.java @@ -0,0 +1,241 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.recursive; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.model.inheritance.recursive.implementation.RecursiveClientImpl; + +/** + * A builder for creating a new instance of the RecursiveClient type. + */ +@ServiceClientBuilder(serviceClients = { RecursiveClient.class }) +public final class RecursiveClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the RecursiveClientBuilder. + */ + @Metadata(generated = true) + public RecursiveClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RecursiveClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RecursiveClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RecursiveClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RecursiveClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RecursiveClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RecursiveClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RecursiveClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RecursiveClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RecursiveClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of RecursiveClientImpl with the provided parameters. + * + * @return an instance of RecursiveClientImpl. + */ + @Metadata(generated = true) + private RecursiveClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + RecursiveClientImpl client = new RecursiveClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of RecursiveClient class. + * + * @return an instance of RecursiveClient. + */ + @Metadata(generated = true) + public RecursiveClient buildClient() { + return new RecursiveClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(RecursiveClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/implementation/RecursiveClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/implementation/RecursiveClientImpl.java new file mode 100644 index 0000000000..6cf964f101 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/implementation/RecursiveClientImpl.java @@ -0,0 +1,140 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.recursive.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.util.binarydata.BinaryData; +import type.model.inheritance.recursive.Extension; + +/** + * Initializes a new instance of the RecursiveClient type. + */ +public final class RecursiveClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RecursiveClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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; + } + + /** + * Initializes an instance of RecursiveClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public RecursiveClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(RecursiveClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for RecursiveClient to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "RecursiveClient", host = "{endpoint}") + public interface RecursiveClientService { + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/model/inheritance/recursive", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData input, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/recursive", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + } + + /** + * The put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     extension (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     level: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.getEndpoint(), contentType, input, requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     extension (Optional): [
+     *         (recursive schema, see above)
+     *     ]
+     *     level: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return extension. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.getEndpoint(), accept, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/implementation/package-info.java new file mode 100644 index 0000000000..48084ea9d2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Recursive. + * Illustrates inheritance recursion. + */ +package type.model.inheritance.recursive.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/package-info.java new file mode 100644 index 0000000000..d9205f8927 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/recursive/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Recursive. + * Illustrates inheritance recursion. + */ +package type.model.inheritance.recursive; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Bird.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Bird.java new file mode 100644 index 0000000000..cdd28a5d08 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Bird.java @@ -0,0 +1,136 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.singlediscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * This is base model for polymorphic single level inheritance with a discriminator. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public class Bird implements JsonSerializable { + /* + * The kind property. + */ + @Metadata(generated = true) + private String kind = "Bird"; + + /* + * The wingspan property. + */ + @Metadata(generated = true) + private final int wingspan; + + /** + * Creates an instance of Bird class. + * + * @param wingspan the wingspan value to set. + */ + @Metadata(generated = true) + public Bird(int wingspan) { + this.wingspan = wingspan; + } + + /** + * Get the kind property: The kind property. + * + * @return the kind value. + */ + @Metadata(generated = true) + public String getKind() { + return this.kind; + } + + /** + * Get the wingspan property: The wingspan property. + * + * @return the wingspan value. + */ + @Metadata(generated = true) + public int getWingspan() { + return this.wingspan; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("wingspan", this.wingspan); + jsonWriter.writeStringField("kind", this.kind); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Bird from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Bird 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 Bird. + */ + @Metadata(generated = true) + public static Bird 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 ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("seagull".equals(discriminatorValue)) { + return SeaGull.fromJson(readerToUse.reset()); + } else if ("sparrow".equals(discriminatorValue)) { + return Sparrow.fromJson(readerToUse.reset()); + } else if ("goose".equals(discriminatorValue)) { + return Goose.fromJson(readerToUse.reset()); + } else if ("eagle".equals(discriminatorValue)) { + return Eagle.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Metadata(generated = true) + static Bird fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int wingspan = 0; + String kind = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("wingspan".equals(fieldName)) { + wingspan = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + Bird deserializedBird = new Bird(wingspan); + deserializedBird.kind = kind; + + return deserializedBird; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Dinosaur.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Dinosaur.java new file mode 100644 index 0000000000..892729f1d1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Dinosaur.java @@ -0,0 +1,130 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.singlediscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Define a base class in the legacy way. Discriminator property is not explicitly defined in the model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public class Dinosaur implements JsonSerializable { + /* + * Discriminator property for Dinosaur. + */ + @Metadata(generated = true) + private String kind = "Dinosaur"; + + /* + * The size property. + */ + @Metadata(generated = true) + private final int size; + + /** + * Creates an instance of Dinosaur class. + * + * @param size the size value to set. + */ + @Metadata(generated = true) + protected Dinosaur(int size) { + this.size = size; + } + + /** + * Get the kind property: Discriminator property for Dinosaur. + * + * @return the kind value. + */ + @Metadata(generated = true) + public String getKind() { + return this.kind; + } + + /** + * Get the size property: The size property. + * + * @return the size value. + */ + @Metadata(generated = true) + public int getSize() { + return this.size; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("size", this.size); + jsonWriter.writeStringField("kind", this.kind); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Dinosaur from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Dinosaur 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 Dinosaur. + */ + @Metadata(generated = true) + public static Dinosaur 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 ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("t-rex".equals(discriminatorValue)) { + return TRex.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Metadata(generated = true) + static Dinosaur fromJsonKnownDiscriminator(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int size = 0; + String kind = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("size".equals(fieldName)) { + size = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + Dinosaur deserializedDinosaur = new Dinosaur(size); + deserializedDinosaur.kind = kind; + + return deserializedDinosaur; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Eagle.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Eagle.java new file mode 100644 index 0000000000..c661a285e6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Eagle.java @@ -0,0 +1,190 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.singlediscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * The second level model in polymorphic single levels inheritance which contains references to other polymorphic + * instances. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class Eagle extends Bird { + /* + * The kind property. + */ + @Metadata(generated = true) + private String kind = "eagle"; + + /* + * The friends property. + */ + @Metadata(generated = true) + private List friends; + + /* + * The hate property. + */ + @Metadata(generated = true) + private Map hate; + + /* + * The partner property. + */ + @Metadata(generated = true) + private Bird partner; + + /** + * Creates an instance of Eagle class. + * + * @param wingspan the wingspan value to set. + */ + @Metadata(generated = true) + public Eagle(int wingspan) { + super(wingspan); + } + + /** + * Get the kind property: The kind property. + * + * @return the kind value. + */ + @Metadata(generated = true) + @Override + public String getKind() { + return this.kind; + } + + /** + * Get the friends property: The friends property. + * + * @return the friends value. + */ + @Metadata(generated = true) + public List getFriends() { + return this.friends; + } + + /** + * Set the friends property: The friends property. + * + * @param friends the friends value to set. + * @return the Eagle object itself. + */ + @Metadata(generated = true) + public Eagle setFriends(List friends) { + this.friends = friends; + return this; + } + + /** + * Get the hate property: The hate property. + * + * @return the hate value. + */ + @Metadata(generated = true) + public Map getHate() { + return this.hate; + } + + /** + * Set the hate property: The hate property. + * + * @param hate the hate value to set. + * @return the Eagle object itself. + */ + @Metadata(generated = true) + public Eagle setHate(Map hate) { + this.hate = hate; + return this; + } + + /** + * Get the partner property: The partner property. + * + * @return the partner value. + */ + @Metadata(generated = true) + public Bird getPartner() { + return this.partner; + } + + /** + * Set the partner property: The partner property. + * + * @param partner the partner value to set. + * @return the Eagle object itself. + */ + @Metadata(generated = true) + public Eagle setPartner(Bird partner) { + this.partner = partner; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("wingspan", getWingspan()); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeArrayField("friends", this.friends, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeMapField("hate", this.hate, (writer, element) -> writer.writeJson(element)); + jsonWriter.writeJsonField("partner", this.partner); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Eagle from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Eagle 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 Eagle. + */ + @Metadata(generated = true) + public static Eagle fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int wingspan = 0; + String kind = "eagle"; + List friends = null; + Map hate = null; + Bird partner = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("wingspan".equals(fieldName)) { + wingspan = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else if ("friends".equals(fieldName)) { + friends = reader.readArray(reader1 -> Bird.fromJson(reader1)); + } else if ("hate".equals(fieldName)) { + hate = reader.readMap(reader1 -> Bird.fromJson(reader1)); + } else if ("partner".equals(fieldName)) { + partner = Bird.fromJson(reader); + } else { + reader.skipChildren(); + } + } + Eagle deserializedEagle = new Eagle(wingspan); + deserializedEagle.kind = kind; + deserializedEagle.friends = friends; + deserializedEagle.hate = hate; + deserializedEagle.partner = partner; + + return deserializedEagle; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Goose.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Goose.java new file mode 100644 index 0000000000..46ba9a821b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Goose.java @@ -0,0 +1,88 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.singlediscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The second level model in polymorphic single level inheritance. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Goose extends Bird { + /* + * The kind property. + */ + @Metadata(generated = true) + private String kind = "goose"; + + /** + * Creates an instance of Goose class. + * + * @param wingspan the wingspan value to set. + */ + @Metadata(generated = true) + public Goose(int wingspan) { + super(wingspan); + } + + /** + * Get the kind property: The kind property. + * + * @return the kind value. + */ + @Metadata(generated = true) + @Override + public String getKind() { + return this.kind; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("wingspan", getWingspan()); + jsonWriter.writeStringField("kind", this.kind); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Goose from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Goose 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 Goose. + */ + @Metadata(generated = true) + public static Goose fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int wingspan = 0; + String kind = "goose"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("wingspan".equals(fieldName)) { + wingspan = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + Goose deserializedGoose = new Goose(wingspan); + deserializedGoose.kind = kind; + + return deserializedGoose; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SeaGull.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SeaGull.java new file mode 100644 index 0000000000..31e1a5a93f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SeaGull.java @@ -0,0 +1,88 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.singlediscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The second level model in polymorphic single level inheritance. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SeaGull extends Bird { + /* + * The kind property. + */ + @Metadata(generated = true) + private String kind = "seagull"; + + /** + * Creates an instance of SeaGull class. + * + * @param wingspan the wingspan value to set. + */ + @Metadata(generated = true) + public SeaGull(int wingspan) { + super(wingspan); + } + + /** + * Get the kind property: The kind property. + * + * @return the kind value. + */ + @Metadata(generated = true) + @Override + public String getKind() { + return this.kind; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("wingspan", getWingspan()); + jsonWriter.writeStringField("kind", this.kind); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SeaGull from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SeaGull 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 SeaGull. + */ + @Metadata(generated = true) + public static SeaGull fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int wingspan = 0; + String kind = "seagull"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("wingspan".equals(fieldName)) { + wingspan = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + SeaGull deserializedSeaGull = new SeaGull(wingspan); + deserializedSeaGull.kind = kind; + + return deserializedSeaGull; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java new file mode 100644 index 0000000000..2fda180cc8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClient.java @@ -0,0 +1,286 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.singlediscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.model.inheritance.singlediscriminator.implementation.SingleDiscriminatorClientImpl; + +/** + * Initializes a new instance of the synchronous SingleDiscriminatorClient type. + */ +@ServiceClient(builder = SingleDiscriminatorClientBuilder.class) +public final class SingleDiscriminatorClient { + @Metadata(generated = true) + private final SingleDiscriminatorClientImpl serviceClient; + + /** + * Initializes an instance of SingleDiscriminatorClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + SingleDiscriminatorClient(SingleDiscriminatorClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return this is base model for polymorphic single level inheritance with a discriminator. + */ + @Metadata(generated = true) + public Response getModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getModelWithResponse(requestOptions); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putModelWithResponse(input, requestOptions); + } + + /** + * The getRecursiveModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return this is base model for polymorphic single level inheritance with a discriminator. + */ + @Metadata(generated = true) + public Response getRecursiveModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getRecursiveModelWithResponse(requestOptions); + } + + /** + * The putRecursiveModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putRecursiveModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putRecursiveModelWithResponse(input, requestOptions); + } + + /** + * The getMissingDiscriminator operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return this is base model for polymorphic single level inheritance with a discriminator. + */ + @Metadata(generated = true) + public Response getMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getMissingDiscriminatorWithResponse(requestOptions); + } + + /** + * The getWrongDiscriminator operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return this is base model for polymorphic single level inheritance with a discriminator. + */ + @Metadata(generated = true) + public Response getWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWrongDiscriminatorWithResponse(requestOptions); + } + + /** + * The getLegacyModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return define a base class in the legacy way. + */ + @Metadata(generated = true) + public Response getLegacyModelWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getLegacyModelWithResponse(requestOptions); + } + + /** + * The getModel operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic single level inheritance with a discriminator. + */ + @Metadata(generated = true) + public Bird getModel() { + // Generated convenience method for getModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getModelWithResponse(requestOptions).getValue(); + } + + /** + * The putModel operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putModel(Bird input) { + // Generated convenience method for putModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The getRecursiveModel operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic single level inheritance with a discriminator. + */ + @Metadata(generated = true) + public Bird getRecursiveModel() { + // Generated convenience method for getRecursiveModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getRecursiveModelWithResponse(requestOptions).getValue(); + } + + /** + * The putRecursiveModel operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putRecursiveModel(Bird input) { + // Generated convenience method for putRecursiveModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putRecursiveModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The getMissingDiscriminator operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic single level inheritance with a discriminator. + */ + @Metadata(generated = true) + public Bird getMissingDiscriminator() { + // Generated convenience method for getMissingDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getMissingDiscriminatorWithResponse(requestOptions).getValue(); + } + + /** + * The getWrongDiscriminator operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return this is base model for polymorphic single level inheritance with a discriminator. + */ + @Metadata(generated = true) + public Bird getWrongDiscriminator() { + // Generated convenience method for getWrongDiscriminatorWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWrongDiscriminatorWithResponse(requestOptions).getValue(); + } + + /** + * The getLegacyModel operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return define a base class in the legacy way. + */ + @Metadata(generated = true) + public Dinosaur getLegacyModel() { + // Generated convenience method for getLegacyModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getLegacyModelWithResponse(requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java new file mode 100644 index 0000000000..cf3365feff --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/SingleDiscriminatorClientBuilder.java @@ -0,0 +1,241 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.singlediscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.model.inheritance.singlediscriminator.implementation.SingleDiscriminatorClientImpl; + +/** + * A builder for creating a new instance of the SingleDiscriminatorClient type. + */ +@ServiceClientBuilder(serviceClients = { SingleDiscriminatorClient.class }) +public final class SingleDiscriminatorClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the SingleDiscriminatorClientBuilder. + */ + @Metadata(generated = true) + public SingleDiscriminatorClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleDiscriminatorClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleDiscriminatorClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleDiscriminatorClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleDiscriminatorClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleDiscriminatorClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleDiscriminatorClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleDiscriminatorClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleDiscriminatorClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public SingleDiscriminatorClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of SingleDiscriminatorClientImpl with the provided parameters. + * + * @return an instance of SingleDiscriminatorClientImpl. + */ + @Metadata(generated = true) + private SingleDiscriminatorClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + SingleDiscriminatorClientImpl client = new SingleDiscriminatorClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of SingleDiscriminatorClient class. + * + * @return an instance of SingleDiscriminatorClient. + */ + @Metadata(generated = true) + public SingleDiscriminatorClient buildClient() { + return new SingleDiscriminatorClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(SingleDiscriminatorClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Sparrow.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Sparrow.java new file mode 100644 index 0000000000..f948ca1331 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/Sparrow.java @@ -0,0 +1,88 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.singlediscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The second level model in polymorphic single level inheritance. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Sparrow extends Bird { + /* + * The kind property. + */ + @Metadata(generated = true) + private String kind = "sparrow"; + + /** + * Creates an instance of Sparrow class. + * + * @param wingspan the wingspan value to set. + */ + @Metadata(generated = true) + public Sparrow(int wingspan) { + super(wingspan); + } + + /** + * Get the kind property: The kind property. + * + * @return the kind value. + */ + @Metadata(generated = true) + @Override + public String getKind() { + return this.kind; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("wingspan", getWingspan()); + jsonWriter.writeStringField("kind", this.kind); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Sparrow from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Sparrow 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 Sparrow. + */ + @Metadata(generated = true) + public static Sparrow fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int wingspan = 0; + String kind = "sparrow"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("wingspan".equals(fieldName)) { + wingspan = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + Sparrow deserializedSparrow = new Sparrow(wingspan); + deserializedSparrow.kind = kind; + + return deserializedSparrow; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/TRex.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/TRex.java new file mode 100644 index 0000000000..bad0603bd2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/TRex.java @@ -0,0 +1,88 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.singlediscriminator; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The second level legacy model in polymorphic single level inheritance. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class TRex extends Dinosaur { + /* + * Discriminator property for Dinosaur. + */ + @Metadata(generated = true) + private String kind = "t-rex"; + + /** + * Creates an instance of TRex class. + * + * @param size the size value to set. + */ + @Metadata(generated = true) + private TRex(int size) { + super(size); + } + + /** + * Get the kind property: Discriminator property for Dinosaur. + * + * @return the kind value. + */ + @Metadata(generated = true) + @Override + public String getKind() { + return this.kind; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("size", getSize()); + jsonWriter.writeStringField("kind", this.kind); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TRex from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TRex 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 TRex. + */ + @Metadata(generated = true) + public static TRex fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int size = 0; + String kind = "t-rex"; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("size".equals(fieldName)) { + size = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else { + reader.skipChildren(); + } + } + TRex deserializedTRex = new TRex(size); + deserializedTRex.kind = kind; + + return deserializedTRex; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java new file mode 100644 index 0000000000..5721c42879 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/SingleDiscriminatorClientImpl.java @@ -0,0 +1,290 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.inheritance.singlediscriminator.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.util.binarydata.BinaryData; +import type.model.inheritance.singlediscriminator.Bird; +import type.model.inheritance.singlediscriminator.Dinosaur; + +/** + * Initializes a new instance of the SingleDiscriminatorClient type. + */ +public final class SingleDiscriminatorClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SingleDiscriminatorClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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; + } + + /** + * Initializes an instance of SingleDiscriminatorClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public SingleDiscriminatorClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(SingleDiscriminatorClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for SingleDiscriminatorClient to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "SingleDiscriminatorC", host = "{endpoint}") + public interface SingleDiscriminatorClientService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/single-discriminator/model", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getModelSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/model/inheritance/single-discriminator/model", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/single-discriminator/recursivemodel", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getRecursiveModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/model/inheritance/single-discriminator/recursivemodel", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putRecursiveModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/single-discriminator/missingdiscriminator", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getMissingDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/single-discriminator/wrongdiscriminator", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getWrongDiscriminatorSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/inheritance/single-discriminator/legacy-model", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getLegacyModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + } + + /** + * The getModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return this is base model for polymorphic single level inheritance with a discriminator. + */ + public Response getModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getModelSync(this.getEndpoint(), accept, requestOptions); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putModelSync(this.getEndpoint(), contentType, input, requestOptions); + } + + /** + * The getRecursiveModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return this is base model for polymorphic single level inheritance with a discriminator. + */ + public Response getRecursiveModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getRecursiveModelSync(this.getEndpoint(), accept, requestOptions); + } + + /** + * The putRecursiveModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: int (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putRecursiveModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putRecursiveModelSync(this.getEndpoint(), contentType, input, requestOptions); + } + + /** + * The getMissingDiscriminator operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return this is base model for polymorphic single level inheritance with a discriminator. + */ + public Response getMissingDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getMissingDiscriminatorSync(this.getEndpoint(), accept, requestOptions); + } + + /** + * The getWrongDiscriminator operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     wingspan: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return this is base model for polymorphic single level inheritance with a discriminator. + */ + public Response getWrongDiscriminatorWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getWrongDiscriminatorSync(this.getEndpoint(), accept, requestOptions); + } + + /** + * The getLegacyModel operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     size: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return define a base class in the legacy way. + */ + public Response getLegacyModelWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getLegacyModelSync(this.getEndpoint(), accept, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/package-info.java new file mode 100644 index 0000000000..98caaf1244 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for SingleDiscriminator. + * Illustrates inheritance with single discriminator. + */ +package type.model.inheritance.singlediscriminator.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/package-info.java new file mode 100644 index 0000000000..59081ba244 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/inheritance/singlediscriminator/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for SingleDiscriminator. + * Illustrates inheritance with single discriminator. + */ +package type.model.inheritance.singlediscriminator; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/InputOutputRecord.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/InputOutputRecord.java new file mode 100644 index 0000000000..029b387234 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/InputOutputRecord.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.usage; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Record used both as operation parameter and return type. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class InputOutputRecord implements JsonSerializable { + /* + * The requiredProp property. + */ + @Metadata(generated = true) + private final String requiredProp; + + /** + * Creates an instance of InputOutputRecord class. + * + * @param requiredProp the requiredProp value to set. + */ + @Metadata(generated = true) + public InputOutputRecord(String requiredProp) { + this.requiredProp = requiredProp; + } + + /** + * Get the requiredProp property: The requiredProp property. + * + * @return the requiredProp value. + */ + @Metadata(generated = true) + public String getRequiredProp() { + return this.requiredProp; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProp", this.requiredProp); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InputOutputRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InputOutputRecord 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 InputOutputRecord. + */ + @Metadata(generated = true) + public static InputOutputRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String requiredProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProp".equals(fieldName)) { + requiredProp = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new InputOutputRecord(requiredProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/InputRecord.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/InputRecord.java new file mode 100644 index 0000000000..1b179c7f96 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/InputRecord.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.usage; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Record used in operation parameters. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class InputRecord implements JsonSerializable { + /* + * The requiredProp property. + */ + @Metadata(generated = true) + private final String requiredProp; + + /** + * Creates an instance of InputRecord class. + * + * @param requiredProp the requiredProp value to set. + */ + @Metadata(generated = true) + public InputRecord(String requiredProp) { + this.requiredProp = requiredProp; + } + + /** + * Get the requiredProp property: The requiredProp property. + * + * @return the requiredProp value. + */ + @Metadata(generated = true) + public String getRequiredProp() { + return this.requiredProp; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProp", this.requiredProp); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InputRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InputRecord 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 InputRecord. + */ + @Metadata(generated = true) + public static InputRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String requiredProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProp".equals(fieldName)) { + requiredProp = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new InputRecord(requiredProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/OutputRecord.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/OutputRecord.java new file mode 100644 index 0000000000..156fe695f6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/OutputRecord.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.usage; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Record used in operation return type. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class OutputRecord implements JsonSerializable { + /* + * The requiredProp property. + */ + @Metadata(generated = true) + private final String requiredProp; + + /** + * Creates an instance of OutputRecord class. + * + * @param requiredProp the requiredProp value to set. + */ + @Metadata(generated = true) + private OutputRecord(String requiredProp) { + this.requiredProp = requiredProp; + } + + /** + * Get the requiredProp property: The requiredProp property. + * + * @return the requiredProp value. + */ + @Metadata(generated = true) + public String getRequiredProp() { + return this.requiredProp; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProp", this.requiredProp); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of OutputRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of OutputRecord 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 OutputRecord. + */ + @Metadata(generated = true) + public static OutputRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String requiredProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProp".equals(fieldName)) { + requiredProp = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new OutputRecord(requiredProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/UsageClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/UsageClient.java new file mode 100644 index 0000000000..a28554e183 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/UsageClient.java @@ -0,0 +1,150 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.usage; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.model.usage.implementation.UsageClientImpl; + +/** + * Initializes a new instance of the synchronous UsageClient type. + */ +@ServiceClient(builder = UsageClientBuilder.class) +public final class UsageClient { + @Metadata(generated = true) + private final UsageClientImpl serviceClient; + + /** + * Initializes an instance of UsageClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + UsageClient(UsageClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The input operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProp: String (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response inputWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.inputWithResponse(input, requestOptions); + } + + /** + * The output operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProp: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return record used in operation return type. + */ + @Metadata(generated = true) + public Response outputWithResponse(RequestOptions requestOptions) { + return this.serviceClient.outputWithResponse(requestOptions); + } + + /** + * The inputAndOutput operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProp: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProp: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return record used both as operation parameter and return type. + */ + @Metadata(generated = true) + public Response inputAndOutputWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.inputAndOutputWithResponse(body, requestOptions); + } + + /** + * The input operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void input(InputRecord input) { + // Generated convenience method for inputWithResponse + RequestOptions requestOptions = new RequestOptions(); + inputWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The output operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return record used in operation return type. + */ + @Metadata(generated = true) + public OutputRecord output() { + // Generated convenience method for outputWithResponse + RequestOptions requestOptions = new RequestOptions(); + return outputWithResponse(requestOptions).getValue(); + } + + /** + * The inputAndOutput operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return record used both as operation parameter and return type. + */ + @Metadata(generated = true) + public InputOutputRecord inputAndOutput(InputOutputRecord body) { + // Generated convenience method for inputAndOutputWithResponse + RequestOptions requestOptions = new RequestOptions(); + return inputAndOutputWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/UsageClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/UsageClientBuilder.java new file mode 100644 index 0000000000..a3cd60e954 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/UsageClientBuilder.java @@ -0,0 +1,240 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.usage; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.model.usage.implementation.UsageClientImpl; + +/** + * A builder for creating a new instance of the UsageClient type. + */ +@ServiceClientBuilder(serviceClients = { UsageClient.class }) +public final class UsageClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the UsageClientBuilder. + */ + @Metadata(generated = true) + public UsageClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UsageClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UsageClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UsageClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UsageClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UsageClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UsageClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UsageClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UsageClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UsageClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of UsageClientImpl with the provided parameters. + * + * @return an instance of UsageClientImpl. + */ + @Metadata(generated = true) + private UsageClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + UsageClientImpl client = new UsageClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of UsageClient class. + * + * @return an instance of UsageClient. + */ + @Metadata(generated = true) + public UsageClient buildClient() { + return new UsageClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(UsageClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/implementation/UsageClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/implementation/UsageClientImpl.java new file mode 100644 index 0000000000..597e579f5e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/implementation/UsageClientImpl.java @@ -0,0 +1,177 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.usage.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.util.binarydata.BinaryData; +import type.model.usage.InputOutputRecord; +import type.model.usage.OutputRecord; + +/** + * Initializes a new instance of the UsageClient type. + */ +public final class UsageClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UsageClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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; + } + + /** + * Initializes an instance of UsageClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public UsageClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(UsageClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for UsageClient to be used by the proxy service to perform REST calls. + */ + @ServiceInterface(name = "UsageClient", host = "{endpoint}") + public interface UsageClientService { + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/type/model/usage/input", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response inputSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/model/usage/output", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response outputSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/type/model/usage/input-output", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response inputAndOutputSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The input operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProp: String (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response inputWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.inputSync(this.getEndpoint(), contentType, input, requestOptions); + } + + /** + * The output operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProp: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return record used in operation return type. + */ + public Response outputWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.outputSync(this.getEndpoint(), accept, requestOptions); + } + + /** + * The inputAndOutput operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProp: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProp: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return record used both as operation parameter and return type. + */ + public Response inputAndOutputWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.inputAndOutputSync(this.getEndpoint(), contentType, accept, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/implementation/package-info.java new file mode 100644 index 0000000000..78e716b68c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Usage. + * Illustrates usage of Record in different places(Operation parameters, return type or both). + */ +package type.model.usage.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/package-info.java new file mode 100644 index 0000000000..38b0c00c41 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/usage/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Usage. + * Illustrates usage of Record in different places(Operation parameters, return type or both). + */ +package type.model.usage; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/ReadOnlyModel.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/ReadOnlyModel.java new file mode 100644 index 0000000000..f60d463be1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/ReadOnlyModel.java @@ -0,0 +1,99 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.visibility; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.List; +import java.util.Map; + +/** + * RoundTrip model with readonly optional properties. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class ReadOnlyModel implements JsonSerializable { + /* + * Optional readonly nullable int list. + */ + @Metadata(generated = true) + private List optionalNullableIntList; + + /* + * Optional readonly string dictionary. + */ + @Metadata(generated = true) + private Map optionalStringRecord; + + /** + * Creates an instance of ReadOnlyModel class. + */ + @Metadata(generated = true) + public ReadOnlyModel() { + } + + /** + * Get the optionalNullableIntList property: Optional readonly nullable int list. + * + * @return the optionalNullableIntList value. + */ + @Metadata(generated = true) + public List getOptionalNullableIntList() { + return this.optionalNullableIntList; + } + + /** + * Get the optionalStringRecord property: Optional readonly string dictionary. + * + * @return the optionalStringRecord value. + */ + @Metadata(generated = true) + public Map getOptionalStringRecord() { + return this.optionalStringRecord; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ReadOnlyModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ReadOnlyModel if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the ReadOnlyModel. + */ + @Metadata(generated = true) + public static ReadOnlyModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ReadOnlyModel deserializedReadOnlyModel = new ReadOnlyModel(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("optionalNullableIntList".equals(fieldName)) { + List optionalNullableIntList = reader.readArray(reader1 -> reader1.getInt()); + deserializedReadOnlyModel.optionalNullableIntList = optionalNullableIntList; + } else if ("optionalStringRecord".equals(fieldName)) { + Map optionalStringRecord = reader.readMap(reader1 -> reader1.getString()); + deserializedReadOnlyModel.optionalStringRecord = optionalStringRecord; + } else { + reader.skipChildren(); + } + } + + return deserializedReadOnlyModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/VisibilityClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/VisibilityClient.java new file mode 100644 index 0000000000..9dda6021f6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/VisibilityClient.java @@ -0,0 +1,377 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.visibility; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.model.visibility.implementation.VisibilityClientImpl; + +/** + * Initializes a new instance of the synchronous VisibilityClient type. + */ +@ServiceClient(builder = VisibilityClientBuilder.class) +public final class VisibilityClient { + @Metadata(generated = true) + private final VisibilityClientImpl serviceClient; + + /** + * Initializes an instance of VisibilityClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + VisibilityClient(VisibilityClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The getModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return output model with visibility properties. + */ + @Metadata(generated = true) + public Response getModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.getModelWithResponse(input, requestOptions); + } + + /** + * The headModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response headModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.headModelWithResponse(input, requestOptions); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putModelWithResponse(input, requestOptions); + } + + /** + * The patchModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response patchModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.patchModelWithResponse(input, requestOptions); + } + + /** + * The postModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response postModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.postModelWithResponse(input, requestOptions); + } + + /** + * The deleteModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response deleteModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.deleteModelWithResponse(input, requestOptions); + } + + /** + * The putReadOnlyModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     optionalNullableIntList (Optional): [
+     *         int (Optional)
+     *     ]
+     *     optionalStringRecord (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     optionalNullableIntList (Optional): [
+     *         int (Optional)
+     *     ]
+     *     optionalStringRecord (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return roundTrip model with readonly optional properties. + */ + @Metadata(generated = true) + public Response putReadOnlyModelWithResponse(BinaryData input, RequestOptions requestOptions) { + return this.serviceClient.putReadOnlyModelWithResponse(input, requestOptions); + } + + /** + * The getModel operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return output model with visibility properties. + */ + @Metadata(generated = true) + public VisibilityModel getModel(VisibilityModel input) { + // Generated convenience method for getModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The headModel operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void headModel(VisibilityModel input) { + // Generated convenience method for headModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + headModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The putModel operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putModel(VisibilityModel input) { + // Generated convenience method for putModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + putModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The patchModel operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void patchModel(VisibilityModel input) { + // Generated convenience method for patchModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + patchModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The postModel operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void postModel(VisibilityModel input) { + // Generated convenience method for postModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + postModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The deleteModel operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void deleteModel(VisibilityModel input) { + // Generated convenience method for deleteModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } + + /** + * The putReadOnlyModel operation. + * + * @param input The input parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return roundTrip model with readonly optional properties. + */ + @Metadata(generated = true) + public ReadOnlyModel putReadOnlyModel(ReadOnlyModel input) { + // Generated convenience method for putReadOnlyModelWithResponse + RequestOptions requestOptions = new RequestOptions(); + return putReadOnlyModelWithResponse(BinaryData.fromObject(input), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/VisibilityClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/VisibilityClientBuilder.java new file mode 100644 index 0000000000..45205f07bc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/VisibilityClientBuilder.java @@ -0,0 +1,241 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.visibility; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.model.visibility.implementation.VisibilityClientImpl; + +/** + * A builder for creating a new instance of the VisibilityClient type. + */ +@ServiceClientBuilder(serviceClients = { VisibilityClient.class }) +public final class VisibilityClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the VisibilityClientBuilder. + */ + @Metadata(generated = true) + public VisibilityClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VisibilityClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VisibilityClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VisibilityClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VisibilityClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VisibilityClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VisibilityClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VisibilityClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VisibilityClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public VisibilityClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of VisibilityClientImpl with the provided parameters. + * + * @return an instance of VisibilityClientImpl. + */ + @Metadata(generated = true) + private VisibilityClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + VisibilityClientImpl client = new VisibilityClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of VisibilityClient class. + * + * @return an instance of VisibilityClient. + */ + @Metadata(generated = true) + public VisibilityClient buildClient() { + return new VisibilityClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(VisibilityClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/VisibilityModel.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/VisibilityModel.java new file mode 100644 index 0000000000..3300d7868f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/VisibilityModel.java @@ -0,0 +1,171 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.visibility; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Output model with visibility properties. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class VisibilityModel implements JsonSerializable { + /* + * Required string, illustrating a readonly property. + */ + @Metadata(generated = true) + private String readProp; + + /* + * Required int32, illustrating a query property. + */ + @Metadata(generated = true) + private final Integer queryProp; + + /* + * Required string[], illustrating a create property. + */ + @Metadata(generated = true) + private final List createProp; + + /* + * Required int32[], illustrating a update property. + */ + @Metadata(generated = true) + private final List updateProp; + + /* + * Required bool, illustrating a delete property. + */ + @Metadata(generated = true) + private final Boolean deleteProp; + + /** + * Creates an instance of VisibilityModel class. + * + * @param queryProp the queryProp value to set. + * @param createProp the createProp value to set. + * @param updateProp the updateProp value to set. + * @param deleteProp the deleteProp value to set. + */ + @Metadata(generated = true) + public VisibilityModel(Integer queryProp, List createProp, List updateProp, Boolean deleteProp) { + this.queryProp = queryProp; + this.createProp = createProp; + this.updateProp = updateProp; + this.deleteProp = deleteProp; + } + + /** + * Get the readProp property: Required string, illustrating a readonly property. + * + * @return the readProp value. + */ + @Metadata(generated = true) + public String getReadProp() { + return this.readProp; + } + + /** + * Get the queryProp property: Required int32, illustrating a query property. + * + * @return the queryProp value. + */ + @Metadata(generated = true) + public Integer getQueryProp() { + return this.queryProp; + } + + /** + * Get the createProp property: Required string[], illustrating a create property. + * + * @return the createProp value. + */ + @Metadata(generated = true) + public List getCreateProp() { + return this.createProp; + } + + /** + * Get the updateProp property: Required int32[], illustrating a update property. + * + * @return the updateProp value. + */ + @Metadata(generated = true) + public List getUpdateProp() { + return this.updateProp; + } + + /** + * Get the deleteProp property: Required bool, illustrating a delete property. + * + * @return the deleteProp value. + */ + @Metadata(generated = true) + public Boolean isDeleteProp() { + return this.deleteProp; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("queryProp", this.queryProp); + jsonWriter.writeArrayField("createProp", this.createProp, (writer, element) -> writer.writeString(element)); + jsonWriter.writeArrayField("updateProp", this.updateProp, (writer, element) -> writer.writeInt(element)); + jsonWriter.writeBooleanField("deleteProp", this.deleteProp); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of VisibilityModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of VisibilityModel 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 VisibilityModel. + */ + @Metadata(generated = true) + public static VisibilityModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String readProp = null; + Integer queryProp = null; + List createProp = null; + List updateProp = null; + Boolean deleteProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("readProp".equals(fieldName)) { + readProp = reader.getString(); + } else if ("queryProp".equals(fieldName)) { + queryProp = reader.getNullable(JsonReader::getInt); + } else if ("createProp".equals(fieldName)) { + createProp = reader.readArray(reader1 -> reader1.getString()); + } else if ("updateProp".equals(fieldName)) { + updateProp = reader.readArray(reader1 -> reader1.getInt()); + } else if ("deleteProp".equals(fieldName)) { + deleteProp = reader.getNullable(JsonReader::getBoolean); + } else { + reader.skipChildren(); + } + } + VisibilityModel deserializedVisibilityModel + = new VisibilityModel(queryProp, createProp, updateProp, deleteProp); + deserializedVisibilityModel.readProp = readProp; + + return deserializedVisibilityModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/implementation/VisibilityClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/implementation/VisibilityClientImpl.java new file mode 100644 index 0000000000..91f50336f7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/implementation/VisibilityClientImpl.java @@ -0,0 +1,375 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.model.visibility.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.util.binarydata.BinaryData; +import type.model.visibility.ReadOnlyModel; +import type.model.visibility.VisibilityModel; + +/** + * Initializes a new instance of the VisibilityClient type. + */ +public final class VisibilityClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final VisibilityClientService service; + + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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; + } + + /** + * Initializes an instance of VisibilityClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public VisibilityClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(VisibilityClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for VisibilityClient to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "VisibilityClient", host = "{endpoint}") + public interface VisibilityClientService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/model/visibility", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData input, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.HEAD, + path = "/type/model/visibility", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response headModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.PUT, path = "/type/model/visibility", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PATCH, + path = "/type/model/visibility", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response patchModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/type/model/visibility", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response postModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.DELETE, + path = "/type/model/visibility", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response deleteModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData input, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/model/visibility/readonlyroundtrip", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response putReadOnlyModelSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData input, RequestOptions requestOptions); + } + + /** + * The getModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return output model with visibility properties. + */ + public Response getModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.getModelSync(this.getEndpoint(), contentType, accept, input, requestOptions); + } + + /** + * The headModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response headModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.headModelSync(this.getEndpoint(), contentType, input, requestOptions); + } + + /** + * The putModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putModelSync(this.getEndpoint(), contentType, input, requestOptions); + } + + /** + * The patchModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response patchModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.patchModelSync(this.getEndpoint(), contentType, input, requestOptions); + } + + /** + * The postModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response postModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.postModelSync(this.getEndpoint(), contentType, input, requestOptions); + } + + /** + * The deleteModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     readProp: String (Required)
+     *     queryProp: Integer (Required)
+     *     createProp (Required): [
+     *         String (Required)
+     *     ]
+     *     updateProp (Required): [
+     *         int (Required)
+     *     ]
+     *     deleteProp: Boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response deleteModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.deleteModelSync(this.getEndpoint(), contentType, input, requestOptions); + } + + /** + * The putReadOnlyModel operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     optionalNullableIntList (Optional): [
+     *         int (Optional)
+     *     ]
+     *     optionalStringRecord (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     optionalNullableIntList (Optional): [
+     *         int (Optional)
+     *     ]
+     *     optionalStringRecord (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param input The input parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return roundTrip model with readonly optional properties. + */ + public Response putReadOnlyModelWithResponse(BinaryData input, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.putReadOnlyModelSync(this.getEndpoint(), contentType, accept, input, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/implementation/package-info.java new file mode 100644 index 0000000000..e19d3c49d4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Visibility. + * Illustrates models with visibility properties. + */ +package type.model.visibility.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/package-info.java new file mode 100644 index 0000000000..8dff88cf64 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/model/visibility/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Visibility. + * Illustrates models with visibility properties. + */ +package type.model.visibility; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/AdditionalPropertiesClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/AdditionalPropertiesClientBuilder.java new file mode 100644 index 0000000000..4d80a1bb44 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/AdditionalPropertiesClientBuilder.java @@ -0,0 +1,586 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.property.additionalproperties.implementation.AdditionalPropertiesClientImpl; + +/** + * A builder for creating a new instance of the AdditionalPropertiesClient type. + */ +@ServiceClientBuilder( + serviceClients = { + ExtendsUnknownClient.class, + ExtendsUnknownDerivedClient.class, + ExtendsUnknownDiscriminatedClient.class, + IsUnknownClient.class, + IsUnknownDerivedClient.class, + IsUnknownDiscriminatedClient.class, + ExtendsStringClient.class, + IsStringClient.class, + SpreadStringClient.class, + ExtendsFloatClient.class, + IsFloatClient.class, + SpreadFloatClient.class, + ExtendsModelClient.class, + IsModelClient.class, + SpreadModelClient.class, + ExtendsModelArrayClient.class, + IsModelArrayClient.class, + SpreadModelArrayClient.class, + SpreadDifferentStringClient.class, + SpreadDifferentFloatClient.class, + SpreadDifferentModelClient.class, + SpreadDifferentModelArrayClient.class, + ExtendsDifferentSpreadStringClient.class, + ExtendsDifferentSpreadFloatClient.class, + ExtendsDifferentSpreadModelClient.class, + ExtendsDifferentSpreadModelArrayClient.class, + MultipleSpreadClient.class, + SpreadRecordUnionClient.class, + SpreadRecordDiscriminatedUnionClient.class, + SpreadRecordNonDiscriminatedUnionClient.class, + SpreadRecordNonDiscriminatedUnion2Client.class, + SpreadRecordNonDiscriminatedUnion3Client.class }) +public final class AdditionalPropertiesClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the AdditionalPropertiesClientBuilder. + */ + @Metadata(generated = true) + public AdditionalPropertiesClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AdditionalPropertiesClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AdditionalPropertiesClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AdditionalPropertiesClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AdditionalPropertiesClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AdditionalPropertiesClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AdditionalPropertiesClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AdditionalPropertiesClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AdditionalPropertiesClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AdditionalPropertiesClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of AdditionalPropertiesClientImpl with the provided parameters. + * + * @return an instance of AdditionalPropertiesClientImpl. + */ + @Metadata(generated = true) + private AdditionalPropertiesClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + AdditionalPropertiesClientImpl client = new AdditionalPropertiesClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of ExtendsUnknownClient class. + * + * @return an instance of ExtendsUnknownClient. + */ + @Metadata(generated = true) + public ExtendsUnknownClient buildExtendsUnknownClient() { + return new ExtendsUnknownClient(buildInnerClient().getExtendsUnknowns()); + } + + /** + * Builds an instance of ExtendsUnknownDerivedClient class. + * + * @return an instance of ExtendsUnknownDerivedClient. + */ + @Metadata(generated = true) + public ExtendsUnknownDerivedClient buildExtendsUnknownDerivedClient() { + return new ExtendsUnknownDerivedClient(buildInnerClient().getExtendsUnknownDeriveds()); + } + + /** + * Builds an instance of ExtendsUnknownDiscriminatedClient class. + * + * @return an instance of ExtendsUnknownDiscriminatedClient. + */ + @Metadata(generated = true) + public ExtendsUnknownDiscriminatedClient buildExtendsUnknownDiscriminatedClient() { + return new ExtendsUnknownDiscriminatedClient(buildInnerClient().getExtendsUnknownDiscriminateds()); + } + + /** + * Builds an instance of IsUnknownClient class. + * + * @return an instance of IsUnknownClient. + */ + @Metadata(generated = true) + public IsUnknownClient buildIsUnknownClient() { + return new IsUnknownClient(buildInnerClient().getIsUnknowns()); + } + + /** + * Builds an instance of IsUnknownDerivedClient class. + * + * @return an instance of IsUnknownDerivedClient. + */ + @Metadata(generated = true) + public IsUnknownDerivedClient buildIsUnknownDerivedClient() { + return new IsUnknownDerivedClient(buildInnerClient().getIsUnknownDeriveds()); + } + + /** + * Builds an instance of IsUnknownDiscriminatedClient class. + * + * @return an instance of IsUnknownDiscriminatedClient. + */ + @Metadata(generated = true) + public IsUnknownDiscriminatedClient buildIsUnknownDiscriminatedClient() { + return new IsUnknownDiscriminatedClient(buildInnerClient().getIsUnknownDiscriminateds()); + } + + /** + * Builds an instance of ExtendsStringClient class. + * + * @return an instance of ExtendsStringClient. + */ + @Metadata(generated = true) + public ExtendsStringClient buildExtendsStringClient() { + return new ExtendsStringClient(buildInnerClient().getExtendsStrings()); + } + + /** + * Builds an instance of IsStringClient class. + * + * @return an instance of IsStringClient. + */ + @Metadata(generated = true) + public IsStringClient buildIsStringClient() { + return new IsStringClient(buildInnerClient().getIsStrings()); + } + + /** + * Builds an instance of SpreadStringClient class. + * + * @return an instance of SpreadStringClient. + */ + @Metadata(generated = true) + public SpreadStringClient buildSpreadStringClient() { + return new SpreadStringClient(buildInnerClient().getSpreadStrings()); + } + + /** + * Builds an instance of ExtendsFloatClient class. + * + * @return an instance of ExtendsFloatClient. + */ + @Metadata(generated = true) + public ExtendsFloatClient buildExtendsFloatClient() { + return new ExtendsFloatClient(buildInnerClient().getExtendsFloats()); + } + + /** + * Builds an instance of IsFloatClient class. + * + * @return an instance of IsFloatClient. + */ + @Metadata(generated = true) + public IsFloatClient buildIsFloatClient() { + return new IsFloatClient(buildInnerClient().getIsFloats()); + } + + /** + * Builds an instance of SpreadFloatClient class. + * + * @return an instance of SpreadFloatClient. + */ + @Metadata(generated = true) + public SpreadFloatClient buildSpreadFloatClient() { + return new SpreadFloatClient(buildInnerClient().getSpreadFloats()); + } + + /** + * Builds an instance of ExtendsModelClient class. + * + * @return an instance of ExtendsModelClient. + */ + @Metadata(generated = true) + public ExtendsModelClient buildExtendsModelClient() { + return new ExtendsModelClient(buildInnerClient().getExtendsModels()); + } + + /** + * Builds an instance of IsModelClient class. + * + * @return an instance of IsModelClient. + */ + @Metadata(generated = true) + public IsModelClient buildIsModelClient() { + return new IsModelClient(buildInnerClient().getIsModels()); + } + + /** + * Builds an instance of SpreadModelClient class. + * + * @return an instance of SpreadModelClient. + */ + @Metadata(generated = true) + public SpreadModelClient buildSpreadModelClient() { + return new SpreadModelClient(buildInnerClient().getSpreadModels()); + } + + /** + * Builds an instance of ExtendsModelArrayClient class. + * + * @return an instance of ExtendsModelArrayClient. + */ + @Metadata(generated = true) + public ExtendsModelArrayClient buildExtendsModelArrayClient() { + return new ExtendsModelArrayClient(buildInnerClient().getExtendsModelArrays()); + } + + /** + * Builds an instance of IsModelArrayClient class. + * + * @return an instance of IsModelArrayClient. + */ + @Metadata(generated = true) + public IsModelArrayClient buildIsModelArrayClient() { + return new IsModelArrayClient(buildInnerClient().getIsModelArrays()); + } + + /** + * Builds an instance of SpreadModelArrayClient class. + * + * @return an instance of SpreadModelArrayClient. + */ + @Metadata(generated = true) + public SpreadModelArrayClient buildSpreadModelArrayClient() { + return new SpreadModelArrayClient(buildInnerClient().getSpreadModelArrays()); + } + + /** + * Builds an instance of SpreadDifferentStringClient class. + * + * @return an instance of SpreadDifferentStringClient. + */ + @Metadata(generated = true) + public SpreadDifferentStringClient buildSpreadDifferentStringClient() { + return new SpreadDifferentStringClient(buildInnerClient().getSpreadDifferentStrings()); + } + + /** + * Builds an instance of SpreadDifferentFloatClient class. + * + * @return an instance of SpreadDifferentFloatClient. + */ + @Metadata(generated = true) + public SpreadDifferentFloatClient buildSpreadDifferentFloatClient() { + return new SpreadDifferentFloatClient(buildInnerClient().getSpreadDifferentFloats()); + } + + /** + * Builds an instance of SpreadDifferentModelClient class. + * + * @return an instance of SpreadDifferentModelClient. + */ + @Metadata(generated = true) + public SpreadDifferentModelClient buildSpreadDifferentModelClient() { + return new SpreadDifferentModelClient(buildInnerClient().getSpreadDifferentModels()); + } + + /** + * Builds an instance of SpreadDifferentModelArrayClient class. + * + * @return an instance of SpreadDifferentModelArrayClient. + */ + @Metadata(generated = true) + public SpreadDifferentModelArrayClient buildSpreadDifferentModelArrayClient() { + return new SpreadDifferentModelArrayClient(buildInnerClient().getSpreadDifferentModelArrays()); + } + + /** + * Builds an instance of ExtendsDifferentSpreadStringClient class. + * + * @return an instance of ExtendsDifferentSpreadStringClient. + */ + @Metadata(generated = true) + public ExtendsDifferentSpreadStringClient buildExtendsDifferentSpreadStringClient() { + return new ExtendsDifferentSpreadStringClient(buildInnerClient().getExtendsDifferentSpreadStrings()); + } + + /** + * Builds an instance of ExtendsDifferentSpreadFloatClient class. + * + * @return an instance of ExtendsDifferentSpreadFloatClient. + */ + @Metadata(generated = true) + public ExtendsDifferentSpreadFloatClient buildExtendsDifferentSpreadFloatClient() { + return new ExtendsDifferentSpreadFloatClient(buildInnerClient().getExtendsDifferentSpreadFloats()); + } + + /** + * Builds an instance of ExtendsDifferentSpreadModelClient class. + * + * @return an instance of ExtendsDifferentSpreadModelClient. + */ + @Metadata(generated = true) + public ExtendsDifferentSpreadModelClient buildExtendsDifferentSpreadModelClient() { + return new ExtendsDifferentSpreadModelClient(buildInnerClient().getExtendsDifferentSpreadModels()); + } + + /** + * Builds an instance of ExtendsDifferentSpreadModelArrayClient class. + * + * @return an instance of ExtendsDifferentSpreadModelArrayClient. + */ + @Metadata(generated = true) + public ExtendsDifferentSpreadModelArrayClient buildExtendsDifferentSpreadModelArrayClient() { + return new ExtendsDifferentSpreadModelArrayClient(buildInnerClient().getExtendsDifferentSpreadModelArrays()); + } + + /** + * Builds an instance of MultipleSpreadClient class. + * + * @return an instance of MultipleSpreadClient. + */ + @Metadata(generated = true) + public MultipleSpreadClient buildMultipleSpreadClient() { + return new MultipleSpreadClient(buildInnerClient().getMultipleSpreads()); + } + + /** + * Builds an instance of SpreadRecordUnionClient class. + * + * @return an instance of SpreadRecordUnionClient. + */ + @Metadata(generated = true) + public SpreadRecordUnionClient buildSpreadRecordUnionClient() { + return new SpreadRecordUnionClient(buildInnerClient().getSpreadRecordUnions()); + } + + /** + * Builds an instance of SpreadRecordDiscriminatedUnionClient class. + * + * @return an instance of SpreadRecordDiscriminatedUnionClient. + */ + @Metadata(generated = true) + public SpreadRecordDiscriminatedUnionClient buildSpreadRecordDiscriminatedUnionClient() { + return new SpreadRecordDiscriminatedUnionClient(buildInnerClient().getSpreadRecordDiscriminatedUnions()); + } + + /** + * Builds an instance of SpreadRecordNonDiscriminatedUnionClient class. + * + * @return an instance of SpreadRecordNonDiscriminatedUnionClient. + */ + @Metadata(generated = true) + public SpreadRecordNonDiscriminatedUnionClient buildSpreadRecordNonDiscriminatedUnionClient() { + return new SpreadRecordNonDiscriminatedUnionClient(buildInnerClient().getSpreadRecordNonDiscriminatedUnions()); + } + + /** + * Builds an instance of SpreadRecordNonDiscriminatedUnion2Client class. + * + * @return an instance of SpreadRecordNonDiscriminatedUnion2Client. + */ + @Metadata(generated = true) + public SpreadRecordNonDiscriminatedUnion2Client buildSpreadRecordNonDiscriminatedUnion2Client() { + return new SpreadRecordNonDiscriminatedUnion2Client( + buildInnerClient().getSpreadRecordNonDiscriminatedUnion2s()); + } + + /** + * Builds an instance of SpreadRecordNonDiscriminatedUnion3Client class. + * + * @return an instance of SpreadRecordNonDiscriminatedUnion3Client. + */ + @Metadata(generated = true) + public SpreadRecordNonDiscriminatedUnion3Client buildSpreadRecordNonDiscriminatedUnion3Client() { + return new SpreadRecordNonDiscriminatedUnion3Client( + buildInnerClient().getSpreadRecordNonDiscriminatedUnion3s()); + } + + private static final ClientLogger LOGGER = new ClientLogger(AdditionalPropertiesClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadFloatDerived.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadFloatDerived.java new file mode 100644 index 0000000000..dbfe700078 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadFloatDerived.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from a model that spread Record<float32> with the different known property type. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class DifferentSpreadFloatDerived extends DifferentSpreadFloatRecord { + /* + * The index property + */ + @Metadata(generated = true) + private final double derivedProp; + + /** + * Creates an instance of DifferentSpreadFloatDerived class. + * + * @param name the name value to set. + * @param derivedProp the derivedProp value to set. + */ + @Metadata(generated = true) + public DifferentSpreadFloatDerived(String name, double derivedProp) { + super(name); + this.derivedProp = derivedProp; + } + + /** + * Get the derivedProp property: The index property. + * + * @return the derivedProp value. + */ + @Metadata(generated = true) + public double getDerivedProp() { + return this.derivedProp; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", getName()); + jsonWriter.writeDoubleField("derivedProp", this.derivedProp); + if (getAdditionalProperties() != null) { + for (Map.Entry additionalProperty : getAdditionalProperties().entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DifferentSpreadFloatDerived from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DifferentSpreadFloatDerived 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 DifferentSpreadFloatDerived. + */ + @Metadata(generated = true) + public static DifferentSpreadFloatDerived fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + double derivedProp = 0.0; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("derivedProp".equals(fieldName)) { + derivedProp = reader.getDouble(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getDouble()); + } + } + DifferentSpreadFloatDerived deserializedDifferentSpreadFloatDerived + = new DifferentSpreadFloatDerived(name, derivedProp); + deserializedDifferentSpreadFloatDerived.setAdditionalProperties(additionalProperties); + + return deserializedDifferentSpreadFloatDerived; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadFloatRecord.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadFloatRecord.java new file mode 100644 index 0000000000..caee3fbc29 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadFloatRecord.java @@ -0,0 +1,126 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<float32> with the different known property type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public class DifferentSpreadFloatRecord implements JsonSerializable { + /* + * The id property + */ + @Metadata(generated = true) + private final String name; + + /* + * The model spread Record with the different known property type + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of DifferentSpreadFloatRecord class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public DifferentSpreadFloatRecord(String name) { + this.name = name; + } + + /** + * Get the name property: The id property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: The model spread Record<float32> with the different known property + * type. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model spread Record<float32> with the different known property + * type. + * + * @param additionalProperties the additionalProperties value to set. + * @return the DifferentSpreadFloatRecord object itself. + */ + @Metadata(generated = true) + public DifferentSpreadFloatRecord setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DifferentSpreadFloatRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DifferentSpreadFloatRecord 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 DifferentSpreadFloatRecord. + */ + @Metadata(generated = true) + public static DifferentSpreadFloatRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getDouble()); + } + } + DifferentSpreadFloatRecord deserializedDifferentSpreadFloatRecord = new DifferentSpreadFloatRecord(name); + deserializedDifferentSpreadFloatRecord.additionalProperties = additionalProperties; + + return deserializedDifferentSpreadFloatRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadModelArrayDerived.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadModelArrayDerived.java new file mode 100644 index 0000000000..c9b05199c6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadModelArrayDerived.java @@ -0,0 +1,105 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * The model extends from a model that spread Record<ModelForRecord[]> with the different known property type. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class DifferentSpreadModelArrayDerived extends DifferentSpreadModelArrayRecord { + /* + * The index property + */ + @Metadata(generated = true) + private final List derivedProp; + + /** + * Creates an instance of DifferentSpreadModelArrayDerived class. + * + * @param knownProp the knownProp value to set. + * @param derivedProp the derivedProp value to set. + */ + @Metadata(generated = true) + public DifferentSpreadModelArrayDerived(String knownProp, List derivedProp) { + super(knownProp); + this.derivedProp = derivedProp; + } + + /** + * Get the derivedProp property: The index property. + * + * @return the derivedProp value. + */ + @Metadata(generated = true) + public List getDerivedProp() { + return this.derivedProp; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("knownProp", getKnownProp()); + jsonWriter.writeArrayField("derivedProp", this.derivedProp, (writer, element) -> writer.writeJson(element)); + if (getAdditionalProperties() != null) { + for (Map.Entry> additionalProperty : getAdditionalProperties().entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DifferentSpreadModelArrayDerived from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DifferentSpreadModelArrayDerived 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 DifferentSpreadModelArrayDerived. + */ + @Metadata(generated = true) + public static DifferentSpreadModelArrayDerived fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String knownProp = null; + List derivedProp = null; + Map> additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = reader.getString(); + } else if ("derivedProp".equals(fieldName)) { + derivedProp = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + List additionalPropertiesArrayItem + = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + additionalProperties.put(fieldName, additionalPropertiesArrayItem); + } + } + DifferentSpreadModelArrayDerived deserializedDifferentSpreadModelArrayDerived + = new DifferentSpreadModelArrayDerived(knownProp, derivedProp); + deserializedDifferentSpreadModelArrayDerived.setAdditionalProperties(additionalProperties); + + return deserializedDifferentSpreadModelArrayDerived; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadModelArrayRecord.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadModelArrayRecord.java new file mode 100644 index 0000000000..e5780d9034 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadModelArrayRecord.java @@ -0,0 +1,131 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * The model spread Record<ModelForRecord[]> with the different known property type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public class DifferentSpreadModelArrayRecord implements JsonSerializable { + /* + * The knownProp property. + */ + @Metadata(generated = true) + private final String knownProp; + + /* + * The model spread Record with the different known property type + */ + @Metadata(generated = true) + private Map> additionalProperties; + + /** + * Creates an instance of DifferentSpreadModelArrayRecord class. + * + * @param knownProp the knownProp value to set. + */ + @Metadata(generated = true) + public DifferentSpreadModelArrayRecord(String knownProp) { + this.knownProp = knownProp; + } + + /** + * Get the knownProp property: The knownProp property. + * + * @return the knownProp value. + */ + @Metadata(generated = true) + public String getKnownProp() { + return this.knownProp; + } + + /** + * Get the additionalProperties property: The model spread Record<ModelForRecord[]> with the different known + * property type. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map> getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model spread Record<ModelForRecord[]> with the different known + * property type. + * + * @param additionalProperties the additionalProperties value to set. + * @return the DifferentSpreadModelArrayRecord object itself. + */ + @Metadata(generated = true) + public DifferentSpreadModelArrayRecord + setAdditionalProperties(Map> additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("knownProp", this.knownProp); + if (additionalProperties != null) { + for (Map.Entry> additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DifferentSpreadModelArrayRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DifferentSpreadModelArrayRecord 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 DifferentSpreadModelArrayRecord. + */ + @Metadata(generated = true) + public static DifferentSpreadModelArrayRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String knownProp = null; + Map> additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + List additionalPropertiesArrayItem + = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + additionalProperties.put(fieldName, additionalPropertiesArrayItem); + } + } + DifferentSpreadModelArrayRecord deserializedDifferentSpreadModelArrayRecord + = new DifferentSpreadModelArrayRecord(knownProp); + deserializedDifferentSpreadModelArrayRecord.additionalProperties = additionalProperties; + + return deserializedDifferentSpreadModelArrayRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadModelDerived.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadModelDerived.java new file mode 100644 index 0000000000..67e14a7dc5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadModelDerived.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from a model that spread Record<ModelForRecord> with the different known property type. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class DifferentSpreadModelDerived extends DifferentSpreadModelRecord { + /* + * The index property + */ + @Metadata(generated = true) + private final ModelForRecord derivedProp; + + /** + * Creates an instance of DifferentSpreadModelDerived class. + * + * @param knownProp the knownProp value to set. + * @param derivedProp the derivedProp value to set. + */ + @Metadata(generated = true) + public DifferentSpreadModelDerived(String knownProp, ModelForRecord derivedProp) { + super(knownProp); + this.derivedProp = derivedProp; + } + + /** + * Get the derivedProp property: The index property. + * + * @return the derivedProp value. + */ + @Metadata(generated = true) + public ModelForRecord getDerivedProp() { + return this.derivedProp; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("knownProp", getKnownProp()); + jsonWriter.writeJsonField("derivedProp", this.derivedProp); + if (getAdditionalProperties() != null) { + for (Map.Entry additionalProperty : getAdditionalProperties().entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DifferentSpreadModelDerived from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DifferentSpreadModelDerived 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 DifferentSpreadModelDerived. + */ + @Metadata(generated = true) + public static DifferentSpreadModelDerived fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String knownProp = null; + ModelForRecord derivedProp = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = reader.getString(); + } else if ("derivedProp".equals(fieldName)) { + derivedProp = ModelForRecord.fromJson(reader); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, ModelForRecord.fromJson(reader)); + } + } + DifferentSpreadModelDerived deserializedDifferentSpreadModelDerived + = new DifferentSpreadModelDerived(knownProp, derivedProp); + deserializedDifferentSpreadModelDerived.setAdditionalProperties(additionalProperties); + + return deserializedDifferentSpreadModelDerived; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadModelRecord.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadModelRecord.java new file mode 100644 index 0000000000..50571d3fa6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadModelRecord.java @@ -0,0 +1,127 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<ModelForRecord> with the different known property type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public class DifferentSpreadModelRecord implements JsonSerializable { + /* + * The knownProp property. + */ + @Metadata(generated = true) + private final String knownProp; + + /* + * The model spread Record with the different known property type + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of DifferentSpreadModelRecord class. + * + * @param knownProp the knownProp value to set. + */ + @Metadata(generated = true) + public DifferentSpreadModelRecord(String knownProp) { + this.knownProp = knownProp; + } + + /** + * Get the knownProp property: The knownProp property. + * + * @return the knownProp value. + */ + @Metadata(generated = true) + public String getKnownProp() { + return this.knownProp; + } + + /** + * Get the additionalProperties property: The model spread Record<ModelForRecord> with the different known + * property type. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model spread Record<ModelForRecord> with the different known + * property type. + * + * @param additionalProperties the additionalProperties value to set. + * @return the DifferentSpreadModelRecord object itself. + */ + @Metadata(generated = true) + public DifferentSpreadModelRecord setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("knownProp", this.knownProp); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DifferentSpreadModelRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DifferentSpreadModelRecord 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 DifferentSpreadModelRecord. + */ + @Metadata(generated = true) + public static DifferentSpreadModelRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String knownProp = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, ModelForRecord.fromJson(reader)); + } + } + DifferentSpreadModelRecord deserializedDifferentSpreadModelRecord + = new DifferentSpreadModelRecord(knownProp); + deserializedDifferentSpreadModelRecord.additionalProperties = additionalProperties; + + return deserializedDifferentSpreadModelRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadStringDerived.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadStringDerived.java new file mode 100644 index 0000000000..c0f3489164 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadStringDerived.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from a model that spread Record<string> with the different known property type. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class DifferentSpreadStringDerived extends DifferentSpreadStringRecord { + /* + * The index property + */ + @Metadata(generated = true) + private final String derivedProp; + + /** + * Creates an instance of DifferentSpreadStringDerived class. + * + * @param id the id value to set. + * @param derivedProp the derivedProp value to set. + */ + @Metadata(generated = true) + public DifferentSpreadStringDerived(double id, String derivedProp) { + super(id); + this.derivedProp = derivedProp; + } + + /** + * Get the derivedProp property: The index property. + * + * @return the derivedProp value. + */ + @Metadata(generated = true) + public String getDerivedProp() { + return this.derivedProp; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("id", getId()); + jsonWriter.writeStringField("derivedProp", this.derivedProp); + if (getAdditionalProperties() != null) { + for (Map.Entry additionalProperty : getAdditionalProperties().entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DifferentSpreadStringDerived from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DifferentSpreadStringDerived 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 DifferentSpreadStringDerived. + */ + @Metadata(generated = true) + public static DifferentSpreadStringDerived fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double id = 0.0; + String derivedProp = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getDouble(); + } else if ("derivedProp".equals(fieldName)) { + derivedProp = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getString()); + } + } + DifferentSpreadStringDerived deserializedDifferentSpreadStringDerived + = new DifferentSpreadStringDerived(id, derivedProp); + deserializedDifferentSpreadStringDerived.setAdditionalProperties(additionalProperties); + + return deserializedDifferentSpreadStringDerived; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadStringRecord.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadStringRecord.java new file mode 100644 index 0000000000..6b18d1181e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/DifferentSpreadStringRecord.java @@ -0,0 +1,126 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<string> with the different known property type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public class DifferentSpreadStringRecord implements JsonSerializable { + /* + * The name property + */ + @Metadata(generated = true) + private final double id; + + /* + * The model spread Record with the different known property type + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of DifferentSpreadStringRecord class. + * + * @param id the id value to set. + */ + @Metadata(generated = true) + public DifferentSpreadStringRecord(double id) { + this.id = id; + } + + /** + * Get the id property: The name property. + * + * @return the id value. + */ + @Metadata(generated = true) + public double getId() { + return this.id; + } + + /** + * Get the additionalProperties property: The model spread Record<string> with the different known property + * type. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model spread Record<string> with the different known property + * type. + * + * @param additionalProperties the additionalProperties value to set. + * @return the DifferentSpreadStringRecord object itself. + */ + @Metadata(generated = true) + public DifferentSpreadStringRecord setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("id", this.id); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DifferentSpreadStringRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DifferentSpreadStringRecord 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 DifferentSpreadStringRecord. + */ + @Metadata(generated = true) + public static DifferentSpreadStringRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double id = 0.0; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getDouble(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getString()); + } + } + DifferentSpreadStringRecord deserializedDifferentSpreadStringRecord = new DifferentSpreadStringRecord(id); + deserializedDifferentSpreadStringRecord.additionalProperties = additionalProperties; + + return deserializedDifferentSpreadStringRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsDifferentSpreadFloatClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsDifferentSpreadFloatClient.java new file mode 100644 index 0000000000..76b39141c0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsDifferentSpreadFloatClient.java @@ -0,0 +1,110 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.ExtendsDifferentSpreadFloatsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsDifferentSpreadFloatClient { + @Metadata(generated = true) + private final ExtendsDifferentSpreadFloatsImpl serviceClient; + + /** + * Initializes an instance of ExtendsDifferentSpreadFloatClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ExtendsDifferentSpreadFloatClient(ExtendsDifferentSpreadFloatsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     *     derivedProp: double (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     *     derivedProp: double (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public DifferentSpreadFloatDerived get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(DifferentSpreadFloatDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsDifferentSpreadModelArrayClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsDifferentSpreadModelArrayClient.java new file mode 100644 index 0000000000..9b662757aa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsDifferentSpreadModelArrayClient.java @@ -0,0 +1,122 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.ExtendsDifferentSpreadModelArraysImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsDifferentSpreadModelArrayClient { + @Metadata(generated = true) + private final ExtendsDifferentSpreadModelArraysImpl serviceClient; + + /** + * Initializes an instance of ExtendsDifferentSpreadModelArrayClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ExtendsDifferentSpreadModelArrayClient(ExtendsDifferentSpreadModelArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     *     derivedProp (Required): [
+     *         (recursive schema, see above)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     *     derivedProp (Required): [
+     *         (recursive schema, see above)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public DifferentSpreadModelArrayDerived get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(DifferentSpreadModelArrayDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsDifferentSpreadModelClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsDifferentSpreadModelClient.java new file mode 100644 index 0000000000..0bd76ec038 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsDifferentSpreadModelClient.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.ExtendsDifferentSpreadModelsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsDifferentSpreadModelClient { + @Metadata(generated = true) + private final ExtendsDifferentSpreadModelsImpl serviceClient; + + /** + * Initializes an instance of ExtendsDifferentSpreadModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ExtendsDifferentSpreadModelClient(ExtendsDifferentSpreadModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     *     derivedProp (Required): (recursive schema, see derivedProp above)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     *     derivedProp (Required): (recursive schema, see derivedProp above)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public DifferentSpreadModelDerived get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(DifferentSpreadModelDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsDifferentSpreadStringClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsDifferentSpreadStringClient.java new file mode 100644 index 0000000000..37bbffea0a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsDifferentSpreadStringClient.java @@ -0,0 +1,110 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.ExtendsDifferentSpreadStringsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsDifferentSpreadStringClient { + @Metadata(generated = true) + private final ExtendsDifferentSpreadStringsImpl serviceClient; + + /** + * Initializes an instance of ExtendsDifferentSpreadStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ExtendsDifferentSpreadStringClient(ExtendsDifferentSpreadStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     *     derivedProp: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     *     derivedProp: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public DifferentSpreadStringDerived get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(DifferentSpreadStringDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsFloatAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsFloatAdditionalProperties.java new file mode 100644 index 0000000000..bc6f50a932 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsFloatAdditionalProperties.java @@ -0,0 +1,125 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from Record<float32> type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class ExtendsFloatAdditionalProperties implements JsonSerializable { + /* + * The id property + */ + @Metadata(generated = true) + private final double id; + + /* + * The model extends from Record type. + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of ExtendsFloatAdditionalProperties class. + * + * @param id the id value to set. + */ + @Metadata(generated = true) + public ExtendsFloatAdditionalProperties(double id) { + this.id = id; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Metadata(generated = true) + public double getId() { + return this.id; + } + + /** + * Get the additionalProperties property: The model extends from Record<float32> type. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model extends from Record<float32> type. + * + * @param additionalProperties the additionalProperties value to set. + * @return the ExtendsFloatAdditionalProperties object itself. + */ + @Metadata(generated = true) + public ExtendsFloatAdditionalProperties setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("id", this.id); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtendsFloatAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtendsFloatAdditionalProperties 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 ExtendsFloatAdditionalProperties. + */ + @Metadata(generated = true) + public static ExtendsFloatAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double id = 0.0; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getDouble(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getDouble()); + } + } + ExtendsFloatAdditionalProperties deserializedExtendsFloatAdditionalProperties + = new ExtendsFloatAdditionalProperties(id); + deserializedExtendsFloatAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedExtendsFloatAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsFloatClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsFloatClient.java new file mode 100644 index 0000000000..41e83d10c0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsFloatClient.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.ExtendsFloatsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsFloatClient { + @Metadata(generated = true) + private final ExtendsFloatsImpl serviceClient; + + /** + * Initializes an instance of ExtendsFloatClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ExtendsFloatClient(ExtendsFloatsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public ExtendsFloatAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(ExtendsFloatAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsModelAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsModelAdditionalProperties.java new file mode 100644 index 0000000000..0bb468a32f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsModelAdditionalProperties.java @@ -0,0 +1,125 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from Record<ModelForRecord> type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class ExtendsModelAdditionalProperties implements JsonSerializable { + /* + * The knownProp property. + */ + @Metadata(generated = true) + private final ModelForRecord knownProp; + + /* + * The model extends from Record type. + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of ExtendsModelAdditionalProperties class. + * + * @param knownProp the knownProp value to set. + */ + @Metadata(generated = true) + public ExtendsModelAdditionalProperties(ModelForRecord knownProp) { + this.knownProp = knownProp; + } + + /** + * Get the knownProp property: The knownProp property. + * + * @return the knownProp value. + */ + @Metadata(generated = true) + public ModelForRecord getKnownProp() { + return this.knownProp; + } + + /** + * Get the additionalProperties property: The model extends from Record<ModelForRecord> type. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model extends from Record<ModelForRecord> type. + * + * @param additionalProperties the additionalProperties value to set. + * @return the ExtendsModelAdditionalProperties object itself. + */ + @Metadata(generated = true) + public ExtendsModelAdditionalProperties setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("knownProp", this.knownProp); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtendsModelAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtendsModelAdditionalProperties 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 ExtendsModelAdditionalProperties. + */ + @Metadata(generated = true) + public static ExtendsModelAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ModelForRecord knownProp = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = ModelForRecord.fromJson(reader); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, ModelForRecord.fromJson(reader)); + } + } + ExtendsModelAdditionalProperties deserializedExtendsModelAdditionalProperties + = new ExtendsModelAdditionalProperties(knownProp); + deserializedExtendsModelAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedExtendsModelAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsModelArrayAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsModelArrayAdditionalProperties.java new file mode 100644 index 0000000000..16751f8e49 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsModelArrayAdditionalProperties.java @@ -0,0 +1,130 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * The model extends from Record<ModelForRecord[]> type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class ExtendsModelArrayAdditionalProperties + implements JsonSerializable { + /* + * The knownProp property. + */ + @Metadata(generated = true) + private final List knownProp; + + /* + * The model extends from Record type. + */ + @Metadata(generated = true) + private Map> additionalProperties; + + /** + * Creates an instance of ExtendsModelArrayAdditionalProperties class. + * + * @param knownProp the knownProp value to set. + */ + @Metadata(generated = true) + public ExtendsModelArrayAdditionalProperties(List knownProp) { + this.knownProp = knownProp; + } + + /** + * Get the knownProp property: The knownProp property. + * + * @return the knownProp value. + */ + @Metadata(generated = true) + public List getKnownProp() { + return this.knownProp; + } + + /** + * Get the additionalProperties property: The model extends from Record<ModelForRecord[]> type. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map> getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model extends from Record<ModelForRecord[]> type. + * + * @param additionalProperties the additionalProperties value to set. + * @return the ExtendsModelArrayAdditionalProperties object itself. + */ + @Metadata(generated = true) + public ExtendsModelArrayAdditionalProperties + setAdditionalProperties(Map> additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("knownProp", this.knownProp, (writer, element) -> writer.writeJson(element)); + if (additionalProperties != null) { + for (Map.Entry> additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtendsModelArrayAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtendsModelArrayAdditionalProperties 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 ExtendsModelArrayAdditionalProperties. + */ + @Metadata(generated = true) + public static ExtendsModelArrayAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List knownProp = null; + Map> additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + List additionalPropertiesArrayItem + = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + additionalProperties.put(fieldName, additionalPropertiesArrayItem); + } + } + ExtendsModelArrayAdditionalProperties deserializedExtendsModelArrayAdditionalProperties + = new ExtendsModelArrayAdditionalProperties(knownProp); + deserializedExtendsModelArrayAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedExtendsModelArrayAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsModelArrayClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsModelArrayClient.java new file mode 100644 index 0000000000..b20ba98913 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsModelArrayClient.java @@ -0,0 +1,120 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.ExtendsModelArraysImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsModelArrayClient { + @Metadata(generated = true) + private final ExtendsModelArraysImpl serviceClient; + + /** + * Initializes an instance of ExtendsModelArrayClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ExtendsModelArrayClient(ExtendsModelArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public ExtendsModelArrayAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(ExtendsModelArrayAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsModelClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsModelClient.java new file mode 100644 index 0000000000..383f4277a4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsModelClient.java @@ -0,0 +1,112 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.ExtendsModelsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsModelClient { + @Metadata(generated = true) + private final ExtendsModelsImpl serviceClient; + + /** + * Initializes an instance of ExtendsModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ExtendsModelClient(ExtendsModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public ExtendsModelAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(ExtendsModelAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsStringAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsStringAdditionalProperties.java new file mode 100644 index 0000000000..a01cd6054d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsStringAdditionalProperties.java @@ -0,0 +1,125 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from Record<string> type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class ExtendsStringAdditionalProperties implements JsonSerializable { + /* + * The name property + */ + @Metadata(generated = true) + private final String name; + + /* + * The model extends from Record type. + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of ExtendsStringAdditionalProperties class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public ExtendsStringAdditionalProperties(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: The model extends from Record<string> type. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model extends from Record<string> type. + * + * @param additionalProperties the additionalProperties value to set. + * @return the ExtendsStringAdditionalProperties object itself. + */ + @Metadata(generated = true) + public ExtendsStringAdditionalProperties setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtendsStringAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtendsStringAdditionalProperties 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 ExtendsStringAdditionalProperties. + */ + @Metadata(generated = true) + public static ExtendsStringAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getString()); + } + } + ExtendsStringAdditionalProperties deserializedExtendsStringAdditionalProperties + = new ExtendsStringAdditionalProperties(name); + deserializedExtendsStringAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedExtendsStringAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsStringClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsStringClient.java new file mode 100644 index 0000000000..04149bcb19 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsStringClient.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.ExtendsStringsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsStringClient { + @Metadata(generated = true) + private final ExtendsStringsImpl serviceClient; + + /** + * Initializes an instance of ExtendsStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ExtendsStringClient(ExtendsStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public ExtendsStringAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(ExtendsStringAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownAdditionalProperties.java new file mode 100644 index 0000000000..e831526657 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownAdditionalProperties.java @@ -0,0 +1,132 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from Record<unknown> type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public class ExtendsUnknownAdditionalProperties implements JsonSerializable { + /* + * The name property + */ + @Metadata(generated = true) + private final String name; + + /* + * The model extends from Record type. + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of ExtendsUnknownAdditionalProperties class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public ExtendsUnknownAdditionalProperties(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: The model extends from Record<unknown> type. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model extends from Record<unknown> type. + * + * @param additionalProperties the additionalProperties value to set. + * @return the ExtendsUnknownAdditionalProperties object itself. + */ + @Metadata(generated = true) + public ExtendsUnknownAdditionalProperties setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeFieldName(additionalProperty.getKey()); + if (additionalProperty.getValue() == null) { + jsonWriter.writeNull(); + } else { + additionalProperty.getValue().writeTo(jsonWriter); + } + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtendsUnknownAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtendsUnknownAdditionalProperties 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 ExtendsUnknownAdditionalProperties. + */ + @Metadata(generated = true) + public static ExtendsUnknownAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + ExtendsUnknownAdditionalProperties deserializedExtendsUnknownAdditionalProperties + = new ExtendsUnknownAdditionalProperties(name); + deserializedExtendsUnknownAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedExtendsUnknownAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownAdditionalPropertiesDerived.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownAdditionalPropertiesDerived.java new file mode 100644 index 0000000000..d464e478f7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownAdditionalPropertiesDerived.java @@ -0,0 +1,142 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from a type that extends from Record<unknown>. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class ExtendsUnknownAdditionalPropertiesDerived extends ExtendsUnknownAdditionalProperties { + /* + * The index property + */ + @Metadata(generated = true) + private final int index; + + /* + * The age property + */ + @Metadata(generated = true) + private Double age; + + /** + * Creates an instance of ExtendsUnknownAdditionalPropertiesDerived class. + * + * @param name the name value to set. + * @param index the index value to set. + */ + @Metadata(generated = true) + public ExtendsUnknownAdditionalPropertiesDerived(String name, int index) { + super(name); + this.index = index; + } + + /** + * Get the index property: The index property. + * + * @return the index value. + */ + @Metadata(generated = true) + public int getIndex() { + return this.index; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + @Metadata(generated = true) + public Double getAge() { + return this.age; + } + + /** + * Set the age property: The age property. + * + * @param age the age value to set. + * @return the ExtendsUnknownAdditionalPropertiesDerived object itself. + */ + @Metadata(generated = true) + public ExtendsUnknownAdditionalPropertiesDerived setAge(Double age) { + this.age = age; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", getName()); + jsonWriter.writeIntField("index", this.index); + jsonWriter.writeNumberField("age", this.age); + if (getAdditionalProperties() != null) { + for (Map.Entry additionalProperty : getAdditionalProperties().entrySet()) { + jsonWriter.writeFieldName(additionalProperty.getKey()); + if (additionalProperty.getValue() == null) { + jsonWriter.writeNull(); + } else { + additionalProperty.getValue().writeTo(jsonWriter); + } + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtendsUnknownAdditionalPropertiesDerived from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtendsUnknownAdditionalPropertiesDerived 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 ExtendsUnknownAdditionalPropertiesDerived. + */ + @Metadata(generated = true) + public static ExtendsUnknownAdditionalPropertiesDerived fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + int index = 0; + Double age = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("age".equals(fieldName)) { + age = reader.getNullable(JsonReader::getDouble); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + ExtendsUnknownAdditionalPropertiesDerived deserializedExtendsUnknownAdditionalPropertiesDerived + = new ExtendsUnknownAdditionalPropertiesDerived(name, index); + deserializedExtendsUnknownAdditionalPropertiesDerived.age = age; + deserializedExtendsUnknownAdditionalPropertiesDerived.setAdditionalProperties(additionalProperties); + + return deserializedExtendsUnknownAdditionalPropertiesDerived; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownAdditionalPropertiesDiscriminated.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownAdditionalPropertiesDiscriminated.java new file mode 100644 index 0000000000..e6b8cefc1e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownAdditionalPropertiesDiscriminated.java @@ -0,0 +1,182 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from Record<unknown> with a discriminator. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public class ExtendsUnknownAdditionalPropertiesDiscriminated + implements JsonSerializable { + /* + * The discriminator + */ + @Metadata(generated = true) + private String kind = "ExtendsUnknownAdditionalPropertiesDiscriminated"; + + /* + * The name property + */ + @Metadata(generated = true) + private final String name; + + /* + * The model extends from Record with a discriminator. + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of ExtendsUnknownAdditionalPropertiesDiscriminated class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public ExtendsUnknownAdditionalPropertiesDiscriminated(String name) { + this.name = name; + } + + /** + * Get the kind property: The discriminator. + * + * @return the kind value. + */ + @Metadata(generated = true) + public String getKind() { + return this.kind; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: The model extends from Record<unknown> with a discriminator. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model extends from Record<unknown> with a discriminator. + * + * @param additionalProperties the additionalProperties value to set. + * @return the ExtendsUnknownAdditionalPropertiesDiscriminated object itself. + */ + @Metadata(generated = true) + public ExtendsUnknownAdditionalPropertiesDiscriminated + setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("kind", this.kind); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeFieldName(additionalProperty.getKey()); + if (additionalProperty.getValue() == null) { + jsonWriter.writeNull(); + } else { + additionalProperty.getValue().writeTo(jsonWriter); + } + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtendsUnknownAdditionalPropertiesDiscriminated from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtendsUnknownAdditionalPropertiesDiscriminated 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 ExtendsUnknownAdditionalPropertiesDiscriminated. + */ + @Metadata(generated = true) + public static ExtendsUnknownAdditionalPropertiesDiscriminated 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 ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("derived".equals(discriminatorValue)) { + return ExtendsUnknownAdditionalPropertiesDiscriminatedDerived.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Metadata(generated = true) + static ExtendsUnknownAdditionalPropertiesDiscriminated fromJsonKnownDiscriminator(JsonReader jsonReader) + throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String kind = null; + Map additionalProperties = 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 { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + ExtendsUnknownAdditionalPropertiesDiscriminated deserializedExtendsUnknownAdditionalPropertiesDiscriminated + = new ExtendsUnknownAdditionalPropertiesDiscriminated(name); + deserializedExtendsUnknownAdditionalPropertiesDiscriminated.kind = kind; + deserializedExtendsUnknownAdditionalPropertiesDiscriminated.additionalProperties = additionalProperties; + + return deserializedExtendsUnknownAdditionalPropertiesDiscriminated; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownAdditionalPropertiesDiscriminatedDerived.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownAdditionalPropertiesDiscriminatedDerived.java new file mode 100644 index 0000000000..2b108261c6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownAdditionalPropertiesDiscriminatedDerived.java @@ -0,0 +1,167 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The derived discriminated type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class ExtendsUnknownAdditionalPropertiesDiscriminatedDerived + extends ExtendsUnknownAdditionalPropertiesDiscriminated { + /* + * The discriminator + */ + @Metadata(generated = true) + private String kind = "derived"; + + /* + * The index property + */ + @Metadata(generated = true) + private final int index; + + /* + * The age property + */ + @Metadata(generated = true) + private Double age; + + /** + * Creates an instance of ExtendsUnknownAdditionalPropertiesDiscriminatedDerived class. + * + * @param name the name value to set. + * @param index the index value to set. + */ + @Metadata(generated = true) + public ExtendsUnknownAdditionalPropertiesDiscriminatedDerived(String name, int index) { + super(name); + this.index = index; + } + + /** + * Get the kind property: The discriminator. + * + * @return the kind value. + */ + @Metadata(generated = true) + @Override + public String getKind() { + return this.kind; + } + + /** + * Get the index property: The index property. + * + * @return the index value. + */ + @Metadata(generated = true) + public int getIndex() { + return this.index; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + @Metadata(generated = true) + public Double getAge() { + return this.age; + } + + /** + * Set the age property: The age property. + * + * @param age the age value to set. + * @return the ExtendsUnknownAdditionalPropertiesDiscriminatedDerived object itself. + */ + @Metadata(generated = true) + public ExtendsUnknownAdditionalPropertiesDiscriminatedDerived setAge(Double age) { + this.age = age; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", getName()); + jsonWriter.writeIntField("index", this.index); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeNumberField("age", this.age); + if (getAdditionalProperties() != null) { + for (Map.Entry additionalProperty : getAdditionalProperties().entrySet()) { + jsonWriter.writeFieldName(additionalProperty.getKey()); + if (additionalProperty.getValue() == null) { + jsonWriter.writeNull(); + } else { + additionalProperty.getValue().writeTo(jsonWriter); + } + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtendsUnknownAdditionalPropertiesDiscriminatedDerived from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtendsUnknownAdditionalPropertiesDiscriminatedDerived 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 ExtendsUnknownAdditionalPropertiesDiscriminatedDerived. + */ + @Metadata(generated = true) + public static ExtendsUnknownAdditionalPropertiesDiscriminatedDerived fromJson(JsonReader jsonReader) + throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + int index = 0; + String kind = "derived"; + Double age = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else if ("age".equals(fieldName)) { + age = reader.getNullable(JsonReader::getDouble); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + ExtendsUnknownAdditionalPropertiesDiscriminatedDerived deserializedExtendsUnknownAdditionalPropertiesDiscriminatedDerived + = new ExtendsUnknownAdditionalPropertiesDiscriminatedDerived(name, index); + deserializedExtendsUnknownAdditionalPropertiesDiscriminatedDerived.kind = kind; + deserializedExtendsUnknownAdditionalPropertiesDiscriminatedDerived.age = age; + deserializedExtendsUnknownAdditionalPropertiesDiscriminatedDerived + .setAdditionalProperties(additionalProperties); + + return deserializedExtendsUnknownAdditionalPropertiesDiscriminatedDerived; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownClient.java new file mode 100644 index 0000000000..a58277eb22 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownClient.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.ExtendsUnknownsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsUnknownClient { + @Metadata(generated = true) + private final ExtendsUnknownsImpl serviceClient; + + /** + * Initializes an instance of ExtendsUnknownClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ExtendsUnknownClient(ExtendsUnknownsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public ExtendsUnknownAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(ExtendsUnknownAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownDerivedClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownDerivedClient.java new file mode 100644 index 0000000000..2eed0caa44 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownDerivedClient.java @@ -0,0 +1,112 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.ExtendsUnknownDerivedsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsUnknownDerivedClient { + @Metadata(generated = true) + private final ExtendsUnknownDerivedsImpl serviceClient; + + /** + * Initializes an instance of ExtendsUnknownDerivedClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ExtendsUnknownDerivedClient(ExtendsUnknownDerivedsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public ExtendsUnknownAdditionalPropertiesDerived get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(ExtendsUnknownAdditionalPropertiesDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownDiscriminatedClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownDiscriminatedClient.java new file mode 100644 index 0000000000..80d90e4841 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ExtendsUnknownDiscriminatedClient.java @@ -0,0 +1,110 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.ExtendsUnknownDiscriminatedsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class ExtendsUnknownDiscriminatedClient { + @Metadata(generated = true) + private final ExtendsUnknownDiscriminatedsImpl serviceClient; + + /** + * Initializes an instance of ExtendsUnknownDiscriminatedClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ExtendsUnknownDiscriminatedClient(ExtendsUnknownDiscriminatedsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public ExtendsUnknownAdditionalPropertiesDiscriminated get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(ExtendsUnknownAdditionalPropertiesDiscriminated body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsFloatAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsFloatAdditionalProperties.java new file mode 100644 index 0000000000..57cff13710 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsFloatAdditionalProperties.java @@ -0,0 +1,124 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model is from Record<float32> type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class IsFloatAdditionalProperties implements JsonSerializable { + /* + * The id property + */ + @Metadata(generated = true) + private final double id; + + /* + * The model is from Record type. + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of IsFloatAdditionalProperties class. + * + * @param id the id value to set. + */ + @Metadata(generated = true) + public IsFloatAdditionalProperties(double id) { + this.id = id; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Metadata(generated = true) + public double getId() { + return this.id; + } + + /** + * Get the additionalProperties property: The model is from Record<float32> type. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model is from Record<float32> type. + * + * @param additionalProperties the additionalProperties value to set. + * @return the IsFloatAdditionalProperties object itself. + */ + @Metadata(generated = true) + public IsFloatAdditionalProperties setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("id", this.id); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IsFloatAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IsFloatAdditionalProperties 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 IsFloatAdditionalProperties. + */ + @Metadata(generated = true) + public static IsFloatAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double id = 0.0; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getDouble(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getDouble()); + } + } + IsFloatAdditionalProperties deserializedIsFloatAdditionalProperties = new IsFloatAdditionalProperties(id); + deserializedIsFloatAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedIsFloatAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsFloatClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsFloatClient.java new file mode 100644 index 0000000000..7fe52ccbc0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsFloatClient.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.IsFloatsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class IsFloatClient { + @Metadata(generated = true) + private final IsFloatsImpl serviceClient; + + /** + * Initializes an instance of IsFloatClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + IsFloatClient(IsFloatsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public IsFloatAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(IsFloatAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsModelAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsModelAdditionalProperties.java new file mode 100644 index 0000000000..3d8f873a83 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsModelAdditionalProperties.java @@ -0,0 +1,125 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model is from Record<ModelForRecord> type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class IsModelAdditionalProperties implements JsonSerializable { + /* + * The knownProp property. + */ + @Metadata(generated = true) + private final ModelForRecord knownProp; + + /* + * The model is from Record type. + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of IsModelAdditionalProperties class. + * + * @param knownProp the knownProp value to set. + */ + @Metadata(generated = true) + public IsModelAdditionalProperties(ModelForRecord knownProp) { + this.knownProp = knownProp; + } + + /** + * Get the knownProp property: The knownProp property. + * + * @return the knownProp value. + */ + @Metadata(generated = true) + public ModelForRecord getKnownProp() { + return this.knownProp; + } + + /** + * Get the additionalProperties property: The model is from Record<ModelForRecord> type. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model is from Record<ModelForRecord> type. + * + * @param additionalProperties the additionalProperties value to set. + * @return the IsModelAdditionalProperties object itself. + */ + @Metadata(generated = true) + public IsModelAdditionalProperties setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("knownProp", this.knownProp); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IsModelAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IsModelAdditionalProperties 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 IsModelAdditionalProperties. + */ + @Metadata(generated = true) + public static IsModelAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ModelForRecord knownProp = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = ModelForRecord.fromJson(reader); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, ModelForRecord.fromJson(reader)); + } + } + IsModelAdditionalProperties deserializedIsModelAdditionalProperties + = new IsModelAdditionalProperties(knownProp); + deserializedIsModelAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedIsModelAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsModelArrayAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsModelArrayAdditionalProperties.java new file mode 100644 index 0000000000..a39eea92e9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsModelArrayAdditionalProperties.java @@ -0,0 +1,129 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * The model is from Record<ModelForRecord[]> type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class IsModelArrayAdditionalProperties implements JsonSerializable { + /* + * The knownProp property. + */ + @Metadata(generated = true) + private final List knownProp; + + /* + * The model is from Record type. + */ + @Metadata(generated = true) + private Map> additionalProperties; + + /** + * Creates an instance of IsModelArrayAdditionalProperties class. + * + * @param knownProp the knownProp value to set. + */ + @Metadata(generated = true) + public IsModelArrayAdditionalProperties(List knownProp) { + this.knownProp = knownProp; + } + + /** + * Get the knownProp property: The knownProp property. + * + * @return the knownProp value. + */ + @Metadata(generated = true) + public List getKnownProp() { + return this.knownProp; + } + + /** + * Get the additionalProperties property: The model is from Record<ModelForRecord[]> type. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map> getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model is from Record<ModelForRecord[]> type. + * + * @param additionalProperties the additionalProperties value to set. + * @return the IsModelArrayAdditionalProperties object itself. + */ + @Metadata(generated = true) + public IsModelArrayAdditionalProperties + setAdditionalProperties(Map> additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("knownProp", this.knownProp, (writer, element) -> writer.writeJson(element)); + if (additionalProperties != null) { + for (Map.Entry> additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IsModelArrayAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IsModelArrayAdditionalProperties 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 IsModelArrayAdditionalProperties. + */ + @Metadata(generated = true) + public static IsModelArrayAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List knownProp = null; + Map> additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + List additionalPropertiesArrayItem + = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + additionalProperties.put(fieldName, additionalPropertiesArrayItem); + } + } + IsModelArrayAdditionalProperties deserializedIsModelArrayAdditionalProperties + = new IsModelArrayAdditionalProperties(knownProp); + deserializedIsModelArrayAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedIsModelArrayAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsModelArrayClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsModelArrayClient.java new file mode 100644 index 0000000000..a19eb580c9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsModelArrayClient.java @@ -0,0 +1,120 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.IsModelArraysImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class IsModelArrayClient { + @Metadata(generated = true) + private final IsModelArraysImpl serviceClient; + + /** + * Initializes an instance of IsModelArrayClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + IsModelArrayClient(IsModelArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public IsModelArrayAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(IsModelArrayAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsModelClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsModelClient.java new file mode 100644 index 0000000000..c781d7a69c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsModelClient.java @@ -0,0 +1,112 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.IsModelsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class IsModelClient { + @Metadata(generated = true) + private final IsModelsImpl serviceClient; + + /** + * Initializes an instance of IsModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + IsModelClient(IsModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public IsModelAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(IsModelAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsStringAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsStringAdditionalProperties.java new file mode 100644 index 0000000000..c5b9c96026 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsStringAdditionalProperties.java @@ -0,0 +1,125 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model is from Record<string> type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class IsStringAdditionalProperties implements JsonSerializable { + /* + * The name property + */ + @Metadata(generated = true) + private final String name; + + /* + * The model is from Record type. + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of IsStringAdditionalProperties class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public IsStringAdditionalProperties(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: The model is from Record<string> type. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model is from Record<string> type. + * + * @param additionalProperties the additionalProperties value to set. + * @return the IsStringAdditionalProperties object itself. + */ + @Metadata(generated = true) + public IsStringAdditionalProperties setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IsStringAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IsStringAdditionalProperties 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 IsStringAdditionalProperties. + */ + @Metadata(generated = true) + public static IsStringAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getString()); + } + } + IsStringAdditionalProperties deserializedIsStringAdditionalProperties + = new IsStringAdditionalProperties(name); + deserializedIsStringAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedIsStringAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsStringClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsStringClient.java new file mode 100644 index 0000000000..7123f767ed --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsStringClient.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.IsStringsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class IsStringClient { + @Metadata(generated = true) + private final IsStringsImpl serviceClient; + + /** + * Initializes an instance of IsStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + IsStringClient(IsStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public IsStringAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(IsStringAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownAdditionalProperties.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownAdditionalProperties.java new file mode 100644 index 0000000000..9c2bc50b2e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownAdditionalProperties.java @@ -0,0 +1,132 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model is from Record<unknown> type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public class IsUnknownAdditionalProperties implements JsonSerializable { + /* + * The name property + */ + @Metadata(generated = true) + private final String name; + + /* + * The model is from Record type. + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of IsUnknownAdditionalProperties class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public IsUnknownAdditionalProperties(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: The model is from Record<unknown> type. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model is from Record<unknown> type. + * + * @param additionalProperties the additionalProperties value to set. + * @return the IsUnknownAdditionalProperties object itself. + */ + @Metadata(generated = true) + public IsUnknownAdditionalProperties setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeFieldName(additionalProperty.getKey()); + if (additionalProperty.getValue() == null) { + jsonWriter.writeNull(); + } else { + additionalProperty.getValue().writeTo(jsonWriter); + } + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IsUnknownAdditionalProperties from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IsUnknownAdditionalProperties 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 IsUnknownAdditionalProperties. + */ + @Metadata(generated = true) + public static IsUnknownAdditionalProperties fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + IsUnknownAdditionalProperties deserializedIsUnknownAdditionalProperties + = new IsUnknownAdditionalProperties(name); + deserializedIsUnknownAdditionalProperties.additionalProperties = additionalProperties; + + return deserializedIsUnknownAdditionalProperties; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownAdditionalPropertiesDerived.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownAdditionalPropertiesDerived.java new file mode 100644 index 0000000000..e985ab9543 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownAdditionalPropertiesDerived.java @@ -0,0 +1,142 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model extends from a type that is Record<unknown> type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class IsUnknownAdditionalPropertiesDerived extends IsUnknownAdditionalProperties { + /* + * The index property + */ + @Metadata(generated = true) + private final int index; + + /* + * The age property + */ + @Metadata(generated = true) + private Double age; + + /** + * Creates an instance of IsUnknownAdditionalPropertiesDerived class. + * + * @param name the name value to set. + * @param index the index value to set. + */ + @Metadata(generated = true) + public IsUnknownAdditionalPropertiesDerived(String name, int index) { + super(name); + this.index = index; + } + + /** + * Get the index property: The index property. + * + * @return the index value. + */ + @Metadata(generated = true) + public int getIndex() { + return this.index; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + @Metadata(generated = true) + public Double getAge() { + return this.age; + } + + /** + * Set the age property: The age property. + * + * @param age the age value to set. + * @return the IsUnknownAdditionalPropertiesDerived object itself. + */ + @Metadata(generated = true) + public IsUnknownAdditionalPropertiesDerived setAge(Double age) { + this.age = age; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", getName()); + jsonWriter.writeIntField("index", this.index); + jsonWriter.writeNumberField("age", this.age); + if (getAdditionalProperties() != null) { + for (Map.Entry additionalProperty : getAdditionalProperties().entrySet()) { + jsonWriter.writeFieldName(additionalProperty.getKey()); + if (additionalProperty.getValue() == null) { + jsonWriter.writeNull(); + } else { + additionalProperty.getValue().writeTo(jsonWriter); + } + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IsUnknownAdditionalPropertiesDerived from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IsUnknownAdditionalPropertiesDerived 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 IsUnknownAdditionalPropertiesDerived. + */ + @Metadata(generated = true) + public static IsUnknownAdditionalPropertiesDerived fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + int index = 0; + Double age = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("age".equals(fieldName)) { + age = reader.getNullable(JsonReader::getDouble); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + IsUnknownAdditionalPropertiesDerived deserializedIsUnknownAdditionalPropertiesDerived + = new IsUnknownAdditionalPropertiesDerived(name, index); + deserializedIsUnknownAdditionalPropertiesDerived.age = age; + deserializedIsUnknownAdditionalPropertiesDerived.setAdditionalProperties(additionalProperties); + + return deserializedIsUnknownAdditionalPropertiesDerived; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownAdditionalPropertiesDiscriminated.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownAdditionalPropertiesDiscriminated.java new file mode 100644 index 0000000000..f3ead4c4de --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownAdditionalPropertiesDiscriminated.java @@ -0,0 +1,182 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model is Record<unknown> with a discriminator. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public class IsUnknownAdditionalPropertiesDiscriminated + implements JsonSerializable { + /* + * The discriminator + */ + @Metadata(generated = true) + private String kind = "IsUnknownAdditionalPropertiesDiscriminated"; + + /* + * The name property + */ + @Metadata(generated = true) + private final String name; + + /* + * The model is Record with a discriminator. + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of IsUnknownAdditionalPropertiesDiscriminated class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public IsUnknownAdditionalPropertiesDiscriminated(String name) { + this.name = name; + } + + /** + * Get the kind property: The discriminator. + * + * @return the kind value. + */ + @Metadata(generated = true) + public String getKind() { + return this.kind; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: The model is Record<unknown> with a discriminator. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model is Record<unknown> with a discriminator. + * + * @param additionalProperties the additionalProperties value to set. + * @return the IsUnknownAdditionalPropertiesDiscriminated object itself. + */ + @Metadata(generated = true) + public IsUnknownAdditionalPropertiesDiscriminated + setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + jsonWriter.writeStringField("kind", this.kind); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeFieldName(additionalProperty.getKey()); + if (additionalProperty.getValue() == null) { + jsonWriter.writeNull(); + } else { + additionalProperty.getValue().writeTo(jsonWriter); + } + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IsUnknownAdditionalPropertiesDiscriminated from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IsUnknownAdditionalPropertiesDiscriminated 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 IsUnknownAdditionalPropertiesDiscriminated. + */ + @Metadata(generated = true) + public static IsUnknownAdditionalPropertiesDiscriminated 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 ("kind".equals(fieldName)) { + discriminatorValue = readerToUse.getString(); + break; + } else { + readerToUse.skipChildren(); + } + } + // Use the discriminator value to determine which subtype should be deserialized. + if ("derived".equals(discriminatorValue)) { + return IsUnknownAdditionalPropertiesDiscriminatedDerived.fromJson(readerToUse.reset()); + } else { + return fromJsonKnownDiscriminator(readerToUse.reset()); + } + } + }); + } + + @Metadata(generated = true) + static IsUnknownAdditionalPropertiesDiscriminated fromJsonKnownDiscriminator(JsonReader jsonReader) + throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + String kind = null; + Map additionalProperties = 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 { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + IsUnknownAdditionalPropertiesDiscriminated deserializedIsUnknownAdditionalPropertiesDiscriminated + = new IsUnknownAdditionalPropertiesDiscriminated(name); + deserializedIsUnknownAdditionalPropertiesDiscriminated.kind = kind; + deserializedIsUnknownAdditionalPropertiesDiscriminated.additionalProperties = additionalProperties; + + return deserializedIsUnknownAdditionalPropertiesDiscriminated; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownAdditionalPropertiesDiscriminatedDerived.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownAdditionalPropertiesDiscriminatedDerived.java new file mode 100644 index 0000000000..df6a450334 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownAdditionalPropertiesDiscriminatedDerived.java @@ -0,0 +1,165 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The derived discriminated type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class IsUnknownAdditionalPropertiesDiscriminatedDerived + extends IsUnknownAdditionalPropertiesDiscriminated { + /* + * The discriminator + */ + @Metadata(generated = true) + private String kind = "derived"; + + /* + * The index property + */ + @Metadata(generated = true) + private final int index; + + /* + * The age property + */ + @Metadata(generated = true) + private Double age; + + /** + * Creates an instance of IsUnknownAdditionalPropertiesDiscriminatedDerived class. + * + * @param name the name value to set. + * @param index the index value to set. + */ + @Metadata(generated = true) + public IsUnknownAdditionalPropertiesDiscriminatedDerived(String name, int index) { + super(name); + this.index = index; + } + + /** + * Get the kind property: The discriminator. + * + * @return the kind value. + */ + @Metadata(generated = true) + @Override + public String getKind() { + return this.kind; + } + + /** + * Get the index property: The index property. + * + * @return the index value. + */ + @Metadata(generated = true) + public int getIndex() { + return this.index; + } + + /** + * Get the age property: The age property. + * + * @return the age value. + */ + @Metadata(generated = true) + public Double getAge() { + return this.age; + } + + /** + * Set the age property: The age property. + * + * @param age the age value to set. + * @return the IsUnknownAdditionalPropertiesDiscriminatedDerived object itself. + */ + @Metadata(generated = true) + public IsUnknownAdditionalPropertiesDiscriminatedDerived setAge(Double age) { + this.age = age; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", getName()); + jsonWriter.writeIntField("index", this.index); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeNumberField("age", this.age); + if (getAdditionalProperties() != null) { + for (Map.Entry additionalProperty : getAdditionalProperties().entrySet()) { + jsonWriter.writeFieldName(additionalProperty.getKey()); + if (additionalProperty.getValue() == null) { + jsonWriter.writeNull(); + } else { + additionalProperty.getValue().writeTo(jsonWriter); + } + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IsUnknownAdditionalPropertiesDiscriminatedDerived from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IsUnknownAdditionalPropertiesDiscriminatedDerived 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 IsUnknownAdditionalPropertiesDiscriminatedDerived. + */ + @Metadata(generated = true) + public static IsUnknownAdditionalPropertiesDiscriminatedDerived fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + int index = 0; + String kind = "derived"; + Double age = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else if ("index".equals(fieldName)) { + index = reader.getInt(); + } else if ("kind".equals(fieldName)) { + kind = reader.getString(); + } else if ("age".equals(fieldName)) { + age = reader.getNullable(JsonReader::getDouble); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + IsUnknownAdditionalPropertiesDiscriminatedDerived deserializedIsUnknownAdditionalPropertiesDiscriminatedDerived + = new IsUnknownAdditionalPropertiesDiscriminatedDerived(name, index); + deserializedIsUnknownAdditionalPropertiesDiscriminatedDerived.kind = kind; + deserializedIsUnknownAdditionalPropertiesDiscriminatedDerived.age = age; + deserializedIsUnknownAdditionalPropertiesDiscriminatedDerived.setAdditionalProperties(additionalProperties); + + return deserializedIsUnknownAdditionalPropertiesDiscriminatedDerived; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownClient.java new file mode 100644 index 0000000000..f5e2f977a3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownClient.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.IsUnknownsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class IsUnknownClient { + @Metadata(generated = true) + private final IsUnknownsImpl serviceClient; + + /** + * Initializes an instance of IsUnknownClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + IsUnknownClient(IsUnknownsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public IsUnknownAdditionalProperties get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(IsUnknownAdditionalProperties body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownDerivedClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownDerivedClient.java new file mode 100644 index 0000000000..53068d00a8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownDerivedClient.java @@ -0,0 +1,112 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.IsUnknownDerivedsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class IsUnknownDerivedClient { + @Metadata(generated = true) + private final IsUnknownDerivedsImpl serviceClient; + + /** + * Initializes an instance of IsUnknownDerivedClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + IsUnknownDerivedClient(IsUnknownDerivedsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public IsUnknownAdditionalPropertiesDerived get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(IsUnknownAdditionalPropertiesDerived body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownDiscriminatedClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownDiscriminatedClient.java new file mode 100644 index 0000000000..7d580cb2c2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/IsUnknownDiscriminatedClient.java @@ -0,0 +1,110 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.IsUnknownDiscriminatedsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class IsUnknownDiscriminatedClient { + @Metadata(generated = true) + private final IsUnknownDiscriminatedsImpl serviceClient; + + /** + * Initializes an instance of IsUnknownDiscriminatedClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + IsUnknownDiscriminatedClient(IsUnknownDiscriminatedsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public IsUnknownAdditionalPropertiesDiscriminated get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(IsUnknownAdditionalPropertiesDiscriminated body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ModelForRecord.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ModelForRecord.java new file mode 100644 index 0000000000..04f9c1de72 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/ModelForRecord.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * model for record. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class ModelForRecord implements JsonSerializable { + /* + * The state property + */ + @Metadata(generated = true) + private final String state; + + /** + * Creates an instance of ModelForRecord class. + * + * @param state the state value to set. + */ + @Metadata(generated = true) + public ModelForRecord(String state) { + this.state = state; + } + + /** + * Get the state property: The state property. + * + * @return the state value. + */ + @Metadata(generated = true) + public String getState() { + return this.state; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("state", this.state); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ModelForRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ModelForRecord 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 ModelForRecord. + */ + @Metadata(generated = true) + public static ModelForRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String state = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("state".equals(fieldName)) { + state = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new ModelForRecord(state); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/MultipleSpreadClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/MultipleSpreadClient.java new file mode 100644 index 0000000000..411a71cb8d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/MultipleSpreadClient.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.MultipleSpreadsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class MultipleSpreadClient { + @Metadata(generated = true) + private final MultipleSpreadsImpl serviceClient; + + /** + * Initializes an instance of MultipleSpreadClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + MultipleSpreadClient(MultipleSpreadsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public MultipleSpreadRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(MultipleSpreadRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/MultipleSpreadRecord.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/MultipleSpreadRecord.java new file mode 100644 index 0000000000..02f4a38e79 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/MultipleSpreadRecord.java @@ -0,0 +1,131 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<string> and Record<float32>. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class MultipleSpreadRecord implements JsonSerializable { + /* + * The name property + */ + @Metadata(generated = true) + private final boolean flag; + + /* + * The model spread Record and Record + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of MultipleSpreadRecord class. + * + * @param flag the flag value to set. + */ + @Metadata(generated = true) + public MultipleSpreadRecord(boolean flag) { + this.flag = flag; + } + + /** + * Get the flag property: The name property. + * + * @return the flag value. + */ + @Metadata(generated = true) + public boolean isFlag() { + return this.flag; + } + + /** + * Get the additionalProperties property: The model spread Record<string> and Record<float32>. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model spread Record<string> and Record<float32>. + * + * @param additionalProperties the additionalProperties value to set. + * @return the MultipleSpreadRecord object itself. + */ + @Metadata(generated = true) + public MultipleSpreadRecord setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("flag", this.flag); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeFieldName(additionalProperty.getKey()); + if (additionalProperty.getValue() == null) { + jsonWriter.writeNull(); + } else { + additionalProperty.getValue().writeTo(jsonWriter); + } + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MultipleSpreadRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MultipleSpreadRecord 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 MultipleSpreadRecord. + */ + @Metadata(generated = true) + public static MultipleSpreadRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean flag = false; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("flag".equals(fieldName)) { + flag = reader.getBoolean(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + MultipleSpreadRecord deserializedMultipleSpreadRecord = new MultipleSpreadRecord(flag); + deserializedMultipleSpreadRecord.additionalProperties = additionalProperties; + + return deserializedMultipleSpreadRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadDifferentFloatClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadDifferentFloatClient.java new file mode 100644 index 0000000000..fe6fc1c34b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadDifferentFloatClient.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.SpreadDifferentFloatsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadDifferentFloatClient { + @Metadata(generated = true) + private final SpreadDifferentFloatsImpl serviceClient; + + /** + * Initializes an instance of SpreadDifferentFloatClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + SpreadDifferentFloatClient(SpreadDifferentFloatsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public DifferentSpreadFloatRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(DifferentSpreadFloatRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadDifferentModelArrayClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadDifferentModelArrayClient.java new file mode 100644 index 0000000000..a7c610a350 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadDifferentModelArrayClient.java @@ -0,0 +1,116 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.SpreadDifferentModelArraysImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadDifferentModelArrayClient { + @Metadata(generated = true) + private final SpreadDifferentModelArraysImpl serviceClient; + + /** + * Initializes an instance of SpreadDifferentModelArrayClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + SpreadDifferentModelArrayClient(SpreadDifferentModelArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public DifferentSpreadModelArrayRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(DifferentSpreadModelArrayRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadDifferentModelClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadDifferentModelClient.java new file mode 100644 index 0000000000..13d7a82832 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadDifferentModelClient.java @@ -0,0 +1,112 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.SpreadDifferentModelsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadDifferentModelClient { + @Metadata(generated = true) + private final SpreadDifferentModelsImpl serviceClient; + + /** + * Initializes an instance of SpreadDifferentModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + SpreadDifferentModelClient(SpreadDifferentModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public DifferentSpreadModelRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(DifferentSpreadModelRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadDifferentStringClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadDifferentStringClient.java new file mode 100644 index 0000000000..29e4725a9c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadDifferentStringClient.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.SpreadDifferentStringsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadDifferentStringClient { + @Metadata(generated = true) + private final SpreadDifferentStringsImpl serviceClient; + + /** + * Initializes an instance of SpreadDifferentStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + SpreadDifferentStringClient(SpreadDifferentStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public DifferentSpreadStringRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(DifferentSpreadStringRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadFloatClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadFloatClient.java new file mode 100644 index 0000000000..f71bd0c263 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadFloatClient.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.SpreadFloatsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadFloatClient { + @Metadata(generated = true) + private final SpreadFloatsImpl serviceClient; + + /** + * Initializes an instance of SpreadFloatClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + SpreadFloatClient(SpreadFloatsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public SpreadFloatRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(SpreadFloatRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadFloatRecord.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadFloatRecord.java new file mode 100644 index 0000000000..bba08a757a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadFloatRecord.java @@ -0,0 +1,124 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<float32> with the same known property type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class SpreadFloatRecord implements JsonSerializable { + /* + * The id property + */ + @Metadata(generated = true) + private final double id; + + /* + * The model spread Record with the same known property type + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of SpreadFloatRecord class. + * + * @param id the id value to set. + */ + @Metadata(generated = true) + public SpreadFloatRecord(double id) { + this.id = id; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Metadata(generated = true) + public double getId() { + return this.id; + } + + /** + * Get the additionalProperties property: The model spread Record<float32> with the same known property type. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model spread Record<float32> with the same known property type. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadFloatRecord object itself. + */ + @Metadata(generated = true) + public SpreadFloatRecord setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("id", this.id); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadFloatRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadFloatRecord 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 SpreadFloatRecord. + */ + @Metadata(generated = true) + public static SpreadFloatRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double id = 0.0; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getDouble(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getDouble()); + } + } + SpreadFloatRecord deserializedSpreadFloatRecord = new SpreadFloatRecord(id); + deserializedSpreadFloatRecord.additionalProperties = additionalProperties; + + return deserializedSpreadFloatRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadModelArrayClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadModelArrayClient.java new file mode 100644 index 0000000000..b66b59afcd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadModelArrayClient.java @@ -0,0 +1,120 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.SpreadModelArraysImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadModelArrayClient { + @Metadata(generated = true) + private final SpreadModelArraysImpl serviceClient; + + /** + * Initializes an instance of SpreadModelArrayClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + SpreadModelArrayClient(SpreadModelArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public SpreadModelArrayRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(SpreadModelArrayRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadModelArrayRecord.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadModelArrayRecord.java new file mode 100644 index 0000000000..2fd1703521 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadModelArrayRecord.java @@ -0,0 +1,127 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * The SpreadModelArrayRecord model. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class SpreadModelArrayRecord implements JsonSerializable { + /* + * The knownProp property. + */ + @Metadata(generated = true) + private final List knownProp; + + /* + * Additional properties + */ + @Metadata(generated = true) + private Map> additionalProperties; + + /** + * Creates an instance of SpreadModelArrayRecord class. + * + * @param knownProp the knownProp value to set. + */ + @Metadata(generated = true) + public SpreadModelArrayRecord(List knownProp) { + this.knownProp = knownProp; + } + + /** + * Get the knownProp property: The knownProp property. + * + * @return the knownProp value. + */ + @Metadata(generated = true) + public List getKnownProp() { + return this.knownProp; + } + + /** + * Get the additionalProperties property: Additional properties. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map> getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: Additional properties. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadModelArrayRecord object itself. + */ + @Metadata(generated = true) + public SpreadModelArrayRecord setAdditionalProperties(Map> additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("knownProp", this.knownProp, (writer, element) -> writer.writeJson(element)); + if (additionalProperties != null) { + for (Map.Entry> additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadModelArrayRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadModelArrayRecord 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 SpreadModelArrayRecord. + */ + @Metadata(generated = true) + public static SpreadModelArrayRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List knownProp = null; + Map> additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + List additionalPropertiesArrayItem + = reader.readArray(reader1 -> ModelForRecord.fromJson(reader1)); + additionalProperties.put(fieldName, additionalPropertiesArrayItem); + } + } + SpreadModelArrayRecord deserializedSpreadModelArrayRecord = new SpreadModelArrayRecord(knownProp); + deserializedSpreadModelArrayRecord.additionalProperties = additionalProperties; + + return deserializedSpreadModelArrayRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadModelClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadModelClient.java new file mode 100644 index 0000000000..614572d6b0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadModelClient.java @@ -0,0 +1,112 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.SpreadModelsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadModelClient { + @Metadata(generated = true) + private final SpreadModelsImpl serviceClient; + + /** + * Initializes an instance of SpreadModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + SpreadModelClient(SpreadModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public SpreadModelRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(SpreadModelRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadModelRecord.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadModelRecord.java new file mode 100644 index 0000000000..ebf5837785 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadModelRecord.java @@ -0,0 +1,126 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<ModelForRecord> with the same known property type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class SpreadModelRecord implements JsonSerializable { + /* + * The knownProp property. + */ + @Metadata(generated = true) + private final ModelForRecord knownProp; + + /* + * The model spread Record with the same known property type + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of SpreadModelRecord class. + * + * @param knownProp the knownProp value to set. + */ + @Metadata(generated = true) + public SpreadModelRecord(ModelForRecord knownProp) { + this.knownProp = knownProp; + } + + /** + * Get the knownProp property: The knownProp property. + * + * @return the knownProp value. + */ + @Metadata(generated = true) + public ModelForRecord getKnownProp() { + return this.knownProp; + } + + /** + * Get the additionalProperties property: The model spread Record<ModelForRecord> with the same known property + * type. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model spread Record<ModelForRecord> with the same known property + * type. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadModelRecord object itself. + */ + @Metadata(generated = true) + public SpreadModelRecord setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("knownProp", this.knownProp); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadModelRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadModelRecord 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 SpreadModelRecord. + */ + @Metadata(generated = true) + public static SpreadModelRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + ModelForRecord knownProp = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("knownProp".equals(fieldName)) { + knownProp = ModelForRecord.fromJson(reader); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, ModelForRecord.fromJson(reader)); + } + } + SpreadModelRecord deserializedSpreadModelRecord = new SpreadModelRecord(knownProp); + deserializedSpreadModelRecord.additionalProperties = additionalProperties; + + return deserializedSpreadModelRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordDiscriminatedUnionClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordDiscriminatedUnionClient.java new file mode 100644 index 0000000000..1debd4ddb2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordDiscriminatedUnionClient.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.SpreadRecordDiscriminatedUnionsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadRecordDiscriminatedUnionClient { + @Metadata(generated = true) + private final SpreadRecordDiscriminatedUnionsImpl serviceClient; + + /** + * Initializes an instance of SpreadRecordDiscriminatedUnionClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + SpreadRecordDiscriminatedUnionClient(SpreadRecordDiscriminatedUnionsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public SpreadRecordForDiscriminatedUnion get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(SpreadRecordForDiscriminatedUnion body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForDiscriminatedUnion.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForDiscriminatedUnion.java new file mode 100644 index 0000000000..867dc9d91c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForDiscriminatedUnion.java @@ -0,0 +1,132 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<WidgetData>. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class SpreadRecordForDiscriminatedUnion implements JsonSerializable { + /* + * The name property + */ + @Metadata(generated = true) + private final String name; + + /* + * The model spread Record + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of SpreadRecordForDiscriminatedUnion class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public SpreadRecordForDiscriminatedUnion(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: The model spread Record<WidgetData>. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model spread Record<WidgetData>. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadRecordForDiscriminatedUnion object itself. + */ + @Metadata(generated = true) + public SpreadRecordForDiscriminatedUnion setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeFieldName(additionalProperty.getKey()); + if (additionalProperty.getValue() == null) { + jsonWriter.writeNull(); + } else { + additionalProperty.getValue().writeTo(jsonWriter); + } + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadRecordForDiscriminatedUnion from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadRecordForDiscriminatedUnion 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 SpreadRecordForDiscriminatedUnion. + */ + @Metadata(generated = true) + public static SpreadRecordForDiscriminatedUnion fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + SpreadRecordForDiscriminatedUnion deserializedSpreadRecordForDiscriminatedUnion + = new SpreadRecordForDiscriminatedUnion(name); + deserializedSpreadRecordForDiscriminatedUnion.additionalProperties = additionalProperties; + + return deserializedSpreadRecordForDiscriminatedUnion; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForNonDiscriminatedUnion.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForNonDiscriminatedUnion.java new file mode 100644 index 0000000000..2d744252f0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForNonDiscriminatedUnion.java @@ -0,0 +1,133 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<WidgetData0 | WidgetData1>. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class SpreadRecordForNonDiscriminatedUnion + implements JsonSerializable { + /* + * The name property + */ + @Metadata(generated = true) + private final String name; + + /* + * The model spread Record + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of SpreadRecordForNonDiscriminatedUnion class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public SpreadRecordForNonDiscriminatedUnion(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: The model spread Record<WidgetData0 | WidgetData1>. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model spread Record<WidgetData0 | WidgetData1>. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadRecordForNonDiscriminatedUnion object itself. + */ + @Metadata(generated = true) + public SpreadRecordForNonDiscriminatedUnion setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeFieldName(additionalProperty.getKey()); + if (additionalProperty.getValue() == null) { + jsonWriter.writeNull(); + } else { + additionalProperty.getValue().writeTo(jsonWriter); + } + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadRecordForNonDiscriminatedUnion from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadRecordForNonDiscriminatedUnion 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 SpreadRecordForNonDiscriminatedUnion. + */ + @Metadata(generated = true) + public static SpreadRecordForNonDiscriminatedUnion fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + SpreadRecordForNonDiscriminatedUnion deserializedSpreadRecordForNonDiscriminatedUnion + = new SpreadRecordForNonDiscriminatedUnion(name); + deserializedSpreadRecordForNonDiscriminatedUnion.additionalProperties = additionalProperties; + + return deserializedSpreadRecordForNonDiscriminatedUnion; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForNonDiscriminatedUnion2.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForNonDiscriminatedUnion2.java new file mode 100644 index 0000000000..d4bfd91308 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForNonDiscriminatedUnion2.java @@ -0,0 +1,133 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<WidgetData2 | WidgetData1>. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class SpreadRecordForNonDiscriminatedUnion2 + implements JsonSerializable { + /* + * The name property + */ + @Metadata(generated = true) + private final String name; + + /* + * The model spread Record + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of SpreadRecordForNonDiscriminatedUnion2 class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public SpreadRecordForNonDiscriminatedUnion2(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: The model spread Record<WidgetData2 | WidgetData1>. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model spread Record<WidgetData2 | WidgetData1>. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadRecordForNonDiscriminatedUnion2 object itself. + */ + @Metadata(generated = true) + public SpreadRecordForNonDiscriminatedUnion2 setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeFieldName(additionalProperty.getKey()); + if (additionalProperty.getValue() == null) { + jsonWriter.writeNull(); + } else { + additionalProperty.getValue().writeTo(jsonWriter); + } + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadRecordForNonDiscriminatedUnion2 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadRecordForNonDiscriminatedUnion2 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 SpreadRecordForNonDiscriminatedUnion2. + */ + @Metadata(generated = true) + public static SpreadRecordForNonDiscriminatedUnion2 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + SpreadRecordForNonDiscriminatedUnion2 deserializedSpreadRecordForNonDiscriminatedUnion2 + = new SpreadRecordForNonDiscriminatedUnion2(name); + deserializedSpreadRecordForNonDiscriminatedUnion2.additionalProperties = additionalProperties; + + return deserializedSpreadRecordForNonDiscriminatedUnion2; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForNonDiscriminatedUnion3.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForNonDiscriminatedUnion3.java new file mode 100644 index 0000000000..1ffdf18fd7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForNonDiscriminatedUnion3.java @@ -0,0 +1,133 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<WidgetData2[] | WidgetData1>. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class SpreadRecordForNonDiscriminatedUnion3 + implements JsonSerializable { + /* + * The name property + */ + @Metadata(generated = true) + private final String name; + + /* + * The model spread Record + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of SpreadRecordForNonDiscriminatedUnion3 class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public SpreadRecordForNonDiscriminatedUnion3(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: The model spread Record<WidgetData2[] | WidgetData1>. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model spread Record<WidgetData2[] | WidgetData1>. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadRecordForNonDiscriminatedUnion3 object itself. + */ + @Metadata(generated = true) + public SpreadRecordForNonDiscriminatedUnion3 setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeFieldName(additionalProperty.getKey()); + if (additionalProperty.getValue() == null) { + jsonWriter.writeNull(); + } else { + additionalProperty.getValue().writeTo(jsonWriter); + } + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadRecordForNonDiscriminatedUnion3 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadRecordForNonDiscriminatedUnion3 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 SpreadRecordForNonDiscriminatedUnion3. + */ + @Metadata(generated = true) + public static SpreadRecordForNonDiscriminatedUnion3 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + SpreadRecordForNonDiscriminatedUnion3 deserializedSpreadRecordForNonDiscriminatedUnion3 + = new SpreadRecordForNonDiscriminatedUnion3(name); + deserializedSpreadRecordForNonDiscriminatedUnion3.additionalProperties = additionalProperties; + + return deserializedSpreadRecordForNonDiscriminatedUnion3; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForUnion.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForUnion.java new file mode 100644 index 0000000000..20be7d5363 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordForUnion.java @@ -0,0 +1,131 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<string | float32>. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class SpreadRecordForUnion implements JsonSerializable { + /* + * The name property + */ + @Metadata(generated = true) + private final boolean flag; + + /* + * The model spread Record + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of SpreadRecordForUnion class. + * + * @param flag the flag value to set. + */ + @Metadata(generated = true) + public SpreadRecordForUnion(boolean flag) { + this.flag = flag; + } + + /** + * Get the flag property: The name property. + * + * @return the flag value. + */ + @Metadata(generated = true) + public boolean isFlag() { + return this.flag; + } + + /** + * Get the additionalProperties property: The model spread Record<string | float32>. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model spread Record<string | float32>. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadRecordForUnion object itself. + */ + @Metadata(generated = true) + public SpreadRecordForUnion setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("flag", this.flag); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeFieldName(additionalProperty.getKey()); + if (additionalProperty.getValue() == null) { + jsonWriter.writeNull(); + } else { + additionalProperty.getValue().writeTo(jsonWriter); + } + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadRecordForUnion from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadRecordForUnion 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 SpreadRecordForUnion. + */ + @Metadata(generated = true) + public static SpreadRecordForUnion fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean flag = false; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("flag".equals(fieldName)) { + flag = reader.getBoolean(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, + reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } + } + SpreadRecordForUnion deserializedSpreadRecordForUnion = new SpreadRecordForUnion(flag); + deserializedSpreadRecordForUnion.additionalProperties = additionalProperties; + + return deserializedSpreadRecordForUnion; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion2Client.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion2Client.java new file mode 100644 index 0000000000..febf72635f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion2Client.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.SpreadRecordNonDiscriminatedUnion2sImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadRecordNonDiscriminatedUnion2Client { + @Metadata(generated = true) + private final SpreadRecordNonDiscriminatedUnion2sImpl serviceClient; + + /** + * Initializes an instance of SpreadRecordNonDiscriminatedUnion2Client class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + SpreadRecordNonDiscriminatedUnion2Client(SpreadRecordNonDiscriminatedUnion2sImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public SpreadRecordForNonDiscriminatedUnion2 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(SpreadRecordForNonDiscriminatedUnion2 body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion3Client.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion3Client.java new file mode 100644 index 0000000000..d40951de9f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnion3Client.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.SpreadRecordNonDiscriminatedUnion3sImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadRecordNonDiscriminatedUnion3Client { + @Metadata(generated = true) + private final SpreadRecordNonDiscriminatedUnion3sImpl serviceClient; + + /** + * Initializes an instance of SpreadRecordNonDiscriminatedUnion3Client class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + SpreadRecordNonDiscriminatedUnion3Client(SpreadRecordNonDiscriminatedUnion3sImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public SpreadRecordForNonDiscriminatedUnion3 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(SpreadRecordForNonDiscriminatedUnion3 body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnionClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnionClient.java new file mode 100644 index 0000000000..8c7298734e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordNonDiscriminatedUnionClient.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.SpreadRecordNonDiscriminatedUnionsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadRecordNonDiscriminatedUnionClient { + @Metadata(generated = true) + private final SpreadRecordNonDiscriminatedUnionsImpl serviceClient; + + /** + * Initializes an instance of SpreadRecordNonDiscriminatedUnionClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + SpreadRecordNonDiscriminatedUnionClient(SpreadRecordNonDiscriminatedUnionsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public SpreadRecordForNonDiscriminatedUnion get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(SpreadRecordForNonDiscriminatedUnion body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordUnionClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordUnionClient.java new file mode 100644 index 0000000000..17afa8097d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadRecordUnionClient.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.SpreadRecordUnionsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadRecordUnionClient { + @Metadata(generated = true) + private final SpreadRecordUnionsImpl serviceClient; + + /** + * Initializes an instance of SpreadRecordUnionClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + SpreadRecordUnionClient(SpreadRecordUnionsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public SpreadRecordForUnion get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(SpreadRecordForUnion body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadStringClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadStringClient.java new file mode 100644 index 0000000000..b7e24675f6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadStringClient.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.implementation.SpreadStringsImpl; + +/** + * Initializes a new instance of the synchronous AdditionalPropertiesClient type. + */ +@ServiceClient(builder = AdditionalPropertiesClientBuilder.class) +public final class SpreadStringClient { + @Metadata(generated = true) + private final SpreadStringsImpl serviceClient; + + /** + * Initializes an instance of SpreadStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + SpreadStringClient(SpreadStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public SpreadStringRecord get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(SpreadStringRecord body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadStringRecord.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadStringRecord.java new file mode 100644 index 0000000000..def9db93a6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/SpreadStringRecord.java @@ -0,0 +1,124 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The model spread Record<string> with the same known property type. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class SpreadStringRecord implements JsonSerializable { + /* + * The name property + */ + @Metadata(generated = true) + private final String name; + + /* + * The model spread Record with the same known property type + */ + @Metadata(generated = true) + private Map additionalProperties; + + /** + * Creates an instance of SpreadStringRecord class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public SpreadStringRecord(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * Get the additionalProperties property: The model spread Record<string> with the same known property type. + * + * @return the additionalProperties value. + */ + @Metadata(generated = true) + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties property: The model spread Record<string> with the same known property type. + * + * @param additionalProperties the additionalProperties value to set. + * @return the SpreadStringRecord object itself. + */ + @Metadata(generated = true) + public SpreadStringRecord setAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + if (additionalProperties != null) { + for (Map.Entry additionalProperty : additionalProperties.entrySet()) { + jsonWriter.writeUntypedField(additionalProperty.getKey(), additionalProperty.getValue()); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SpreadStringRecord from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SpreadStringRecord 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 SpreadStringRecord. + */ + @Metadata(generated = true) + public static SpreadStringRecord fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + Map additionalProperties = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + if (additionalProperties == null) { + additionalProperties = new LinkedHashMap<>(); + } + + additionalProperties.put(fieldName, reader.getString()); + } + } + SpreadStringRecord deserializedSpreadStringRecord = new SpreadStringRecord(name); + deserializedSpreadStringRecord.additionalProperties = additionalProperties; + + return deserializedSpreadStringRecord; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/WidgetData0.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/WidgetData0.java new file mode 100644 index 0000000000..1df64d7277 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/WidgetData0.java @@ -0,0 +1,98 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The WidgetData0 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class WidgetData0 implements JsonSerializable { + /* + * The kind property. + */ + @Metadata(generated = true) + private final String kind = "kind0"; + + /* + * The fooProp property. + */ + @Metadata(generated = true) + private final String fooProp; + + /** + * Creates an instance of WidgetData0 class. + * + * @param fooProp the fooProp value to set. + */ + @Metadata(generated = true) + public WidgetData0(String fooProp) { + this.fooProp = fooProp; + } + + /** + * Get the kind property: The kind property. + * + * @return the kind value. + */ + @Metadata(generated = true) + public String getKind() { + return this.kind; + } + + /** + * Get the fooProp property: The fooProp property. + * + * @return the fooProp value. + */ + @Metadata(generated = true) + public String getFooProp() { + return this.fooProp; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeStringField("fooProp", this.fooProp); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of WidgetData0 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of WidgetData0 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 WidgetData0. + */ + @Metadata(generated = true) + public static WidgetData0 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String fooProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("fooProp".equals(fieldName)) { + fooProp = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new WidgetData0(fooProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/WidgetData1.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/WidgetData1.java new file mode 100644 index 0000000000..55998c668c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/WidgetData1.java @@ -0,0 +1,137 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +/** + * The WidgetData1 model. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class WidgetData1 implements JsonSerializable { + /* + * The kind property. + */ + @Metadata(generated = true) + private final String kind = "kind1"; + + /* + * The start property. + */ + @Metadata(generated = true) + private final OffsetDateTime start; + + /* + * The end property. + */ + @Metadata(generated = true) + private OffsetDateTime end; + + /** + * Creates an instance of WidgetData1 class. + * + * @param start the start value to set. + */ + @Metadata(generated = true) + public WidgetData1(OffsetDateTime start) { + this.start = start; + } + + /** + * Get the kind property: The kind property. + * + * @return the kind value. + */ + @Metadata(generated = true) + public String getKind() { + return this.kind; + } + + /** + * Get the start property: The start property. + * + * @return the start value. + */ + @Metadata(generated = true) + public OffsetDateTime getStart() { + return this.start; + } + + /** + * Get the end property: The end property. + * + * @return the end value. + */ + @Metadata(generated = true) + public OffsetDateTime getEnd() { + return this.end; + } + + /** + * Set the end property: The end property. + * + * @param end the end value to set. + * @return the WidgetData1 object itself. + */ + @Metadata(generated = true) + public WidgetData1 setEnd(OffsetDateTime end) { + this.end = end; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeStringField("start", + this.start == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.start)); + jsonWriter.writeStringField("end", + this.end == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.end)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of WidgetData1 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of WidgetData1 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 WidgetData1. + */ + @Metadata(generated = true) + public static WidgetData1 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OffsetDateTime start = null; + OffsetDateTime end = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("start".equals(fieldName)) { + start = reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())); + } else if ("end".equals(fieldName)) { + end = reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + WidgetData1 deserializedWidgetData1 = new WidgetData1(start); + deserializedWidgetData1.end = end; + + return deserializedWidgetData1; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/WidgetData2.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/WidgetData2.java new file mode 100644 index 0000000000..e746676e03 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/WidgetData2.java @@ -0,0 +1,98 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The WidgetData2 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class WidgetData2 implements JsonSerializable { + /* + * The kind property. + */ + @Metadata(generated = true) + private final String kind = "kind1"; + + /* + * The start property. + */ + @Metadata(generated = true) + private final String start; + + /** + * Creates an instance of WidgetData2 class. + * + * @param start the start value to set. + */ + @Metadata(generated = true) + public WidgetData2(String start) { + this.start = start; + } + + /** + * Get the kind property: The kind property. + * + * @return the kind value. + */ + @Metadata(generated = true) + public String getKind() { + return this.kind; + } + + /** + * Get the start property: The start property. + * + * @return the start value. + */ + @Metadata(generated = true) + public String getStart() { + return this.start; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("kind", this.kind); + jsonWriter.writeStringField("start", this.start); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of WidgetData2 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of WidgetData2 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 WidgetData2. + */ + @Metadata(generated = true) + public static WidgetData2 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String start = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("start".equals(fieldName)) { + start = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new WidgetData2(start); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/AdditionalPropertiesClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/AdditionalPropertiesClientImpl.java new file mode 100644 index 0000000000..26d9f17f8d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/AdditionalPropertiesClientImpl.java @@ -0,0 +1,529 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the AdditionalPropertiesClient type. + */ +public final class AdditionalPropertiesClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 ExtendsUnknownsImpl object to access its operations. + */ + private final ExtendsUnknownsImpl extendsUnknowns; + + /** + * Gets the ExtendsUnknownsImpl object to access its operations. + * + * @return the ExtendsUnknownsImpl object. + */ + public ExtendsUnknownsImpl getExtendsUnknowns() { + return this.extendsUnknowns; + } + + /** + * The ExtendsUnknownDerivedsImpl object to access its operations. + */ + private final ExtendsUnknownDerivedsImpl extendsUnknownDeriveds; + + /** + * Gets the ExtendsUnknownDerivedsImpl object to access its operations. + * + * @return the ExtendsUnknownDerivedsImpl object. + */ + public ExtendsUnknownDerivedsImpl getExtendsUnknownDeriveds() { + return this.extendsUnknownDeriveds; + } + + /** + * The ExtendsUnknownDiscriminatedsImpl object to access its operations. + */ + private final ExtendsUnknownDiscriminatedsImpl extendsUnknownDiscriminateds; + + /** + * Gets the ExtendsUnknownDiscriminatedsImpl object to access its operations. + * + * @return the ExtendsUnknownDiscriminatedsImpl object. + */ + public ExtendsUnknownDiscriminatedsImpl getExtendsUnknownDiscriminateds() { + return this.extendsUnknownDiscriminateds; + } + + /** + * The IsUnknownsImpl object to access its operations. + */ + private final IsUnknownsImpl isUnknowns; + + /** + * Gets the IsUnknownsImpl object to access its operations. + * + * @return the IsUnknownsImpl object. + */ + public IsUnknownsImpl getIsUnknowns() { + return this.isUnknowns; + } + + /** + * The IsUnknownDerivedsImpl object to access its operations. + */ + private final IsUnknownDerivedsImpl isUnknownDeriveds; + + /** + * Gets the IsUnknownDerivedsImpl object to access its operations. + * + * @return the IsUnknownDerivedsImpl object. + */ + public IsUnknownDerivedsImpl getIsUnknownDeriveds() { + return this.isUnknownDeriveds; + } + + /** + * The IsUnknownDiscriminatedsImpl object to access its operations. + */ + private final IsUnknownDiscriminatedsImpl isUnknownDiscriminateds; + + /** + * Gets the IsUnknownDiscriminatedsImpl object to access its operations. + * + * @return the IsUnknownDiscriminatedsImpl object. + */ + public IsUnknownDiscriminatedsImpl getIsUnknownDiscriminateds() { + return this.isUnknownDiscriminateds; + } + + /** + * The ExtendsStringsImpl object to access its operations. + */ + private final ExtendsStringsImpl extendsStrings; + + /** + * Gets the ExtendsStringsImpl object to access its operations. + * + * @return the ExtendsStringsImpl object. + */ + public ExtendsStringsImpl getExtendsStrings() { + return this.extendsStrings; + } + + /** + * The IsStringsImpl object to access its operations. + */ + private final IsStringsImpl isStrings; + + /** + * Gets the IsStringsImpl object to access its operations. + * + * @return the IsStringsImpl object. + */ + public IsStringsImpl getIsStrings() { + return this.isStrings; + } + + /** + * The SpreadStringsImpl object to access its operations. + */ + private final SpreadStringsImpl spreadStrings; + + /** + * Gets the SpreadStringsImpl object to access its operations. + * + * @return the SpreadStringsImpl object. + */ + public SpreadStringsImpl getSpreadStrings() { + return this.spreadStrings; + } + + /** + * The ExtendsFloatsImpl object to access its operations. + */ + private final ExtendsFloatsImpl extendsFloats; + + /** + * Gets the ExtendsFloatsImpl object to access its operations. + * + * @return the ExtendsFloatsImpl object. + */ + public ExtendsFloatsImpl getExtendsFloats() { + return this.extendsFloats; + } + + /** + * The IsFloatsImpl object to access its operations. + */ + private final IsFloatsImpl isFloats; + + /** + * Gets the IsFloatsImpl object to access its operations. + * + * @return the IsFloatsImpl object. + */ + public IsFloatsImpl getIsFloats() { + return this.isFloats; + } + + /** + * The SpreadFloatsImpl object to access its operations. + */ + private final SpreadFloatsImpl spreadFloats; + + /** + * Gets the SpreadFloatsImpl object to access its operations. + * + * @return the SpreadFloatsImpl object. + */ + public SpreadFloatsImpl getSpreadFloats() { + return this.spreadFloats; + } + + /** + * The ExtendsModelsImpl object to access its operations. + */ + private final ExtendsModelsImpl extendsModels; + + /** + * Gets the ExtendsModelsImpl object to access its operations. + * + * @return the ExtendsModelsImpl object. + */ + public ExtendsModelsImpl getExtendsModels() { + return this.extendsModels; + } + + /** + * The IsModelsImpl object to access its operations. + */ + private final IsModelsImpl isModels; + + /** + * Gets the IsModelsImpl object to access its operations. + * + * @return the IsModelsImpl object. + */ + public IsModelsImpl getIsModels() { + return this.isModels; + } + + /** + * The SpreadModelsImpl object to access its operations. + */ + private final SpreadModelsImpl spreadModels; + + /** + * Gets the SpreadModelsImpl object to access its operations. + * + * @return the SpreadModelsImpl object. + */ + public SpreadModelsImpl getSpreadModels() { + return this.spreadModels; + } + + /** + * The ExtendsModelArraysImpl object to access its operations. + */ + private final ExtendsModelArraysImpl extendsModelArrays; + + /** + * Gets the ExtendsModelArraysImpl object to access its operations. + * + * @return the ExtendsModelArraysImpl object. + */ + public ExtendsModelArraysImpl getExtendsModelArrays() { + return this.extendsModelArrays; + } + + /** + * The IsModelArraysImpl object to access its operations. + */ + private final IsModelArraysImpl isModelArrays; + + /** + * Gets the IsModelArraysImpl object to access its operations. + * + * @return the IsModelArraysImpl object. + */ + public IsModelArraysImpl getIsModelArrays() { + return this.isModelArrays; + } + + /** + * The SpreadModelArraysImpl object to access its operations. + */ + private final SpreadModelArraysImpl spreadModelArrays; + + /** + * Gets the SpreadModelArraysImpl object to access its operations. + * + * @return the SpreadModelArraysImpl object. + */ + public SpreadModelArraysImpl getSpreadModelArrays() { + return this.spreadModelArrays; + } + + /** + * The SpreadDifferentStringsImpl object to access its operations. + */ + private final SpreadDifferentStringsImpl spreadDifferentStrings; + + /** + * Gets the SpreadDifferentStringsImpl object to access its operations. + * + * @return the SpreadDifferentStringsImpl object. + */ + public SpreadDifferentStringsImpl getSpreadDifferentStrings() { + return this.spreadDifferentStrings; + } + + /** + * The SpreadDifferentFloatsImpl object to access its operations. + */ + private final SpreadDifferentFloatsImpl spreadDifferentFloats; + + /** + * Gets the SpreadDifferentFloatsImpl object to access its operations. + * + * @return the SpreadDifferentFloatsImpl object. + */ + public SpreadDifferentFloatsImpl getSpreadDifferentFloats() { + return this.spreadDifferentFloats; + } + + /** + * The SpreadDifferentModelsImpl object to access its operations. + */ + private final SpreadDifferentModelsImpl spreadDifferentModels; + + /** + * Gets the SpreadDifferentModelsImpl object to access its operations. + * + * @return the SpreadDifferentModelsImpl object. + */ + public SpreadDifferentModelsImpl getSpreadDifferentModels() { + return this.spreadDifferentModels; + } + + /** + * The SpreadDifferentModelArraysImpl object to access its operations. + */ + private final SpreadDifferentModelArraysImpl spreadDifferentModelArrays; + + /** + * Gets the SpreadDifferentModelArraysImpl object to access its operations. + * + * @return the SpreadDifferentModelArraysImpl object. + */ + public SpreadDifferentModelArraysImpl getSpreadDifferentModelArrays() { + return this.spreadDifferentModelArrays; + } + + /** + * The ExtendsDifferentSpreadStringsImpl object to access its operations. + */ + private final ExtendsDifferentSpreadStringsImpl extendsDifferentSpreadStrings; + + /** + * Gets the ExtendsDifferentSpreadStringsImpl object to access its operations. + * + * @return the ExtendsDifferentSpreadStringsImpl object. + */ + public ExtendsDifferentSpreadStringsImpl getExtendsDifferentSpreadStrings() { + return this.extendsDifferentSpreadStrings; + } + + /** + * The ExtendsDifferentSpreadFloatsImpl object to access its operations. + */ + private final ExtendsDifferentSpreadFloatsImpl extendsDifferentSpreadFloats; + + /** + * Gets the ExtendsDifferentSpreadFloatsImpl object to access its operations. + * + * @return the ExtendsDifferentSpreadFloatsImpl object. + */ + public ExtendsDifferentSpreadFloatsImpl getExtendsDifferentSpreadFloats() { + return this.extendsDifferentSpreadFloats; + } + + /** + * The ExtendsDifferentSpreadModelsImpl object to access its operations. + */ + private final ExtendsDifferentSpreadModelsImpl extendsDifferentSpreadModels; + + /** + * Gets the ExtendsDifferentSpreadModelsImpl object to access its operations. + * + * @return the ExtendsDifferentSpreadModelsImpl object. + */ + public ExtendsDifferentSpreadModelsImpl getExtendsDifferentSpreadModels() { + return this.extendsDifferentSpreadModels; + } + + /** + * The ExtendsDifferentSpreadModelArraysImpl object to access its operations. + */ + private final ExtendsDifferentSpreadModelArraysImpl extendsDifferentSpreadModelArrays; + + /** + * Gets the ExtendsDifferentSpreadModelArraysImpl object to access its operations. + * + * @return the ExtendsDifferentSpreadModelArraysImpl object. + */ + public ExtendsDifferentSpreadModelArraysImpl getExtendsDifferentSpreadModelArrays() { + return this.extendsDifferentSpreadModelArrays; + } + + /** + * The MultipleSpreadsImpl object to access its operations. + */ + private final MultipleSpreadsImpl multipleSpreads; + + /** + * Gets the MultipleSpreadsImpl object to access its operations. + * + * @return the MultipleSpreadsImpl object. + */ + public MultipleSpreadsImpl getMultipleSpreads() { + return this.multipleSpreads; + } + + /** + * The SpreadRecordUnionsImpl object to access its operations. + */ + private final SpreadRecordUnionsImpl spreadRecordUnions; + + /** + * Gets the SpreadRecordUnionsImpl object to access its operations. + * + * @return the SpreadRecordUnionsImpl object. + */ + public SpreadRecordUnionsImpl getSpreadRecordUnions() { + return this.spreadRecordUnions; + } + + /** + * The SpreadRecordDiscriminatedUnionsImpl object to access its operations. + */ + private final SpreadRecordDiscriminatedUnionsImpl spreadRecordDiscriminatedUnions; + + /** + * Gets the SpreadRecordDiscriminatedUnionsImpl object to access its operations. + * + * @return the SpreadRecordDiscriminatedUnionsImpl object. + */ + public SpreadRecordDiscriminatedUnionsImpl getSpreadRecordDiscriminatedUnions() { + return this.spreadRecordDiscriminatedUnions; + } + + /** + * The SpreadRecordNonDiscriminatedUnionsImpl object to access its operations. + */ + private final SpreadRecordNonDiscriminatedUnionsImpl spreadRecordNonDiscriminatedUnions; + + /** + * Gets the SpreadRecordNonDiscriminatedUnionsImpl object to access its operations. + * + * @return the SpreadRecordNonDiscriminatedUnionsImpl object. + */ + public SpreadRecordNonDiscriminatedUnionsImpl getSpreadRecordNonDiscriminatedUnions() { + return this.spreadRecordNonDiscriminatedUnions; + } + + /** + * The SpreadRecordNonDiscriminatedUnion2sImpl object to access its operations. + */ + private final SpreadRecordNonDiscriminatedUnion2sImpl spreadRecordNonDiscriminatedUnion2s; + + /** + * Gets the SpreadRecordNonDiscriminatedUnion2sImpl object to access its operations. + * + * @return the SpreadRecordNonDiscriminatedUnion2sImpl object. + */ + public SpreadRecordNonDiscriminatedUnion2sImpl getSpreadRecordNonDiscriminatedUnion2s() { + return this.spreadRecordNonDiscriminatedUnion2s; + } + + /** + * The SpreadRecordNonDiscriminatedUnion3sImpl object to access its operations. + */ + private final SpreadRecordNonDiscriminatedUnion3sImpl spreadRecordNonDiscriminatedUnion3s; + + /** + * Gets the SpreadRecordNonDiscriminatedUnion3sImpl object to access its operations. + * + * @return the SpreadRecordNonDiscriminatedUnion3sImpl object. + */ + public SpreadRecordNonDiscriminatedUnion3sImpl getSpreadRecordNonDiscriminatedUnion3s() { + return this.spreadRecordNonDiscriminatedUnion3s; + } + + /** + * Initializes an instance of AdditionalPropertiesClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public AdditionalPropertiesClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.extendsUnknowns = new ExtendsUnknownsImpl(this); + this.extendsUnknownDeriveds = new ExtendsUnknownDerivedsImpl(this); + this.extendsUnknownDiscriminateds = new ExtendsUnknownDiscriminatedsImpl(this); + this.isUnknowns = new IsUnknownsImpl(this); + this.isUnknownDeriveds = new IsUnknownDerivedsImpl(this); + this.isUnknownDiscriminateds = new IsUnknownDiscriminatedsImpl(this); + this.extendsStrings = new ExtendsStringsImpl(this); + this.isStrings = new IsStringsImpl(this); + this.spreadStrings = new SpreadStringsImpl(this); + this.extendsFloats = new ExtendsFloatsImpl(this); + this.isFloats = new IsFloatsImpl(this); + this.spreadFloats = new SpreadFloatsImpl(this); + this.extendsModels = new ExtendsModelsImpl(this); + this.isModels = new IsModelsImpl(this); + this.spreadModels = new SpreadModelsImpl(this); + this.extendsModelArrays = new ExtendsModelArraysImpl(this); + this.isModelArrays = new IsModelArraysImpl(this); + this.spreadModelArrays = new SpreadModelArraysImpl(this); + this.spreadDifferentStrings = new SpreadDifferentStringsImpl(this); + this.spreadDifferentFloats = new SpreadDifferentFloatsImpl(this); + this.spreadDifferentModels = new SpreadDifferentModelsImpl(this); + this.spreadDifferentModelArrays = new SpreadDifferentModelArraysImpl(this); + this.extendsDifferentSpreadStrings = new ExtendsDifferentSpreadStringsImpl(this); + this.extendsDifferentSpreadFloats = new ExtendsDifferentSpreadFloatsImpl(this); + this.extendsDifferentSpreadModels = new ExtendsDifferentSpreadModelsImpl(this); + this.extendsDifferentSpreadModelArrays = new ExtendsDifferentSpreadModelArraysImpl(this); + this.multipleSpreads = new MultipleSpreadsImpl(this); + this.spreadRecordUnions = new SpreadRecordUnionsImpl(this); + this.spreadRecordDiscriminatedUnions = new SpreadRecordDiscriminatedUnionsImpl(this); + this.spreadRecordNonDiscriminatedUnions = new SpreadRecordNonDiscriminatedUnionsImpl(this); + this.spreadRecordNonDiscriminatedUnion2s = new SpreadRecordNonDiscriminatedUnion2sImpl(this); + this.spreadRecordNonDiscriminatedUnion3s = new SpreadRecordNonDiscriminatedUnion3sImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsDifferentSpreadFloatsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsDifferentSpreadFloatsImpl.java new file mode 100644 index 0000000000..db20127ccb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsDifferentSpreadFloatsImpl.java @@ -0,0 +1,116 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.DifferentSpreadFloatDerived; + +/** + * An instance of this class provides access to all the operations defined in ExtendsDifferentSpreadFloats. + */ +public final class ExtendsDifferentSpreadFloatsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsDifferentSpreadFloatsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsDifferentSpreadFloatsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsDifferentSpreadFloatsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsDifferentSpreadFloatsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsDifferentSpreadFloats to be used by + * the proxy service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface ExtendsDifferentSpreadFloatsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/extendsDifferentSpreadFloat", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/extendsDifferentSpreadFloat", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     *     derivedProp: double (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     *     derivedProp: double (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelArraysImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelArraysImpl.java new file mode 100644 index 0000000000..055070d9d1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelArraysImpl.java @@ -0,0 +1,128 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.DifferentSpreadModelArrayDerived; + +/** + * An instance of this class provides access to all the operations defined in ExtendsDifferentSpreadModelArrays. + */ +public final class ExtendsDifferentSpreadModelArraysImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsDifferentSpreadModelArraysService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsDifferentSpreadModelArraysImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsDifferentSpreadModelArraysImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsDifferentSpreadModelArraysService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsDifferentSpreadModelArrays to be + * used by the proxy service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface ExtendsDifferentSpreadModelArraysService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/extendsDifferentSpreadModelArray", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/extendsDifferentSpreadModelArray", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     *     derivedProp (Required): [
+     *         (recursive schema, see above)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     *     derivedProp (Required): [
+     *         (recursive schema, see above)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelsImpl.java new file mode 100644 index 0000000000..a9df71e15e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsDifferentSpreadModelsImpl.java @@ -0,0 +1,120 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.DifferentSpreadModelDerived; + +/** + * An instance of this class provides access to all the operations defined in ExtendsDifferentSpreadModels. + */ +public final class ExtendsDifferentSpreadModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsDifferentSpreadModelsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsDifferentSpreadModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsDifferentSpreadModelsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsDifferentSpreadModelsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsDifferentSpreadModels to be used by + * the proxy service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface ExtendsDifferentSpreadModelsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/extendsDifferentSpreadModel", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/extendsDifferentSpreadModel", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     *     derivedProp (Required): (recursive schema, see derivedProp above)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     *     derivedProp (Required): (recursive schema, see derivedProp above)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsDifferentSpreadStringsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsDifferentSpreadStringsImpl.java new file mode 100644 index 0000000000..07cb86622b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsDifferentSpreadStringsImpl.java @@ -0,0 +1,116 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.DifferentSpreadStringDerived; + +/** + * An instance of this class provides access to all the operations defined in ExtendsDifferentSpreadStrings. + */ +public final class ExtendsDifferentSpreadStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsDifferentSpreadStringsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsDifferentSpreadStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsDifferentSpreadStringsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsDifferentSpreadStringsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsDifferentSpreadStrings to be used by + * the proxy service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface ExtendsDifferentSpreadStringsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/extendsDifferentSpreadString", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/extendsDifferentSpreadString", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     *     derivedProp: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     *     derivedProp: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsFloatsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsFloatsImpl.java new file mode 100644 index 0000000000..a26fd836a7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsFloatsImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.ExtendsFloatAdditionalProperties; + +/** + * An instance of this class provides access to all the operations defined in ExtendsFloats. + */ +public final class ExtendsFloatsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsFloatsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsFloatsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsFloatsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsFloatsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsFloats to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface ExtendsFloatsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/extendsRecordFloat", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/extendsRecordFloat", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsModelArraysImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsModelArraysImpl.java new file mode 100644 index 0000000000..e401ec51c0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsModelArraysImpl.java @@ -0,0 +1,126 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.ExtendsModelArrayAdditionalProperties; + +/** + * An instance of this class provides access to all the operations defined in ExtendsModelArrays. + */ +public final class ExtendsModelArraysImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsModelArraysService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsModelArraysImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsModelArraysImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsModelArraysService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsModelArrays to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface ExtendsModelArraysService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/extendsRecordModelArray", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/extendsRecordModelArray", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsModelsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsModelsImpl.java new file mode 100644 index 0000000000..9fed55a6fb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsModelsImpl.java @@ -0,0 +1,118 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.ExtendsModelAdditionalProperties; + +/** + * An instance of this class provides access to all the operations defined in ExtendsModels. + */ +public final class ExtendsModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsModelsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsModelsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsModelsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsModels to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface ExtendsModelsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/extendsRecordModel", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/extendsRecordModel", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsStringsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsStringsImpl.java new file mode 100644 index 0000000000..29178ab3eb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsStringsImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.ExtendsStringAdditionalProperties; + +/** + * An instance of this class provides access to all the operations defined in ExtendsStrings. + */ +public final class ExtendsStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsStringsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsStringsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsStringsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsStrings to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface ExtendsStringsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/extendsRecordString", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/extendsRecordString", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsUnknownDerivedsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsUnknownDerivedsImpl.java new file mode 100644 index 0000000000..c542d81b50 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsUnknownDerivedsImpl.java @@ -0,0 +1,118 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.ExtendsUnknownAdditionalPropertiesDerived; + +/** + * An instance of this class provides access to all the operations defined in ExtendsUnknownDeriveds. + */ +public final class ExtendsUnknownDerivedsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsUnknownDerivedsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsUnknownDerivedsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsUnknownDerivedsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsUnknownDerivedsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsUnknownDeriveds to be used by the + * proxy service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface ExtendsUnknownDerivedsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/extendsRecordUnknownDerived", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/extendsRecordUnknownDerived", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsUnknownDiscriminatedsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsUnknownDiscriminatedsImpl.java new file mode 100644 index 0000000000..4375b5cff5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsUnknownDiscriminatedsImpl.java @@ -0,0 +1,116 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.ExtendsUnknownAdditionalPropertiesDiscriminated; + +/** + * An instance of this class provides access to all the operations defined in ExtendsUnknownDiscriminateds. + */ +public final class ExtendsUnknownDiscriminatedsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsUnknownDiscriminatedsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsUnknownDiscriminatedsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsUnknownDiscriminatedsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsUnknownDiscriminatedsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsUnknownDiscriminateds to be used by + * the proxy service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface ExtendsUnknownDiscriminatedsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/extendsUnknownDiscriminated", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/extendsUnknownDiscriminated", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsUnknownsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsUnknownsImpl.java new file mode 100644 index 0000000000..fcdf1b1726 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/ExtendsUnknownsImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.ExtendsUnknownAdditionalProperties; + +/** + * An instance of this class provides access to all the operations defined in ExtendsUnknowns. + */ +public final class ExtendsUnknownsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtendsUnknownsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of ExtendsUnknownsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtendsUnknownsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(ExtendsUnknownsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientExtendsUnknowns to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface ExtendsUnknownsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/extendsRecordUnknown", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/extendsRecordUnknown", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsFloatsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsFloatsImpl.java new file mode 100644 index 0000000000..df113ccf74 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsFloatsImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.IsFloatAdditionalProperties; + +/** + * An instance of this class provides access to all the operations defined in IsFloats. + */ +public final class IsFloatsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IsFloatsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of IsFloatsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IsFloatsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(IsFloatsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientIsFloats to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface IsFloatsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/isRecordFloat", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/isRecordFloat", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsModelArraysImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsModelArraysImpl.java new file mode 100644 index 0000000000..0302a653ff --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsModelArraysImpl.java @@ -0,0 +1,126 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.IsModelArrayAdditionalProperties; + +/** + * An instance of this class provides access to all the operations defined in IsModelArrays. + */ +public final class IsModelArraysImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IsModelArraysService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of IsModelArraysImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IsModelArraysImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(IsModelArraysService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientIsModelArrays to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface IsModelArraysService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/isRecordModelArray", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/isRecordModelArray", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsModelsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsModelsImpl.java new file mode 100644 index 0000000000..5a73f25e8a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsModelsImpl.java @@ -0,0 +1,118 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.IsModelAdditionalProperties; + +/** + * An instance of this class provides access to all the operations defined in IsModels. + */ +public final class IsModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IsModelsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of IsModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IsModelsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(IsModelsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientIsModels to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface IsModelsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/isRecordModel", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/isRecordModel", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsStringsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsStringsImpl.java new file mode 100644 index 0000000000..5c03f3ff31 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsStringsImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.IsStringAdditionalProperties; + +/** + * An instance of this class provides access to all the operations defined in IsStrings. + */ +public final class IsStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IsStringsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of IsStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IsStringsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(IsStringsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientIsStrings to be used by the proxy service + * to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface IsStringsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/isRecordstring", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/isRecordstring", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsUnknownDerivedsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsUnknownDerivedsImpl.java new file mode 100644 index 0000000000..75ccbf00ed --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsUnknownDerivedsImpl.java @@ -0,0 +1,118 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.IsUnknownAdditionalPropertiesDerived; + +/** + * An instance of this class provides access to all the operations defined in IsUnknownDeriveds. + */ +public final class IsUnknownDerivedsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IsUnknownDerivedsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of IsUnknownDerivedsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IsUnknownDerivedsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(IsUnknownDerivedsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientIsUnknownDeriveds to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface IsUnknownDerivedsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/isRecordUnknownDerived", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/isRecordUnknownDerived", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     *     index: int (Required)
+     *     age: Double (Optional)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsUnknownDiscriminatedsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsUnknownDiscriminatedsImpl.java new file mode 100644 index 0000000000..13f65c57ab --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsUnknownDiscriminatedsImpl.java @@ -0,0 +1,116 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.IsUnknownAdditionalPropertiesDiscriminated; + +/** + * An instance of this class provides access to all the operations defined in IsUnknownDiscriminateds. + */ +public final class IsUnknownDiscriminatedsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IsUnknownDiscriminatedsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of IsUnknownDiscriminatedsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IsUnknownDiscriminatedsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(IsUnknownDiscriminatedsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientIsUnknownDiscriminateds to be used by the + * proxy service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface IsUnknownDiscriminatedsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/isUnknownDiscriminated", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/isUnknownDiscriminated", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     kind: String (Required)
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsUnknownsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsUnknownsImpl.java new file mode 100644 index 0000000000..3bdaf3a6de --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/IsUnknownsImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.IsUnknownAdditionalProperties; + +/** + * An instance of this class provides access to all the operations defined in IsUnknowns. + */ +public final class IsUnknownsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IsUnknownsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of IsUnknownsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IsUnknownsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(IsUnknownsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientIsUnknowns to be used by the proxy service + * to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface IsUnknownsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/isRecordUnknown", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/isRecordUnknown", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/MultipleSpreadsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/MultipleSpreadsImpl.java new file mode 100644 index 0000000000..3dbfebda6c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/MultipleSpreadsImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.MultipleSpreadRecord; + +/** + * An instance of this class provides access to all the operations defined in MultipleSpreads. + */ +public final class MultipleSpreadsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final MultipleSpreadsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of MultipleSpreadsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + MultipleSpreadsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(MultipleSpreadsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientMultipleSpreads to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface MultipleSpreadsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/multipleSpreadRecord", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/multipleSpreadRecord", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadDifferentFloatsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadDifferentFloatsImpl.java new file mode 100644 index 0000000000..994d902814 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadDifferentFloatsImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.DifferentSpreadFloatRecord; + +/** + * An instance of this class provides access to all the operations defined in SpreadDifferentFloats. + */ +public final class SpreadDifferentFloatsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadDifferentFloatsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadDifferentFloatsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadDifferentFloatsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadDifferentFloatsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadDifferentFloats to be used by the + * proxy service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface SpreadDifferentFloatsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/spreadDifferentRecordFloat", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/spreadDifferentRecordFloat", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadDifferentModelArraysImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadDifferentModelArraysImpl.java new file mode 100644 index 0000000000..b544a03b87 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadDifferentModelArraysImpl.java @@ -0,0 +1,122 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.DifferentSpreadModelArrayRecord; + +/** + * An instance of this class provides access to all the operations defined in SpreadDifferentModelArrays. + */ +public final class SpreadDifferentModelArraysImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadDifferentModelArraysService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadDifferentModelArraysImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadDifferentModelArraysImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadDifferentModelArraysService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadDifferentModelArrays to be used by + * the proxy service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface SpreadDifferentModelArraysService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/spreadDifferentRecordModelArray", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/spreadDifferentRecordModelArray", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): [
+     *              (Required){
+     *                 state: String (Required)
+     *             }
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadDifferentModelsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadDifferentModelsImpl.java new file mode 100644 index 0000000000..a436eea219 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadDifferentModelsImpl.java @@ -0,0 +1,118 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.DifferentSpreadModelRecord; + +/** + * An instance of this class provides access to all the operations defined in SpreadDifferentModels. + */ +public final class SpreadDifferentModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadDifferentModelsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadDifferentModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadDifferentModelsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadDifferentModelsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadDifferentModels to be used by the + * proxy service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface SpreadDifferentModelsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/spreadDifferentRecordModel", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/spreadDifferentRecordModel", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp: String (Required)
+     *      (Optional): {
+     *         String (Required): {
+     *             state: String (Required)
+     *         }
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadDifferentStringsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadDifferentStringsImpl.java new file mode 100644 index 0000000000..183baae3bd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadDifferentStringsImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.DifferentSpreadStringRecord; + +/** + * An instance of this class provides access to all the operations defined in SpreadDifferentStrings. + */ +public final class SpreadDifferentStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadDifferentStringsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadDifferentStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadDifferentStringsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadDifferentStringsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadDifferentStrings to be used by the + * proxy service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface SpreadDifferentStringsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/spreadDifferentRecordString", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/spreadDifferentRecordString", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadFloatsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadFloatsImpl.java new file mode 100644 index 0000000000..1a55367b07 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadFloatsImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.SpreadFloatRecord; + +/** + * An instance of this class provides access to all the operations defined in SpreadFloats. + */ +public final class SpreadFloatsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadFloatsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadFloatsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadFloatsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadFloatsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadFloats to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface SpreadFloatsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/spreadRecordFloat", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/spreadRecordFloat", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: double (Required)
+     *      (Optional): {
+     *         String: double (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadModelArraysImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadModelArraysImpl.java new file mode 100644 index 0000000000..f3c8397e53 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadModelArraysImpl.java @@ -0,0 +1,126 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.SpreadModelArrayRecord; + +/** + * An instance of this class provides access to all the operations defined in SpreadModelArrays. + */ +public final class SpreadModelArraysImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadModelArraysService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadModelArraysImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadModelArraysImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadModelArraysService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadModelArrays to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface SpreadModelArraysService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/spreadRecordModelArray", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/spreadRecordModelArray", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): [
+     *          (Required){
+     *             state: String (Required)
+     *         }
+     *     ]
+     *      (Optional): {
+     *         String (Required): [
+     *             (recursive schema, see above)
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadModelsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadModelsImpl.java new file mode 100644 index 0000000000..446321656c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadModelsImpl.java @@ -0,0 +1,118 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.SpreadModelRecord; + +/** + * An instance of this class provides access to all the operations defined in SpreadModels. + */ +public final class SpreadModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadModelsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadModelsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadModelsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadModels to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface SpreadModelsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/spreadRecordModel", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/spreadRecordModel", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     knownProp (Required): {
+     *         state: String (Required)
+     *     }
+     *      (Optional): {
+     *         String (Required): (recursive schema, see String above)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordDiscriminatedUnionsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordDiscriminatedUnionsImpl.java new file mode 100644 index 0000000000..d0b7b4e8f8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordDiscriminatedUnionsImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.SpreadRecordForDiscriminatedUnion; + +/** + * An instance of this class provides access to all the operations defined in SpreadRecordDiscriminatedUnions. + */ +public final class SpreadRecordDiscriminatedUnionsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadRecordDiscriminatedUnionsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadRecordDiscriminatedUnionsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadRecordDiscriminatedUnionsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadRecordDiscriminatedUnionsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadRecordDiscriminatedUnions to be used + * by the proxy service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface SpreadRecordDiscriminatedUnionsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/spreadRecordDiscriminatedUnion", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/spreadRecordDiscriminatedUnion", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion2sImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion2sImpl.java new file mode 100644 index 0000000000..4287935720 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion2sImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.SpreadRecordForNonDiscriminatedUnion2; + +/** + * An instance of this class provides access to all the operations defined in SpreadRecordNonDiscriminatedUnion2s. + */ +public final class SpreadRecordNonDiscriminatedUnion2sImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadRecordNonDiscriminatedUnion2sService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadRecordNonDiscriminatedUnion2sImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadRecordNonDiscriminatedUnion2sImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadRecordNonDiscriminatedUnion2sService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadRecordNonDiscriminatedUnion2s to be + * used by the proxy service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface SpreadRecordNonDiscriminatedUnion2sService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion2", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion2", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion3sImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion3sImpl.java new file mode 100644 index 0000000000..36777d3da6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnion3sImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.SpreadRecordForNonDiscriminatedUnion3; + +/** + * An instance of this class provides access to all the operations defined in SpreadRecordNonDiscriminatedUnion3s. + */ +public final class SpreadRecordNonDiscriminatedUnion3sImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadRecordNonDiscriminatedUnion3sService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadRecordNonDiscriminatedUnion3sImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadRecordNonDiscriminatedUnion3sImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadRecordNonDiscriminatedUnion3sService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadRecordNonDiscriminatedUnion3s to be + * used by the proxy service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface SpreadRecordNonDiscriminatedUnion3sService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion3", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion3", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnionsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnionsImpl.java new file mode 100644 index 0000000000..3fd74bd955 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordNonDiscriminatedUnionsImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.SpreadRecordForNonDiscriminatedUnion; + +/** + * An instance of this class provides access to all the operations defined in SpreadRecordNonDiscriminatedUnions. + */ +public final class SpreadRecordNonDiscriminatedUnionsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadRecordNonDiscriminatedUnionsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadRecordNonDiscriminatedUnionsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadRecordNonDiscriminatedUnionsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadRecordNonDiscriminatedUnionsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadRecordNonDiscriminatedUnions to be + * used by the proxy service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface SpreadRecordNonDiscriminatedUnionsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/spreadRecordNonDiscriminatedUnion", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordUnionsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordUnionsImpl.java new file mode 100644 index 0000000000..0bd4ef7739 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadRecordUnionsImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.SpreadRecordForUnion; + +/** + * An instance of this class provides access to all the operations defined in SpreadRecordUnions. + */ +public final class SpreadRecordUnionsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadRecordUnionsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadRecordUnionsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadRecordUnionsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadRecordUnionsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadRecordUnions to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface SpreadRecordUnionsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/spreadRecordUnion", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/spreadRecordUnion", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     flag: boolean (Required)
+     *      (Optional): {
+     *         String: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadStringsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadStringsImpl.java new file mode 100644 index 0000000000..6d161a0ad5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/SpreadStringsImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.additionalproperties.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.additionalproperties.SpreadStringRecord; + +/** + * An instance of this class provides access to all the operations defined in SpreadStrings. + */ +public final class SpreadStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final SpreadStringsService service; + + /** + * The service client containing this operation class. + */ + private final AdditionalPropertiesClientImpl client; + + /** + * Initializes an instance of SpreadStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + SpreadStringsImpl(AdditionalPropertiesClientImpl client) { + this.service = RestProxy.create(SpreadStringsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for AdditionalPropertiesClientSpreadStrings to be used by the proxy + * service to perform REST calls. + */ + @ServiceInterface(name = "AdditionalProperties", host = "{endpoint}") + public interface SpreadStringsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/additionalProperties/spreadRecordString", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/additionalProperties/spreadRecordString", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     name: String (Required)
+     *      (Optional): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/package-info.java new file mode 100644 index 0000000000..0fed00f13e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for AdditionalProperties. + * Tests for additional properties of models. + */ +package type.property.additionalproperties.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/package-info.java new file mode 100644 index 0000000000..4022eb6bd9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/additionalproperties/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for AdditionalProperties. + * Tests for additional properties of models. + */ +package type.property.additionalproperties; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/BytesClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/BytesClient.java new file mode 100644 index 0000000000..c5574d41bb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/BytesClient.java @@ -0,0 +1,189 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.nullable.implementation.BytesImpl; +import type.property.nullable.implementation.JsonMergePatchHelper; + +/** + * Initializes a new instance of the synchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class) +public final class BytesClient { + @Metadata(generated = true) + private final BytesImpl serviceClient; + + /** + * Initializes an instance of BytesClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + BytesClient(BytesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public BytesProperty getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public BytesProperty getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void patchNonNull(BytesProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getBytesPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getBytesPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNonNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void patchNull(BytesProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getBytesPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getBytesPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/BytesProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/BytesProperty.java new file mode 100644 index 0000000000..5168da9ea0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/BytesProperty.java @@ -0,0 +1,181 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; +import type.property.nullable.implementation.JsonMergePatchHelper; + +/** + * Template type for testing models with nullable property. Pass in the type of the property you are looking for. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class BytesProperty implements JsonSerializable { + /* + * Required property + */ + @Metadata(generated = true) + private String requiredProperty; + + /* + * Property + */ + @Metadata(generated = true) + private byte[] nullableProperty; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Metadata(generated = true) + private final Set updatedProperties = new HashSet<>(); + + @Metadata(generated = true) + private boolean jsonMergePatch; + + @Metadata(generated = true) + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setBytesPropertyAccessor(new JsonMergePatchHelper.BytesPropertyAccessor() { + @Override + public BytesProperty prepareModelForJsonMergePatch(BytesProperty model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(BytesProperty model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of BytesProperty class. + */ + @Metadata(generated = true) + public BytesProperty() { + } + + /** + * Get the requiredProperty property: Required property. + * + * @return the requiredProperty value. + */ + @Metadata(generated = true) + public String getRequiredProperty() { + return this.requiredProperty; + } + + /** + * Set the requiredProperty property: Required property. + *

Required when create the resource.

+ * + * @param requiredProperty the requiredProperty value to set. + * @return the BytesProperty object itself. + */ + @Metadata(generated = true) + public BytesProperty setRequiredProperty(String requiredProperty) { + this.requiredProperty = requiredProperty; + this.updatedProperties.add("requiredProperty"); + return this; + } + + /** + * Get the nullableProperty property: Property. + * + * @return the nullableProperty value. + */ + @Metadata(generated = true) + public byte[] getNullableProperty() { + return this.nullableProperty; + } + + /** + * Set the nullableProperty property: Property. + *

Required when create the resource.

+ * + * @param nullableProperty the nullableProperty value to set. + * @return the BytesProperty object itself. + */ + @Metadata(generated = true) + public BytesProperty setNullableProperty(byte[] nullableProperty) { + this.nullableProperty = nullableProperty; + this.updatedProperties.add("nullableProperty"); + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + jsonWriter.writeBinaryField("nullableProperty", this.nullableProperty); + return jsonWriter.writeEndObject(); + } + } + + @Metadata(generated = true) + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("requiredProperty")) { + if (this.requiredProperty == null) { + jsonWriter.writeNullField("requiredProperty"); + } else { + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + } + } + if (updatedProperties.contains("nullableProperty")) { + if (this.nullableProperty == null) { + jsonWriter.writeNullField("nullableProperty"); + } else { + jsonWriter.writeBinaryField("nullableProperty", this.nullableProperty); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BytesProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BytesProperty if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the BytesProperty. + */ + @Metadata(generated = true) + public static BytesProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BytesProperty deserializedBytesProperty = new BytesProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProperty".equals(fieldName)) { + deserializedBytesProperty.requiredProperty = reader.getString(); + } else if ("nullableProperty".equals(fieldName)) { + deserializedBytesProperty.nullableProperty = reader.getBinary(); + } else { + reader.skipChildren(); + } + } + + return deserializedBytesProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsByteClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsByteClient.java new file mode 100644 index 0000000000..6f67f0d1d0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsByteClient.java @@ -0,0 +1,197 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.nullable.implementation.CollectionsBytesImpl; +import type.property.nullable.implementation.JsonMergePatchHelper; + +/** + * Initializes a new instance of the synchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class) +public final class CollectionsByteClient { + @Metadata(generated = true) + private final CollectionsBytesImpl serviceClient; + + /** + * Initializes an instance of CollectionsByteClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + CollectionsByteClient(CollectionsBytesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public CollectionsByteProperty getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public CollectionsByteProperty getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void patchNonNull(CollectionsByteProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsBytePropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsBytePropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNonNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void patchNull(CollectionsByteProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsBytePropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsBytePropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsByteProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsByteProperty.java new file mode 100644 index 0000000000..59fd7fd04e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsByteProperty.java @@ -0,0 +1,187 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import type.property.nullable.implementation.JsonMergePatchHelper; + +/** + * Model with collection bytes properties. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class CollectionsByteProperty implements JsonSerializable { + /* + * Required property + */ + @Metadata(generated = true) + private String requiredProperty; + + /* + * Property + */ + @Metadata(generated = true) + private List nullableProperty; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Metadata(generated = true) + private final Set updatedProperties = new HashSet<>(); + + @Metadata(generated = true) + private boolean jsonMergePatch; + + @Metadata(generated = true) + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper + .setCollectionsBytePropertyAccessor(new JsonMergePatchHelper.CollectionsBytePropertyAccessor() { + @Override + public CollectionsByteProperty prepareModelForJsonMergePatch(CollectionsByteProperty model, + boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(CollectionsByteProperty model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of CollectionsByteProperty class. + */ + @Metadata(generated = true) + public CollectionsByteProperty() { + } + + /** + * Get the requiredProperty property: Required property. + * + * @return the requiredProperty value. + */ + @Metadata(generated = true) + public String getRequiredProperty() { + return this.requiredProperty; + } + + /** + * Set the requiredProperty property: Required property. + *

Required when create the resource.

+ * + * @param requiredProperty the requiredProperty value to set. + * @return the CollectionsByteProperty object itself. + */ + @Metadata(generated = true) + public CollectionsByteProperty setRequiredProperty(String requiredProperty) { + this.requiredProperty = requiredProperty; + this.updatedProperties.add("requiredProperty"); + return this; + } + + /** + * Get the nullableProperty property: Property. + * + * @return the nullableProperty value. + */ + @Metadata(generated = true) + public List getNullableProperty() { + return this.nullableProperty; + } + + /** + * Set the nullableProperty property: Property. + *

Required when create the resource.

+ * + * @param nullableProperty the nullableProperty value to set. + * @return the CollectionsByteProperty object itself. + */ + @Metadata(generated = true) + public CollectionsByteProperty setNullableProperty(List nullableProperty) { + this.nullableProperty = nullableProperty; + this.updatedProperties.add("nullableProperty"); + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + jsonWriter.writeArrayField("nullableProperty", this.nullableProperty, + (writer, element) -> writer.writeBinary(element)); + return jsonWriter.writeEndObject(); + } + } + + @Metadata(generated = true) + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("requiredProperty")) { + if (this.requiredProperty == null) { + jsonWriter.writeNullField("requiredProperty"); + } else { + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + } + } + if (updatedProperties.contains("nullableProperty")) { + if (this.nullableProperty == null) { + jsonWriter.writeNullField("nullableProperty"); + } else { + jsonWriter.writeArrayField("nullableProperty", this.nullableProperty, + (writer, element) -> writer.writeBinary(element)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionsByteProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionsByteProperty if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the CollectionsByteProperty. + */ + @Metadata(generated = true) + public static CollectionsByteProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CollectionsByteProperty deserializedCollectionsByteProperty = new CollectionsByteProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProperty".equals(fieldName)) { + deserializedCollectionsByteProperty.requiredProperty = reader.getString(); + } else if ("nullableProperty".equals(fieldName)) { + List nullableProperty = reader.readArray(reader1 -> reader1.getBinary()); + deserializedCollectionsByteProperty.nullableProperty = nullableProperty; + } else { + reader.skipChildren(); + } + } + + return deserializedCollectionsByteProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsModelClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsModelClient.java new file mode 100644 index 0000000000..7f7de68b1f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsModelClient.java @@ -0,0 +1,205 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.nullable.implementation.CollectionsModelsImpl; +import type.property.nullable.implementation.JsonMergePatchHelper; + +/** + * Initializes a new instance of the synchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class) +public final class CollectionsModelClient { + @Metadata(generated = true) + private final CollectionsModelsImpl serviceClient; + + /** + * Initializes an instance of CollectionsModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + CollectionsModelClient(CollectionsModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public CollectionsModelProperty getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public CollectionsModelProperty getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void patchNonNull(CollectionsModelProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsModelPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsModelPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNonNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void patchNull(CollectionsModelProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsModelPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsModelPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsModelProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsModelProperty.java new file mode 100644 index 0000000000..3ac2a20b9c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsModelProperty.java @@ -0,0 +1,187 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import type.property.nullable.implementation.JsonMergePatchHelper; + +/** + * Model with collection models properties. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class CollectionsModelProperty implements JsonSerializable { + /* + * Required property + */ + @Metadata(generated = true) + private String requiredProperty; + + /* + * Property + */ + @Metadata(generated = true) + private List nullableProperty; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Metadata(generated = true) + private final Set updatedProperties = new HashSet<>(); + + @Metadata(generated = true) + private boolean jsonMergePatch; + + @Metadata(generated = true) + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper + .setCollectionsModelPropertyAccessor(new JsonMergePatchHelper.CollectionsModelPropertyAccessor() { + @Override + public CollectionsModelProperty prepareModelForJsonMergePatch(CollectionsModelProperty model, + boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(CollectionsModelProperty model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of CollectionsModelProperty class. + */ + @Metadata(generated = true) + public CollectionsModelProperty() { + } + + /** + * Get the requiredProperty property: Required property. + * + * @return the requiredProperty value. + */ + @Metadata(generated = true) + public String getRequiredProperty() { + return this.requiredProperty; + } + + /** + * Set the requiredProperty property: Required property. + *

Required when create the resource.

+ * + * @param requiredProperty the requiredProperty value to set. + * @return the CollectionsModelProperty object itself. + */ + @Metadata(generated = true) + public CollectionsModelProperty setRequiredProperty(String requiredProperty) { + this.requiredProperty = requiredProperty; + this.updatedProperties.add("requiredProperty"); + return this; + } + + /** + * Get the nullableProperty property: Property. + * + * @return the nullableProperty value. + */ + @Metadata(generated = true) + public List getNullableProperty() { + return this.nullableProperty; + } + + /** + * Set the nullableProperty property: Property. + *

Required when create the resource.

+ * + * @param nullableProperty the nullableProperty value to set. + * @return the CollectionsModelProperty object itself. + */ + @Metadata(generated = true) + public CollectionsModelProperty setNullableProperty(List nullableProperty) { + this.nullableProperty = nullableProperty; + this.updatedProperties.add("nullableProperty"); + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + jsonWriter.writeArrayField("nullableProperty", this.nullableProperty, + (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + } + + @Metadata(generated = true) + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("requiredProperty")) { + if (this.requiredProperty == null) { + jsonWriter.writeNullField("requiredProperty"); + } else { + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + } + } + if (updatedProperties.contains("nullableProperty")) { + if (this.nullableProperty == null) { + jsonWriter.writeNullField("nullableProperty"); + } else { + jsonWriter.writeArrayField("nullableProperty", this.nullableProperty, + (writer, element) -> writer.writeJson(element)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionsModelProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionsModelProperty if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the CollectionsModelProperty. + */ + @Metadata(generated = true) + public static CollectionsModelProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CollectionsModelProperty deserializedCollectionsModelProperty = new CollectionsModelProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProperty".equals(fieldName)) { + deserializedCollectionsModelProperty.requiredProperty = reader.getString(); + } else if ("nullableProperty".equals(fieldName)) { + List nullableProperty = reader.readArray(reader1 -> InnerModel.fromJson(reader1)); + deserializedCollectionsModelProperty.nullableProperty = nullableProperty; + } else { + reader.skipChildren(); + } + } + + return deserializedCollectionsModelProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsStringClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsStringClient.java new file mode 100644 index 0000000000..1d2bdd6460 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsStringClient.java @@ -0,0 +1,197 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.nullable.implementation.CollectionsStringsImpl; +import type.property.nullable.implementation.JsonMergePatchHelper; + +/** + * Initializes a new instance of the synchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class) +public final class CollectionsStringClient { + @Metadata(generated = true) + private final CollectionsStringsImpl serviceClient; + + /** + * Initializes an instance of CollectionsStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + CollectionsStringClient(CollectionsStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public CollectionsStringProperty getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public CollectionsStringProperty getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void patchNonNull(CollectionsStringProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsStringPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsStringPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNonNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void patchNull(CollectionsStringProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getCollectionsStringPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getCollectionsStringPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsStringProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsStringProperty.java new file mode 100644 index 0000000000..2ff9ba5881 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/CollectionsStringProperty.java @@ -0,0 +1,187 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import type.property.nullable.implementation.JsonMergePatchHelper; + +/** + * Model with collection string properties. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class CollectionsStringProperty implements JsonSerializable { + /* + * Required property + */ + @Metadata(generated = true) + private String requiredProperty; + + /* + * Property + */ + @Metadata(generated = true) + private List nullableProperty; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Metadata(generated = true) + private final Set updatedProperties = new HashSet<>(); + + @Metadata(generated = true) + private boolean jsonMergePatch; + + @Metadata(generated = true) + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper + .setCollectionsStringPropertyAccessor(new JsonMergePatchHelper.CollectionsStringPropertyAccessor() { + @Override + public CollectionsStringProperty prepareModelForJsonMergePatch(CollectionsStringProperty model, + boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(CollectionsStringProperty model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of CollectionsStringProperty class. + */ + @Metadata(generated = true) + public CollectionsStringProperty() { + } + + /** + * Get the requiredProperty property: Required property. + * + * @return the requiredProperty value. + */ + @Metadata(generated = true) + public String getRequiredProperty() { + return this.requiredProperty; + } + + /** + * Set the requiredProperty property: Required property. + *

Required when create the resource.

+ * + * @param requiredProperty the requiredProperty value to set. + * @return the CollectionsStringProperty object itself. + */ + @Metadata(generated = true) + public CollectionsStringProperty setRequiredProperty(String requiredProperty) { + this.requiredProperty = requiredProperty; + this.updatedProperties.add("requiredProperty"); + return this; + } + + /** + * Get the nullableProperty property: Property. + * + * @return the nullableProperty value. + */ + @Metadata(generated = true) + public List getNullableProperty() { + return this.nullableProperty; + } + + /** + * Set the nullableProperty property: Property. + *

Required when create the resource.

+ * + * @param nullableProperty the nullableProperty value to set. + * @return the CollectionsStringProperty object itself. + */ + @Metadata(generated = true) + public CollectionsStringProperty setNullableProperty(List nullableProperty) { + this.nullableProperty = nullableProperty; + this.updatedProperties.add("nullableProperty"); + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + jsonWriter.writeArrayField("nullableProperty", this.nullableProperty, + (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + } + + @Metadata(generated = true) + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("requiredProperty")) { + if (this.requiredProperty == null) { + jsonWriter.writeNullField("requiredProperty"); + } else { + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + } + } + if (updatedProperties.contains("nullableProperty")) { + if (this.nullableProperty == null) { + jsonWriter.writeNullField("nullableProperty"); + } else { + jsonWriter.writeArrayField("nullableProperty", this.nullableProperty, + (writer, element) -> writer.writeString(element)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionsStringProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionsStringProperty if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the CollectionsStringProperty. + */ + @Metadata(generated = true) + public static CollectionsStringProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CollectionsStringProperty deserializedCollectionsStringProperty = new CollectionsStringProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProperty".equals(fieldName)) { + deserializedCollectionsStringProperty.requiredProperty = reader.getString(); + } else if ("nullableProperty".equals(fieldName)) { + List nullableProperty = reader.readArray(reader1 -> reader1.getString()); + deserializedCollectionsStringProperty.nullableProperty = nullableProperty; + } else { + reader.skipChildren(); + } + } + + return deserializedCollectionsStringProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/DatetimeOperationClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/DatetimeOperationClient.java new file mode 100644 index 0000000000..5a7513223a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/DatetimeOperationClient.java @@ -0,0 +1,189 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.nullable.implementation.DatetimeOperationsImpl; +import type.property.nullable.implementation.JsonMergePatchHelper; + +/** + * Initializes a new instance of the synchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class) +public final class DatetimeOperationClient { + @Metadata(generated = true) + private final DatetimeOperationsImpl serviceClient; + + /** + * Initializes an instance of DatetimeOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + DatetimeOperationClient(DatetimeOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public DatetimeProperty getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public DatetimeProperty getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void patchNonNull(DatetimeProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getDatetimePropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getDatetimePropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNonNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void patchNull(DatetimeProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getDatetimePropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getDatetimePropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/DatetimeProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/DatetimeProperty.java new file mode 100644 index 0000000000..409a896c60 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/DatetimeProperty.java @@ -0,0 +1,191 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.HashSet; +import java.util.Set; +import type.property.nullable.implementation.JsonMergePatchHelper; + +/** + * Model with a datetime property. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class DatetimeProperty implements JsonSerializable { + /* + * Required property + */ + @Metadata(generated = true) + private String requiredProperty; + + /* + * Property + */ + @Metadata(generated = true) + private OffsetDateTime nullableProperty; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Metadata(generated = true) + private final Set updatedProperties = new HashSet<>(); + + @Metadata(generated = true) + private boolean jsonMergePatch; + + @Metadata(generated = true) + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setDatetimePropertyAccessor(new JsonMergePatchHelper.DatetimePropertyAccessor() { + @Override + public DatetimeProperty prepareModelForJsonMergePatch(DatetimeProperty model, + boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(DatetimeProperty model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of DatetimeProperty class. + */ + @Metadata(generated = true) + public DatetimeProperty() { + } + + /** + * Get the requiredProperty property: Required property. + * + * @return the requiredProperty value. + */ + @Metadata(generated = true) + public String getRequiredProperty() { + return this.requiredProperty; + } + + /** + * Set the requiredProperty property: Required property. + *

Required when create the resource.

+ * + * @param requiredProperty the requiredProperty value to set. + * @return the DatetimeProperty object itself. + */ + @Metadata(generated = true) + public DatetimeProperty setRequiredProperty(String requiredProperty) { + this.requiredProperty = requiredProperty; + this.updatedProperties.add("requiredProperty"); + return this; + } + + /** + * Get the nullableProperty property: Property. + * + * @return the nullableProperty value. + */ + @Metadata(generated = true) + public OffsetDateTime getNullableProperty() { + return this.nullableProperty; + } + + /** + * Set the nullableProperty property: Property. + *

Required when create the resource.

+ * + * @param nullableProperty the nullableProperty value to set. + * @return the DatetimeProperty object itself. + */ + @Metadata(generated = true) + public DatetimeProperty setNullableProperty(OffsetDateTime nullableProperty) { + this.nullableProperty = nullableProperty; + this.updatedProperties.add("nullableProperty"); + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + jsonWriter.writeStringField("nullableProperty", + this.nullableProperty == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.nullableProperty)); + return jsonWriter.writeEndObject(); + } + } + + @Metadata(generated = true) + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("requiredProperty")) { + if (this.requiredProperty == null) { + jsonWriter.writeNullField("requiredProperty"); + } else { + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + } + } + if (updatedProperties.contains("nullableProperty")) { + if (this.nullableProperty == null) { + jsonWriter.writeNullField("nullableProperty"); + } else { + jsonWriter.writeStringField("nullableProperty", + this.nullableProperty == null + ? null + : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.nullableProperty)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DatetimeProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DatetimeProperty if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the DatetimeProperty. + */ + @Metadata(generated = true) + public static DatetimeProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DatetimeProperty deserializedDatetimeProperty = new DatetimeProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProperty".equals(fieldName)) { + deserializedDatetimeProperty.requiredProperty = reader.getString(); + } else if ("nullableProperty".equals(fieldName)) { + deserializedDatetimeProperty.nullableProperty + = reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedDatetimeProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/DurationOperationClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/DurationOperationClient.java new file mode 100644 index 0000000000..4e051895b4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/DurationOperationClient.java @@ -0,0 +1,189 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.nullable.implementation.DurationOperationsImpl; +import type.property.nullable.implementation.JsonMergePatchHelper; + +/** + * Initializes a new instance of the synchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class) +public final class DurationOperationClient { + @Metadata(generated = true) + private final DurationOperationsImpl serviceClient; + + /** + * Initializes an instance of DurationOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + DurationOperationClient(DurationOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public DurationProperty getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public DurationProperty getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void patchNonNull(DurationProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getDurationPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getDurationPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNonNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void patchNull(DurationProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getDurationPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getDurationPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/DurationProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/DurationProperty.java new file mode 100644 index 0000000000..ac0c1e5876 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/DurationProperty.java @@ -0,0 +1,185 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.time.Duration; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; +import type.property.nullable.implementation.JsonMergePatchHelper; + +/** + * Model with a duration property. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class DurationProperty implements JsonSerializable { + /* + * Required property + */ + @Metadata(generated = true) + private String requiredProperty; + + /* + * Property + */ + @Metadata(generated = true) + private Duration nullableProperty; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Metadata(generated = true) + private final Set updatedProperties = new HashSet<>(); + + @Metadata(generated = true) + private boolean jsonMergePatch; + + @Metadata(generated = true) + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setDurationPropertyAccessor(new JsonMergePatchHelper.DurationPropertyAccessor() { + @Override + public DurationProperty prepareModelForJsonMergePatch(DurationProperty model, + boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(DurationProperty model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of DurationProperty class. + */ + @Metadata(generated = true) + public DurationProperty() { + } + + /** + * Get the requiredProperty property: Required property. + * + * @return the requiredProperty value. + */ + @Metadata(generated = true) + public String getRequiredProperty() { + return this.requiredProperty; + } + + /** + * Set the requiredProperty property: Required property. + *

Required when create the resource.

+ * + * @param requiredProperty the requiredProperty value to set. + * @return the DurationProperty object itself. + */ + @Metadata(generated = true) + public DurationProperty setRequiredProperty(String requiredProperty) { + this.requiredProperty = requiredProperty; + this.updatedProperties.add("requiredProperty"); + return this; + } + + /** + * Get the nullableProperty property: Property. + * + * @return the nullableProperty value. + */ + @Metadata(generated = true) + public Duration getNullableProperty() { + return this.nullableProperty; + } + + /** + * Set the nullableProperty property: Property. + *

Required when create the resource.

+ * + * @param nullableProperty the nullableProperty value to set. + * @return the DurationProperty object itself. + */ + @Metadata(generated = true) + public DurationProperty setNullableProperty(Duration nullableProperty) { + this.nullableProperty = nullableProperty; + this.updatedProperties.add("nullableProperty"); + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + jsonWriter.writeStringField("nullableProperty", Objects.toString(this.nullableProperty, null)); + return jsonWriter.writeEndObject(); + } + } + + @Metadata(generated = true) + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("requiredProperty")) { + if (this.requiredProperty == null) { + jsonWriter.writeNullField("requiredProperty"); + } else { + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + } + } + if (updatedProperties.contains("nullableProperty")) { + if (this.nullableProperty == null) { + jsonWriter.writeNullField("nullableProperty"); + } else { + jsonWriter.writeStringField("nullableProperty", Objects.toString(this.nullableProperty, null)); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DurationProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DurationProperty if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the DurationProperty. + */ + @Metadata(generated = true) + public static DurationProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DurationProperty deserializedDurationProperty = new DurationProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProperty".equals(fieldName)) { + deserializedDurationProperty.requiredProperty = reader.getString(); + } else if ("nullableProperty".equals(fieldName)) { + deserializedDurationProperty.nullableProperty + = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedDurationProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/InnerModel.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/InnerModel.java new file mode 100644 index 0000000000..79db61824d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/InnerModel.java @@ -0,0 +1,141 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; +import type.property.nullable.implementation.JsonMergePatchHelper; + +/** + * Inner model used in collections model property. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class InnerModel implements JsonSerializable { + /* + * Inner model property + */ + @Metadata(generated = true) + private String property; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Metadata(generated = true) + private final Set updatedProperties = new HashSet<>(); + + @Metadata(generated = true) + private boolean jsonMergePatch; + + @Metadata(generated = true) + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setInnerModelAccessor(new JsonMergePatchHelper.InnerModelAccessor() { + @Override + public InnerModel prepareModelForJsonMergePatch(InnerModel model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(InnerModel model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of InnerModel class. + */ + @Metadata(generated = true) + public InnerModel() { + } + + /** + * Get the property property: Inner model property. + * + * @return the property value. + */ + @Metadata(generated = true) + public String getProperty() { + return this.property; + } + + /** + * Set the property property: Inner model property. + *

Required when create the resource.

+ * + * @param property the property value to set. + * @return the InnerModel object itself. + */ + @Metadata(generated = true) + public InnerModel setProperty(String property) { + this.property = property; + this.updatedProperties.add("property"); + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property); + return jsonWriter.writeEndObject(); + } + } + + @Metadata(generated = true) + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("property")) { + if (this.property == null) { + jsonWriter.writeNullField("property"); + } else { + jsonWriter.writeStringField("property", this.property); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InnerModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InnerModel if the JsonReader was pointing to an instance of it, or null if it was pointing + * to JSON null. + * @throws IOException If an error occurs while reading the InnerModel. + */ + @Metadata(generated = true) + public static InnerModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + InnerModel deserializedInnerModel = new InnerModel(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedInnerModel.property = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedInnerModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/NullableClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/NullableClientBuilder.java new file mode 100644 index 0000000000..8ae843a5a7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/NullableClientBuilder.java @@ -0,0 +1,308 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.property.nullable.implementation.NullableClientImpl; + +/** + * A builder for creating a new instance of the NullableClient type. + */ +@ServiceClientBuilder( + serviceClients = { + StringOperationClient.class, + BytesClient.class, + DatetimeOperationClient.class, + DurationOperationClient.class, + CollectionsByteClient.class, + CollectionsModelClient.class, + CollectionsStringClient.class }) +public final class NullableClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the NullableClientBuilder. + */ + @Metadata(generated = true) + public NullableClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NullableClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NullableClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NullableClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NullableClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NullableClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NullableClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NullableClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NullableClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public NullableClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of NullableClientImpl with the provided parameters. + * + * @return an instance of NullableClientImpl. + */ + @Metadata(generated = true) + private NullableClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + NullableClientImpl client = new NullableClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of StringOperationClient class. + * + * @return an instance of StringOperationClient. + */ + @Metadata(generated = true) + public StringOperationClient buildStringOperationClient() { + return new StringOperationClient(buildInnerClient().getStringOperations()); + } + + /** + * Builds an instance of BytesClient class. + * + * @return an instance of BytesClient. + */ + @Metadata(generated = true) + public BytesClient buildBytesClient() { + return new BytesClient(buildInnerClient().getBytes()); + } + + /** + * Builds an instance of DatetimeOperationClient class. + * + * @return an instance of DatetimeOperationClient. + */ + @Metadata(generated = true) + public DatetimeOperationClient buildDatetimeOperationClient() { + return new DatetimeOperationClient(buildInnerClient().getDatetimeOperations()); + } + + /** + * Builds an instance of DurationOperationClient class. + * + * @return an instance of DurationOperationClient. + */ + @Metadata(generated = true) + public DurationOperationClient buildDurationOperationClient() { + return new DurationOperationClient(buildInnerClient().getDurationOperations()); + } + + /** + * Builds an instance of CollectionsByteClient class. + * + * @return an instance of CollectionsByteClient. + */ + @Metadata(generated = true) + public CollectionsByteClient buildCollectionsByteClient() { + return new CollectionsByteClient(buildInnerClient().getCollectionsBytes()); + } + + /** + * Builds an instance of CollectionsModelClient class. + * + * @return an instance of CollectionsModelClient. + */ + @Metadata(generated = true) + public CollectionsModelClient buildCollectionsModelClient() { + return new CollectionsModelClient(buildInnerClient().getCollectionsModels()); + } + + /** + * Builds an instance of CollectionsStringClient class. + * + * @return an instance of CollectionsStringClient. + */ + @Metadata(generated = true) + public CollectionsStringClient buildCollectionsStringClient() { + return new CollectionsStringClient(buildInnerClient().getCollectionsStrings()); + } + + private static final ClientLogger LOGGER = new ClientLogger(NullableClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/StringOperationClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/StringOperationClient.java new file mode 100644 index 0000000000..7efd2634d2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/StringOperationClient.java @@ -0,0 +1,189 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.nullable.implementation.JsonMergePatchHelper; +import type.property.nullable.implementation.StringOperationsImpl; + +/** + * Initializes a new instance of the synchronous NullableClient type. + */ +@ServiceClient(builder = NullableClientBuilder.class) +public final class StringOperationClient { + @Metadata(generated = true) + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of StringOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + StringOperationClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getNonNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNonNullWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getNullWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getNullWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNonNullWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.patchNullWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public StringProperty getNonNull() { + // Generated convenience method for getNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNonNullWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public StringProperty getNull() { + // Generated convenience method for getNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getNullWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void patchNonNull(StringProperty body) { + // Generated convenience method for patchNonNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getStringPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getStringPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNonNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void patchNull(StringProperty body) { + // Generated convenience method for patchNullWithResponse + RequestOptions requestOptions = new RequestOptions(); + JsonMergePatchHelper.getStringPropertyAccessor().prepareModelForJsonMergePatch(body, true); + BinaryData bodyInBinaryData = BinaryData.fromObject(body); + // BinaryData.fromObject() will not fire serialization, use getLength() to fire serialization. + bodyInBinaryData.getLength(); + JsonMergePatchHelper.getStringPropertyAccessor().prepareModelForJsonMergePatch(body, false); + patchNullWithResponse(bodyInBinaryData, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/StringProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/StringProperty.java new file mode 100644 index 0000000000..a893053f89 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/StringProperty.java @@ -0,0 +1,181 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; +import type.property.nullable.implementation.JsonMergePatchHelper; + +/** + * Template type for testing models with nullable property. Pass in the type of the property you are looking for. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class StringProperty implements JsonSerializable { + /* + * Required property + */ + @Metadata(generated = true) + private String requiredProperty; + + /* + * Property + */ + @Metadata(generated = true) + private String nullableProperty; + + /** + * Stores updated model property, the value is property name, not serialized name. + */ + @Metadata(generated = true) + private final Set updatedProperties = new HashSet<>(); + + @Metadata(generated = true) + private boolean jsonMergePatch; + + @Metadata(generated = true) + private void serializeAsJsonMergePatch(boolean jsonMergePatch) { + this.jsonMergePatch = jsonMergePatch; + } + + static { + JsonMergePatchHelper.setStringPropertyAccessor(new JsonMergePatchHelper.StringPropertyAccessor() { + @Override + public StringProperty prepareModelForJsonMergePatch(StringProperty model, boolean jsonMergePatchEnabled) { + model.serializeAsJsonMergePatch(jsonMergePatchEnabled); + return model; + } + + @Override + public boolean isJsonMergePatch(StringProperty model) { + return model.jsonMergePatch; + } + }); + } + + /** + * Creates an instance of StringProperty class. + */ + @Metadata(generated = true) + public StringProperty() { + } + + /** + * Get the requiredProperty property: Required property. + * + * @return the requiredProperty value. + */ + @Metadata(generated = true) + public String getRequiredProperty() { + return this.requiredProperty; + } + + /** + * Set the requiredProperty property: Required property. + *

Required when create the resource.

+ * + * @param requiredProperty the requiredProperty value to set. + * @return the StringProperty object itself. + */ + @Metadata(generated = true) + public StringProperty setRequiredProperty(String requiredProperty) { + this.requiredProperty = requiredProperty; + this.updatedProperties.add("requiredProperty"); + return this; + } + + /** + * Get the nullableProperty property: Property. + * + * @return the nullableProperty value. + */ + @Metadata(generated = true) + public String getNullableProperty() { + return this.nullableProperty; + } + + /** + * Set the nullableProperty property: Property. + *

Required when create the resource.

+ * + * @param nullableProperty the nullableProperty value to set. + * @return the StringProperty object itself. + */ + @Metadata(generated = true) + public StringProperty setNullableProperty(String nullableProperty) { + this.nullableProperty = nullableProperty; + this.updatedProperties.add("nullableProperty"); + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + if (jsonMergePatch) { + return toJsonMergePatch(jsonWriter); + } else { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + jsonWriter.writeStringField("nullableProperty", this.nullableProperty); + return jsonWriter.writeEndObject(); + } + } + + @Metadata(generated = true) + private JsonWriter toJsonMergePatch(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + if (updatedProperties.contains("requiredProperty")) { + if (this.requiredProperty == null) { + jsonWriter.writeNullField("requiredProperty"); + } else { + jsonWriter.writeStringField("requiredProperty", this.requiredProperty); + } + } + if (updatedProperties.contains("nullableProperty")) { + if (this.nullableProperty == null) { + jsonWriter.writeNullField("nullableProperty"); + } else { + jsonWriter.writeStringField("nullableProperty", this.nullableProperty); + } + } + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StringProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StringProperty if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the StringProperty. + */ + @Metadata(generated = true) + public static StringProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StringProperty deserializedStringProperty = new StringProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProperty".equals(fieldName)) { + deserializedStringProperty.requiredProperty = reader.getString(); + } else if ("nullableProperty".equals(fieldName)) { + deserializedStringProperty.nullableProperty = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedStringProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/BytesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/BytesImpl.java new file mode 100644 index 0000000000..643e2a520e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/BytesImpl.java @@ -0,0 +1,173 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.nullable.BytesProperty; + +/** + * An instance of this class provides access to all the operations defined in Bytes. + */ +public final class BytesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BytesService service; + + /** + * The service client containing this operation class. + */ + private final NullableClientImpl client; + + /** + * Initializes an instance of BytesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BytesImpl(NullableClientImpl client) { + this.service = RestProxy.create(BytesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for NullableClientBytes to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "NullableClientBytes", host = "{endpoint}") + public interface BytesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/nullable/bytes/non-null", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/nullable/bytes/null", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PATCH, + path = "/type/property/nullable/bytes/non-null", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response patchNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PATCH, + path = "/type/property/nullable/bytes/null", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getNonNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: byte[] (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/CollectionsBytesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/CollectionsBytesImpl.java new file mode 100644 index 0000000000..d6b841b41d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/CollectionsBytesImpl.java @@ -0,0 +1,181 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.nullable.CollectionsByteProperty; + +/** + * An instance of this class provides access to all the operations defined in CollectionsBytes. + */ +public final class CollectionsBytesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CollectionsBytesService service; + + /** + * The service client containing this operation class. + */ + private final NullableClientImpl client; + + /** + * Initializes an instance of CollectionsBytesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CollectionsBytesImpl(NullableClientImpl client) { + this.service = RestProxy.create(CollectionsBytesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for NullableClientCollectionsBytes to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "NullableClientCollec", host = "{endpoint}") + public interface CollectionsBytesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/nullable/collections/bytes/non-null", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/nullable/collections/bytes/null", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PATCH, + path = "/type/property/nullable/collections/bytes/non-null", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response patchNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PATCH, + path = "/type/property/nullable/collections/bytes/null", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getNonNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         byte[] (Optional, Required on create)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/CollectionsModelsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/CollectionsModelsImpl.java new file mode 100644 index 0000000000..7586c4dea6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/CollectionsModelsImpl.java @@ -0,0 +1,189 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.nullable.CollectionsModelProperty; + +/** + * An instance of this class provides access to all the operations defined in CollectionsModels. + */ +public final class CollectionsModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CollectionsModelsService service; + + /** + * The service client containing this operation class. + */ + private final NullableClientImpl client; + + /** + * Initializes an instance of CollectionsModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CollectionsModelsImpl(NullableClientImpl client) { + this.service = RestProxy.create(CollectionsModelsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for NullableClientCollectionsModels to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "NullableClientCollec", host = "{endpoint}") + public interface CollectionsModelsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/nullable/collections/model/non-null", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/nullable/collections/model/null", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PATCH, + path = "/type/property/nullable/collections/model/non-null", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response patchNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PATCH, + path = "/type/property/nullable/collections/model/null", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getNonNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *          (Optional, Required on create){
+     *             property: String (Optional, Required on create)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/CollectionsStringsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/CollectionsStringsImpl.java new file mode 100644 index 0000000000..aff8dca0cd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/CollectionsStringsImpl.java @@ -0,0 +1,181 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.nullable.CollectionsStringProperty; + +/** + * An instance of this class provides access to all the operations defined in CollectionsStrings. + */ +public final class CollectionsStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CollectionsStringsService service; + + /** + * The service client containing this operation class. + */ + private final NullableClientImpl client; + + /** + * Initializes an instance of CollectionsStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CollectionsStringsImpl(NullableClientImpl client) { + this.service = RestProxy.create(CollectionsStringsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for NullableClientCollectionsStrings to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "NullableClientCollec", host = "{endpoint}") + public interface CollectionsStringsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/nullable/collections/string/non-null", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/nullable/collections/string/null", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PATCH, + path = "/type/property/nullable/collections/string/non-null", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response patchNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PATCH, + path = "/type/property/nullable/collections/string/null", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getNonNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty (Optional, Required on create): [
+     *         String (Optional, Required on create)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/DatetimeOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/DatetimeOperationsImpl.java new file mode 100644 index 0000000000..95c1432aba --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/DatetimeOperationsImpl.java @@ -0,0 +1,173 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.nullable.DatetimeProperty; + +/** + * An instance of this class provides access to all the operations defined in DatetimeOperations. + */ +public final class DatetimeOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DatetimeOperationsService service; + + /** + * The service client containing this operation class. + */ + private final NullableClientImpl client; + + /** + * Initializes an instance of DatetimeOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DatetimeOperationsImpl(NullableClientImpl client) { + this.service = RestProxy.create(DatetimeOperationsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for NullableClientDatetimeOperations to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "NullableClientDateti", host = "{endpoint}") + public interface DatetimeOperationsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/nullable/datetime/non-null", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/nullable/datetime/null", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PATCH, + path = "/type/property/nullable/datetime/non-null", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response patchNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PATCH, + path = "/type/property/nullable/datetime/null", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getNonNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: OffsetDateTime (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/DurationOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/DurationOperationsImpl.java new file mode 100644 index 0000000000..fd765e66c5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/DurationOperationsImpl.java @@ -0,0 +1,173 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.nullable.DurationProperty; + +/** + * An instance of this class provides access to all the operations defined in DurationOperations. + */ +public final class DurationOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DurationOperationsService service; + + /** + * The service client containing this operation class. + */ + private final NullableClientImpl client; + + /** + * Initializes an instance of DurationOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DurationOperationsImpl(NullableClientImpl client) { + this.service = RestProxy.create(DurationOperationsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for NullableClientDurationOperations to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "NullableClientDurati", host = "{endpoint}") + public interface DurationOperationsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/nullable/duration/non-null", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/nullable/duration/null", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PATCH, + path = "/type/property/nullable/duration/non-null", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response patchNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PATCH, + path = "/type/property/nullable/duration/null", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getNonNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: Duration (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/JsonMergePatchHelper.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/JsonMergePatchHelper.java new file mode 100644 index 0000000000..77e9dad602 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/JsonMergePatchHelper.java @@ -0,0 +1,150 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable.implementation; + +import type.property.nullable.BytesProperty; +import type.property.nullable.CollectionsByteProperty; +import type.property.nullable.CollectionsModelProperty; +import type.property.nullable.CollectionsStringProperty; +import type.property.nullable.DatetimeProperty; +import type.property.nullable.DurationProperty; +import type.property.nullable.InnerModel; +import type.property.nullable.StringProperty; + +/** + * This is the Helper class to enable json merge patch serialization for a model. + */ +public class JsonMergePatchHelper { + private static StringPropertyAccessor stringPropertyAccessor; + + public interface StringPropertyAccessor { + StringProperty prepareModelForJsonMergePatch(StringProperty stringProperty, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(StringProperty stringProperty); + } + + public static void setStringPropertyAccessor(StringPropertyAccessor accessor) { + stringPropertyAccessor = accessor; + } + + public static StringPropertyAccessor getStringPropertyAccessor() { + return stringPropertyAccessor; + } + + private static BytesPropertyAccessor bytesPropertyAccessor; + + public interface BytesPropertyAccessor { + BytesProperty prepareModelForJsonMergePatch(BytesProperty bytesProperty, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(BytesProperty bytesProperty); + } + + public static void setBytesPropertyAccessor(BytesPropertyAccessor accessor) { + bytesPropertyAccessor = accessor; + } + + public static BytesPropertyAccessor getBytesPropertyAccessor() { + return bytesPropertyAccessor; + } + + private static DatetimePropertyAccessor datetimePropertyAccessor; + + public interface DatetimePropertyAccessor { + DatetimeProperty prepareModelForJsonMergePatch(DatetimeProperty datetimeProperty, + boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(DatetimeProperty datetimeProperty); + } + + public static void setDatetimePropertyAccessor(DatetimePropertyAccessor accessor) { + datetimePropertyAccessor = accessor; + } + + public static DatetimePropertyAccessor getDatetimePropertyAccessor() { + return datetimePropertyAccessor; + } + + private static DurationPropertyAccessor durationPropertyAccessor; + + public interface DurationPropertyAccessor { + DurationProperty prepareModelForJsonMergePatch(DurationProperty durationProperty, + boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(DurationProperty durationProperty); + } + + public static void setDurationPropertyAccessor(DurationPropertyAccessor accessor) { + durationPropertyAccessor = accessor; + } + + public static DurationPropertyAccessor getDurationPropertyAccessor() { + return durationPropertyAccessor; + } + + private static CollectionsBytePropertyAccessor collectionsBytePropertyAccessor; + + public interface CollectionsBytePropertyAccessor { + CollectionsByteProperty prepareModelForJsonMergePatch(CollectionsByteProperty collectionsByteProperty, + boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(CollectionsByteProperty collectionsByteProperty); + } + + public static void setCollectionsBytePropertyAccessor(CollectionsBytePropertyAccessor accessor) { + collectionsBytePropertyAccessor = accessor; + } + + public static CollectionsBytePropertyAccessor getCollectionsBytePropertyAccessor() { + return collectionsBytePropertyAccessor; + } + + private static CollectionsModelPropertyAccessor collectionsModelPropertyAccessor; + + public interface CollectionsModelPropertyAccessor { + CollectionsModelProperty prepareModelForJsonMergePatch(CollectionsModelProperty collectionsModelProperty, + boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(CollectionsModelProperty collectionsModelProperty); + } + + public static void setCollectionsModelPropertyAccessor(CollectionsModelPropertyAccessor accessor) { + collectionsModelPropertyAccessor = accessor; + } + + public static CollectionsModelPropertyAccessor getCollectionsModelPropertyAccessor() { + return collectionsModelPropertyAccessor; + } + + private static InnerModelAccessor innerModelAccessor; + + public interface InnerModelAccessor { + InnerModel prepareModelForJsonMergePatch(InnerModel innerModel, boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(InnerModel innerModel); + } + + public static void setInnerModelAccessor(InnerModelAccessor accessor) { + innerModelAccessor = accessor; + } + + public static InnerModelAccessor getInnerModelAccessor() { + return innerModelAccessor; + } + + private static CollectionsStringPropertyAccessor collectionsStringPropertyAccessor; + + public interface CollectionsStringPropertyAccessor { + CollectionsStringProperty prepareModelForJsonMergePatch(CollectionsStringProperty collectionsStringProperty, + boolean jsonMergePatchEnabled); + + boolean isJsonMergePatch(CollectionsStringProperty collectionsStringProperty); + } + + public static void setCollectionsStringPropertyAccessor(CollectionsStringPropertyAccessor accessor) { + collectionsStringPropertyAccessor = accessor; + } + + public static CollectionsStringPropertyAccessor getCollectionsStringPropertyAccessor() { + return collectionsStringPropertyAccessor; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/NullableClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/NullableClientImpl.java new file mode 100644 index 0000000000..64674a77c9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/NullableClientImpl.java @@ -0,0 +1,154 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the NullableClient type. + */ +public final class NullableClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 StringOperationsImpl object to access its operations. + */ + private final StringOperationsImpl stringOperations; + + /** + * Gets the StringOperationsImpl object to access its operations. + * + * @return the StringOperationsImpl object. + */ + public StringOperationsImpl getStringOperations() { + return this.stringOperations; + } + + /** + * The BytesImpl object to access its operations. + */ + private final BytesImpl bytes; + + /** + * Gets the BytesImpl object to access its operations. + * + * @return the BytesImpl object. + */ + public BytesImpl getBytes() { + return this.bytes; + } + + /** + * The DatetimeOperationsImpl object to access its operations. + */ + private final DatetimeOperationsImpl datetimeOperations; + + /** + * Gets the DatetimeOperationsImpl object to access its operations. + * + * @return the DatetimeOperationsImpl object. + */ + public DatetimeOperationsImpl getDatetimeOperations() { + return this.datetimeOperations; + } + + /** + * The DurationOperationsImpl object to access its operations. + */ + private final DurationOperationsImpl durationOperations; + + /** + * Gets the DurationOperationsImpl object to access its operations. + * + * @return the DurationOperationsImpl object. + */ + public DurationOperationsImpl getDurationOperations() { + return this.durationOperations; + } + + /** + * The CollectionsBytesImpl object to access its operations. + */ + private final CollectionsBytesImpl collectionsBytes; + + /** + * Gets the CollectionsBytesImpl object to access its operations. + * + * @return the CollectionsBytesImpl object. + */ + public CollectionsBytesImpl getCollectionsBytes() { + return this.collectionsBytes; + } + + /** + * The CollectionsModelsImpl object to access its operations. + */ + private final CollectionsModelsImpl collectionsModels; + + /** + * Gets the CollectionsModelsImpl object to access its operations. + * + * @return the CollectionsModelsImpl object. + */ + public CollectionsModelsImpl getCollectionsModels() { + return this.collectionsModels; + } + + /** + * The CollectionsStringsImpl object to access its operations. + */ + private final CollectionsStringsImpl collectionsStrings; + + /** + * Gets the CollectionsStringsImpl object to access its operations. + * + * @return the CollectionsStringsImpl object. + */ + public CollectionsStringsImpl getCollectionsStrings() { + return this.collectionsStrings; + } + + /** + * Initializes an instance of NullableClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public NullableClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.stringOperations = new StringOperationsImpl(this); + this.bytes = new BytesImpl(this); + this.datetimeOperations = new DatetimeOperationsImpl(this); + this.durationOperations = new DurationOperationsImpl(this); + this.collectionsBytes = new CollectionsBytesImpl(this); + this.collectionsModels = new CollectionsModelsImpl(this); + this.collectionsStrings = new CollectionsStringsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/StringOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/StringOperationsImpl.java new file mode 100644 index 0000000000..18b892b200 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/StringOperationsImpl.java @@ -0,0 +1,173 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.nullable.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.nullable.StringProperty; + +/** + * An instance of this class provides access to all the operations defined in StringOperations. + */ +public final class StringOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringOperationsService service; + + /** + * The service client containing this operation class. + */ + private final NullableClientImpl client; + + /** + * Initializes an instance of StringOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringOperationsImpl(NullableClientImpl client) { + this.service = RestProxy.create(StringOperationsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for NullableClientStringOperations to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "NullableClientString", host = "{endpoint}") + public interface StringOperationsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/nullable/string/non-null", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/nullable/string/null", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PATCH, + path = "/type/property/nullable/string/non-null", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response patchNonNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PATCH, + path = "/type/property/nullable/string/null", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response patchNullSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/merge-patch+json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getNonNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNonNullSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getNullWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getNullSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response patchNonNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNonNullSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     requiredProperty: String (Optional, Required on create)
+     *     nullableProperty: String (Optional, Required on create)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response patchNullWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/merge-patch+json"; + return service.patchNullSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/package-info.java new file mode 100644 index 0000000000..a23fcc1fe0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Nullable. + * Illustrates models with nullable properties. + */ +package type.property.nullable.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/package-info.java new file mode 100644 index 0000000000..769feb4209 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/nullable/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Nullable. + * Illustrates models with nullable properties. + */ +package type.property.nullable; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BooleanLiteralClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BooleanLiteralClient.java new file mode 100644 index 0000000000..b61df80167 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BooleanLiteralClient.java @@ -0,0 +1,174 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.implementation.BooleanLiteralsImpl; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class BooleanLiteralClient { + @Metadata(generated = true) + private final BooleanLiteralsImpl serviceClient; + + /** + * Initializes an instance of BooleanLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + BooleanLiteralClient(BooleanLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public BooleanLiteralProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public BooleanLiteralProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putAll(BooleanLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putDefault(BooleanLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BooleanLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BooleanLiteralProperty.java new file mode 100644 index 0000000000..846ed07623 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BooleanLiteralProperty.java @@ -0,0 +1,91 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with boolean literal property. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class BooleanLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private BooleanLiteralPropertyProperty property; + + /** + * Creates an instance of BooleanLiteralProperty class. + */ + @Metadata(generated = true) + public BooleanLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public BooleanLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the BooleanLiteralProperty object itself. + */ + @Metadata(generated = true) + public BooleanLiteralProperty setProperty(BooleanLiteralPropertyProperty property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("property", this.property == null ? null : this.property.toBoolean()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BooleanLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BooleanLiteralProperty if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the BooleanLiteralProperty. + */ + @Metadata(generated = true) + public static BooleanLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BooleanLiteralProperty deserializedBooleanLiteralProperty = new BooleanLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedBooleanLiteralProperty.property + = BooleanLiteralPropertyProperty.fromBoolean(reader.getBoolean()); + } else { + reader.skipChildren(); + } + } + + return deserializedBooleanLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BooleanLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BooleanLiteralPropertyProperty.java new file mode 100644 index 0000000000..6ab8e02be9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BooleanLiteralPropertyProperty.java @@ -0,0 +1,47 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +/** + * Defines values for BooleanLiteralPropertyProperty. + */ +public enum BooleanLiteralPropertyProperty { + /** + * Enum value true. + */ + TRUE(true); + + /** + * The actual serialized value for a BooleanLiteralPropertyProperty instance. + */ + private final boolean value; + + BooleanLiteralPropertyProperty(boolean value) { + this.value = value; + } + + /** + * Parses a serialized value to a BooleanLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed BooleanLiteralPropertyProperty object, or null if unable to parse. + */ + public static BooleanLiteralPropertyProperty fromBoolean(boolean value) { + BooleanLiteralPropertyProperty[] items = BooleanLiteralPropertyProperty.values(); + for (BooleanLiteralPropertyProperty item : items) { + if (item.toBoolean() == value) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to boolean value. + * + * @return the boolean value. + */ + public boolean toBoolean() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BytesClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BytesClient.java new file mode 100644 index 0000000000..ef6c3ed9c6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BytesClient.java @@ -0,0 +1,174 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.implementation.BytesImpl; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class BytesClient { + @Metadata(generated = true) + private final BytesImpl serviceClient; + + /** + * Initializes an instance of BytesClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + BytesClient(BytesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public BytesProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public BytesProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putAll(BytesProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putDefault(BytesProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BytesProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BytesProperty.java new file mode 100644 index 0000000000..ea8949ee2e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/BytesProperty.java @@ -0,0 +1,90 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Template type for testing models with optional property. Pass in the type of the property you are looking for. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class BytesProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private byte[] property; + + /** + * Creates an instance of BytesProperty class. + */ + @Metadata(generated = true) + public BytesProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public byte[] getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the BytesProperty object itself. + */ + @Metadata(generated = true) + public BytesProperty setProperty(byte[] property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBinaryField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BytesProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BytesProperty if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the BytesProperty. + */ + @Metadata(generated = true) + public static BytesProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BytesProperty deserializedBytesProperty = new BytesProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedBytesProperty.property = reader.getBinary(); + } else { + reader.skipChildren(); + } + } + + return deserializedBytesProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/CollectionsByteClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/CollectionsByteClient.java new file mode 100644 index 0000000000..130cf5565a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/CollectionsByteClient.java @@ -0,0 +1,182 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.implementation.CollectionsBytesImpl; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class CollectionsByteClient { + @Metadata(generated = true) + private final CollectionsBytesImpl serviceClient; + + /** + * Initializes an instance of CollectionsByteClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + CollectionsByteClient(CollectionsBytesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public CollectionsByteProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public CollectionsByteProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putAll(CollectionsByteProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putDefault(CollectionsByteProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/CollectionsByteProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/CollectionsByteProperty.java new file mode 100644 index 0000000000..4a2100e8e4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/CollectionsByteProperty.java @@ -0,0 +1,92 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Model with collection bytes properties. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class CollectionsByteProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private List property; + + /** + * Creates an instance of CollectionsByteProperty class. + */ + @Metadata(generated = true) + public CollectionsByteProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public List getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the CollectionsByteProperty object itself. + */ + @Metadata(generated = true) + public CollectionsByteProperty setProperty(List property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("property", this.property, (writer, element) -> writer.writeBinary(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionsByteProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionsByteProperty if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the CollectionsByteProperty. + */ + @Metadata(generated = true) + public static CollectionsByteProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CollectionsByteProperty deserializedCollectionsByteProperty = new CollectionsByteProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + List property = reader.readArray(reader1 -> reader1.getBinary()); + deserializedCollectionsByteProperty.property = property; + } else { + reader.skipChildren(); + } + } + + return deserializedCollectionsByteProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/CollectionsModelClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/CollectionsModelClient.java new file mode 100644 index 0000000000..5353c6c921 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/CollectionsModelClient.java @@ -0,0 +1,190 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.implementation.CollectionsModelsImpl; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class CollectionsModelClient { + @Metadata(generated = true) + private final CollectionsModelsImpl serviceClient; + + /** + * Initializes an instance of CollectionsModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + CollectionsModelClient(CollectionsModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public CollectionsModelProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public CollectionsModelProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putAll(CollectionsModelProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putDefault(CollectionsModelProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/CollectionsModelProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/CollectionsModelProperty.java new file mode 100644 index 0000000000..2329959002 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/CollectionsModelProperty.java @@ -0,0 +1,92 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Model with collection models properties. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class CollectionsModelProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private List property; + + /** + * Creates an instance of CollectionsModelProperty class. + */ + @Metadata(generated = true) + public CollectionsModelProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public List getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the CollectionsModelProperty object itself. + */ + @Metadata(generated = true) + public CollectionsModelProperty setProperty(List property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("property", this.property, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionsModelProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionsModelProperty if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the CollectionsModelProperty. + */ + @Metadata(generated = true) + public static CollectionsModelProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + CollectionsModelProperty deserializedCollectionsModelProperty = new CollectionsModelProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + List property = reader.readArray(reader1 -> StringProperty.fromJson(reader1)); + deserializedCollectionsModelProperty.property = property; + } else { + reader.skipChildren(); + } + } + + return deserializedCollectionsModelProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/DatetimeOperationClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/DatetimeOperationClient.java new file mode 100644 index 0000000000..7e3a19460d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/DatetimeOperationClient.java @@ -0,0 +1,174 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.implementation.DatetimeOperationsImpl; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class DatetimeOperationClient { + @Metadata(generated = true) + private final DatetimeOperationsImpl serviceClient; + + /** + * Initializes an instance of DatetimeOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + DatetimeOperationClient(DatetimeOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public DatetimeProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public DatetimeProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putAll(DatetimeProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putDefault(DatetimeProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/DatetimeProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/DatetimeProperty.java new file mode 100644 index 0000000000..8829e37c90 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/DatetimeProperty.java @@ -0,0 +1,94 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +/** + * Model with a datetime property. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class DatetimeProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private OffsetDateTime property; + + /** + * Creates an instance of DatetimeProperty class. + */ + @Metadata(generated = true) + public DatetimeProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public OffsetDateTime getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the DatetimeProperty object itself. + */ + @Metadata(generated = true) + public DatetimeProperty setProperty(OffsetDateTime property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", + this.property == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.property)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DatetimeProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DatetimeProperty if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the DatetimeProperty. + */ + @Metadata(generated = true) + public static DatetimeProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DatetimeProperty deserializedDatetimeProperty = new DatetimeProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedDatetimeProperty.property + = reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedDatetimeProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/DurationOperationClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/DurationOperationClient.java new file mode 100644 index 0000000000..42283796a6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/DurationOperationClient.java @@ -0,0 +1,174 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.implementation.DurationOperationsImpl; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class DurationOperationClient { + @Metadata(generated = true) + private final DurationOperationsImpl serviceClient; + + /** + * Initializes an instance of DurationOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + DurationOperationClient(DurationOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public DurationProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public DurationProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putAll(DurationProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putDefault(DurationProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/DurationProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/DurationProperty.java new file mode 100644 index 0000000000..4c35a57fb0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/DurationProperty.java @@ -0,0 +1,93 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.time.Duration; +import java.util.Objects; + +/** + * Model with a duration property. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class DurationProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private Duration property; + + /** + * Creates an instance of DurationProperty class. + */ + @Metadata(generated = true) + public DurationProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public Duration getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the DurationProperty object itself. + */ + @Metadata(generated = true) + public DurationProperty setProperty(Duration property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", Objects.toString(this.property, null)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DurationProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DurationProperty if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the DurationProperty. + */ + @Metadata(generated = true) + public static DurationProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + DurationProperty deserializedDurationProperty = new DurationProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedDurationProperty.property + = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedDurationProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/FloatLiteralClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/FloatLiteralClient.java new file mode 100644 index 0000000000..f5648307ec --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/FloatLiteralClient.java @@ -0,0 +1,174 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.implementation.FloatLiteralsImpl; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class FloatLiteralClient { + @Metadata(generated = true) + private final FloatLiteralsImpl serviceClient; + + /** + * Initializes an instance of FloatLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + FloatLiteralClient(FloatLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public FloatLiteralProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public FloatLiteralProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putAll(FloatLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putDefault(FloatLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/FloatLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/FloatLiteralProperty.java new file mode 100644 index 0000000000..00dc9aa4d5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/FloatLiteralProperty.java @@ -0,0 +1,91 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with float literal property. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class FloatLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private FloatLiteralPropertyProperty property; + + /** + * Creates an instance of FloatLiteralProperty class. + */ + @Metadata(generated = true) + public FloatLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public FloatLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the FloatLiteralProperty object itself. + */ + @Metadata(generated = true) + public FloatLiteralProperty setProperty(FloatLiteralPropertyProperty property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("property", this.property == null ? null : this.property.toDouble()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FloatLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FloatLiteralProperty if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the FloatLiteralProperty. + */ + @Metadata(generated = true) + public static FloatLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FloatLiteralProperty deserializedFloatLiteralProperty = new FloatLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedFloatLiteralProperty.property + = FloatLiteralPropertyProperty.fromDouble(reader.getDouble()); + } else { + reader.skipChildren(); + } + } + + return deserializedFloatLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/FloatLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/FloatLiteralPropertyProperty.java new file mode 100644 index 0000000000..b6e8d9b159 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/FloatLiteralPropertyProperty.java @@ -0,0 +1,47 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +/** + * Defines values for FloatLiteralPropertyProperty. + */ +public enum FloatLiteralPropertyProperty { + /** + * Enum value 1.25. + */ + ONE_TWO_FIVE(1.25); + + /** + * The actual serialized value for a FloatLiteralPropertyProperty instance. + */ + private final double value; + + FloatLiteralPropertyProperty(double value) { + this.value = value; + } + + /** + * Parses a serialized value to a FloatLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed FloatLiteralPropertyProperty object, or null if unable to parse. + */ + public static FloatLiteralPropertyProperty fromDouble(double value) { + FloatLiteralPropertyProperty[] items = FloatLiteralPropertyProperty.values(); + for (FloatLiteralPropertyProperty item : items) { + if (Double.doubleToLongBits(item.toDouble()) == Double.doubleToLongBits(value)) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to double value. + * + * @return the double value. + */ + public double toDouble() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/IntLiteralClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/IntLiteralClient.java new file mode 100644 index 0000000000..1a3d3fe484 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/IntLiteralClient.java @@ -0,0 +1,174 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.implementation.IntLiteralsImpl; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class IntLiteralClient { + @Metadata(generated = true) + private final IntLiteralsImpl serviceClient; + + /** + * Initializes an instance of IntLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + IntLiteralClient(IntLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public IntLiteralProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public IntLiteralProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putAll(IntLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putDefault(IntLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/IntLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/IntLiteralProperty.java new file mode 100644 index 0000000000..0285e572de --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/IntLiteralProperty.java @@ -0,0 +1,90 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with int literal property. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class IntLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private IntLiteralPropertyProperty property; + + /** + * Creates an instance of IntLiteralProperty class. + */ + @Metadata(generated = true) + public IntLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public IntLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the IntLiteralProperty object itself. + */ + @Metadata(generated = true) + public IntLiteralProperty setProperty(IntLiteralPropertyProperty property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("property", this.property == null ? null : this.property.toInt()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IntLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IntLiteralProperty if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the IntLiteralProperty. + */ + @Metadata(generated = true) + public static IntLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + IntLiteralProperty deserializedIntLiteralProperty = new IntLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedIntLiteralProperty.property = IntLiteralPropertyProperty.fromInt(reader.getInt()); + } else { + reader.skipChildren(); + } + } + + return deserializedIntLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/IntLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/IntLiteralPropertyProperty.java new file mode 100644 index 0000000000..29bf22cc7e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/IntLiteralPropertyProperty.java @@ -0,0 +1,47 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +/** + * Defines values for IntLiteralPropertyProperty. + */ +public enum IntLiteralPropertyProperty { + /** + * Enum value 1. + */ + ONE(1); + + /** + * The actual serialized value for a IntLiteralPropertyProperty instance. + */ + private final int value; + + IntLiteralPropertyProperty(int value) { + this.value = value; + } + + /** + * Parses a serialized value to a IntLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed IntLiteralPropertyProperty object, or null if unable to parse. + */ + public static IntLiteralPropertyProperty fromInt(int value) { + IntLiteralPropertyProperty[] items = IntLiteralPropertyProperty.values(); + for (IntLiteralPropertyProperty item : items) { + if (item.toInt() == value) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to int value. + * + * @return the int value. + */ + public int toInt() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/OptionalClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/OptionalClientBuilder.java new file mode 100644 index 0000000000..f3885bebc8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/OptionalClientBuilder.java @@ -0,0 +1,407 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.property.optional.implementation.OptionalClientImpl; + +/** + * A builder for creating a new instance of the OptionalClient type. + */ +@ServiceClientBuilder( + serviceClients = { + StringOperationClient.class, + BytesClient.class, + DatetimeOperationClient.class, + DurationOperationClient.class, + PlainDateClient.class, + PlainTimeClient.class, + CollectionsByteClient.class, + CollectionsModelClient.class, + StringLiteralClient.class, + IntLiteralClient.class, + FloatLiteralClient.class, + BooleanLiteralClient.class, + UnionStringLiteralClient.class, + UnionIntLiteralClient.class, + UnionFloatLiteralClient.class, + RequiredAndOptionalClient.class }) +public final class OptionalClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the OptionalClientBuilder. + */ + @Metadata(generated = true) + public OptionalClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public OptionalClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public OptionalClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public OptionalClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public OptionalClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public OptionalClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public OptionalClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public OptionalClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public OptionalClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public OptionalClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of OptionalClientImpl with the provided parameters. + * + * @return an instance of OptionalClientImpl. + */ + @Metadata(generated = true) + private OptionalClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + OptionalClientImpl client = new OptionalClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of StringOperationClient class. + * + * @return an instance of StringOperationClient. + */ + @Metadata(generated = true) + public StringOperationClient buildStringOperationClient() { + return new StringOperationClient(buildInnerClient().getStringOperations()); + } + + /** + * Builds an instance of BytesClient class. + * + * @return an instance of BytesClient. + */ + @Metadata(generated = true) + public BytesClient buildBytesClient() { + return new BytesClient(buildInnerClient().getBytes()); + } + + /** + * Builds an instance of DatetimeOperationClient class. + * + * @return an instance of DatetimeOperationClient. + */ + @Metadata(generated = true) + public DatetimeOperationClient buildDatetimeOperationClient() { + return new DatetimeOperationClient(buildInnerClient().getDatetimeOperations()); + } + + /** + * Builds an instance of DurationOperationClient class. + * + * @return an instance of DurationOperationClient. + */ + @Metadata(generated = true) + public DurationOperationClient buildDurationOperationClient() { + return new DurationOperationClient(buildInnerClient().getDurationOperations()); + } + + /** + * Builds an instance of PlainDateClient class. + * + * @return an instance of PlainDateClient. + */ + @Metadata(generated = true) + public PlainDateClient buildPlainDateClient() { + return new PlainDateClient(buildInnerClient().getPlainDates()); + } + + /** + * Builds an instance of PlainTimeClient class. + * + * @return an instance of PlainTimeClient. + */ + @Metadata(generated = true) + public PlainTimeClient buildPlainTimeClient() { + return new PlainTimeClient(buildInnerClient().getPlainTimes()); + } + + /** + * Builds an instance of CollectionsByteClient class. + * + * @return an instance of CollectionsByteClient. + */ + @Metadata(generated = true) + public CollectionsByteClient buildCollectionsByteClient() { + return new CollectionsByteClient(buildInnerClient().getCollectionsBytes()); + } + + /** + * Builds an instance of CollectionsModelClient class. + * + * @return an instance of CollectionsModelClient. + */ + @Metadata(generated = true) + public CollectionsModelClient buildCollectionsModelClient() { + return new CollectionsModelClient(buildInnerClient().getCollectionsModels()); + } + + /** + * Builds an instance of StringLiteralClient class. + * + * @return an instance of StringLiteralClient. + */ + @Metadata(generated = true) + public StringLiteralClient buildStringLiteralClient() { + return new StringLiteralClient(buildInnerClient().getStringLiterals()); + } + + /** + * Builds an instance of IntLiteralClient class. + * + * @return an instance of IntLiteralClient. + */ + @Metadata(generated = true) + public IntLiteralClient buildIntLiteralClient() { + return new IntLiteralClient(buildInnerClient().getIntLiterals()); + } + + /** + * Builds an instance of FloatLiteralClient class. + * + * @return an instance of FloatLiteralClient. + */ + @Metadata(generated = true) + public FloatLiteralClient buildFloatLiteralClient() { + return new FloatLiteralClient(buildInnerClient().getFloatLiterals()); + } + + /** + * Builds an instance of BooleanLiteralClient class. + * + * @return an instance of BooleanLiteralClient. + */ + @Metadata(generated = true) + public BooleanLiteralClient buildBooleanLiteralClient() { + return new BooleanLiteralClient(buildInnerClient().getBooleanLiterals()); + } + + /** + * Builds an instance of UnionStringLiteralClient class. + * + * @return an instance of UnionStringLiteralClient. + */ + @Metadata(generated = true) + public UnionStringLiteralClient buildUnionStringLiteralClient() { + return new UnionStringLiteralClient(buildInnerClient().getUnionStringLiterals()); + } + + /** + * Builds an instance of UnionIntLiteralClient class. + * + * @return an instance of UnionIntLiteralClient. + */ + @Metadata(generated = true) + public UnionIntLiteralClient buildUnionIntLiteralClient() { + return new UnionIntLiteralClient(buildInnerClient().getUnionIntLiterals()); + } + + /** + * Builds an instance of UnionFloatLiteralClient class. + * + * @return an instance of UnionFloatLiteralClient. + */ + @Metadata(generated = true) + public UnionFloatLiteralClient buildUnionFloatLiteralClient() { + return new UnionFloatLiteralClient(buildInnerClient().getUnionFloatLiterals()); + } + + /** + * Builds an instance of RequiredAndOptionalClient class. + * + * @return an instance of RequiredAndOptionalClient. + */ + @Metadata(generated = true) + public RequiredAndOptionalClient buildRequiredAndOptionalClient() { + return new RequiredAndOptionalClient(buildInnerClient().getRequiredAndOptionals()); + } + + private static final ClientLogger LOGGER = new ClientLogger(OptionalClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/PlainDateClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/PlainDateClient.java new file mode 100644 index 0000000000..fe957ea7f7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/PlainDateClient.java @@ -0,0 +1,174 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.implementation.PlainDatesImpl; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class PlainDateClient { + @Metadata(generated = true) + private final PlainDatesImpl serviceClient; + + /** + * Initializes an instance of PlainDateClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + PlainDateClient(PlainDatesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public PlainDateProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public PlainDateProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putAll(PlainDateProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putDefault(PlainDateProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/PlainDateProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/PlainDateProperty.java new file mode 100644 index 0000000000..7a730f5178 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/PlainDateProperty.java @@ -0,0 +1,93 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.time.LocalDate; +import java.util.Objects; + +/** + * Model with a plainDate property. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class PlainDateProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private LocalDate property; + + /** + * Creates an instance of PlainDateProperty class. + */ + @Metadata(generated = true) + public PlainDateProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public LocalDate getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the PlainDateProperty object itself. + */ + @Metadata(generated = true) + public PlainDateProperty setProperty(LocalDate property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", Objects.toString(this.property, null)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PlainDateProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PlainDateProperty if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the PlainDateProperty. + */ + @Metadata(generated = true) + public static PlainDateProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PlainDateProperty deserializedPlainDateProperty = new PlainDateProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedPlainDateProperty.property + = reader.getNullable(nonNullReader -> LocalDate.parse(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + + return deserializedPlainDateProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/PlainTimeClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/PlainTimeClient.java new file mode 100644 index 0000000000..20945bec0c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/PlainTimeClient.java @@ -0,0 +1,174 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.implementation.PlainTimesImpl; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class PlainTimeClient { + @Metadata(generated = true) + private final PlainTimesImpl serviceClient; + + /** + * Initializes an instance of PlainTimeClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + PlainTimeClient(PlainTimesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public PlainTimeProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public PlainTimeProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putAll(PlainTimeProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putDefault(PlainTimeProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/PlainTimeProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/PlainTimeProperty.java new file mode 100644 index 0000000000..24dbac1f14 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/PlainTimeProperty.java @@ -0,0 +1,90 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with a plainTime property. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class PlainTimeProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private String property; + + /** + * Creates an instance of PlainTimeProperty class. + */ + @Metadata(generated = true) + public PlainTimeProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public String getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the PlainTimeProperty object itself. + */ + @Metadata(generated = true) + public PlainTimeProperty setProperty(String property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of PlainTimeProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of PlainTimeProperty if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the PlainTimeProperty. + */ + @Metadata(generated = true) + public static PlainTimeProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + PlainTimeProperty deserializedPlainTimeProperty = new PlainTimeProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedPlainTimeProperty.property = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedPlainTimeProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/RequiredAndOptionalClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/RequiredAndOptionalClient.java new file mode 100644 index 0000000000..a9302c0a9c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/RequiredAndOptionalClient.java @@ -0,0 +1,178 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.implementation.RequiredAndOptionalsImpl; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class RequiredAndOptionalClient { + @Metadata(generated = true) + private final RequiredAndOptionalsImpl serviceClient; + + /** + * Initializes an instance of RequiredAndOptionalClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + RequiredAndOptionalClient(RequiredAndOptionalsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return only the required properties. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return only the required properties. + */ + @Metadata(generated = true) + public Response getRequiredOnlyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getRequiredOnlyWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: int (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with only required properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: int (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putRequiredOnlyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putRequiredOnlyWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public RequiredAndOptionalProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return only the required properties. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return only the required properties. + */ + @Metadata(generated = true) + public RequiredAndOptionalProperty getRequiredOnly() { + // Generated convenience method for getRequiredOnlyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getRequiredOnlyWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putAll(RequiredAndOptionalProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with only required properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putRequiredOnly(RequiredAndOptionalProperty body) { + // Generated convenience method for putRequiredOnlyWithResponse + RequestOptions requestOptions = new RequestOptions(); + putRequiredOnlyWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/RequiredAndOptionalProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/RequiredAndOptionalProperty.java new file mode 100644 index 0000000000..977fca7d15 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/RequiredAndOptionalProperty.java @@ -0,0 +1,117 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with required and optional properties. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class RequiredAndOptionalProperty implements JsonSerializable { + /* + * optional string property + */ + @Metadata(generated = true) + private String optionalProperty; + + /* + * required int property + */ + @Metadata(generated = true) + private final int requiredProperty; + + /** + * Creates an instance of RequiredAndOptionalProperty class. + * + * @param requiredProperty the requiredProperty value to set. + */ + @Metadata(generated = true) + public RequiredAndOptionalProperty(int requiredProperty) { + this.requiredProperty = requiredProperty; + } + + /** + * Get the optionalProperty property: optional string property. + * + * @return the optionalProperty value. + */ + @Metadata(generated = true) + public String getOptionalProperty() { + return this.optionalProperty; + } + + /** + * Set the optionalProperty property: optional string property. + * + * @param optionalProperty the optionalProperty value to set. + * @return the RequiredAndOptionalProperty object itself. + */ + @Metadata(generated = true) + public RequiredAndOptionalProperty setOptionalProperty(String optionalProperty) { + this.optionalProperty = optionalProperty; + return this; + } + + /** + * Get the requiredProperty property: required int property. + * + * @return the requiredProperty value. + */ + @Metadata(generated = true) + public int getRequiredProperty() { + return this.requiredProperty; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("requiredProperty", this.requiredProperty); + jsonWriter.writeStringField("optionalProperty", this.optionalProperty); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of RequiredAndOptionalProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of RequiredAndOptionalProperty 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 RequiredAndOptionalProperty. + */ + @Metadata(generated = true) + public static RequiredAndOptionalProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int requiredProperty = 0; + String optionalProperty = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("requiredProperty".equals(fieldName)) { + requiredProperty = reader.getInt(); + } else if ("optionalProperty".equals(fieldName)) { + optionalProperty = reader.getString(); + } else { + reader.skipChildren(); + } + } + RequiredAndOptionalProperty deserializedRequiredAndOptionalProperty + = new RequiredAndOptionalProperty(requiredProperty); + deserializedRequiredAndOptionalProperty.optionalProperty = optionalProperty; + + return deserializedRequiredAndOptionalProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringLiteralClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringLiteralClient.java new file mode 100644 index 0000000000..7e76bfd845 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringLiteralClient.java @@ -0,0 +1,174 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.implementation.StringLiteralsImpl; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class StringLiteralClient { + @Metadata(generated = true) + private final StringLiteralsImpl serviceClient; + + /** + * Initializes an instance of StringLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + StringLiteralClient(StringLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public StringLiteralProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public StringLiteralProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putAll(StringLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putDefault(StringLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringLiteralProperty.java new file mode 100644 index 0000000000..5ea04215cd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringLiteralProperty.java @@ -0,0 +1,91 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with string literal property. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class StringLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private StringLiteralPropertyProperty property; + + /** + * Creates an instance of StringLiteralProperty class. + */ + @Metadata(generated = true) + public StringLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public StringLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the StringLiteralProperty object itself. + */ + @Metadata(generated = true) + public StringLiteralProperty setProperty(StringLiteralPropertyProperty property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property == null ? null : this.property.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StringLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StringLiteralProperty if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the StringLiteralProperty. + */ + @Metadata(generated = true) + public static StringLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StringLiteralProperty deserializedStringLiteralProperty = new StringLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedStringLiteralProperty.property + = StringLiteralPropertyProperty.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedStringLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringLiteralPropertyProperty.java new file mode 100644 index 0000000000..e5f1b8d988 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringLiteralPropertyProperty.java @@ -0,0 +1,49 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +/** + * Defines values for StringLiteralPropertyProperty. + */ +public enum StringLiteralPropertyProperty { + /** + * Enum value hello. + */ + HELLO("hello"); + + /** + * The actual serialized value for a StringLiteralPropertyProperty instance. + */ + private final String value; + + StringLiteralPropertyProperty(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a StringLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed StringLiteralPropertyProperty object, or null if unable to parse. + */ + public static StringLiteralPropertyProperty fromString(String value) { + if (value == null) { + return null; + } + StringLiteralPropertyProperty[] items = StringLiteralPropertyProperty.values(); + for (StringLiteralPropertyProperty item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringOperationClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringOperationClient.java new file mode 100644 index 0000000000..2280a2f111 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringOperationClient.java @@ -0,0 +1,174 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.implementation.StringOperationsImpl; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class StringOperationClient { + @Metadata(generated = true) + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of StringOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + StringOperationClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public StringProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public StringProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putAll(StringProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putDefault(StringProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringProperty.java new file mode 100644 index 0000000000..cd12755873 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/StringProperty.java @@ -0,0 +1,90 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Template type for testing models with optional property. Pass in the type of the property you are looking for. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class StringProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private String property; + + /** + * Creates an instance of StringProperty class. + */ + @Metadata(generated = true) + public StringProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public String getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the StringProperty object itself. + */ + @Metadata(generated = true) + public StringProperty setProperty(String property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StringProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StringProperty if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the StringProperty. + */ + @Metadata(generated = true) + public static StringProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StringProperty deserializedStringProperty = new StringProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedStringProperty.property = reader.getString(); + } else { + reader.skipChildren(); + } + } + + return deserializedStringProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionFloatLiteralClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionFloatLiteralClient.java new file mode 100644 index 0000000000..bb65a7cafe --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionFloatLiteralClient.java @@ -0,0 +1,174 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.implementation.UnionFloatLiteralsImpl; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class UnionFloatLiteralClient { + @Metadata(generated = true) + private final UnionFloatLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionFloatLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + UnionFloatLiteralClient(UnionFloatLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public UnionFloatLiteralProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public UnionFloatLiteralProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putAll(UnionFloatLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putDefault(UnionFloatLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionFloatLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionFloatLiteralProperty.java new file mode 100644 index 0000000000..4cda887f6e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionFloatLiteralProperty.java @@ -0,0 +1,91 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with union of float literal property. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class UnionFloatLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private UnionFloatLiteralPropertyProperty property; + + /** + * Creates an instance of UnionFloatLiteralProperty class. + */ + @Metadata(generated = true) + public UnionFloatLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public UnionFloatLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the UnionFloatLiteralProperty object itself. + */ + @Metadata(generated = true) + public UnionFloatLiteralProperty setProperty(UnionFloatLiteralPropertyProperty property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("property", this.property == null ? null : this.property.toDouble()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnionFloatLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnionFloatLiteralProperty if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the UnionFloatLiteralProperty. + */ + @Metadata(generated = true) + public static UnionFloatLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UnionFloatLiteralProperty deserializedUnionFloatLiteralProperty = new UnionFloatLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedUnionFloatLiteralProperty.property + = UnionFloatLiteralPropertyProperty.fromDouble(reader.getDouble()); + } else { + reader.skipChildren(); + } + } + + return deserializedUnionFloatLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionFloatLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionFloatLiteralPropertyProperty.java new file mode 100644 index 0000000000..864ea6f240 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionFloatLiteralPropertyProperty.java @@ -0,0 +1,52 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +/** + * Defines values for UnionFloatLiteralPropertyProperty. + */ +public enum UnionFloatLiteralPropertyProperty { + /** + * Enum value 1.25. + */ + ONE_TWO_FIVE(1.25), + + /** + * Enum value 2.375. + */ + TWO_THREE_SEVEN_FIVE(2.375); + + /** + * The actual serialized value for a UnionFloatLiteralPropertyProperty instance. + */ + private final double value; + + UnionFloatLiteralPropertyProperty(double value) { + this.value = value; + } + + /** + * Parses a serialized value to a UnionFloatLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed UnionFloatLiteralPropertyProperty object, or null if unable to parse. + */ + public static UnionFloatLiteralPropertyProperty fromDouble(double value) { + UnionFloatLiteralPropertyProperty[] items = UnionFloatLiteralPropertyProperty.values(); + for (UnionFloatLiteralPropertyProperty item : items) { + if (Double.doubleToLongBits(item.toDouble()) == Double.doubleToLongBits(value)) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to double value. + * + * @return the double value. + */ + public double toDouble() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionIntLiteralClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionIntLiteralClient.java new file mode 100644 index 0000000000..bba16c012f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionIntLiteralClient.java @@ -0,0 +1,174 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.implementation.UnionIntLiteralsImpl; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class UnionIntLiteralClient { + @Metadata(generated = true) + private final UnionIntLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionIntLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + UnionIntLiteralClient(UnionIntLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public UnionIntLiteralProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public UnionIntLiteralProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putAll(UnionIntLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putDefault(UnionIntLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionIntLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionIntLiteralProperty.java new file mode 100644 index 0000000000..40af17275e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionIntLiteralProperty.java @@ -0,0 +1,91 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with union of int literal property. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class UnionIntLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private UnionIntLiteralPropertyProperty property; + + /** + * Creates an instance of UnionIntLiteralProperty class. + */ + @Metadata(generated = true) + public UnionIntLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public UnionIntLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the UnionIntLiteralProperty object itself. + */ + @Metadata(generated = true) + public UnionIntLiteralProperty setProperty(UnionIntLiteralPropertyProperty property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("property", this.property == null ? null : this.property.toInt()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnionIntLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnionIntLiteralProperty if the JsonReader was pointing to an instance of it, or null if it + * was pointing to JSON null. + * @throws IOException If an error occurs while reading the UnionIntLiteralProperty. + */ + @Metadata(generated = true) + public static UnionIntLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UnionIntLiteralProperty deserializedUnionIntLiteralProperty = new UnionIntLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedUnionIntLiteralProperty.property + = UnionIntLiteralPropertyProperty.fromInt(reader.getInt()); + } else { + reader.skipChildren(); + } + } + + return deserializedUnionIntLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionIntLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionIntLiteralPropertyProperty.java new file mode 100644 index 0000000000..f831e4d5a1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionIntLiteralPropertyProperty.java @@ -0,0 +1,52 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +/** + * Defines values for UnionIntLiteralPropertyProperty. + */ +public enum UnionIntLiteralPropertyProperty { + /** + * Enum value 1. + */ + ONE(1), + + /** + * Enum value 2. + */ + TWO(2); + + /** + * The actual serialized value for a UnionIntLiteralPropertyProperty instance. + */ + private final int value; + + UnionIntLiteralPropertyProperty(int value) { + this.value = value; + } + + /** + * Parses a serialized value to a UnionIntLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed UnionIntLiteralPropertyProperty object, or null if unable to parse. + */ + public static UnionIntLiteralPropertyProperty fromInt(int value) { + UnionIntLiteralPropertyProperty[] items = UnionIntLiteralPropertyProperty.values(); + for (UnionIntLiteralPropertyProperty item : items) { + if (item.toInt() == value) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to int value. + * + * @return the int value. + */ + public int toInt() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionStringLiteralClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionStringLiteralClient.java new file mode 100644 index 0000000000..5b2b754182 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionStringLiteralClient.java @@ -0,0 +1,174 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.implementation.UnionStringLiteralsImpl; + +/** + * Initializes a new instance of the synchronous OptionalClient type. + */ +@ServiceClient(builder = OptionalClientBuilder.class) +public final class UnionStringLiteralClient { + @Metadata(generated = true) + private final UnionStringLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionStringLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + UnionStringLiteralClient(UnionStringLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public Response getAllWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getAllWithResponse(requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public Response getDefaultWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getDefaultWithResponse(requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putAllWithResponse(body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putDefaultWithResponse(body, requestOptions); + } + + /** + * Get models that will return all properties in the model. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return all properties in the model. + */ + @Metadata(generated = true) + public UnionStringLiteralProperty getAll() { + // Generated convenience method for getAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getAllWithResponse(requestOptions).getValue(); + } + + /** + * Get models that will return the default object. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return models that will return the default object. + */ + @Metadata(generated = true) + public UnionStringLiteralProperty getDefault() { + // Generated convenience method for getDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getDefaultWithResponse(requestOptions).getValue(); + } + + /** + * Put a body with all properties present. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putAll(UnionStringLiteralProperty body) { + // Generated convenience method for putAllWithResponse + RequestOptions requestOptions = new RequestOptions(); + putAllWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * Put a body with default properties. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void putDefault(UnionStringLiteralProperty body) { + // Generated convenience method for putDefaultWithResponse + RequestOptions requestOptions = new RequestOptions(); + putDefaultWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionStringLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionStringLiteralProperty.java new file mode 100644 index 0000000000..039213aaf5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionStringLiteralProperty.java @@ -0,0 +1,91 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with union of string literal property. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class UnionStringLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private UnionStringLiteralPropertyProperty property; + + /** + * Creates an instance of UnionStringLiteralProperty class. + */ + @Metadata(generated = true) + public UnionStringLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public UnionStringLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * Set the property property: Property. + * + * @param property the property value to set. + * @return the UnionStringLiteralProperty object itself. + */ + @Metadata(generated = true) + public UnionStringLiteralProperty setProperty(UnionStringLiteralPropertyProperty property) { + this.property = property; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property == null ? null : this.property.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnionStringLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnionStringLiteralProperty if the JsonReader was pointing to an instance of it, or null if + * it was pointing to JSON null. + * @throws IOException If an error occurs while reading the UnionStringLiteralProperty. + */ + @Metadata(generated = true) + public static UnionStringLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UnionStringLiteralProperty deserializedUnionStringLiteralProperty = new UnionStringLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + deserializedUnionStringLiteralProperty.property + = UnionStringLiteralPropertyProperty.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + + return deserializedUnionStringLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionStringLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionStringLiteralPropertyProperty.java new file mode 100644 index 0000000000..54bc7560fd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/UnionStringLiteralPropertyProperty.java @@ -0,0 +1,54 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional; + +/** + * Defines values for UnionStringLiteralPropertyProperty. + */ +public enum UnionStringLiteralPropertyProperty { + /** + * Enum value hello. + */ + HELLO("hello"), + + /** + * Enum value world. + */ + WORLD("world"); + + /** + * The actual serialized value for a UnionStringLiteralPropertyProperty instance. + */ + private final String value; + + UnionStringLiteralPropertyProperty(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a UnionStringLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed UnionStringLiteralPropertyProperty object, or null if unable to parse. + */ + public static UnionStringLiteralPropertyProperty fromString(String value) { + if (value == null) { + return null; + } + UnionStringLiteralPropertyProperty[] items = UnionStringLiteralPropertyProperty.values(); + for (UnionStringLiteralPropertyProperty item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/BooleanLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/BooleanLiteralsImpl.java new file mode 100644 index 0000000000..d7b5401ad1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/BooleanLiteralsImpl.java @@ -0,0 +1,169 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.BooleanLiteralProperty; + +/** + * An instance of this class provides access to all the operations defined in BooleanLiterals. + */ +public final class BooleanLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BooleanLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of BooleanLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BooleanLiteralsImpl(OptionalClientImpl client) { + this.service = RestProxy.create(BooleanLiteralsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientBooleanLiterals to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "OptionalClientBoolea", host = "{endpoint}") + public interface BooleanLiteralsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/boolean/literal/all", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/boolean/literal/default", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/boolean/literal/all", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/boolean/literal/default", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(true) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/BytesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/BytesImpl.java new file mode 100644 index 0000000000..b126662d3e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/BytesImpl.java @@ -0,0 +1,169 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.BytesProperty; + +/** + * An instance of this class provides access to all the operations defined in Bytes. + */ +public final class BytesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BytesService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of BytesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BytesImpl(OptionalClientImpl client) { + this.service = RestProxy.create(BytesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientBytes to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "OptionalClientBytes", host = "{endpoint}") + public interface BytesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/bytes/all", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAllSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/bytes/default", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/bytes/all", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/bytes/default", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: byte[] (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/CollectionsBytesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/CollectionsBytesImpl.java new file mode 100644 index 0000000000..ef5431d83f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/CollectionsBytesImpl.java @@ -0,0 +1,177 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.CollectionsByteProperty; + +/** + * An instance of this class provides access to all the operations defined in CollectionsBytes. + */ +public final class CollectionsBytesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CollectionsBytesService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of CollectionsBytesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CollectionsBytesImpl(OptionalClientImpl client) { + this.service = RestProxy.create(CollectionsBytesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientCollectionsBytes to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "OptionalClientCollec", host = "{endpoint}") + public interface CollectionsBytesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/collections/bytes/all", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/collections/bytes/default", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/collections/bytes/all", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/collections/bytes/default", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Optional): [
+     *         byte[] (Optional)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/CollectionsModelsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/CollectionsModelsImpl.java new file mode 100644 index 0000000000..3efc0ed41c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/CollectionsModelsImpl.java @@ -0,0 +1,185 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.CollectionsModelProperty; + +/** + * An instance of this class provides access to all the operations defined in CollectionsModels. + */ +public final class CollectionsModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CollectionsModelsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of CollectionsModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CollectionsModelsImpl(OptionalClientImpl client) { + this.service = RestProxy.create(CollectionsModelsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientCollectionsModels to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "OptionalClientCollec", host = "{endpoint}") + public interface CollectionsModelsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/collections/model/all", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/collections/model/default", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/collections/model/all", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/collections/model/default", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Optional): [
+     *          (Optional){
+     *             property: String (Optional)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/DatetimeOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/DatetimeOperationsImpl.java new file mode 100644 index 0000000000..e10f24ea0c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/DatetimeOperationsImpl.java @@ -0,0 +1,169 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.DatetimeProperty; + +/** + * An instance of this class provides access to all the operations defined in DatetimeOperations. + */ +public final class DatetimeOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DatetimeOperationsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of DatetimeOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DatetimeOperationsImpl(OptionalClientImpl client) { + this.service = RestProxy.create(DatetimeOperationsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientDatetimeOperations to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "OptionalClientDateti", host = "{endpoint}") + public interface DatetimeOperationsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/datetime/all", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/datetime/default", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/datetime/all", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/datetime/default", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: OffsetDateTime (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/DurationOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/DurationOperationsImpl.java new file mode 100644 index 0000000000..ff3fccb2c0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/DurationOperationsImpl.java @@ -0,0 +1,169 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.DurationProperty; + +/** + * An instance of this class provides access to all the operations defined in DurationOperations. + */ +public final class DurationOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DurationOperationsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of DurationOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DurationOperationsImpl(OptionalClientImpl client) { + this.service = RestProxy.create(DurationOperationsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientDurationOperations to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "OptionalClientDurati", host = "{endpoint}") + public interface DurationOperationsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/duration/all", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/duration/default", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/duration/all", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/duration/default", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: Duration (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/FloatLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/FloatLiteralsImpl.java new file mode 100644 index 0000000000..4b538db43e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/FloatLiteralsImpl.java @@ -0,0 +1,169 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.FloatLiteralProperty; + +/** + * An instance of this class provides access to all the operations defined in FloatLiterals. + */ +public final class FloatLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FloatLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of FloatLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FloatLiteralsImpl(OptionalClientImpl client) { + this.service = RestProxy.create(FloatLiteralsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientFloatLiterals to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "OptionalClientFloatL", host = "{endpoint}") + public interface FloatLiteralsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/float/literal/all", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/float/literal/default", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/float/literal/all", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/float/literal/default", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1.25) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/IntLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/IntLiteralsImpl.java new file mode 100644 index 0000000000..99f40f6c66 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/IntLiteralsImpl.java @@ -0,0 +1,169 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.IntLiteralProperty; + +/** + * An instance of this class provides access to all the operations defined in IntLiterals. + */ +public final class IntLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IntLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of IntLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IntLiteralsImpl(OptionalClientImpl client) { + this.service = RestProxy.create(IntLiteralsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientIntLiterals to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "OptionalClientIntLit", host = "{endpoint}") + public interface IntLiteralsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/int/literal/all", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/int/literal/default", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/int/literal/all", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/int/literal/default", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/OptionalClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/OptionalClientImpl.java new file mode 100644 index 0000000000..783652d62c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/OptionalClientImpl.java @@ -0,0 +1,289 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the OptionalClient type. + */ +public final class OptionalClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 StringOperationsImpl object to access its operations. + */ + private final StringOperationsImpl stringOperations; + + /** + * Gets the StringOperationsImpl object to access its operations. + * + * @return the StringOperationsImpl object. + */ + public StringOperationsImpl getStringOperations() { + return this.stringOperations; + } + + /** + * The BytesImpl object to access its operations. + */ + private final BytesImpl bytes; + + /** + * Gets the BytesImpl object to access its operations. + * + * @return the BytesImpl object. + */ + public BytesImpl getBytes() { + return this.bytes; + } + + /** + * The DatetimeOperationsImpl object to access its operations. + */ + private final DatetimeOperationsImpl datetimeOperations; + + /** + * Gets the DatetimeOperationsImpl object to access its operations. + * + * @return the DatetimeOperationsImpl object. + */ + public DatetimeOperationsImpl getDatetimeOperations() { + return this.datetimeOperations; + } + + /** + * The DurationOperationsImpl object to access its operations. + */ + private final DurationOperationsImpl durationOperations; + + /** + * Gets the DurationOperationsImpl object to access its operations. + * + * @return the DurationOperationsImpl object. + */ + public DurationOperationsImpl getDurationOperations() { + return this.durationOperations; + } + + /** + * The PlainDatesImpl object to access its operations. + */ + private final PlainDatesImpl plainDates; + + /** + * Gets the PlainDatesImpl object to access its operations. + * + * @return the PlainDatesImpl object. + */ + public PlainDatesImpl getPlainDates() { + return this.plainDates; + } + + /** + * The PlainTimesImpl object to access its operations. + */ + private final PlainTimesImpl plainTimes; + + /** + * Gets the PlainTimesImpl object to access its operations. + * + * @return the PlainTimesImpl object. + */ + public PlainTimesImpl getPlainTimes() { + return this.plainTimes; + } + + /** + * The CollectionsBytesImpl object to access its operations. + */ + private final CollectionsBytesImpl collectionsBytes; + + /** + * Gets the CollectionsBytesImpl object to access its operations. + * + * @return the CollectionsBytesImpl object. + */ + public CollectionsBytesImpl getCollectionsBytes() { + return this.collectionsBytes; + } + + /** + * The CollectionsModelsImpl object to access its operations. + */ + private final CollectionsModelsImpl collectionsModels; + + /** + * Gets the CollectionsModelsImpl object to access its operations. + * + * @return the CollectionsModelsImpl object. + */ + public CollectionsModelsImpl getCollectionsModels() { + return this.collectionsModels; + } + + /** + * The StringLiteralsImpl object to access its operations. + */ + private final StringLiteralsImpl stringLiterals; + + /** + * Gets the StringLiteralsImpl object to access its operations. + * + * @return the StringLiteralsImpl object. + */ + public StringLiteralsImpl getStringLiterals() { + return this.stringLiterals; + } + + /** + * The IntLiteralsImpl object to access its operations. + */ + private final IntLiteralsImpl intLiterals; + + /** + * Gets the IntLiteralsImpl object to access its operations. + * + * @return the IntLiteralsImpl object. + */ + public IntLiteralsImpl getIntLiterals() { + return this.intLiterals; + } + + /** + * The FloatLiteralsImpl object to access its operations. + */ + private final FloatLiteralsImpl floatLiterals; + + /** + * Gets the FloatLiteralsImpl object to access its operations. + * + * @return the FloatLiteralsImpl object. + */ + public FloatLiteralsImpl getFloatLiterals() { + return this.floatLiterals; + } + + /** + * The BooleanLiteralsImpl object to access its operations. + */ + private final BooleanLiteralsImpl booleanLiterals; + + /** + * Gets the BooleanLiteralsImpl object to access its operations. + * + * @return the BooleanLiteralsImpl object. + */ + public BooleanLiteralsImpl getBooleanLiterals() { + return this.booleanLiterals; + } + + /** + * The UnionStringLiteralsImpl object to access its operations. + */ + private final UnionStringLiteralsImpl unionStringLiterals; + + /** + * Gets the UnionStringLiteralsImpl object to access its operations. + * + * @return the UnionStringLiteralsImpl object. + */ + public UnionStringLiteralsImpl getUnionStringLiterals() { + return this.unionStringLiterals; + } + + /** + * The UnionIntLiteralsImpl object to access its operations. + */ + private final UnionIntLiteralsImpl unionIntLiterals; + + /** + * Gets the UnionIntLiteralsImpl object to access its operations. + * + * @return the UnionIntLiteralsImpl object. + */ + public UnionIntLiteralsImpl getUnionIntLiterals() { + return this.unionIntLiterals; + } + + /** + * The UnionFloatLiteralsImpl object to access its operations. + */ + private final UnionFloatLiteralsImpl unionFloatLiterals; + + /** + * Gets the UnionFloatLiteralsImpl object to access its operations. + * + * @return the UnionFloatLiteralsImpl object. + */ + public UnionFloatLiteralsImpl getUnionFloatLiterals() { + return this.unionFloatLiterals; + } + + /** + * The RequiredAndOptionalsImpl object to access its operations. + */ + private final RequiredAndOptionalsImpl requiredAndOptionals; + + /** + * Gets the RequiredAndOptionalsImpl object to access its operations. + * + * @return the RequiredAndOptionalsImpl object. + */ + public RequiredAndOptionalsImpl getRequiredAndOptionals() { + return this.requiredAndOptionals; + } + + /** + * Initializes an instance of OptionalClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public OptionalClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.stringOperations = new StringOperationsImpl(this); + this.bytes = new BytesImpl(this); + this.datetimeOperations = new DatetimeOperationsImpl(this); + this.durationOperations = new DurationOperationsImpl(this); + this.plainDates = new PlainDatesImpl(this); + this.plainTimes = new PlainTimesImpl(this); + this.collectionsBytes = new CollectionsBytesImpl(this); + this.collectionsModels = new CollectionsModelsImpl(this); + this.stringLiterals = new StringLiteralsImpl(this); + this.intLiterals = new IntLiteralsImpl(this); + this.floatLiterals = new FloatLiteralsImpl(this); + this.booleanLiterals = new BooleanLiteralsImpl(this); + this.unionStringLiterals = new UnionStringLiteralsImpl(this); + this.unionIntLiterals = new UnionIntLiteralsImpl(this); + this.unionFloatLiterals = new UnionFloatLiteralsImpl(this); + this.requiredAndOptionals = new RequiredAndOptionalsImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/PlainDatesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/PlainDatesImpl.java new file mode 100644 index 0000000000..01ab27271a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/PlainDatesImpl.java @@ -0,0 +1,169 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.PlainDateProperty; + +/** + * An instance of this class provides access to all the operations defined in PlainDates. + */ +public final class PlainDatesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PlainDatesService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of PlainDatesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PlainDatesImpl(OptionalClientImpl client) { + this.service = RestProxy.create(PlainDatesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientPlainDates to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "OptionalClientPlainD", host = "{endpoint}") + public interface PlainDatesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/plainDate/all", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/plainDate/default", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/plainDate/all", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/plainDate/default", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: LocalDate (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/PlainTimesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/PlainTimesImpl.java new file mode 100644 index 0000000000..4f9ca28de9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/PlainTimesImpl.java @@ -0,0 +1,169 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.PlainTimeProperty; + +/** + * An instance of this class provides access to all the operations defined in PlainTimes. + */ +public final class PlainTimesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final PlainTimesService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of PlainTimesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + PlainTimesImpl(OptionalClientImpl client) { + this.service = RestProxy.create(PlainTimesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientPlainTimes to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "OptionalClientPlainT", host = "{endpoint}") + public interface PlainTimesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/plainTime/all", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/plainTime/default", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/plainTime/all", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/plainTime/default", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/RequiredAndOptionalsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/RequiredAndOptionalsImpl.java new file mode 100644 index 0000000000..1d018345c3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/RequiredAndOptionalsImpl.java @@ -0,0 +1,173 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.RequiredAndOptionalProperty; + +/** + * An instance of this class provides access to all the operations defined in RequiredAndOptionals. + */ +public final class RequiredAndOptionalsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RequiredAndOptionalsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of RequiredAndOptionalsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + RequiredAndOptionalsImpl(OptionalClientImpl client) { + this.service = RestProxy.create(RequiredAndOptionalsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientRequiredAndOptionals to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "OptionalClientRequir", host = "{endpoint}") + public interface RequiredAndOptionalsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/requiredAndOptional/all", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/requiredAndOptional/requiredOnly", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getRequiredOnlySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/requiredAndOptional/all", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/requiredAndOptional/requiredOnly", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putRequiredOnlySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return only the required properties. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return only the required properties. + */ + public Response getRequiredOnlyWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getRequiredOnlySync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: int (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with only required properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     optionalProperty: String (Optional)
+     *     requiredProperty: int (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putRequiredOnlyWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putRequiredOnlySync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/StringLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/StringLiteralsImpl.java new file mode 100644 index 0000000000..4c246f105a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/StringLiteralsImpl.java @@ -0,0 +1,169 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.StringLiteralProperty; + +/** + * An instance of this class provides access to all the operations defined in StringLiterals. + */ +public final class StringLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of StringLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringLiteralsImpl(OptionalClientImpl client) { + this.service = RestProxy.create(StringLiteralsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientStringLiterals to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "OptionalClientString", host = "{endpoint}") + public interface StringLiteralsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/string/literal/all", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/string/literal/default", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/string/literal/all", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/string/literal/default", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/StringOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/StringOperationsImpl.java new file mode 100644 index 0000000000..c9cdf0a920 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/StringOperationsImpl.java @@ -0,0 +1,169 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.StringProperty; + +/** + * An instance of this class provides access to all the operations defined in StringOperations. + */ +public final class StringOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringOperationsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of StringOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringOperationsImpl(OptionalClientImpl client) { + this.service = RestProxy.create(StringOperationsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientStringOperations to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "OptionalClientString", host = "{endpoint}") + public interface StringOperationsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/string/all", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/string/default", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/string/all", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/string/default", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/UnionFloatLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/UnionFloatLiteralsImpl.java new file mode 100644 index 0000000000..de49f1d95d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/UnionFloatLiteralsImpl.java @@ -0,0 +1,169 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.UnionFloatLiteralProperty; + +/** + * An instance of this class provides access to all the operations defined in UnionFloatLiterals. + */ +public final class UnionFloatLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnionFloatLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of UnionFloatLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnionFloatLiteralsImpl(OptionalClientImpl client) { + this.service = RestProxy.create(UnionFloatLiteralsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientUnionFloatLiterals to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "OptionalClientUnionF", host = "{endpoint}") + public interface UnionFloatLiteralsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/union/float/literal/all", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/union/float/literal/default", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/union/float/literal/all", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/union/float/literal/default", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1.25/2.375) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/UnionIntLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/UnionIntLiteralsImpl.java new file mode 100644 index 0000000000..1c7a1237cb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/UnionIntLiteralsImpl.java @@ -0,0 +1,169 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.UnionIntLiteralProperty; + +/** + * An instance of this class provides access to all the operations defined in UnionIntLiterals. + */ +public final class UnionIntLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnionIntLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of UnionIntLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnionIntLiteralsImpl(OptionalClientImpl client) { + this.service = RestProxy.create(UnionIntLiteralsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientUnionIntLiterals to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "OptionalClientUnionI", host = "{endpoint}") + public interface UnionIntLiteralsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/union/int/literal/all", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/union/int/literal/default", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/union/int/literal/all", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/union/int/literal/default", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(1/2) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/UnionStringLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/UnionStringLiteralsImpl.java new file mode 100644 index 0000000000..bc26b23bb3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/UnionStringLiteralsImpl.java @@ -0,0 +1,169 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.optional.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.optional.UnionStringLiteralProperty; + +/** + * An instance of this class provides access to all the operations defined in UnionStringLiterals. + */ +public final class UnionStringLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnionStringLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final OptionalClientImpl client; + + /** + * Initializes an instance of UnionStringLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnionStringLiteralsImpl(OptionalClientImpl client) { + this.service = RestProxy.create(UnionStringLiteralsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for OptionalClientUnionStringLiterals to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "OptionalClientUnionS", host = "{endpoint}") + public interface UnionStringLiteralsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/union/string/literal/all", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/optional/union/string/literal/default", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/union/string/literal/all", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putAllSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/optional/union/string/literal/default", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putDefaultSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * Get models that will return all properties in the model. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return all properties in the model. + */ + public Response getAllWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getAllSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Get models that will return the default object. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return models that will return the default object. + */ + public Response getDefaultWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getDefaultSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put a body with all properties present. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putAllWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putAllSync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * Put a body with default properties. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello/world) (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putDefaultWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putDefaultSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/package-info.java new file mode 100644 index 0000000000..7d183631c9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Optional. + * Illustrates models with optional properties. + */ +package type.property.optional.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/package-info.java new file mode 100644 index 0000000000..4e28bf8bed --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/optional/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Optional. + * Illustrates models with optional properties. + */ +package type.property.optional; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BooleanLiteralClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BooleanLiteralClient.java new file mode 100644 index 0000000000..54cde307de --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BooleanLiteralClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.BooleanLiteralsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class BooleanLiteralClient { + @Metadata(generated = true) + private final BooleanLiteralsImpl serviceClient; + + /** + * Initializes an instance of BooleanLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + BooleanLiteralClient(BooleanLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public BooleanLiteralProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(BooleanLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BooleanLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BooleanLiteralProperty.java new file mode 100644 index 0000000000..4ee3f57abd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BooleanLiteralProperty.java @@ -0,0 +1,75 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with a boolean literal property. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class BooleanLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final boolean property = true; + + /** + * Creates an instance of BooleanLiteralProperty class. + */ + @Metadata(generated = true) + public BooleanLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public boolean isProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BooleanLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BooleanLiteralProperty 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 BooleanLiteralProperty. + */ + @Metadata(generated = true) + public static BooleanLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BooleanLiteralProperty deserializedBooleanLiteralProperty = new BooleanLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedBooleanLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BooleanOperationClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BooleanOperationClient.java new file mode 100644 index 0000000000..340f9d1a09 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BooleanOperationClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.BooleanOperationsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class BooleanOperationClient { + @Metadata(generated = true) + private final BooleanOperationsImpl serviceClient; + + /** + * Initializes an instance of BooleanOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + BooleanOperationClient(BooleanOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public BooleanProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(BooleanProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BooleanProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BooleanProperty.java new file mode 100644 index 0000000000..8c12be9005 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BooleanProperty.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with a boolean property. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class BooleanProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final boolean property; + + /** + * Creates an instance of BooleanProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public BooleanProperty(boolean property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public boolean isProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBooleanField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BooleanProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BooleanProperty 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 BooleanProperty. + */ + @Metadata(generated = true) + public static BooleanProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + boolean property = false; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getBoolean(); + } else { + reader.skipChildren(); + } + } + return new BooleanProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BytesClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BytesClient.java new file mode 100644 index 0000000000..fe43513a38 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BytesClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.BytesImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class BytesClient { + @Metadata(generated = true) + private final BytesImpl serviceClient; + + /** + * Initializes an instance of BytesClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + BytesClient(BytesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: byte[] (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: byte[] (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public BytesProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(BytesProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BytesProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BytesProperty.java new file mode 100644 index 0000000000..11cafaaaf0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/BytesProperty.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with a bytes property. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class BytesProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final byte[] property; + + /** + * Creates an instance of BytesProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public BytesProperty(byte[] property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public byte[] getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeBinaryField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of BytesProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of BytesProperty 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 BytesProperty. + */ + @Metadata(generated = true) + public static BytesProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + byte[] property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getBinary(); + } else { + reader.skipChildren(); + } + } + return new BytesProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsIntClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsIntClient.java new file mode 100644 index 0000000000..325501e36b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsIntClient.java @@ -0,0 +1,106 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.CollectionsIntsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class CollectionsIntClient { + @Metadata(generated = true) + private final CollectionsIntsImpl serviceClient; + + /** + * Initializes an instance of CollectionsIntClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + CollectionsIntClient(CollectionsIntsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public CollectionsIntProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(CollectionsIntProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsIntProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsIntProperty.java new file mode 100644 index 0000000000..f3c9a8c542 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsIntProperty.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Model with collection int properties. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class CollectionsIntProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final List property; + + /** + * Creates an instance of CollectionsIntProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public CollectionsIntProperty(List property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public List getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("property", this.property, (writer, element) -> writer.writeInt(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionsIntProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionsIntProperty 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 CollectionsIntProperty. + */ + @Metadata(generated = true) + public static CollectionsIntProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.readArray(reader1 -> reader1.getInt()); + } else { + reader.skipChildren(); + } + } + return new CollectionsIntProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsModelClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsModelClient.java new file mode 100644 index 0000000000..a813761363 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsModelClient.java @@ -0,0 +1,110 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.CollectionsModelsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class CollectionsModelClient { + @Metadata(generated = true) + private final CollectionsModelsImpl serviceClient; + + /** + * Initializes an instance of CollectionsModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + CollectionsModelClient(CollectionsModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): [
+     *          (Required){
+     *             property: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): [
+     *          (Required){
+     *             property: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public CollectionsModelProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(CollectionsModelProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsModelProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsModelProperty.java new file mode 100644 index 0000000000..3bf7417dff --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsModelProperty.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Model with collection model properties. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class CollectionsModelProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final List property; + + /** + * Creates an instance of CollectionsModelProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public CollectionsModelProperty(List property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public List getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("property", this.property, (writer, element) -> writer.writeJson(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionsModelProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionsModelProperty 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 CollectionsModelProperty. + */ + @Metadata(generated = true) + public static CollectionsModelProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.readArray(reader1 -> InnerModel.fromJson(reader1)); + } else { + reader.skipChildren(); + } + } + return new CollectionsModelProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsStringClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsStringClient.java new file mode 100644 index 0000000000..69cd31508b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsStringClient.java @@ -0,0 +1,106 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.CollectionsStringsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class CollectionsStringClient { + @Metadata(generated = true) + private final CollectionsStringsImpl serviceClient; + + /** + * Initializes an instance of CollectionsStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + CollectionsStringClient(CollectionsStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): [
+     *         String (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): [
+     *         String (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public CollectionsStringProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(CollectionsStringProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsStringProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsStringProperty.java new file mode 100644 index 0000000000..448030912b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/CollectionsStringProperty.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.List; + +/** + * Model with collection string properties. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class CollectionsStringProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final List property; + + /** + * Creates an instance of CollectionsStringProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public CollectionsStringProperty(List property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public List getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeArrayField("property", this.property, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of CollectionsStringProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of CollectionsStringProperty 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 CollectionsStringProperty. + */ + @Metadata(generated = true) + public static CollectionsStringProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + List property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.readArray(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + return new CollectionsStringProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DatetimeOperationClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DatetimeOperationClient.java new file mode 100644 index 0000000000..d56fc0ac2f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DatetimeOperationClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.DatetimeOperationsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class DatetimeOperationClient { + @Metadata(generated = true) + private final DatetimeOperationsImpl serviceClient; + + /** + * Initializes an instance of DatetimeOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + DatetimeOperationClient(DatetimeOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public DatetimeProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(DatetimeProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DatetimeProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DatetimeProperty.java new file mode 100644 index 0000000000..3a00d678aa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DatetimeProperty.java @@ -0,0 +1,84 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; + +/** + * Model with a datetime property. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class DatetimeProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final OffsetDateTime property; + + /** + * Creates an instance of DatetimeProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public DatetimeProperty(OffsetDateTime property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public OffsetDateTime getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", + this.property == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.property)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DatetimeProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DatetimeProperty 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 DatetimeProperty. + */ + @Metadata(generated = true) + public static DatetimeProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + OffsetDateTime property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new DatetimeProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/Decimal128Client.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/Decimal128Client.java new file mode 100644 index 0000000000..8a34e98f83 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/Decimal128Client.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.Decimal128sImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class Decimal128Client { + @Metadata(generated = true) + private final Decimal128sImpl serviceClient; + + /** + * Initializes an instance of Decimal128Client class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + Decimal128Client(Decimal128sImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BigDecimal (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BigDecimal (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public Decimal128Property get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(Decimal128Property body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/Decimal128Property.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/Decimal128Property.java new file mode 100644 index 0000000000..b0001fc5c2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/Decimal128Property.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; + +/** + * Model with a decimal128 property. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Decimal128Property implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final BigDecimal property; + + /** + * Creates an instance of Decimal128Property class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public Decimal128Property(BigDecimal property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public BigDecimal getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Decimal128Property from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Decimal128Property 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 Decimal128Property. + */ + @Metadata(generated = true) + public static Decimal128Property fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BigDecimal property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getNullable(nonNullReader -> new BigDecimal(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new Decimal128Property(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DecimalClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DecimalClient.java new file mode 100644 index 0000000000..c8d881dfbe --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DecimalClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.DecimalsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class DecimalClient { + @Metadata(generated = true) + private final DecimalsImpl serviceClient; + + /** + * Initializes an instance of DecimalClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + DecimalClient(DecimalsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BigDecimal (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BigDecimal (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public DecimalProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(DecimalProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DecimalProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DecimalProperty.java new file mode 100644 index 0000000000..c29fea971a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DecimalProperty.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; + +/** + * Model with a decimal property. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class DecimalProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final BigDecimal property; + + /** + * Creates an instance of DecimalProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public DecimalProperty(BigDecimal property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public BigDecimal getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DecimalProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DecimalProperty 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 DecimalProperty. + */ + @Metadata(generated = true) + public static DecimalProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BigDecimal property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getNullable(nonNullReader -> new BigDecimal(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new DecimalProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DictionaryStringClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DictionaryStringClient.java new file mode 100644 index 0000000000..5b6de796a9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DictionaryStringClient.java @@ -0,0 +1,106 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.DictionaryStringsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class DictionaryStringClient { + @Metadata(generated = true) + private final DictionaryStringsImpl serviceClient; + + /** + * Initializes an instance of DictionaryStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + DictionaryStringClient(DictionaryStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public DictionaryStringProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(DictionaryStringProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DictionaryStringProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DictionaryStringProperty.java new file mode 100644 index 0000000000..0d19b807d9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DictionaryStringProperty.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.util.Map; + +/** + * Model with dictionary string properties. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class DictionaryStringProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final Map property; + + /** + * Creates an instance of DictionaryStringProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public DictionaryStringProperty(Map property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public Map getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeMapField("property", this.property, (writer, element) -> writer.writeString(element)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DictionaryStringProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DictionaryStringProperty 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 DictionaryStringProperty. + */ + @Metadata(generated = true) + public static DictionaryStringProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Map property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.readMap(reader1 -> reader1.getString()); + } else { + reader.skipChildren(); + } + } + return new DictionaryStringProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DurationOperationClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DurationOperationClient.java new file mode 100644 index 0000000000..bfbfe80e9d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DurationOperationClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.DurationOperationsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class DurationOperationClient { + @Metadata(generated = true) + private final DurationOperationsImpl serviceClient; + + /** + * Initializes an instance of DurationOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + DurationOperationClient(DurationOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: Duration (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: Duration (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public DurationProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(DurationProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DurationProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DurationProperty.java new file mode 100644 index 0000000000..066b7a8c0f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/DurationProperty.java @@ -0,0 +1,83 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import java.time.Duration; +import java.util.Objects; + +/** + * Model with a duration property. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class DurationProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final Duration property; + + /** + * Creates an instance of DurationProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public DurationProperty(Duration property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public Duration getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", Objects.toString(this.property, null)); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of DurationProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of DurationProperty 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 DurationProperty. + */ + @Metadata(generated = true) + public static DurationProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + Duration property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getNullable(nonNullReader -> Duration.parse(nonNullReader.getString())); + } else { + reader.skipChildren(); + } + } + return new DurationProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/EnumClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/EnumClient.java new file mode 100644 index 0000000000..fc48d8f8f9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/EnumClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.EnumsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class EnumClient { + @Metadata(generated = true) + private final EnumsImpl serviceClient; + + /** + * Initializes an instance of EnumClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + EnumClient(EnumsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public EnumProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(EnumProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/EnumProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/EnumProperty.java new file mode 100644 index 0000000000..a8a55b8191 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/EnumProperty.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with enum properties. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class EnumProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final FixedInnerEnum property; + + /** + * Creates an instance of EnumProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public EnumProperty(FixedInnerEnum property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public FixedInnerEnum getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property == null ? null : this.property.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EnumProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EnumProperty 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 EnumProperty. + */ + @Metadata(generated = true) + public static EnumProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FixedInnerEnum property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = FixedInnerEnum.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new EnumProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ExtendedEnum.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ExtendedEnum.java new file mode 100644 index 0000000000..8e18456b84 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ExtendedEnum.java @@ -0,0 +1,87 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.util.ExpandableEnum; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; + +/** + * Defines values for ExtendedEnum. + */ +public final class ExtendedEnum implements ExpandableEnum { + private static final Map VALUES = new ConcurrentHashMap<>(); + + private static final Function NEW_INSTANCE = ExtendedEnum::new; + + /** + * Static value value2 for ExtendedEnum. + */ + @Metadata(generated = true) + public static final ExtendedEnum ENUM_VALUE2 = fromValue("value2"); + + private final String value; + + private ExtendedEnum(String value) { + this.value = value; + } + + /** + * Creates or finds a ExtendedEnum. + * + * @param value a value to look for. + * @return the corresponding ExtendedEnum. + * @throws IllegalArgumentException if value is null. + */ + @Metadata(generated = true) + public static ExtendedEnum fromValue(String value) { + if (value == null) { + throw new IllegalArgumentException("'value' cannot be null."); + } + return VALUES.computeIfAbsent(value, NEW_INSTANCE); + } + + /** + * Gets known ExtendedEnum values. + * + * @return Known ExtendedEnum values. + */ + @Metadata(generated = true) + public static Collection values() { + return new ArrayList<>(VALUES.values()); + } + + /** + * Gets the value of the ExtendedEnum instance. + * + * @return the value of the ExtendedEnum instance. + */ + @Metadata(generated = true) + @Override + public String getValue() { + return this.value; + } + + @Metadata(generated = true) + @Override + public String toString() { + return Objects.toString(this.value); + } + + @Metadata(generated = true) + @Override + public boolean equals(Object obj) { + return this == obj; + } + + @Metadata(generated = true) + @Override + public int hashCode() { + return Objects.hashCode(this.value); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ExtensibleEnumClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ExtensibleEnumClient.java new file mode 100644 index 0000000000..20696d62c8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ExtensibleEnumClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.ExtensibleEnumsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class ExtensibleEnumClient { + @Metadata(generated = true) + private final ExtensibleEnumsImpl serviceClient; + + /** + * Initializes an instance of ExtensibleEnumClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ExtensibleEnumClient(ExtensibleEnumsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public ExtensibleEnumProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(ExtensibleEnumProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ExtensibleEnumProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ExtensibleEnumProperty.java new file mode 100644 index 0000000000..0105537f3f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ExtensibleEnumProperty.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with extensible enum properties. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class ExtensibleEnumProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final InnerEnum property; + + /** + * Creates an instance of ExtensibleEnumProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public ExtensibleEnumProperty(InnerEnum property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public InnerEnum getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property == null ? null : this.property.getValue()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ExtensibleEnumProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ExtensibleEnumProperty 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 ExtensibleEnumProperty. + */ + @Metadata(generated = true) + public static ExtensibleEnumProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + InnerEnum property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = InnerEnum.fromValue(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new ExtensibleEnumProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FixedInnerEnum.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FixedInnerEnum.java new file mode 100644 index 0000000000..b67b1a25bd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FixedInnerEnum.java @@ -0,0 +1,54 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +/** + * Enum that will be used as a property for model EnumProperty. Non-extensible. + */ +public enum FixedInnerEnum { + /** + * First value. + */ + VALUE_ONE("ValueOne"), + + /** + * Second value. + */ + VALUE_TWO("ValueTwo"); + + /** + * The actual serialized value for a FixedInnerEnum instance. + */ + private final String value; + + FixedInnerEnum(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a FixedInnerEnum instance. + * + * @param value the serialized value to parse. + * @return the parsed FixedInnerEnum object, or null if unable to parse. + */ + public static FixedInnerEnum fromString(String value) { + if (value == null) { + return null; + } + FixedInnerEnum[] items = FixedInnerEnum.values(); + for (FixedInnerEnum item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FloatLiteralClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FloatLiteralClient.java new file mode 100644 index 0000000000..375a44ff29 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FloatLiteralClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.FloatLiteralsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class FloatLiteralClient { + @Metadata(generated = true) + private final FloatLiteralsImpl serviceClient; + + /** + * Initializes an instance of FloatLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + FloatLiteralClient(FloatLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: double (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: double (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public FloatLiteralProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(FloatLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FloatLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FloatLiteralProperty.java new file mode 100644 index 0000000000..8e5ef31e6f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FloatLiteralProperty.java @@ -0,0 +1,75 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with a float literal property. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class FloatLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final double property = 43.125; + + /** + * Creates an instance of FloatLiteralProperty class. + */ + @Metadata(generated = true) + public FloatLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public double getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FloatLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FloatLiteralProperty 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 FloatLiteralProperty. + */ + @Metadata(generated = true) + public static FloatLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + FloatLiteralProperty deserializedFloatLiteralProperty = new FloatLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedFloatLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FloatOperationClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FloatOperationClient.java new file mode 100644 index 0000000000..43ed639710 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FloatOperationClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.FloatOperationsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class FloatOperationClient { + @Metadata(generated = true) + private final FloatOperationsImpl serviceClient; + + /** + * Initializes an instance of FloatOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + FloatOperationClient(FloatOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: double (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: double (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public FloatProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(FloatProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FloatProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FloatProperty.java new file mode 100644 index 0000000000..989a854394 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/FloatProperty.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with a float property. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class FloatProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final double property; + + /** + * Creates an instance of FloatProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public FloatProperty(double property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public double getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeDoubleField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of FloatProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of FloatProperty 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 FloatProperty. + */ + @Metadata(generated = true) + public static FloatProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + double property = 0.0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getDouble(); + } else { + reader.skipChildren(); + } + } + return new FloatProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/InnerEnum.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/InnerEnum.java new file mode 100644 index 0000000000..86ca9dc474 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/InnerEnum.java @@ -0,0 +1,93 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.util.ExpandableEnum; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; + +/** + * Enum that will be used as a property for model EnumProperty. Extensible. + */ +public final class InnerEnum implements ExpandableEnum { + private static final Map VALUES = new ConcurrentHashMap<>(); + + private static final Function NEW_INSTANCE = InnerEnum::new; + + /** + * First value. + */ + @Metadata(generated = true) + public static final InnerEnum VALUE_ONE = fromValue("ValueOne"); + + /** + * Second value. + */ + @Metadata(generated = true) + public static final InnerEnum VALUE_TWO = fromValue("ValueTwo"); + + private final String value; + + private InnerEnum(String value) { + this.value = value; + } + + /** + * Creates or finds a InnerEnum. + * + * @param value a value to look for. + * @return the corresponding InnerEnum. + * @throws IllegalArgumentException if value is null. + */ + @Metadata(generated = true) + public static InnerEnum fromValue(String value) { + if (value == null) { + throw new IllegalArgumentException("'value' cannot be null."); + } + return VALUES.computeIfAbsent(value, NEW_INSTANCE); + } + + /** + * Gets known InnerEnum values. + * + * @return Known InnerEnum values. + */ + @Metadata(generated = true) + public static Collection values() { + return new ArrayList<>(VALUES.values()); + } + + /** + * Gets the value of the InnerEnum instance. + * + * @return the value of the InnerEnum instance. + */ + @Metadata(generated = true) + @Override + public String getValue() { + return this.value; + } + + @Metadata(generated = true) + @Override + public String toString() { + return Objects.toString(this.value); + } + + @Metadata(generated = true) + @Override + public boolean equals(Object obj) { + return this == obj; + } + + @Metadata(generated = true) + @Override + public int hashCode() { + return Objects.hashCode(this.value); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/InnerModel.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/InnerModel.java new file mode 100644 index 0000000000..ee448cf37c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/InnerModel.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Inner model. Will be a property type for ModelWithModelProperties. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class InnerModel implements JsonSerializable { + /* + * Required string property + */ + @Metadata(generated = true) + private final String property; + + /** + * Creates an instance of InnerModel class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public InnerModel(String property) { + this.property = property; + } + + /** + * Get the property property: Required string property. + * + * @return the property value. + */ + @Metadata(generated = true) + public String getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of InnerModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of InnerModel 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 InnerModel. + */ + @Metadata(generated = true) + public static InnerModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new InnerModel(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/IntClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/IntClient.java new file mode 100644 index 0000000000..1ed2266b77 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/IntClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.IntsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class IntClient { + @Metadata(generated = true) + private final IntsImpl serviceClient; + + /** + * Initializes an instance of IntClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + IntClient(IntsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: int (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public IntProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(IntProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/IntLiteralClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/IntLiteralClient.java new file mode 100644 index 0000000000..4ec750156d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/IntLiteralClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.IntLiteralsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class IntLiteralClient { + @Metadata(generated = true) + private final IntLiteralsImpl serviceClient; + + /** + * Initializes an instance of IntLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + IntLiteralClient(IntLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: int (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public IntLiteralProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(IntLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/IntLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/IntLiteralProperty.java new file mode 100644 index 0000000000..ba17e58be8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/IntLiteralProperty.java @@ -0,0 +1,75 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with a int literal property. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class IntLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final int property = 42; + + /** + * Creates an instance of IntLiteralProperty class. + */ + @Metadata(generated = true) + public IntLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public int getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IntLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IntLiteralProperty 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 IntLiteralProperty. + */ + @Metadata(generated = true) + public static IntLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + IntLiteralProperty deserializedIntLiteralProperty = new IntLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedIntLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/IntProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/IntProperty.java new file mode 100644 index 0000000000..1e24820470 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/IntProperty.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with a int property. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class IntProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final int property; + + /** + * Creates an instance of IntProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public IntProperty(int property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public int getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeIntField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of IntProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of IntProperty 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 IntProperty. + */ + @Metadata(generated = true) + public static IntProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + int property = 0; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getInt(); + } else { + reader.skipChildren(); + } + } + return new IntProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ModelClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ModelClient.java new file mode 100644 index 0000000000..54f60146ca --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ModelClient.java @@ -0,0 +1,106 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.ModelsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class ModelClient { + @Metadata(generated = true) + private final ModelsImpl serviceClient; + + /** + * Initializes an instance of ModelClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ModelClient(ModelsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): {
+     *         property: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): {
+     *         property: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public ModelProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(ModelProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ModelProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ModelProperty.java new file mode 100644 index 0000000000..f6446ee149 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ModelProperty.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with model properties. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class ModelProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final InnerModel property; + + /** + * Creates an instance of ModelProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public ModelProperty(InnerModel property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public InnerModel getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ModelProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ModelProperty 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 ModelProperty. + */ + @Metadata(generated = true) + public static ModelProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + InnerModel property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = InnerModel.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new ModelProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/NeverClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/NeverClient.java new file mode 100644 index 0000000000..db65cbe499 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/NeverClient.java @@ -0,0 +1,100 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.NeversImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class NeverClient { + @Metadata(generated = true) + private final NeversImpl serviceClient; + + /** + * Initializes an instance of NeverClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + NeverClient(NeversImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public NeverProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(NeverProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/NeverProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/NeverProperty.java new file mode 100644 index 0000000000..8060e350fe --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/NeverProperty.java @@ -0,0 +1,57 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with a property never. (This property should not be included). + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class NeverProperty implements JsonSerializable { + /** + * Creates an instance of NeverProperty class. + */ + @Metadata(generated = true) + public NeverProperty() { + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NeverProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NeverProperty if the JsonReader was pointing to an instance of it, or null if it was + * pointing to JSON null. + * @throws IOException If an error occurs while reading the NeverProperty. + */ + @Metadata(generated = true) + public static NeverProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + NeverProperty deserializedNeverProperty = new NeverProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedNeverProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/StringLiteralClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/StringLiteralClient.java new file mode 100644 index 0000000000..522738442c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/StringLiteralClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.StringLiteralsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class StringLiteralClient { + @Metadata(generated = true) + private final StringLiteralsImpl serviceClient; + + /** + * Initializes an instance of StringLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + StringLiteralClient(StringLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public StringLiteralProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(StringLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/StringLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/StringLiteralProperty.java new file mode 100644 index 0000000000..0916507b35 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/StringLiteralProperty.java @@ -0,0 +1,75 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with a string literal property. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class StringLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final String property = "hello"; + + /** + * Creates an instance of StringLiteralProperty class. + */ + @Metadata(generated = true) + public StringLiteralProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public String getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StringLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StringLiteralProperty 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 StringLiteralProperty. + */ + @Metadata(generated = true) + public static StringLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StringLiteralProperty deserializedStringLiteralProperty = new StringLiteralProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedStringLiteralProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/StringOperationClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/StringOperationClient.java new file mode 100644 index 0000000000..41e948c6ec --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/StringOperationClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.StringOperationsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class StringOperationClient { + @Metadata(generated = true) + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of StringOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + StringOperationClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public StringProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(StringProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/StringProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/StringProperty.java new file mode 100644 index 0000000000..6ce73a9a34 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/StringProperty.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with a string property. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class StringProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final String property; + + /** + * Creates an instance of StringProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public StringProperty(String property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public String getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StringProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StringProperty 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 StringProperty. + */ + @Metadata(generated = true) + public static StringProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new StringProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionEnumValueClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionEnumValueClient.java new file mode 100644 index 0000000000..60557537f9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionEnumValueClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.UnionEnumValuesImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class UnionEnumValueClient { + @Metadata(generated = true) + private final UnionEnumValuesImpl serviceClient; + + /** + * Initializes an instance of UnionEnumValueClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + UnionEnumValueClient(UnionEnumValuesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(value2) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(value2) (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public UnionEnumValueProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(UnionEnumValueProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionEnumValueProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionEnumValueProperty.java new file mode 100644 index 0000000000..bedf932a82 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionEnumValueProperty.java @@ -0,0 +1,75 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Template type for testing models with specific properties. Pass in the type of the property you are looking for. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class UnionEnumValueProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final ExtendedEnum property = ExtendedEnum.ENUM_VALUE2; + + /** + * Creates an instance of UnionEnumValueProperty class. + */ + @Metadata(generated = true) + public UnionEnumValueProperty() { + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public ExtendedEnum getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property == null ? null : this.property.getValue()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnionEnumValueProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnionEnumValueProperty 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 UnionEnumValueProperty. + */ + @Metadata(generated = true) + public static UnionEnumValueProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UnionEnumValueProperty deserializedUnionEnumValueProperty = new UnionEnumValueProperty(); + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + reader.skipChildren(); + } + + return deserializedUnionEnumValueProperty; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionFloatLiteralClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionFloatLiteralClient.java new file mode 100644 index 0000000000..2f4c29cd50 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionFloatLiteralClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.UnionFloatLiteralsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class UnionFloatLiteralClient { + @Metadata(generated = true) + private final UnionFloatLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionFloatLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + UnionFloatLiteralClient(UnionFloatLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(43.125/46.875) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(43.125/46.875) (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public UnionFloatLiteralProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(UnionFloatLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionFloatLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionFloatLiteralProperty.java new file mode 100644 index 0000000000..63b8295639 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionFloatLiteralProperty.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with a union of float literal as property. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class UnionFloatLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final UnionFloatLiteralPropertyProperty property; + + /** + * Creates an instance of UnionFloatLiteralProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public UnionFloatLiteralProperty(UnionFloatLiteralPropertyProperty property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public UnionFloatLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("property", this.property == null ? null : this.property.toDouble()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnionFloatLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnionFloatLiteralProperty 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 UnionFloatLiteralProperty. + */ + @Metadata(generated = true) + public static UnionFloatLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UnionFloatLiteralPropertyProperty property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = UnionFloatLiteralPropertyProperty.fromDouble(reader.getDouble()); + } else { + reader.skipChildren(); + } + } + return new UnionFloatLiteralProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionFloatLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionFloatLiteralPropertyProperty.java new file mode 100644 index 0000000000..ecdf3d773e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionFloatLiteralPropertyProperty.java @@ -0,0 +1,52 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +/** + * Defines values for UnionFloatLiteralPropertyProperty. + */ +public enum UnionFloatLiteralPropertyProperty { + /** + * Enum value 43.125. + */ + FOUR_THREE_ONE_TWO_FIVE(43.125), + + /** + * Enum value 46.875. + */ + FOUR_SIX_EIGHT_SEVEN_FIVE(46.875); + + /** + * The actual serialized value for a UnionFloatLiteralPropertyProperty instance. + */ + private final double value; + + UnionFloatLiteralPropertyProperty(double value) { + this.value = value; + } + + /** + * Parses a serialized value to a UnionFloatLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed UnionFloatLiteralPropertyProperty object, or null if unable to parse. + */ + public static UnionFloatLiteralPropertyProperty fromDouble(double value) { + UnionFloatLiteralPropertyProperty[] items = UnionFloatLiteralPropertyProperty.values(); + for (UnionFloatLiteralPropertyProperty item : items) { + if (Double.doubleToLongBits(item.toDouble()) == Double.doubleToLongBits(value)) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to double value. + * + * @return the double value. + */ + public double toDouble() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionIntLiteralClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionIntLiteralClient.java new file mode 100644 index 0000000000..ff7fd079a4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionIntLiteralClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.UnionIntLiteralsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class UnionIntLiteralClient { + @Metadata(generated = true) + private final UnionIntLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionIntLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + UnionIntLiteralClient(UnionIntLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(42/43) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(42/43) (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public UnionIntLiteralProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(UnionIntLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionIntLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionIntLiteralProperty.java new file mode 100644 index 0000000000..6d80cd4c05 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionIntLiteralProperty.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with a union of int literal as property. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class UnionIntLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final UnionIntLiteralPropertyProperty property; + + /** + * Creates an instance of UnionIntLiteralProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public UnionIntLiteralProperty(UnionIntLiteralPropertyProperty property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public UnionIntLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("property", this.property == null ? null : this.property.toInt()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnionIntLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnionIntLiteralProperty 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 UnionIntLiteralProperty. + */ + @Metadata(generated = true) + public static UnionIntLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UnionIntLiteralPropertyProperty property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = UnionIntLiteralPropertyProperty.fromInt(reader.getInt()); + } else { + reader.skipChildren(); + } + } + return new UnionIntLiteralProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionIntLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionIntLiteralPropertyProperty.java new file mode 100644 index 0000000000..d813f1fc35 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionIntLiteralPropertyProperty.java @@ -0,0 +1,52 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +/** + * Defines values for UnionIntLiteralPropertyProperty. + */ +public enum UnionIntLiteralPropertyProperty { + /** + * Enum value 42. + */ + FOUR_TWO(42), + + /** + * Enum value 43. + */ + FOUR_THREE(43); + + /** + * The actual serialized value for a UnionIntLiteralPropertyProperty instance. + */ + private final int value; + + UnionIntLiteralPropertyProperty(int value) { + this.value = value; + } + + /** + * Parses a serialized value to a UnionIntLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed UnionIntLiteralPropertyProperty object, or null if unable to parse. + */ + public static UnionIntLiteralPropertyProperty fromInt(int value) { + UnionIntLiteralPropertyProperty[] items = UnionIntLiteralPropertyProperty.values(); + for (UnionIntLiteralPropertyProperty item : items) { + if (item.toInt() == value) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to int value. + * + * @return the int value. + */ + public int toInt() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionStringLiteralClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionStringLiteralClient.java new file mode 100644 index 0000000000..4c6b846d1d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionStringLiteralClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.UnionStringLiteralsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class UnionStringLiteralClient { + @Metadata(generated = true) + private final UnionStringLiteralsImpl serviceClient; + + /** + * Initializes an instance of UnionStringLiteralClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + UnionStringLiteralClient(UnionStringLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello/world) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello/world) (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public UnionStringLiteralProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(UnionStringLiteralProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionStringLiteralProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionStringLiteralProperty.java new file mode 100644 index 0000000000..404bd1be6c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionStringLiteralProperty.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * Model with a union of string literal as property. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class UnionStringLiteralProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final UnionStringLiteralPropertyProperty property; + + /** + * Creates an instance of UnionStringLiteralProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public UnionStringLiteralProperty(UnionStringLiteralPropertyProperty property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public UnionStringLiteralPropertyProperty getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("property", this.property == null ? null : this.property.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnionStringLiteralProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnionStringLiteralProperty 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 UnionStringLiteralProperty. + */ + @Metadata(generated = true) + public static UnionStringLiteralProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + UnionStringLiteralPropertyProperty property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = UnionStringLiteralPropertyProperty.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new UnionStringLiteralProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionStringLiteralPropertyProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionStringLiteralPropertyProperty.java new file mode 100644 index 0000000000..97b8eec21f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnionStringLiteralPropertyProperty.java @@ -0,0 +1,54 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +/** + * Defines values for UnionStringLiteralPropertyProperty. + */ +public enum UnionStringLiteralPropertyProperty { + /** + * Enum value hello. + */ + HELLO("hello"), + + /** + * Enum value world. + */ + WORLD("world"); + + /** + * The actual serialized value for a UnionStringLiteralPropertyProperty instance. + */ + private final String value; + + UnionStringLiteralPropertyProperty(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a UnionStringLiteralPropertyProperty instance. + * + * @param value the serialized value to parse. + * @return the parsed UnionStringLiteralPropertyProperty object, or null if unable to parse. + */ + public static UnionStringLiteralPropertyProperty fromString(String value) { + if (value == null) { + return null; + } + UnionStringLiteralPropertyProperty[] items = UnionStringLiteralPropertyProperty.values(); + for (UnionStringLiteralPropertyProperty item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownArrayClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownArrayClient.java new file mode 100644 index 0000000000..97718f2792 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownArrayClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.UnknownArraysImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class UnknownArrayClient { + @Metadata(generated = true) + private final UnknownArraysImpl serviceClient; + + /** + * Initializes an instance of UnknownArrayClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + UnknownArrayClient(UnknownArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public UnknownArrayProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(UnknownArrayProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownArrayProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownArrayProperty.java new file mode 100644 index 0000000000..fcd5c1bf50 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownArrayProperty.java @@ -0,0 +1,83 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; + +/** + * Model with a property unknown, and the data is an array. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class UnknownArrayProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final BinaryData property; + + /** + * Creates an instance of UnknownArrayProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public UnknownArrayProperty(BinaryData property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public BinaryData getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeFieldName("property"); + this.property.writeTo(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnknownArrayProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnknownArrayProperty 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 UnknownArrayProperty. + */ + @Metadata(generated = true) + public static UnknownArrayProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BinaryData property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new UnknownArrayProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownDictClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownDictClient.java new file mode 100644 index 0000000000..27b99a8ce5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownDictClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.UnknownDictsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class UnknownDictClient { + @Metadata(generated = true) + private final UnknownDictsImpl serviceClient; + + /** + * Initializes an instance of UnknownDictClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + UnknownDictClient(UnknownDictsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public UnknownDictProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(UnknownDictProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownDictProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownDictProperty.java new file mode 100644 index 0000000000..e9a5d76daa --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownDictProperty.java @@ -0,0 +1,83 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; + +/** + * Model with a property unknown, and the data is a dictionnary. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class UnknownDictProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final BinaryData property; + + /** + * Creates an instance of UnknownDictProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public UnknownDictProperty(BinaryData property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public BinaryData getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeFieldName("property"); + this.property.writeTo(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnknownDictProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnknownDictProperty 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 UnknownDictProperty. + */ + @Metadata(generated = true) + public static UnknownDictProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BinaryData property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new UnknownDictProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownIntClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownIntClient.java new file mode 100644 index 0000000000..d70fc87285 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownIntClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.UnknownIntsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class UnknownIntClient { + @Metadata(generated = true) + private final UnknownIntsImpl serviceClient; + + /** + * Initializes an instance of UnknownIntClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + UnknownIntClient(UnknownIntsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public UnknownIntProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(UnknownIntProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownIntProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownIntProperty.java new file mode 100644 index 0000000000..ec416396ca --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownIntProperty.java @@ -0,0 +1,83 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; + +/** + * Model with a property unknown, and the data is a int32. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class UnknownIntProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final BinaryData property; + + /** + * Creates an instance of UnknownIntProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public UnknownIntProperty(BinaryData property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public BinaryData getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeFieldName("property"); + this.property.writeTo(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnknownIntProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnknownIntProperty 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 UnknownIntProperty. + */ + @Metadata(generated = true) + public static UnknownIntProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BinaryData property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new UnknownIntProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownStringClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownStringClient.java new file mode 100644 index 0000000000..fc36e33ec6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownStringClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.implementation.UnknownStringsImpl; + +/** + * Initializes a new instance of the synchronous ValueTypesClient type. + */ +@ServiceClient(builder = ValueTypesClientBuilder.class) +public final class UnknownStringClient { + @Metadata(generated = true) + private final UnknownStringsImpl serviceClient; + + /** + * Initializes an instance of UnknownStringClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + UnknownStringClient(UnknownStringsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * Get call. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return call. + */ + @Metadata(generated = true) + public UnknownStringProperty get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * Put operation. + * + * @param body body. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(UnknownStringProperty body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownStringProperty.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownStringProperty.java new file mode 100644 index 0000000000..fe5a5ecd56 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/UnknownStringProperty.java @@ -0,0 +1,83 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; + +/** + * Model with a property unknown, and the data is a string. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class UnknownStringProperty implements JsonSerializable { + /* + * Property + */ + @Metadata(generated = true) + private final BinaryData property; + + /** + * Creates an instance of UnknownStringProperty class. + * + * @param property the property value to set. + */ + @Metadata(generated = true) + public UnknownStringProperty(BinaryData property) { + this.property = property; + } + + /** + * Get the property property: Property. + * + * @return the property value. + */ + @Metadata(generated = true) + public BinaryData getProperty() { + return this.property; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeFieldName("property"); + this.property.writeTo(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of UnknownStringProperty from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of UnknownStringProperty 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 UnknownStringProperty. + */ + @Metadata(generated = true) + public static UnknownStringProperty fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BinaryData property = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("property".equals(fieldName)) { + property = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new UnknownStringProperty(property); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ValueTypesClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ValueTypesClientBuilder.java new file mode 100644 index 0000000000..e302814a2f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/ValueTypesClientBuilder.java @@ -0,0 +1,551 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.property.valuetypes.implementation.ValueTypesClientImpl; + +/** + * A builder for creating a new instance of the ValueTypesClient type. + */ +@ServiceClientBuilder( + serviceClients = { + BooleanOperationClient.class, + StringOperationClient.class, + BytesClient.class, + IntClient.class, + FloatOperationClient.class, + DecimalClient.class, + Decimal128Client.class, + DatetimeOperationClient.class, + DurationOperationClient.class, + EnumClient.class, + ExtensibleEnumClient.class, + ModelClient.class, + CollectionsStringClient.class, + CollectionsIntClient.class, + CollectionsModelClient.class, + DictionaryStringClient.class, + NeverClient.class, + UnknownStringClient.class, + UnknownIntClient.class, + UnknownDictClient.class, + UnknownArrayClient.class, + StringLiteralClient.class, + IntLiteralClient.class, + FloatLiteralClient.class, + BooleanLiteralClient.class, + UnionStringLiteralClient.class, + UnionIntLiteralClient.class, + UnionFloatLiteralClient.class, + UnionEnumValueClient.class }) +public final class ValueTypesClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the ValueTypesClientBuilder. + */ + @Metadata(generated = true) + public ValueTypesClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ValueTypesClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ValueTypesClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ValueTypesClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ValueTypesClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ValueTypesClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ValueTypesClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ValueTypesClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ValueTypesClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ValueTypesClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of ValueTypesClientImpl with the provided parameters. + * + * @return an instance of ValueTypesClientImpl. + */ + @Metadata(generated = true) + private ValueTypesClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ValueTypesClientImpl client = new ValueTypesClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of BooleanOperationClient class. + * + * @return an instance of BooleanOperationClient. + */ + @Metadata(generated = true) + public BooleanOperationClient buildBooleanOperationClient() { + return new BooleanOperationClient(buildInnerClient().getBooleanOperations()); + } + + /** + * Builds an instance of StringOperationClient class. + * + * @return an instance of StringOperationClient. + */ + @Metadata(generated = true) + public StringOperationClient buildStringOperationClient() { + return new StringOperationClient(buildInnerClient().getStringOperations()); + } + + /** + * Builds an instance of BytesClient class. + * + * @return an instance of BytesClient. + */ + @Metadata(generated = true) + public BytesClient buildBytesClient() { + return new BytesClient(buildInnerClient().getBytes()); + } + + /** + * Builds an instance of IntClient class. + * + * @return an instance of IntClient. + */ + @Metadata(generated = true) + public IntClient buildIntClient() { + return new IntClient(buildInnerClient().getInts()); + } + + /** + * Builds an instance of FloatOperationClient class. + * + * @return an instance of FloatOperationClient. + */ + @Metadata(generated = true) + public FloatOperationClient buildFloatOperationClient() { + return new FloatOperationClient(buildInnerClient().getFloatOperations()); + } + + /** + * Builds an instance of DecimalClient class. + * + * @return an instance of DecimalClient. + */ + @Metadata(generated = true) + public DecimalClient buildDecimalClient() { + return new DecimalClient(buildInnerClient().getDecimals()); + } + + /** + * Builds an instance of Decimal128Client class. + * + * @return an instance of Decimal128Client. + */ + @Metadata(generated = true) + public Decimal128Client buildDecimal128Client() { + return new Decimal128Client(buildInnerClient().getDecimal128s()); + } + + /** + * Builds an instance of DatetimeOperationClient class. + * + * @return an instance of DatetimeOperationClient. + */ + @Metadata(generated = true) + public DatetimeOperationClient buildDatetimeOperationClient() { + return new DatetimeOperationClient(buildInnerClient().getDatetimeOperations()); + } + + /** + * Builds an instance of DurationOperationClient class. + * + * @return an instance of DurationOperationClient. + */ + @Metadata(generated = true) + public DurationOperationClient buildDurationOperationClient() { + return new DurationOperationClient(buildInnerClient().getDurationOperations()); + } + + /** + * Builds an instance of EnumClient class. + * + * @return an instance of EnumClient. + */ + @Metadata(generated = true) + public EnumClient buildEnumClient() { + return new EnumClient(buildInnerClient().getEnums()); + } + + /** + * Builds an instance of ExtensibleEnumClient class. + * + * @return an instance of ExtensibleEnumClient. + */ + @Metadata(generated = true) + public ExtensibleEnumClient buildExtensibleEnumClient() { + return new ExtensibleEnumClient(buildInnerClient().getExtensibleEnums()); + } + + /** + * Builds an instance of ModelClient class. + * + * @return an instance of ModelClient. + */ + @Metadata(generated = true) + public ModelClient buildModelClient() { + return new ModelClient(buildInnerClient().getModels()); + } + + /** + * Builds an instance of CollectionsStringClient class. + * + * @return an instance of CollectionsStringClient. + */ + @Metadata(generated = true) + public CollectionsStringClient buildCollectionsStringClient() { + return new CollectionsStringClient(buildInnerClient().getCollectionsStrings()); + } + + /** + * Builds an instance of CollectionsIntClient class. + * + * @return an instance of CollectionsIntClient. + */ + @Metadata(generated = true) + public CollectionsIntClient buildCollectionsIntClient() { + return new CollectionsIntClient(buildInnerClient().getCollectionsInts()); + } + + /** + * Builds an instance of CollectionsModelClient class. + * + * @return an instance of CollectionsModelClient. + */ + @Metadata(generated = true) + public CollectionsModelClient buildCollectionsModelClient() { + return new CollectionsModelClient(buildInnerClient().getCollectionsModels()); + } + + /** + * Builds an instance of DictionaryStringClient class. + * + * @return an instance of DictionaryStringClient. + */ + @Metadata(generated = true) + public DictionaryStringClient buildDictionaryStringClient() { + return new DictionaryStringClient(buildInnerClient().getDictionaryStrings()); + } + + /** + * Builds an instance of NeverClient class. + * + * @return an instance of NeverClient. + */ + @Metadata(generated = true) + public NeverClient buildNeverClient() { + return new NeverClient(buildInnerClient().getNevers()); + } + + /** + * Builds an instance of UnknownStringClient class. + * + * @return an instance of UnknownStringClient. + */ + @Metadata(generated = true) + public UnknownStringClient buildUnknownStringClient() { + return new UnknownStringClient(buildInnerClient().getUnknownStrings()); + } + + /** + * Builds an instance of UnknownIntClient class. + * + * @return an instance of UnknownIntClient. + */ + @Metadata(generated = true) + public UnknownIntClient buildUnknownIntClient() { + return new UnknownIntClient(buildInnerClient().getUnknownInts()); + } + + /** + * Builds an instance of UnknownDictClient class. + * + * @return an instance of UnknownDictClient. + */ + @Metadata(generated = true) + public UnknownDictClient buildUnknownDictClient() { + return new UnknownDictClient(buildInnerClient().getUnknownDicts()); + } + + /** + * Builds an instance of UnknownArrayClient class. + * + * @return an instance of UnknownArrayClient. + */ + @Metadata(generated = true) + public UnknownArrayClient buildUnknownArrayClient() { + return new UnknownArrayClient(buildInnerClient().getUnknownArrays()); + } + + /** + * Builds an instance of StringLiteralClient class. + * + * @return an instance of StringLiteralClient. + */ + @Metadata(generated = true) + public StringLiteralClient buildStringLiteralClient() { + return new StringLiteralClient(buildInnerClient().getStringLiterals()); + } + + /** + * Builds an instance of IntLiteralClient class. + * + * @return an instance of IntLiteralClient. + */ + @Metadata(generated = true) + public IntLiteralClient buildIntLiteralClient() { + return new IntLiteralClient(buildInnerClient().getIntLiterals()); + } + + /** + * Builds an instance of FloatLiteralClient class. + * + * @return an instance of FloatLiteralClient. + */ + @Metadata(generated = true) + public FloatLiteralClient buildFloatLiteralClient() { + return new FloatLiteralClient(buildInnerClient().getFloatLiterals()); + } + + /** + * Builds an instance of BooleanLiteralClient class. + * + * @return an instance of BooleanLiteralClient. + */ + @Metadata(generated = true) + public BooleanLiteralClient buildBooleanLiteralClient() { + return new BooleanLiteralClient(buildInnerClient().getBooleanLiterals()); + } + + /** + * Builds an instance of UnionStringLiteralClient class. + * + * @return an instance of UnionStringLiteralClient. + */ + @Metadata(generated = true) + public UnionStringLiteralClient buildUnionStringLiteralClient() { + return new UnionStringLiteralClient(buildInnerClient().getUnionStringLiterals()); + } + + /** + * Builds an instance of UnionIntLiteralClient class. + * + * @return an instance of UnionIntLiteralClient. + */ + @Metadata(generated = true) + public UnionIntLiteralClient buildUnionIntLiteralClient() { + return new UnionIntLiteralClient(buildInnerClient().getUnionIntLiterals()); + } + + /** + * Builds an instance of UnionFloatLiteralClient class. + * + * @return an instance of UnionFloatLiteralClient. + */ + @Metadata(generated = true) + public UnionFloatLiteralClient buildUnionFloatLiteralClient() { + return new UnionFloatLiteralClient(buildInnerClient().getUnionFloatLiterals()); + } + + /** + * Builds an instance of UnionEnumValueClient class. + * + * @return an instance of UnionEnumValueClient. + */ + @Metadata(generated = true) + public UnionEnumValueClient buildUnionEnumValueClient() { + return new UnionEnumValueClient(buildInnerClient().getUnionEnumValues()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ValueTypesClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/BooleanLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/BooleanLiteralsImpl.java new file mode 100644 index 0000000000..bd4fcd955b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/BooleanLiteralsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.BooleanLiteralProperty; + +/** + * An instance of this class provides access to all the operations defined in BooleanLiterals. + */ +public final class BooleanLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BooleanLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of BooleanLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BooleanLiteralsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(BooleanLiteralsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientBooleanLiterals to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientBool", host = "{endpoint}") + public interface BooleanLiteralsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/boolean/literal", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/boolean/literal", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/BooleanOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/BooleanOperationsImpl.java new file mode 100644 index 0000000000..74f33dce0e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/BooleanOperationsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.BooleanProperty; + +/** + * An instance of this class provides access to all the operations defined in BooleanOperations. + */ +public final class BooleanOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BooleanOperationsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of BooleanOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BooleanOperationsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(BooleanOperationsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientBooleanOperations to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientBool", host = "{endpoint}") + public interface BooleanOperationsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/boolean", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/boolean", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: boolean (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/BytesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/BytesImpl.java new file mode 100644 index 0000000000..84c7d3cd97 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/BytesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.BytesProperty; + +/** + * An instance of this class provides access to all the operations defined in Bytes. + */ +public final class BytesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BytesService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of BytesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BytesImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(BytesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientBytes to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "ValueTypesClientByte", host = "{endpoint}") + public interface BytesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/bytes", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/bytes", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: byte[] (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: byte[] (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/CollectionsIntsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/CollectionsIntsImpl.java new file mode 100644 index 0000000000..16a0cf6bce --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/CollectionsIntsImpl.java @@ -0,0 +1,112 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.CollectionsIntProperty; + +/** + * An instance of this class provides access to all the operations defined in CollectionsInts. + */ +public final class CollectionsIntsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CollectionsIntsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of CollectionsIntsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CollectionsIntsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(CollectionsIntsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientCollectionsInts to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientColl", host = "{endpoint}") + public interface CollectionsIntsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/collections/int", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/collections/int", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): [
+     *         int (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/CollectionsModelsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/CollectionsModelsImpl.java new file mode 100644 index 0000000000..e8f3361fe6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/CollectionsModelsImpl.java @@ -0,0 +1,116 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.CollectionsModelProperty; + +/** + * An instance of this class provides access to all the operations defined in CollectionsModels. + */ +public final class CollectionsModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CollectionsModelsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of CollectionsModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CollectionsModelsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(CollectionsModelsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientCollectionsModels to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientColl", host = "{endpoint}") + public interface CollectionsModelsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/collections/model", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/collections/model", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): [
+     *          (Required){
+     *             property: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): [
+     *          (Required){
+     *             property: String (Required)
+     *         }
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/CollectionsStringsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/CollectionsStringsImpl.java new file mode 100644 index 0000000000..a6701de1be --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/CollectionsStringsImpl.java @@ -0,0 +1,112 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.CollectionsStringProperty; + +/** + * An instance of this class provides access to all the operations defined in CollectionsStrings. + */ +public final class CollectionsStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final CollectionsStringsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of CollectionsStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + CollectionsStringsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(CollectionsStringsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientCollectionsStrings to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientColl", host = "{endpoint}") + public interface CollectionsStringsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/collections/string", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/collections/string", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): [
+     *         String (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): [
+     *         String (Required)
+     *     ]
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/DatetimeOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/DatetimeOperationsImpl.java new file mode 100644 index 0000000000..75d369f831 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/DatetimeOperationsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.DatetimeProperty; + +/** + * An instance of this class provides access to all the operations defined in DatetimeOperations. + */ +public final class DatetimeOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DatetimeOperationsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of DatetimeOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DatetimeOperationsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(DatetimeOperationsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientDatetimeOperations to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientDate", host = "{endpoint}") + public interface DatetimeOperationsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/datetime", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/datetime", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: OffsetDateTime (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/Decimal128sImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/Decimal128sImpl.java new file mode 100644 index 0000000000..6f3803f8bc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/Decimal128sImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.Decimal128Property; + +/** + * An instance of this class provides access to all the operations defined in Decimal128s. + */ +public final class Decimal128sImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Decimal128sService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of Decimal128sImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Decimal128sImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(Decimal128sService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientDecimal128s to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientDeci", host = "{endpoint}") + public interface Decimal128sService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/decimal128", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/decimal128", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BigDecimal (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BigDecimal (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/DecimalsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/DecimalsImpl.java new file mode 100644 index 0000000000..be3709eacc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/DecimalsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.DecimalProperty; + +/** + * An instance of this class provides access to all the operations defined in Decimals. + */ +public final class DecimalsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DecimalsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of DecimalsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DecimalsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(DecimalsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientDecimals to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "ValueTypesClientDeci", host = "{endpoint}") + public interface DecimalsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/decimal", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/decimal", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BigDecimal (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BigDecimal (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/DictionaryStringsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/DictionaryStringsImpl.java new file mode 100644 index 0000000000..79999cc870 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/DictionaryStringsImpl.java @@ -0,0 +1,112 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.DictionaryStringProperty; + +/** + * An instance of this class provides access to all the operations defined in DictionaryStrings. + */ +public final class DictionaryStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DictionaryStringsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of DictionaryStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DictionaryStringsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(DictionaryStringsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientDictionaryStrings to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientDict", host = "{endpoint}") + public interface DictionaryStringsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/dictionary/string", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/dictionary/string", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): {
+     *         String: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/DurationOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/DurationOperationsImpl.java new file mode 100644 index 0000000000..d1248bc445 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/DurationOperationsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.DurationProperty; + +/** + * An instance of this class provides access to all the operations defined in DurationOperations. + */ +public final class DurationOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DurationOperationsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of DurationOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DurationOperationsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(DurationOperationsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientDurationOperations to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientDura", host = "{endpoint}") + public interface DurationOperationsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/duration", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/duration", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: Duration (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: Duration (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/EnumsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/EnumsImpl.java new file mode 100644 index 0000000000..4085a46511 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/EnumsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.EnumProperty; + +/** + * An instance of this class provides access to all the operations defined in Enums. + */ +public final class EnumsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final EnumsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of EnumsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + EnumsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(EnumsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientEnums to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "ValueTypesClientEnum", host = "{endpoint}") + public interface EnumsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/enum", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/enum", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/ExtensibleEnumsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/ExtensibleEnumsImpl.java new file mode 100644 index 0000000000..f03daeff3e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/ExtensibleEnumsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.ExtensibleEnumProperty; + +/** + * An instance of this class provides access to all the operations defined in ExtensibleEnums. + */ +public final class ExtensibleEnumsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ExtensibleEnumsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of ExtensibleEnumsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ExtensibleEnumsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(ExtensibleEnumsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientExtensibleEnums to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientExte", host = "{endpoint}") + public interface ExtensibleEnumsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/extensible-enum", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/extensible-enum", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(ValueOne/ValueTwo) (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/FloatLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/FloatLiteralsImpl.java new file mode 100644 index 0000000000..7d2526dedf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/FloatLiteralsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.FloatLiteralProperty; + +/** + * An instance of this class provides access to all the operations defined in FloatLiterals. + */ +public final class FloatLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FloatLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of FloatLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FloatLiteralsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(FloatLiteralsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientFloatLiterals to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientFloa", host = "{endpoint}") + public interface FloatLiteralsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/float/literal", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/float/literal", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: double (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: double (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/FloatOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/FloatOperationsImpl.java new file mode 100644 index 0000000000..7854a050ca --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/FloatOperationsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.FloatProperty; + +/** + * An instance of this class provides access to all the operations defined in FloatOperations. + */ +public final class FloatOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FloatOperationsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of FloatOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FloatOperationsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(FloatOperationsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientFloatOperations to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientFloa", host = "{endpoint}") + public interface FloatOperationsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/float", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/float", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: double (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: double (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/IntLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/IntLiteralsImpl.java new file mode 100644 index 0000000000..1949c90758 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/IntLiteralsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.IntLiteralProperty; + +/** + * An instance of this class provides access to all the operations defined in IntLiterals. + */ +public final class IntLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IntLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of IntLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IntLiteralsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(IntLiteralsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientIntLiterals to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientIntL", host = "{endpoint}") + public interface IntLiteralsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/int/literal", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/int/literal", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: int (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/IntsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/IntsImpl.java new file mode 100644 index 0000000000..f547bc1479 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/IntsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.IntProperty; + +/** + * An instance of this class provides access to all the operations defined in Ints. + */ +public final class IntsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IntsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of IntsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IntsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(IntsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientInts to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "ValueTypesClientInts", host = "{endpoint}") + public interface IntsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/int", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/int", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: int (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: int (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/ModelsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/ModelsImpl.java new file mode 100644 index 0000000000..69ad470fe1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/ModelsImpl.java @@ -0,0 +1,112 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.ModelProperty; + +/** + * An instance of this class provides access to all the operations defined in Models. + */ +public final class ModelsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ModelsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of ModelsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ModelsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(ModelsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientModels to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "ValueTypesClientMode", host = "{endpoint}") + public interface ModelsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/model", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/model", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): {
+     *         property: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property (Required): {
+     *         property: String (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/NeversImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/NeversImpl.java new file mode 100644 index 0000000000..83ba6cbd09 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/NeversImpl.java @@ -0,0 +1,106 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.NeverProperty; + +/** + * An instance of this class provides access to all the operations defined in Nevers. + */ +public final class NeversImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NeversService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of NeversImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NeversImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(NeversService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientNevers to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "ValueTypesClientNeve", host = "{endpoint}") + public interface NeversService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/never", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/never", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/StringLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/StringLiteralsImpl.java new file mode 100644 index 0000000000..b074683adb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/StringLiteralsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.StringLiteralProperty; + +/** + * An instance of this class provides access to all the operations defined in StringLiterals. + */ +public final class StringLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of StringLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringLiteralsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(StringLiteralsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientStringLiterals to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientStri", host = "{endpoint}") + public interface StringLiteralsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/string/literal", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/string/literal", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/StringOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/StringOperationsImpl.java new file mode 100644 index 0000000000..4683dac038 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/StringOperationsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.StringProperty; + +/** + * An instance of this class provides access to all the operations defined in StringOperations. + */ +public final class StringOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringOperationsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of StringOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringOperationsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(StringOperationsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientStringOperations to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientStri", host = "{endpoint}") + public interface StringOperationsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/string", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/string", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnionEnumValuesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnionEnumValuesImpl.java new file mode 100644 index 0000000000..308e986b18 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnionEnumValuesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.UnionEnumValueProperty; + +/** + * An instance of this class provides access to all the operations defined in UnionEnumValues. + */ +public final class UnionEnumValuesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnionEnumValuesService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of UnionEnumValuesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnionEnumValuesImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(UnionEnumValuesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientUnionEnumValues to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientUnio", host = "{endpoint}") + public interface UnionEnumValuesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/union-enum-value", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/union-enum-value", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(value2) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(value2) (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnionFloatLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnionFloatLiteralsImpl.java new file mode 100644 index 0000000000..50a573efb2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnionFloatLiteralsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.UnionFloatLiteralProperty; + +/** + * An instance of this class provides access to all the operations defined in UnionFloatLiterals. + */ +public final class UnionFloatLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnionFloatLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of UnionFloatLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnionFloatLiteralsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(UnionFloatLiteralsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientUnionFloatLiterals to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientUnio", host = "{endpoint}") + public interface UnionFloatLiteralsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/union/float/literal", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/union/float/literal", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(43.125/46.875) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(43.125/46.875) (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnionIntLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnionIntLiteralsImpl.java new file mode 100644 index 0000000000..4fc43d2046 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnionIntLiteralsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.UnionIntLiteralProperty; + +/** + * An instance of this class provides access to all the operations defined in UnionIntLiterals. + */ +public final class UnionIntLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnionIntLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of UnionIntLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnionIntLiteralsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(UnionIntLiteralsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientUnionIntLiterals to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientUnio", host = "{endpoint}") + public interface UnionIntLiteralsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/union/int/literal", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/union/int/literal", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(42/43) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(42/43) (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnionStringLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnionStringLiteralsImpl.java new file mode 100644 index 0000000000..c237d4a265 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnionStringLiteralsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.UnionStringLiteralProperty; + +/** + * An instance of this class provides access to all the operations defined in UnionStringLiterals. + */ +public final class UnionStringLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnionStringLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of UnionStringLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnionStringLiteralsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(UnionStringLiteralsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientUnionStringLiterals to be used by the proxy service + * to perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientUnio", host = "{endpoint}") + public interface UnionStringLiteralsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/union/string/literal", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/union/string/literal", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello/world) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: String(hello/world) (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnknownArraysImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnknownArraysImpl.java new file mode 100644 index 0000000000..3fabe0d927 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnknownArraysImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.UnknownArrayProperty; + +/** + * An instance of this class provides access to all the operations defined in UnknownArrays. + */ +public final class UnknownArraysImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnknownArraysService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of UnknownArraysImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnknownArraysImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(UnknownArraysService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientUnknownArrays to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientUnkn", host = "{endpoint}") + public interface UnknownArraysService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/unknown/array", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/unknown/array", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnknownDictsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnknownDictsImpl.java new file mode 100644 index 0000000000..20194a5df8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnknownDictsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.UnknownDictProperty; + +/** + * An instance of this class provides access to all the operations defined in UnknownDicts. + */ +public final class UnknownDictsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnknownDictsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of UnknownDictsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnknownDictsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(UnknownDictsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientUnknownDicts to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientUnkn", host = "{endpoint}") + public interface UnknownDictsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/unknown/dict", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/unknown/dict", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnknownIntsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnknownIntsImpl.java new file mode 100644 index 0000000000..4cd82b983c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnknownIntsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.UnknownIntProperty; + +/** + * An instance of this class provides access to all the operations defined in UnknownInts. + */ +public final class UnknownIntsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnknownIntsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of UnknownIntsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnknownIntsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(UnknownIntsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientUnknownInts to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientUnkn", host = "{endpoint}") + public interface UnknownIntsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/unknown/int", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/unknown/int", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnknownStringsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnknownStringsImpl.java new file mode 100644 index 0000000000..f963ab04bf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/UnknownStringsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.property.valuetypes.UnknownStringProperty; + +/** + * An instance of this class provides access to all the operations defined in UnknownStrings. + */ +public final class UnknownStringsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnknownStringsService service; + + /** + * The service client containing this operation class. + */ + private final ValueTypesClientImpl client; + + /** + * Initializes an instance of UnknownStringsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnknownStringsImpl(ValueTypesClientImpl client) { + this.service = RestProxy.create(UnknownStringsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ValueTypesClientUnknownStrings to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ValueTypesClientUnkn", host = "{endpoint}") + public interface UnknownStringsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/property/value-types/unknown/string", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/property/value-types/unknown/string", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * Get call. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return call. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * Put operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     property: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param body body. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/ValueTypesClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/ValueTypesClientImpl.java new file mode 100644 index 0000000000..fa8ab53c37 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/ValueTypesClientImpl.java @@ -0,0 +1,484 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.property.valuetypes.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the ValueTypesClient type. + */ +public final class ValueTypesClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 BooleanOperationsImpl object to access its operations. + */ + private final BooleanOperationsImpl booleanOperations; + + /** + * Gets the BooleanOperationsImpl object to access its operations. + * + * @return the BooleanOperationsImpl object. + */ + public BooleanOperationsImpl getBooleanOperations() { + return this.booleanOperations; + } + + /** + * The StringOperationsImpl object to access its operations. + */ + private final StringOperationsImpl stringOperations; + + /** + * Gets the StringOperationsImpl object to access its operations. + * + * @return the StringOperationsImpl object. + */ + public StringOperationsImpl getStringOperations() { + return this.stringOperations; + } + + /** + * The BytesImpl object to access its operations. + */ + private final BytesImpl bytes; + + /** + * Gets the BytesImpl object to access its operations. + * + * @return the BytesImpl object. + */ + public BytesImpl getBytes() { + return this.bytes; + } + + /** + * The IntsImpl object to access its operations. + */ + private final IntsImpl ints; + + /** + * Gets the IntsImpl object to access its operations. + * + * @return the IntsImpl object. + */ + public IntsImpl getInts() { + return this.ints; + } + + /** + * The FloatOperationsImpl object to access its operations. + */ + private final FloatOperationsImpl floatOperations; + + /** + * Gets the FloatOperationsImpl object to access its operations. + * + * @return the FloatOperationsImpl object. + */ + public FloatOperationsImpl getFloatOperations() { + return this.floatOperations; + } + + /** + * The DecimalsImpl object to access its operations. + */ + private final DecimalsImpl decimals; + + /** + * Gets the DecimalsImpl object to access its operations. + * + * @return the DecimalsImpl object. + */ + public DecimalsImpl getDecimals() { + return this.decimals; + } + + /** + * The Decimal128sImpl object to access its operations. + */ + private final Decimal128sImpl decimal128s; + + /** + * Gets the Decimal128sImpl object to access its operations. + * + * @return the Decimal128sImpl object. + */ + public Decimal128sImpl getDecimal128s() { + return this.decimal128s; + } + + /** + * The DatetimeOperationsImpl object to access its operations. + */ + private final DatetimeOperationsImpl datetimeOperations; + + /** + * Gets the DatetimeOperationsImpl object to access its operations. + * + * @return the DatetimeOperationsImpl object. + */ + public DatetimeOperationsImpl getDatetimeOperations() { + return this.datetimeOperations; + } + + /** + * The DurationOperationsImpl object to access its operations. + */ + private final DurationOperationsImpl durationOperations; + + /** + * Gets the DurationOperationsImpl object to access its operations. + * + * @return the DurationOperationsImpl object. + */ + public DurationOperationsImpl getDurationOperations() { + return this.durationOperations; + } + + /** + * The EnumsImpl object to access its operations. + */ + private final EnumsImpl enums; + + /** + * Gets the EnumsImpl object to access its operations. + * + * @return the EnumsImpl object. + */ + public EnumsImpl getEnums() { + return this.enums; + } + + /** + * The ExtensibleEnumsImpl object to access its operations. + */ + private final ExtensibleEnumsImpl extensibleEnums; + + /** + * Gets the ExtensibleEnumsImpl object to access its operations. + * + * @return the ExtensibleEnumsImpl object. + */ + public ExtensibleEnumsImpl getExtensibleEnums() { + return this.extensibleEnums; + } + + /** + * The ModelsImpl object to access its operations. + */ + private final ModelsImpl models; + + /** + * Gets the ModelsImpl object to access its operations. + * + * @return the ModelsImpl object. + */ + public ModelsImpl getModels() { + return this.models; + } + + /** + * The CollectionsStringsImpl object to access its operations. + */ + private final CollectionsStringsImpl collectionsStrings; + + /** + * Gets the CollectionsStringsImpl object to access its operations. + * + * @return the CollectionsStringsImpl object. + */ + public CollectionsStringsImpl getCollectionsStrings() { + return this.collectionsStrings; + } + + /** + * The CollectionsIntsImpl object to access its operations. + */ + private final CollectionsIntsImpl collectionsInts; + + /** + * Gets the CollectionsIntsImpl object to access its operations. + * + * @return the CollectionsIntsImpl object. + */ + public CollectionsIntsImpl getCollectionsInts() { + return this.collectionsInts; + } + + /** + * The CollectionsModelsImpl object to access its operations. + */ + private final CollectionsModelsImpl collectionsModels; + + /** + * Gets the CollectionsModelsImpl object to access its operations. + * + * @return the CollectionsModelsImpl object. + */ + public CollectionsModelsImpl getCollectionsModels() { + return this.collectionsModels; + } + + /** + * The DictionaryStringsImpl object to access its operations. + */ + private final DictionaryStringsImpl dictionaryStrings; + + /** + * Gets the DictionaryStringsImpl object to access its operations. + * + * @return the DictionaryStringsImpl object. + */ + public DictionaryStringsImpl getDictionaryStrings() { + return this.dictionaryStrings; + } + + /** + * The NeversImpl object to access its operations. + */ + private final NeversImpl nevers; + + /** + * Gets the NeversImpl object to access its operations. + * + * @return the NeversImpl object. + */ + public NeversImpl getNevers() { + return this.nevers; + } + + /** + * The UnknownStringsImpl object to access its operations. + */ + private final UnknownStringsImpl unknownStrings; + + /** + * Gets the UnknownStringsImpl object to access its operations. + * + * @return the UnknownStringsImpl object. + */ + public UnknownStringsImpl getUnknownStrings() { + return this.unknownStrings; + } + + /** + * The UnknownIntsImpl object to access its operations. + */ + private final UnknownIntsImpl unknownInts; + + /** + * Gets the UnknownIntsImpl object to access its operations. + * + * @return the UnknownIntsImpl object. + */ + public UnknownIntsImpl getUnknownInts() { + return this.unknownInts; + } + + /** + * The UnknownDictsImpl object to access its operations. + */ + private final UnknownDictsImpl unknownDicts; + + /** + * Gets the UnknownDictsImpl object to access its operations. + * + * @return the UnknownDictsImpl object. + */ + public UnknownDictsImpl getUnknownDicts() { + return this.unknownDicts; + } + + /** + * The UnknownArraysImpl object to access its operations. + */ + private final UnknownArraysImpl unknownArrays; + + /** + * Gets the UnknownArraysImpl object to access its operations. + * + * @return the UnknownArraysImpl object. + */ + public UnknownArraysImpl getUnknownArrays() { + return this.unknownArrays; + } + + /** + * The StringLiteralsImpl object to access its operations. + */ + private final StringLiteralsImpl stringLiterals; + + /** + * Gets the StringLiteralsImpl object to access its operations. + * + * @return the StringLiteralsImpl object. + */ + public StringLiteralsImpl getStringLiterals() { + return this.stringLiterals; + } + + /** + * The IntLiteralsImpl object to access its operations. + */ + private final IntLiteralsImpl intLiterals; + + /** + * Gets the IntLiteralsImpl object to access its operations. + * + * @return the IntLiteralsImpl object. + */ + public IntLiteralsImpl getIntLiterals() { + return this.intLiterals; + } + + /** + * The FloatLiteralsImpl object to access its operations. + */ + private final FloatLiteralsImpl floatLiterals; + + /** + * Gets the FloatLiteralsImpl object to access its operations. + * + * @return the FloatLiteralsImpl object. + */ + public FloatLiteralsImpl getFloatLiterals() { + return this.floatLiterals; + } + + /** + * The BooleanLiteralsImpl object to access its operations. + */ + private final BooleanLiteralsImpl booleanLiterals; + + /** + * Gets the BooleanLiteralsImpl object to access its operations. + * + * @return the BooleanLiteralsImpl object. + */ + public BooleanLiteralsImpl getBooleanLiterals() { + return this.booleanLiterals; + } + + /** + * The UnionStringLiteralsImpl object to access its operations. + */ + private final UnionStringLiteralsImpl unionStringLiterals; + + /** + * Gets the UnionStringLiteralsImpl object to access its operations. + * + * @return the UnionStringLiteralsImpl object. + */ + public UnionStringLiteralsImpl getUnionStringLiterals() { + return this.unionStringLiterals; + } + + /** + * The UnionIntLiteralsImpl object to access its operations. + */ + private final UnionIntLiteralsImpl unionIntLiterals; + + /** + * Gets the UnionIntLiteralsImpl object to access its operations. + * + * @return the UnionIntLiteralsImpl object. + */ + public UnionIntLiteralsImpl getUnionIntLiterals() { + return this.unionIntLiterals; + } + + /** + * The UnionFloatLiteralsImpl object to access its operations. + */ + private final UnionFloatLiteralsImpl unionFloatLiterals; + + /** + * Gets the UnionFloatLiteralsImpl object to access its operations. + * + * @return the UnionFloatLiteralsImpl object. + */ + public UnionFloatLiteralsImpl getUnionFloatLiterals() { + return this.unionFloatLiterals; + } + + /** + * The UnionEnumValuesImpl object to access its operations. + */ + private final UnionEnumValuesImpl unionEnumValues; + + /** + * Gets the UnionEnumValuesImpl object to access its operations. + * + * @return the UnionEnumValuesImpl object. + */ + public UnionEnumValuesImpl getUnionEnumValues() { + return this.unionEnumValues; + } + + /** + * Initializes an instance of ValueTypesClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public ValueTypesClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.booleanOperations = new BooleanOperationsImpl(this); + this.stringOperations = new StringOperationsImpl(this); + this.bytes = new BytesImpl(this); + this.ints = new IntsImpl(this); + this.floatOperations = new FloatOperationsImpl(this); + this.decimals = new DecimalsImpl(this); + this.decimal128s = new Decimal128sImpl(this); + this.datetimeOperations = new DatetimeOperationsImpl(this); + this.durationOperations = new DurationOperationsImpl(this); + this.enums = new EnumsImpl(this); + this.extensibleEnums = new ExtensibleEnumsImpl(this); + this.models = new ModelsImpl(this); + this.collectionsStrings = new CollectionsStringsImpl(this); + this.collectionsInts = new CollectionsIntsImpl(this); + this.collectionsModels = new CollectionsModelsImpl(this); + this.dictionaryStrings = new DictionaryStringsImpl(this); + this.nevers = new NeversImpl(this); + this.unknownStrings = new UnknownStringsImpl(this); + this.unknownInts = new UnknownIntsImpl(this); + this.unknownDicts = new UnknownDictsImpl(this); + this.unknownArrays = new UnknownArraysImpl(this); + this.stringLiterals = new StringLiteralsImpl(this); + this.intLiterals = new IntLiteralsImpl(this); + this.floatLiterals = new FloatLiteralsImpl(this); + this.booleanLiterals = new BooleanLiteralsImpl(this); + this.unionStringLiterals = new UnionStringLiteralsImpl(this); + this.unionIntLiterals = new UnionIntLiteralsImpl(this); + this.unionFloatLiterals = new UnionFloatLiteralsImpl(this); + this.unionEnumValues = new UnionEnumValuesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/package-info.java new file mode 100644 index 0000000000..b2ada71fef --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for ValueTypes. + * Illustrates various property types for models. + */ +package type.property.valuetypes.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/package-info.java new file mode 100644 index 0000000000..d2dc0e4c9f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/property/valuetypes/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for ValueTypes. + * Illustrates various property types for models. + */ +package type.property.valuetypes; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/BooleanOperationClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/BooleanOperationClient.java new file mode 100644 index 0000000000..f3c233e499 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/BooleanOperationClient.java @@ -0,0 +1,98 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.scalar; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.scalar.implementation.BooleanOperationsImpl; + +/** + * Initializes a new instance of the synchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class) +public final class BooleanOperationClient { + @Metadata(generated = true) + private final BooleanOperationsImpl serviceClient; + + /** + * Initializes an instance of BooleanOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + BooleanOperationClient(BooleanOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * get boolean value. + *

Response Body Schema

+ * + *
+     * {@code
+     * boolean
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return boolean value. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * put boolean value. + *

Request Body Schema

+ * + *
+     * {@code
+     * boolean
+     * }
+     * 
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * get boolean value. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return boolean value. + */ + @Metadata(generated = true) + public boolean get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * put boolean value. + * + * @param body _. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(boolean body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/Decimal128TypeClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/Decimal128TypeClient.java new file mode 100644 index 0000000000..5c8ec98bcd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/Decimal128TypeClient.java @@ -0,0 +1,127 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.scalar; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.math.BigDecimal; +import type.scalar.implementation.Decimal128TypesImpl; + +/** + * Initializes a new instance of the synchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class) +public final class Decimal128TypeClient { + @Metadata(generated = true) + private final Decimal128TypesImpl serviceClient; + + /** + * Initializes an instance of Decimal128TypeClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + Decimal128TypeClient(Decimal128TypesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The responseBody operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BigDecimal
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a 128-bit decimal number. + */ + @Metadata(generated = true) + public Response responseBodyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.responseBodyWithResponse(requestOptions); + } + + /** + * The requestBody operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BigDecimal
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response requestBodyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.requestBodyWithResponse(body, requestOptions); + } + + /** + * The requestParameter operation. + * + * @param value The value parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response requestParameterWithResponse(BigDecimal value, RequestOptions requestOptions) { + return this.serviceClient.requestParameterWithResponse(value, requestOptions); + } + + /** + * The responseBody operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a 128-bit decimal number. + */ + @Metadata(generated = true) + public BigDecimal responseBody() { + // Generated convenience method for responseBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return responseBodyWithResponse(requestOptions).getValue(); + } + + /** + * The requestBody operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void requestBody(BigDecimal body) { + // Generated convenience method for requestBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + requestBodyWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The requestParameter operation. + * + * @param value The value parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void requestParameter(BigDecimal value) { + // Generated convenience method for requestParameterWithResponse + RequestOptions requestOptions = new RequestOptions(); + requestParameterWithResponse(value, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/Decimal128VerifyClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/Decimal128VerifyClient.java new file mode 100644 index 0000000000..3f63370893 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/Decimal128VerifyClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.scalar; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.math.BigDecimal; +import java.util.List; +import type.scalar.implementation.Decimal128VerifiesImpl; + +/** + * Initializes a new instance of the synchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class) +public final class Decimal128VerifyClient { + @Metadata(generated = true) + private final Decimal128VerifiesImpl serviceClient; + + /** + * Initializes an instance of Decimal128VerifyClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + Decimal128VerifyClient(Decimal128VerifiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The prepareVerify operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     BigDecimal (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> prepareVerifyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.prepareVerifyWithResponse(requestOptions); + } + + /** + * The verify operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BigDecimal
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response verifyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.verifyWithResponse(body, requestOptions); + } + + /** + * The prepareVerify operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public List prepareVerify() { + // Generated convenience method for prepareVerifyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return prepareVerifyWithResponse(requestOptions).getValue(); + } + + /** + * The verify operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void verify(BigDecimal body) { + // Generated convenience method for verifyWithResponse + RequestOptions requestOptions = new RequestOptions(); + verifyWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/DecimalTypeClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/DecimalTypeClient.java new file mode 100644 index 0000000000..bb66071410 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/DecimalTypeClient.java @@ -0,0 +1,127 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.scalar; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.math.BigDecimal; +import type.scalar.implementation.DecimalTypesImpl; + +/** + * Initializes a new instance of the synchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class) +public final class DecimalTypeClient { + @Metadata(generated = true) + private final DecimalTypesImpl serviceClient; + + /** + * Initializes an instance of DecimalTypeClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + DecimalTypeClient(DecimalTypesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The responseBody operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BigDecimal
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a decimal number with any length and precision. + */ + @Metadata(generated = true) + public Response responseBodyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.responseBodyWithResponse(requestOptions); + } + + /** + * The requestBody operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BigDecimal
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response requestBodyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.requestBodyWithResponse(body, requestOptions); + } + + /** + * The requestParameter operation. + * + * @param value The value parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response requestParameterWithResponse(BigDecimal value, RequestOptions requestOptions) { + return this.serviceClient.requestParameterWithResponse(value, requestOptions); + } + + /** + * The responseBody operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a decimal number with any length and precision. + */ + @Metadata(generated = true) + public BigDecimal responseBody() { + // Generated convenience method for responseBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return responseBodyWithResponse(requestOptions).getValue(); + } + + /** + * The requestBody operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void requestBody(BigDecimal body) { + // Generated convenience method for requestBodyWithResponse + RequestOptions requestOptions = new RequestOptions(); + requestBodyWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The requestParameter operation. + * + * @param value The value parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void requestParameter(BigDecimal value) { + // Generated convenience method for requestParameterWithResponse + RequestOptions requestOptions = new RequestOptions(); + requestParameterWithResponse(value, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/DecimalVerifyClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/DecimalVerifyClient.java new file mode 100644 index 0000000000..8efe36cd27 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/DecimalVerifyClient.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.scalar; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.math.BigDecimal; +import java.util.List; +import type.scalar.implementation.DecimalVerifiesImpl; + +/** + * Initializes a new instance of the synchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class) +public final class DecimalVerifyClient { + @Metadata(generated = true) + private final DecimalVerifiesImpl serviceClient; + + /** + * Initializes an instance of DecimalVerifyClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + DecimalVerifyClient(DecimalVerifiesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The prepareVerify operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     BigDecimal (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response> prepareVerifyWithResponse(RequestOptions requestOptions) { + return this.serviceClient.prepareVerifyWithResponse(requestOptions); + } + + /** + * The verify operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BigDecimal
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response verifyWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.verifyWithResponse(body, requestOptions); + } + + /** + * The prepareVerify operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public List prepareVerify() { + // Generated convenience method for prepareVerifyWithResponse + RequestOptions requestOptions = new RequestOptions(); + return prepareVerifyWithResponse(requestOptions).getValue(); + } + + /** + * The verify operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void verify(BigDecimal body) { + // Generated convenience method for verifyWithResponse + RequestOptions requestOptions = new RequestOptions(); + verifyWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/ScalarClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/ScalarClientBuilder.java new file mode 100644 index 0000000000..748a17447d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/ScalarClientBuilder.java @@ -0,0 +1,308 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.scalar; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.scalar.implementation.ScalarClientImpl; + +/** + * A builder for creating a new instance of the ScalarClient type. + */ +@ServiceClientBuilder( + serviceClients = { + StringOperationClient.class, + BooleanOperationClient.class, + UnknownClient.class, + DecimalTypeClient.class, + Decimal128TypeClient.class, + DecimalVerifyClient.class, + Decimal128VerifyClient.class }) +public final class ScalarClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the ScalarClientBuilder. + */ + @Metadata(generated = true) + public ScalarClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ScalarClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ScalarClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ScalarClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ScalarClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ScalarClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ScalarClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ScalarClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ScalarClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ScalarClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of ScalarClientImpl with the provided parameters. + * + * @return an instance of ScalarClientImpl. + */ + @Metadata(generated = true) + private ScalarClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + ScalarClientImpl client = new ScalarClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of StringOperationClient class. + * + * @return an instance of StringOperationClient. + */ + @Metadata(generated = true) + public StringOperationClient buildStringOperationClient() { + return new StringOperationClient(buildInnerClient().getStringOperations()); + } + + /** + * Builds an instance of BooleanOperationClient class. + * + * @return an instance of BooleanOperationClient. + */ + @Metadata(generated = true) + public BooleanOperationClient buildBooleanOperationClient() { + return new BooleanOperationClient(buildInnerClient().getBooleanOperations()); + } + + /** + * Builds an instance of UnknownClient class. + * + * @return an instance of UnknownClient. + */ + @Metadata(generated = true) + public UnknownClient buildUnknownClient() { + return new UnknownClient(buildInnerClient().getUnknowns()); + } + + /** + * Builds an instance of DecimalTypeClient class. + * + * @return an instance of DecimalTypeClient. + */ + @Metadata(generated = true) + public DecimalTypeClient buildDecimalTypeClient() { + return new DecimalTypeClient(buildInnerClient().getDecimalTypes()); + } + + /** + * Builds an instance of Decimal128TypeClient class. + * + * @return an instance of Decimal128TypeClient. + */ + @Metadata(generated = true) + public Decimal128TypeClient buildDecimal128TypeClient() { + return new Decimal128TypeClient(buildInnerClient().getDecimal128Types()); + } + + /** + * Builds an instance of DecimalVerifyClient class. + * + * @return an instance of DecimalVerifyClient. + */ + @Metadata(generated = true) + public DecimalVerifyClient buildDecimalVerifyClient() { + return new DecimalVerifyClient(buildInnerClient().getDecimalVerifies()); + } + + /** + * Builds an instance of Decimal128VerifyClient class. + * + * @return an instance of Decimal128VerifyClient. + */ + @Metadata(generated = true) + public Decimal128VerifyClient buildDecimal128VerifyClient() { + return new Decimal128VerifyClient(buildInnerClient().getDecimal128Verifies()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ScalarClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/StringOperationClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/StringOperationClient.java new file mode 100644 index 0000000000..618f5caff9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/StringOperationClient.java @@ -0,0 +1,98 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.scalar; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.scalar.implementation.StringOperationsImpl; + +/** + * Initializes a new instance of the synchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class) +public final class StringOperationClient { + @Metadata(generated = true) + private final StringOperationsImpl serviceClient; + + /** + * Initializes an instance of StringOperationClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + StringOperationClient(StringOperationsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * get string value. + *

Response Body Schema

+ * + *
+     * {@code
+     * String
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return string value. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * put string value. + *

Request Body Schema

+ * + *
+     * {@code
+     * String
+     * }
+     * 
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * get string value. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return string value. + */ + @Metadata(generated = true) + public String get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * put string value. + * + * @param body _. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(String body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/UnknownClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/UnknownClient.java new file mode 100644 index 0000000000..1d8e3a8212 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/UnknownClient.java @@ -0,0 +1,98 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.scalar; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.scalar.implementation.UnknownsImpl; + +/** + * Initializes a new instance of the synchronous ScalarClient type. + */ +@ServiceClient(builder = ScalarClientBuilder.class) +public final class UnknownClient { + @Metadata(generated = true) + private final UnknownsImpl serviceClient; + + /** + * Initializes an instance of UnknownClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + UnknownClient(UnknownsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * get unknown value. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return unknown value. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * put unknown value. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.putWithResponse(body, requestOptions); + } + + /** + * get unknown value. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return unknown value. + */ + @Metadata(generated = true) + public BinaryData get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * put unknown value. + * + * @param body _. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void put(BinaryData body) { + // Generated convenience method for putWithResponse + RequestOptions requestOptions = new RequestOptions(); + putWithResponse(body, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/BooleanOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/BooleanOperationsImpl.java new file mode 100644 index 0000000000..25d74ea95a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/BooleanOperationsImpl.java @@ -0,0 +1,97 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.scalar.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * An instance of this class provides access to all the operations defined in BooleanOperations. + */ +public final class BooleanOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final BooleanOperationsService service; + + /** + * The service client containing this operation class. + */ + private final ScalarClientImpl client; + + /** + * Initializes an instance of BooleanOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + BooleanOperationsImpl(ScalarClientImpl client) { + this.service = RestProxy.create(BooleanOperationsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ScalarClientBooleanOperations to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ScalarClientBooleanO", host = "{endpoint}") + public interface BooleanOperationsService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/scalar/boolean", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.PUT, path = "/type/scalar/boolean", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * get boolean value. + *

Response Body Schema

+ * + *
+     * {@code
+     * boolean
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return boolean value. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * put boolean value. + *

Request Body Schema

+ * + *
+     * {@code
+     * boolean
+     * }
+     * 
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/Decimal128TypesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/Decimal128TypesImpl.java new file mode 100644 index 0000000000..0e5095dcfe --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/Decimal128TypesImpl.java @@ -0,0 +1,126 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.scalar.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.QueryParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.math.BigDecimal; + +/** + * An instance of this class provides access to all the operations defined in Decimal128Types. + */ +public final class Decimal128TypesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Decimal128TypesService service; + + /** + * The service client containing this operation class. + */ + private final ScalarClientImpl client; + + /** + * Initializes an instance of Decimal128TypesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Decimal128TypesImpl(ScalarClientImpl client) { + this.service = RestProxy.create(Decimal128TypesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ScalarClientDecimal128Types to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ScalarClientDecimal1", host = "{endpoint}") + public interface Decimal128TypesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/scalar/decimal128/response_body", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response responseBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/scalar/decimal128/resquest_body", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response requestBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/scalar/decimal128/request_parameter", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response requestParameterSync(@HostParam("endpoint") String endpoint, + @QueryParam("value") BigDecimal value, RequestOptions requestOptions); + } + + /** + * The responseBody operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BigDecimal
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a 128-bit decimal number. + */ + public Response responseBodyWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.responseBodySync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The requestBody operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BigDecimal
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response requestBodyWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.requestBodySync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The requestParameter operation. + * + * @param value The value parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response requestParameterWithResponse(BigDecimal value, RequestOptions requestOptions) { + return service.requestParameterSync(this.client.getEndpoint(), value, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/Decimal128VerifiesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/Decimal128VerifiesImpl.java new file mode 100644 index 0000000000..59eef764f6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/Decimal128VerifiesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.scalar.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.math.BigDecimal; +import java.util.List; + +/** + * An instance of this class provides access to all the operations defined in Decimal128Verifies. + */ +public final class Decimal128VerifiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final Decimal128VerifiesService service; + + /** + * The service client containing this operation class. + */ + private final ScalarClientImpl client; + + /** + * Initializes an instance of Decimal128VerifiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + Decimal128VerifiesImpl(ScalarClientImpl client) { + this.service = RestProxy.create(Decimal128VerifiesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ScalarClientDecimal128Verifies to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ScalarClientDecimal1", host = "{endpoint}") + public interface Decimal128VerifiesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/scalar/decimal128/prepare_verify", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> prepareVerifySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/type/scalar/decimal128/verify", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response verifySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * The prepareVerify operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     BigDecimal (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> prepareVerifyWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.prepareVerifySync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The verify operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BigDecimal
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response verifyWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.verifySync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/DecimalTypesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/DecimalTypesImpl.java new file mode 100644 index 0000000000..296280a935 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/DecimalTypesImpl.java @@ -0,0 +1,126 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.scalar.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.QueryParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.math.BigDecimal; + +/** + * An instance of this class provides access to all the operations defined in DecimalTypes. + */ +public final class DecimalTypesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DecimalTypesService service; + + /** + * The service client containing this operation class. + */ + private final ScalarClientImpl client; + + /** + * Initializes an instance of DecimalTypesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DecimalTypesImpl(ScalarClientImpl client) { + this.service = RestProxy.create(DecimalTypesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ScalarClientDecimalTypes to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "ScalarClientDecimalT", host = "{endpoint}") + public interface DecimalTypesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/scalar/decimal/response_body", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response responseBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.PUT, + path = "/type/scalar/decimal/resquest_body", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response requestBodySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/scalar/decimal/request_parameter", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response requestParameterSync(@HostParam("endpoint") String endpoint, + @QueryParam("value") BigDecimal value, RequestOptions requestOptions); + } + + /** + * The responseBody operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * BigDecimal
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a decimal number with any length and precision. + */ + public Response responseBodyWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.responseBodySync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The requestBody operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BigDecimal
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response requestBodyWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.requestBodySync(this.client.getEndpoint(), contentType, body, requestOptions); + } + + /** + * The requestParameter operation. + * + * @param value The value parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response requestParameterWithResponse(BigDecimal value, RequestOptions requestOptions) { + return service.requestParameterSync(this.client.getEndpoint(), value, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/DecimalVerifiesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/DecimalVerifiesImpl.java new file mode 100644 index 0000000000..0506bcc2cb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/DecimalVerifiesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.scalar.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import java.math.BigDecimal; +import java.util.List; + +/** + * An instance of this class provides access to all the operations defined in DecimalVerifies. + */ +public final class DecimalVerifiesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final DecimalVerifiesService service; + + /** + * The service client containing this operation class. + */ + private final ScalarClientImpl client; + + /** + * Initializes an instance of DecimalVerifiesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + DecimalVerifiesImpl(ScalarClientImpl client) { + this.service = RestProxy.create(DecimalVerifiesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ScalarClientDecimalVerifies to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ScalarClientDecimalV", host = "{endpoint}") + public interface DecimalVerifiesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/scalar/decimal/prepare_verify", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response> prepareVerifySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Accept") String accept, RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/type/scalar/decimal/verify", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response verifySync(@HostParam("endpoint") String endpoint, + @HeaderParam("Content-Type") String contentType, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * The prepareVerify operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * [
+     *     BigDecimal (Required)
+     * ]
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response> prepareVerifyWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.prepareVerifySync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The verify operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * BigDecimal
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response verifyWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.verifySync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/ScalarClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/ScalarClientImpl.java new file mode 100644 index 0000000000..7dbe8df1d9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/ScalarClientImpl.java @@ -0,0 +1,154 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.scalar.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the ScalarClient type. + */ +public final class ScalarClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 StringOperationsImpl object to access its operations. + */ + private final StringOperationsImpl stringOperations; + + /** + * Gets the StringOperationsImpl object to access its operations. + * + * @return the StringOperationsImpl object. + */ + public StringOperationsImpl getStringOperations() { + return this.stringOperations; + } + + /** + * The BooleanOperationsImpl object to access its operations. + */ + private final BooleanOperationsImpl booleanOperations; + + /** + * Gets the BooleanOperationsImpl object to access its operations. + * + * @return the BooleanOperationsImpl object. + */ + public BooleanOperationsImpl getBooleanOperations() { + return this.booleanOperations; + } + + /** + * The UnknownsImpl object to access its operations. + */ + private final UnknownsImpl unknowns; + + /** + * Gets the UnknownsImpl object to access its operations. + * + * @return the UnknownsImpl object. + */ + public UnknownsImpl getUnknowns() { + return this.unknowns; + } + + /** + * The DecimalTypesImpl object to access its operations. + */ + private final DecimalTypesImpl decimalTypes; + + /** + * Gets the DecimalTypesImpl object to access its operations. + * + * @return the DecimalTypesImpl object. + */ + public DecimalTypesImpl getDecimalTypes() { + return this.decimalTypes; + } + + /** + * The Decimal128TypesImpl object to access its operations. + */ + private final Decimal128TypesImpl decimal128Types; + + /** + * Gets the Decimal128TypesImpl object to access its operations. + * + * @return the Decimal128TypesImpl object. + */ + public Decimal128TypesImpl getDecimal128Types() { + return this.decimal128Types; + } + + /** + * The DecimalVerifiesImpl object to access its operations. + */ + private final DecimalVerifiesImpl decimalVerifies; + + /** + * Gets the DecimalVerifiesImpl object to access its operations. + * + * @return the DecimalVerifiesImpl object. + */ + public DecimalVerifiesImpl getDecimalVerifies() { + return this.decimalVerifies; + } + + /** + * The Decimal128VerifiesImpl object to access its operations. + */ + private final Decimal128VerifiesImpl decimal128Verifies; + + /** + * Gets the Decimal128VerifiesImpl object to access its operations. + * + * @return the Decimal128VerifiesImpl object. + */ + public Decimal128VerifiesImpl getDecimal128Verifies() { + return this.decimal128Verifies; + } + + /** + * Initializes an instance of ScalarClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public ScalarClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.stringOperations = new StringOperationsImpl(this); + this.booleanOperations = new BooleanOperationsImpl(this); + this.unknowns = new UnknownsImpl(this); + this.decimalTypes = new DecimalTypesImpl(this); + this.decimal128Types = new Decimal128TypesImpl(this); + this.decimalVerifies = new DecimalVerifiesImpl(this); + this.decimal128Verifies = new Decimal128VerifiesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/StringOperationsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/StringOperationsImpl.java new file mode 100644 index 0000000000..aba2449cc0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/StringOperationsImpl.java @@ -0,0 +1,97 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.scalar.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * An instance of this class provides access to all the operations defined in StringOperations. + */ +public final class StringOperationsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringOperationsService service; + + /** + * The service client containing this operation class. + */ + private final ScalarClientImpl client; + + /** + * Initializes an instance of StringOperationsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringOperationsImpl(ScalarClientImpl client) { + this.service = RestProxy.create(StringOperationsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ScalarClientStringOperations to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "ScalarClientStringOp", host = "{endpoint}") + public interface StringOperationsService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/scalar/string", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.PUT, path = "/type/scalar/string", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * get string value. + *

Response Body Schema

+ * + *
+     * {@code
+     * String
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return string value. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * put string value. + *

Request Body Schema

+ * + *
+     * {@code
+     * String
+     * }
+     * 
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/UnknownsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/UnknownsImpl.java new file mode 100644 index 0000000000..5b02f20ef7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/UnknownsImpl.java @@ -0,0 +1,97 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.scalar.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; + +/** + * An instance of this class provides access to all the operations defined in Unknowns. + */ +public final class UnknownsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final UnknownsService service; + + /** + * The service client containing this operation class. + */ + private final ScalarClientImpl client; + + /** + * Initializes an instance of UnknownsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + UnknownsImpl(ScalarClientImpl client) { + this.service = RestProxy.create(UnknownsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for ScalarClientUnknowns to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "ScalarClientUnknowns", host = "{endpoint}") + public interface UnknownsService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/scalar/unknown", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.PUT, path = "/type/scalar/unknown", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response putSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * get unknown value. + *

Response Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return unknown value. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * put unknown value. + *

Request Body Schema

+ * + *
+     * {@code
+     * BinaryData
+     * }
+     * 
+ * + * @param body _. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response putWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.putSync(this.client.getEndpoint(), contentType, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/package-info.java new file mode 100644 index 0000000000..ceab9fef55 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/implementation/package-info.java @@ -0,0 +1,6 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Scalar. + */ +package type.scalar.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/package-info.java new file mode 100644 index 0000000000..127559caec --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/scalar/package-info.java @@ -0,0 +1,6 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Scalar. + */ +package type.scalar; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/Cat.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/Cat.java new file mode 100644 index 0000000000..637b283913 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/Cat.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Cat model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Cat implements JsonSerializable { + /* + * The name property. + */ + @Metadata(generated = true) + private final String name; + + /** + * Creates an instance of Cat class. + * + * @param name the name value to set. + */ + @Metadata(generated = true) + public Cat(String name) { + this.name = name; + } + + /** + * Get the name property: The name property. + * + * @return the name value. + */ + @Metadata(generated = true) + public String getName() { + return this.name; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("name", this.name); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Cat from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Cat 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 Cat. + */ + @Metadata(generated = true) + public static Cat fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String name = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("name".equals(fieldName)) { + name = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Cat(name); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/Dog.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/Dog.java new file mode 100644 index 0000000000..caacae3231 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/Dog.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The Dog model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class Dog implements JsonSerializable { + /* + * The bark property. + */ + @Metadata(generated = true) + private final String bark; + + /** + * Creates an instance of Dog class. + * + * @param bark the bark value to set. + */ + @Metadata(generated = true) + public Dog(String bark) { + this.bark = bark; + } + + /** + * Get the bark property: The bark property. + * + * @return the bark value. + */ + @Metadata(generated = true) + public String getBark() { + return this.bark; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("bark", this.bark); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of Dog from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of Dog 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 Dog. + */ + @Metadata(generated = true) + public static Dog fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String bark = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("bark".equals(fieldName)) { + bark = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new Dog(bark); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/EnumsOnlyCases.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/EnumsOnlyCases.java new file mode 100644 index 0000000000..40ce63c26d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/EnumsOnlyCases.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The EnumsOnlyCases model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class EnumsOnlyCases implements JsonSerializable { + /* + * This should be receive/send the left variant + */ + @Metadata(generated = true) + private final EnumsOnlyCasesLr lr; + + /* + * This should be receive/send the up variant + */ + @Metadata(generated = true) + private final EnumsOnlyCasesUd ud; + + /** + * Creates an instance of EnumsOnlyCases class. + * + * @param lr the lr value to set. + * @param ud the ud value to set. + */ + @Metadata(generated = true) + public EnumsOnlyCases(EnumsOnlyCasesLr lr, EnumsOnlyCasesUd ud) { + this.lr = lr; + this.ud = ud; + } + + /** + * Get the lr property: This should be receive/send the left variant. + * + * @return the lr value. + */ + @Metadata(generated = true) + public EnumsOnlyCasesLr getLr() { + return this.lr; + } + + /** + * Get the ud property: This should be receive/send the up variant. + * + * @return the ud value. + */ + @Metadata(generated = true) + public EnumsOnlyCasesUd getUd() { + return this.ud; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("lr", this.lr == null ? null : this.lr.toString()); + jsonWriter.writeStringField("ud", this.ud == null ? null : this.ud.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of EnumsOnlyCases from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of EnumsOnlyCases 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 EnumsOnlyCases. + */ + @Metadata(generated = true) + public static EnumsOnlyCases fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EnumsOnlyCasesLr lr = null; + EnumsOnlyCasesUd ud = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("lr".equals(fieldName)) { + lr = EnumsOnlyCasesLr.fromString(reader.getString()); + } else if ("ud".equals(fieldName)) { + ud = EnumsOnlyCasesUd.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new EnumsOnlyCases(lr, ud); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/EnumsOnlyCasesLr.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/EnumsOnlyCasesLr.java new file mode 100644 index 0000000000..4526c6aade --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/EnumsOnlyCasesLr.java @@ -0,0 +1,64 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +/** + * Defines values for EnumsOnlyCasesLr. + */ +public enum EnumsOnlyCasesLr { + /** + * Enum value left. + */ + LEFT("left"), + + /** + * Enum value right. + */ + RIGHT("right"), + + /** + * Enum value up. + */ + UP("up"), + + /** + * Enum value down. + */ + DOWN("down"); + + /** + * The actual serialized value for a EnumsOnlyCasesLr instance. + */ + private final String value; + + EnumsOnlyCasesLr(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a EnumsOnlyCasesLr instance. + * + * @param value the serialized value to parse. + * @return the parsed EnumsOnlyCasesLr object, or null if unable to parse. + */ + public static EnumsOnlyCasesLr fromString(String value) { + if (value == null) { + return null; + } + EnumsOnlyCasesLr[] items = EnumsOnlyCasesLr.values(); + for (EnumsOnlyCasesLr item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/EnumsOnlyCasesUd.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/EnumsOnlyCasesUd.java new file mode 100644 index 0000000000..4ef1955e7f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/EnumsOnlyCasesUd.java @@ -0,0 +1,54 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +/** + * Defines values for EnumsOnlyCasesUd. + */ +public enum EnumsOnlyCasesUd { + /** + * Enum value up. + */ + UP("up"), + + /** + * Enum value down. + */ + DOWN("down"); + + /** + * The actual serialized value for a EnumsOnlyCasesUd instance. + */ + private final String value; + + EnumsOnlyCasesUd(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a EnumsOnlyCasesUd instance. + * + * @param value the serialized value to parse. + * @return the parsed EnumsOnlyCasesUd object, or null if unable to parse. + */ + public static EnumsOnlyCasesUd fromString(String value) { + if (value == null) { + return null; + } + EnumsOnlyCasesUd[] items = EnumsOnlyCasesUd.values(); + for (EnumsOnlyCasesUd item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/EnumsOnlyClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/EnumsOnlyClient.java new file mode 100644 index 0000000000..48c9c25cf7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/EnumsOnlyClient.java @@ -0,0 +1,111 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.implementation.EnumsOnliesImpl; +import type.union.implementation.SendRequest3; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class EnumsOnlyClient { + @Metadata(generated = true) + private final EnumsOnliesImpl serviceClient; + + /** + * Initializes an instance of EnumsOnlyClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + EnumsOnlyClient(EnumsOnliesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop (Required): {
+     *         lr: String(left/right/up/down) (Required)
+     *         ud: String(up/down) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop (Required): {
+     *         lr: String(left/right/up/down) (Required)
+     *         ud: String(up/down) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param sendRequest3 The sendRequest3 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response sendWithResponse(BinaryData sendRequest3, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest3, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public GetResponse3 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The send operation. + * + * @param prop The prop parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void send(EnumsOnlyCases prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest3 sendRequest3Obj = new SendRequest3(prop); + BinaryData sendRequest3 = BinaryData.fromObject(sendRequest3Obj); + sendWithResponse(sendRequest3, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/FloatsOnlyClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/FloatsOnlyClient.java new file mode 100644 index 0000000000..bb3bbf666e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/FloatsOnlyClient.java @@ -0,0 +1,105 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.implementation.FloatsOnliesImpl; +import type.union.implementation.SendRequest5; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class FloatsOnlyClient { + @Metadata(generated = true) + private final FloatsOnliesImpl serviceClient; + + /** + * Initializes an instance of FloatsOnlyClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + FloatsOnlyClient(FloatsOnliesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(1.1/2.2/3.3) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(1.1/2.2/3.3) (Required)
+     * }
+     * }
+     * 
+ * + * @param sendRequest5 The sendRequest5 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response sendWithResponse(BinaryData sendRequest5, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest5, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public GetResponse5 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The send operation. + * + * @param prop The prop parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void send(GetResponseProp1 prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest5 sendRequest5Obj = new SendRequest5(prop); + BinaryData sendRequest5 = BinaryData.fromObject(sendRequest5Obj); + sendWithResponse(sendRequest5, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse.java new file mode 100644 index 0000000000..4694fc653c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The GetResponse model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class GetResponse implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final MixedTypesCases prop; + + /** + * Creates an instance of GetResponse class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + private GetResponse(MixedTypesCases prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public MixedTypesCases getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse 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 GetResponse. + */ + @Metadata(generated = true) + public static GetResponse fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MixedTypesCases prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = MixedTypesCases.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new GetResponse(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse1.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse1.java new file mode 100644 index 0000000000..decb9d4c7f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse1.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The GetResponse1 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class GetResponse1 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final MixedLiteralsCases prop; + + /** + * Creates an instance of GetResponse1 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + private GetResponse1(MixedLiteralsCases prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public MixedLiteralsCases getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse1 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse1 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 GetResponse1. + */ + @Metadata(generated = true) + public static GetResponse1 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MixedLiteralsCases prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = MixedLiteralsCases.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new GetResponse1(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse2.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse2.java new file mode 100644 index 0000000000..918e91fd4d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse2.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The GetResponse2 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class GetResponse2 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final StringAndArrayCases prop; + + /** + * Creates an instance of GetResponse2 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + private GetResponse2(StringAndArrayCases prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public StringAndArrayCases getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse2 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse2 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 GetResponse2. + */ + @Metadata(generated = true) + public static GetResponse2 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StringAndArrayCases prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = StringAndArrayCases.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new GetResponse2(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse3.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse3.java new file mode 100644 index 0000000000..eb89f997fe --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse3.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The GetResponse3 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class GetResponse3 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final EnumsOnlyCases prop; + + /** + * Creates an instance of GetResponse3 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + private GetResponse3(EnumsOnlyCases prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public EnumsOnlyCases getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse3 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse3 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 GetResponse3. + */ + @Metadata(generated = true) + public static GetResponse3 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EnumsOnlyCases prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = EnumsOnlyCases.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new GetResponse3(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse4.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse4.java new file mode 100644 index 0000000000..85323fec01 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse4.java @@ -0,0 +1,83 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; + +/** + * The GetResponse4 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class GetResponse4 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final BinaryData prop; + + /** + * Creates an instance of GetResponse4 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + private GetResponse4(BinaryData prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public BinaryData getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeFieldName("prop"); + this.prop.writeTo(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse4 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse4 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 GetResponse4. + */ + @Metadata(generated = true) + public static GetResponse4 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BinaryData prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new GetResponse4(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse5.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse5.java new file mode 100644 index 0000000000..a2d3e50778 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse5.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The GetResponse5 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class GetResponse5 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final GetResponseProp1 prop; + + /** + * Creates an instance of GetResponse5 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + private GetResponse5(GetResponseProp1 prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public GetResponseProp1 getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("prop", this.prop == null ? null : this.prop.toDouble()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse5 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse5 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 GetResponse5. + */ + @Metadata(generated = true) + public static GetResponse5 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GetResponseProp1 prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = GetResponseProp1.fromDouble(reader.getDouble()); + } else { + reader.skipChildren(); + } + } + return new GetResponse5(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse6.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse6.java new file mode 100644 index 0000000000..faf91fdb5c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse6.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The GetResponse6 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class GetResponse6 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final GetResponseProp2 prop; + + /** + * Creates an instance of GetResponse6 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + private GetResponse6(GetResponseProp2 prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public GetResponseProp2 getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("prop", this.prop == null ? null : this.prop.toInt()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse6 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse6 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 GetResponse6. + */ + @Metadata(generated = true) + public static GetResponse6 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GetResponseProp2 prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = GetResponseProp2.fromInt(reader.getInt()); + } else { + reader.skipChildren(); + } + } + return new GetResponse6(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse7.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse7.java new file mode 100644 index 0000000000..9010f93ea2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse7.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The GetResponse7 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class GetResponse7 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final StringExtensibleNamedUnion prop; + + /** + * Creates an instance of GetResponse7 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + private GetResponse7(StringExtensibleNamedUnion prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public StringExtensibleNamedUnion getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop == null ? null : this.prop.getValue()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse7 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse7 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 GetResponse7. + */ + @Metadata(generated = true) + public static GetResponse7 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StringExtensibleNamedUnion prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = StringExtensibleNamedUnion.fromValue(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new GetResponse7(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse8.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse8.java new file mode 100644 index 0000000000..47907b5b9f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse8.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The GetResponse8 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class GetResponse8 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final GetResponseProp3 prop; + + /** + * Creates an instance of GetResponse8 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + private GetResponse8(GetResponseProp3 prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public GetResponseProp3 getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop == null ? null : this.prop.getValue()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse8 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse8 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 GetResponse8. + */ + @Metadata(generated = true) + public static GetResponse8 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GetResponseProp3 prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = GetResponseProp3.fromValue(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new GetResponse8(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse9.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse9.java new file mode 100644 index 0000000000..ddb1142cc7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponse9.java @@ -0,0 +1,81 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The GetResponse9 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class GetResponse9 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final GetResponseProp4 prop; + + /** + * Creates an instance of GetResponse9 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + private GetResponse9(GetResponseProp4 prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public GetResponseProp4 getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop == null ? null : this.prop.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of GetResponse9 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of GetResponse9 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 GetResponse9. + */ + @Metadata(generated = true) + public static GetResponse9 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GetResponseProp4 prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = GetResponseProp4.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new GetResponse9(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponseProp1.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponseProp1.java new file mode 100644 index 0000000000..de7db6e199 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponseProp1.java @@ -0,0 +1,57 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +/** + * Defines values for GetResponseProp1. + */ +public enum GetResponseProp1 { + /** + * Enum value 1.1. + */ + ONE_ONE(1.1), + + /** + * Enum value 2.2. + */ + TWO_TWO(2.2), + + /** + * Enum value 3.3. + */ + THREE_THREE(3.3); + + /** + * The actual serialized value for a GetResponseProp1 instance. + */ + private final double value; + + GetResponseProp1(double value) { + this.value = value; + } + + /** + * Parses a serialized value to a GetResponseProp1 instance. + * + * @param value the serialized value to parse. + * @return the parsed GetResponseProp1 object, or null if unable to parse. + */ + public static GetResponseProp1 fromDouble(double value) { + GetResponseProp1[] items = GetResponseProp1.values(); + for (GetResponseProp1 item : items) { + if (Double.doubleToLongBits(item.toDouble()) == Double.doubleToLongBits(value)) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to double value. + * + * @return the double value. + */ + public double toDouble() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponseProp2.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponseProp2.java new file mode 100644 index 0000000000..5e167213a4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponseProp2.java @@ -0,0 +1,57 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +/** + * Defines values for GetResponseProp2. + */ +public enum GetResponseProp2 { + /** + * Enum value 1. + */ + ONE(1), + + /** + * Enum value 2. + */ + TWO(2), + + /** + * Enum value 3. + */ + THREE(3); + + /** + * The actual serialized value for a GetResponseProp2 instance. + */ + private final int value; + + GetResponseProp2(int value) { + this.value = value; + } + + /** + * Parses a serialized value to a GetResponseProp2 instance. + * + * @param value the serialized value to parse. + * @return the parsed GetResponseProp2 object, or null if unable to parse. + */ + public static GetResponseProp2 fromInt(int value) { + GetResponseProp2[] items = GetResponseProp2.values(); + for (GetResponseProp2 item : items) { + if (item.toInt() == value) { + return item; + } + } + return null; + } + + /** + * De-serializes the instance to int value. + * + * @return the int value. + */ + public int toInt() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponseProp3.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponseProp3.java new file mode 100644 index 0000000000..0a07711131 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponseProp3.java @@ -0,0 +1,93 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.util.ExpandableEnum; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; + +/** + * Defines values for GetResponseProp3. + */ +public final class GetResponseProp3 implements ExpandableEnum { + private static final Map VALUES = new ConcurrentHashMap<>(); + + private static final Function NEW_INSTANCE = GetResponseProp3::new; + + /** + * Static value b for GetResponseProp3. + */ + @Metadata(generated = true) + public static final GetResponseProp3 B = fromValue("b"); + + /** + * Static value c for GetResponseProp3. + */ + @Metadata(generated = true) + public static final GetResponseProp3 C = fromValue("c"); + + private final String value; + + private GetResponseProp3(String value) { + this.value = value; + } + + /** + * Creates or finds a GetResponseProp3. + * + * @param value a value to look for. + * @return the corresponding GetResponseProp3. + * @throws IllegalArgumentException if value is null. + */ + @Metadata(generated = true) + public static GetResponseProp3 fromValue(String value) { + if (value == null) { + throw new IllegalArgumentException("'value' cannot be null."); + } + return VALUES.computeIfAbsent(value, NEW_INSTANCE); + } + + /** + * Gets known GetResponseProp3 values. + * + * @return Known GetResponseProp3 values. + */ + @Metadata(generated = true) + public static Collection values() { + return new ArrayList<>(VALUES.values()); + } + + /** + * Gets the value of the GetResponseProp3 instance. + * + * @return the value of the GetResponseProp3 instance. + */ + @Metadata(generated = true) + @Override + public String getValue() { + return this.value; + } + + @Metadata(generated = true) + @Override + public String toString() { + return Objects.toString(this.value); + } + + @Metadata(generated = true) + @Override + public boolean equals(Object obj) { + return this == obj; + } + + @Metadata(generated = true) + @Override + public int hashCode() { + return Objects.hashCode(this.value); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponseProp4.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponseProp4.java new file mode 100644 index 0000000000..2afc7db942 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/GetResponseProp4.java @@ -0,0 +1,59 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +/** + * Defines values for GetResponseProp4. + */ +public enum GetResponseProp4 { + /** + * Enum value a. + */ + A("a"), + + /** + * Enum value b. + */ + B("b"), + + /** + * Enum value c. + */ + C("c"); + + /** + * The actual serialized value for a GetResponseProp4 instance. + */ + private final String value; + + GetResponseProp4(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a GetResponseProp4 instance. + * + * @param value the serialized value to parse. + * @return the parsed GetResponseProp4 object, or null if unable to parse. + */ + public static GetResponseProp4 fromString(String value) { + if (value == null) { + return null; + } + GetResponseProp4[] items = GetResponseProp4.values(); + for (GetResponseProp4 item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/IntsOnlyClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/IntsOnlyClient.java new file mode 100644 index 0000000000..cfd79bb0c4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/IntsOnlyClient.java @@ -0,0 +1,105 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.implementation.IntsOnliesImpl; +import type.union.implementation.SendRequest6; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class IntsOnlyClient { + @Metadata(generated = true) + private final IntsOnliesImpl serviceClient; + + /** + * Initializes an instance of IntsOnlyClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + IntsOnlyClient(IntsOnliesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(1/2/3) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(1/2/3) (Required)
+     * }
+     * }
+     * 
+ * + * @param sendRequest6 The sendRequest6 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response sendWithResponse(BinaryData sendRequest6, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest6, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public GetResponse6 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The send operation. + * + * @param prop The prop parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void send(GetResponseProp2 prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest6 sendRequest6Obj = new SendRequest6(prop); + BinaryData sendRequest6 = BinaryData.fromObject(sendRequest6Obj); + sendWithResponse(sendRequest6, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/MixedLiteralsCases.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/MixedLiteralsCases.java new file mode 100644 index 0000000000..eb9f329410 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/MixedLiteralsCases.java @@ -0,0 +1,157 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; + +/** + * The MixedLiteralsCases model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class MixedLiteralsCases implements JsonSerializable { + /* + * This should be receive/send the "a" variant + */ + @Metadata(generated = true) + private final BinaryData stringLiteral; + + /* + * This should be receive/send the 2 variant + */ + @Metadata(generated = true) + private final BinaryData intLiteral; + + /* + * This should be receive/send the 3.3 variant + */ + @Metadata(generated = true) + private final BinaryData floatLiteral; + + /* + * This should be receive/send the true variant + */ + @Metadata(generated = true) + private final BinaryData booleanLiteral; + + /** + * Creates an instance of MixedLiteralsCases class. + * + * @param stringLiteral the stringLiteral value to set. + * @param intLiteral the intLiteral value to set. + * @param floatLiteral the floatLiteral value to set. + * @param booleanLiteral the booleanLiteral value to set. + */ + @Metadata(generated = true) + public MixedLiteralsCases(BinaryData stringLiteral, BinaryData intLiteral, BinaryData floatLiteral, + BinaryData booleanLiteral) { + this.stringLiteral = stringLiteral; + this.intLiteral = intLiteral; + this.floatLiteral = floatLiteral; + this.booleanLiteral = booleanLiteral; + } + + /** + * Get the stringLiteral property: This should be receive/send the "a" variant. + * + * @return the stringLiteral value. + */ + @Metadata(generated = true) + public BinaryData getStringLiteral() { + return this.stringLiteral; + } + + /** + * Get the intLiteral property: This should be receive/send the 2 variant. + * + * @return the intLiteral value. + */ + @Metadata(generated = true) + public BinaryData getIntLiteral() { + return this.intLiteral; + } + + /** + * Get the floatLiteral property: This should be receive/send the 3.3 variant. + * + * @return the floatLiteral value. + */ + @Metadata(generated = true) + public BinaryData getFloatLiteral() { + return this.floatLiteral; + } + + /** + * Get the booleanLiteral property: This should be receive/send the true variant. + * + * @return the booleanLiteral value. + */ + @Metadata(generated = true) + public BinaryData getBooleanLiteral() { + return this.booleanLiteral; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeFieldName("stringLiteral"); + this.stringLiteral.writeTo(jsonWriter); + jsonWriter.writeFieldName("intLiteral"); + this.intLiteral.writeTo(jsonWriter); + jsonWriter.writeFieldName("floatLiteral"); + this.floatLiteral.writeTo(jsonWriter); + jsonWriter.writeFieldName("booleanLiteral"); + this.booleanLiteral.writeTo(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MixedLiteralsCases from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MixedLiteralsCases 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 MixedLiteralsCases. + */ + @Metadata(generated = true) + public static MixedLiteralsCases fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BinaryData stringLiteral = null; + BinaryData intLiteral = null; + BinaryData floatLiteral = null; + BinaryData booleanLiteral = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("stringLiteral".equals(fieldName)) { + stringLiteral + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("intLiteral".equals(fieldName)) { + intLiteral + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("floatLiteral".equals(fieldName)) { + floatLiteral + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("booleanLiteral".equals(fieldName)) { + booleanLiteral + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new MixedLiteralsCases(stringLiteral, intLiteral, floatLiteral, booleanLiteral); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/MixedLiteralsClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/MixedLiteralsClient.java new file mode 100644 index 0000000000..a6d3c143e2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/MixedLiteralsClient.java @@ -0,0 +1,115 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.implementation.MixedLiteralsImpl; +import type.union.implementation.SendRequest1; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class MixedLiteralsClient { + @Metadata(generated = true) + private final MixedLiteralsImpl serviceClient; + + /** + * Initializes an instance of MixedLiteralsClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + MixedLiteralsClient(MixedLiteralsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop (Required): {
+     *         stringLiteral: BinaryData (Required)
+     *         intLiteral: BinaryData (Required)
+     *         floatLiteral: BinaryData (Required)
+     *         booleanLiteral: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop (Required): {
+     *         stringLiteral: BinaryData (Required)
+     *         intLiteral: BinaryData (Required)
+     *         floatLiteral: BinaryData (Required)
+     *         booleanLiteral: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param sendRequest1 The sendRequest1 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response sendWithResponse(BinaryData sendRequest1, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest1, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public GetResponse1 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The send operation. + * + * @param prop The prop parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void send(MixedLiteralsCases prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest1 sendRequest1Obj = new SendRequest1(prop); + BinaryData sendRequest1 = BinaryData.fromObject(sendRequest1Obj); + sendWithResponse(sendRequest1, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/MixedTypesCases.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/MixedTypesCases.java new file mode 100644 index 0000000000..809636969f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/MixedTypesCases.java @@ -0,0 +1,180 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.List; + +/** + * The MixedTypesCases model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class MixedTypesCases implements JsonSerializable { + /* + * This should be receive/send the Cat variant + */ + @Metadata(generated = true) + private final BinaryData model; + + /* + * This should be receive/send the "a" variant + */ + @Metadata(generated = true) + private final BinaryData literal; + + /* + * This should be receive/send the int variant + */ + @Metadata(generated = true) + private final BinaryData intProperty; + + /* + * This should be receive/send the boolean variant + */ + @Metadata(generated = true) + private final BinaryData booleanProperty; + + /* + * This should be receive/send 4 element with Cat, "a", int, and boolean + */ + @Metadata(generated = true) + private final List array; + + /** + * Creates an instance of MixedTypesCases class. + * + * @param model the model value to set. + * @param literal the literal value to set. + * @param intProperty the intProperty value to set. + * @param booleanProperty the booleanProperty value to set. + * @param array the array value to set. + */ + @Metadata(generated = true) + public MixedTypesCases(BinaryData model, BinaryData literal, BinaryData intProperty, BinaryData booleanProperty, + List array) { + this.model = model; + this.literal = literal; + this.intProperty = intProperty; + this.booleanProperty = booleanProperty; + this.array = array; + } + + /** + * Get the model property: This should be receive/send the Cat variant. + * + * @return the model value. + */ + @Metadata(generated = true) + public BinaryData getModel() { + return this.model; + } + + /** + * Get the literal property: This should be receive/send the "a" variant. + * + * @return the literal value. + */ + @Metadata(generated = true) + public BinaryData getLiteral() { + return this.literal; + } + + /** + * Get the intProperty property: This should be receive/send the int variant. + * + * @return the intProperty value. + */ + @Metadata(generated = true) + public BinaryData getIntProperty() { + return this.intProperty; + } + + /** + * Get the booleanProperty property: This should be receive/send the boolean variant. + * + * @return the booleanProperty value. + */ + @Metadata(generated = true) + public BinaryData getBooleanProperty() { + return this.booleanProperty; + } + + /** + * Get the array property: This should be receive/send 4 element with Cat, "a", int, and boolean. + * + * @return the array value. + */ + @Metadata(generated = true) + public List getArray() { + return this.array; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeFieldName("model"); + this.model.writeTo(jsonWriter); + jsonWriter.writeFieldName("literal"); + this.literal.writeTo(jsonWriter); + jsonWriter.writeFieldName("int"); + this.intProperty.writeTo(jsonWriter); + jsonWriter.writeFieldName("boolean"); + this.booleanProperty.writeTo(jsonWriter); + jsonWriter.writeArrayField("array", this.array, + (writer, element) -> writer.writeUntyped(element == null ? null : element.toObject(Object.class))); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of MixedTypesCases from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of MixedTypesCases 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 MixedTypesCases. + */ + @Metadata(generated = true) + public static MixedTypesCases fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BinaryData model = null; + BinaryData literal = null; + BinaryData intProperty = null; + BinaryData booleanProperty = null; + List array = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("model".equals(fieldName)) { + model = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("literal".equals(fieldName)) { + literal = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("int".equals(fieldName)) { + intProperty + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("boolean".equals(fieldName)) { + booleanProperty + = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("array".equals(fieldName)) { + array = reader.readArray(reader1 -> reader1 + .getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()))); + } else { + reader.skipChildren(); + } + } + return new MixedTypesCases(model, literal, intProperty, booleanProperty, array); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/MixedTypesClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/MixedTypesClient.java new file mode 100644 index 0000000000..95957345a3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/MixedTypesClient.java @@ -0,0 +1,121 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.implementation.MixedTypesImpl; +import type.union.implementation.SendRequest; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class MixedTypesClient { + @Metadata(generated = true) + private final MixedTypesImpl serviceClient; + + /** + * Initializes an instance of MixedTypesClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + MixedTypesClient(MixedTypesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop (Required): {
+     *         model: BinaryData (Required)
+     *         literal: BinaryData (Required)
+     *         int: BinaryData (Required)
+     *         boolean: BinaryData (Required)
+     *         array (Required): [
+     *             BinaryData (Required)
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop (Required): {
+     *         model: BinaryData (Required)
+     *         literal: BinaryData (Required)
+     *         int: BinaryData (Required)
+     *         boolean: BinaryData (Required)
+     *         array (Required): [
+     *             BinaryData (Required)
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param sendRequest The sendRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response sendWithResponse(BinaryData sendRequest, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public GetResponse get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The send operation. + * + * @param prop The prop parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void send(MixedTypesCases prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest sendRequestObj = new SendRequest(prop); + BinaryData sendRequest = BinaryData.fromObject(sendRequestObj); + sendWithResponse(sendRequest, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/ModelsOnlyClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/ModelsOnlyClient.java new file mode 100644 index 0000000000..b52e902bd4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/ModelsOnlyClient.java @@ -0,0 +1,105 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.implementation.ModelsOnliesImpl; +import type.union.implementation.SendRequest4; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class ModelsOnlyClient { + @Metadata(generated = true) + private final ModelsOnliesImpl serviceClient; + + /** + * Initializes an instance of ModelsOnlyClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ModelsOnlyClient(ModelsOnliesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param sendRequest4 The sendRequest4 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response sendWithResponse(BinaryData sendRequest4, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest4, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public GetResponse4 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The send operation. + * + * @param prop The prop parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void send(BinaryData prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest4 sendRequest4Obj = new SendRequest4(prop); + BinaryData sendRequest4 = BinaryData.fromObject(sendRequest4Obj); + sendWithResponse(sendRequest4, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringAndArrayCases.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringAndArrayCases.java new file mode 100644 index 0000000000..4678cceb04 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringAndArrayCases.java @@ -0,0 +1,106 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; + +/** + * The StringAndArrayCases model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class StringAndArrayCases implements JsonSerializable { + /* + * This should be receive/send the string variant + */ + @Metadata(generated = true) + private final BinaryData string; + + /* + * This should be receive/send the array variant + */ + @Metadata(generated = true) + private final BinaryData array; + + /** + * Creates an instance of StringAndArrayCases class. + * + * @param string the string value to set. + * @param array the array value to set. + */ + @Metadata(generated = true) + public StringAndArrayCases(BinaryData string, BinaryData array) { + this.string = string; + this.array = array; + } + + /** + * Get the string property: This should be receive/send the string variant. + * + * @return the string value. + */ + @Metadata(generated = true) + public BinaryData getString() { + return this.string; + } + + /** + * Get the array property: This should be receive/send the array variant. + * + * @return the array value. + */ + @Metadata(generated = true) + public BinaryData getArray() { + return this.array; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeFieldName("string"); + this.string.writeTo(jsonWriter); + jsonWriter.writeFieldName("array"); + this.array.writeTo(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of StringAndArrayCases from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of StringAndArrayCases 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 StringAndArrayCases. + */ + @Metadata(generated = true) + public static StringAndArrayCases fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BinaryData string = null; + BinaryData array = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("string".equals(fieldName)) { + string = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else if ("array".equals(fieldName)) { + array = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new StringAndArrayCases(string, array); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringAndArrayClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringAndArrayClient.java new file mode 100644 index 0000000000..cab455cbdf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringAndArrayClient.java @@ -0,0 +1,111 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.implementation.SendRequest2; +import type.union.implementation.StringAndArraysImpl; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class StringAndArrayClient { + @Metadata(generated = true) + private final StringAndArraysImpl serviceClient; + + /** + * Initializes an instance of StringAndArrayClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + StringAndArrayClient(StringAndArraysImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop (Required): {
+     *         string: BinaryData (Required)
+     *         array: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop (Required): {
+     *         string: BinaryData (Required)
+     *         array: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param sendRequest2 The sendRequest2 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response sendWithResponse(BinaryData sendRequest2, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest2, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public GetResponse2 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The send operation. + * + * @param prop The prop parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void send(StringAndArrayCases prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest2 sendRequest2Obj = new SendRequest2(prop); + BinaryData sendRequest2 = BinaryData.fromObject(sendRequest2Obj); + sendWithResponse(sendRequest2, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringExtensibleClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringExtensibleClient.java new file mode 100644 index 0000000000..3e4fed5a24 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringExtensibleClient.java @@ -0,0 +1,105 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.implementation.SendRequest8; +import type.union.implementation.StringExtensiblesImpl; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class StringExtensibleClient { + @Metadata(generated = true) + private final StringExtensiblesImpl serviceClient; + + /** + * Initializes an instance of StringExtensibleClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + StringExtensibleClient(StringExtensiblesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(b/c) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(b/c) (Required)
+     * }
+     * }
+     * 
+ * + * @param sendRequest8 The sendRequest8 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response sendWithResponse(BinaryData sendRequest8, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest8, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public GetResponse8 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The send operation. + * + * @param prop The prop parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void send(GetResponseProp3 prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest8 sendRequest8Obj = new SendRequest8(prop); + BinaryData sendRequest8 = BinaryData.fromObject(sendRequest8Obj); + sendWithResponse(sendRequest8, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringExtensibleNamedClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringExtensibleNamedClient.java new file mode 100644 index 0000000000..61daef7d3e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringExtensibleNamedClient.java @@ -0,0 +1,105 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.implementation.SendRequest7; +import type.union.implementation.StringExtensibleNamedsImpl; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class StringExtensibleNamedClient { + @Metadata(generated = true) + private final StringExtensibleNamedsImpl serviceClient; + + /** + * Initializes an instance of StringExtensibleNamedClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + StringExtensibleNamedClient(StringExtensibleNamedsImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(b/c) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(b/c) (Required)
+     * }
+     * }
+     * 
+ * + * @param sendRequest7 The sendRequest7 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response sendWithResponse(BinaryData sendRequest7, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest7, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public GetResponse7 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The send operation. + * + * @param prop The prop parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void send(StringExtensibleNamedUnion prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest7 sendRequest7Obj = new SendRequest7(prop); + BinaryData sendRequest7 = BinaryData.fromObject(sendRequest7Obj); + sendWithResponse(sendRequest7, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringExtensibleNamedUnion.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringExtensibleNamedUnion.java new file mode 100644 index 0000000000..61ffd0f268 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringExtensibleNamedUnion.java @@ -0,0 +1,93 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.util.ExpandableEnum; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; + +/** + * Defines values for StringExtensibleNamedUnion. + */ +public final class StringExtensibleNamedUnion implements ExpandableEnum { + private static final Map VALUES = new ConcurrentHashMap<>(); + + private static final Function NEW_INSTANCE = StringExtensibleNamedUnion::new; + + /** + * Static value b for StringExtensibleNamedUnion. + */ + @Metadata(generated = true) + public static final StringExtensibleNamedUnion OPTIONB = fromValue("b"); + + /** + * Static value c for StringExtensibleNamedUnion. + */ + @Metadata(generated = true) + public static final StringExtensibleNamedUnion C = fromValue("c"); + + private final String value; + + private StringExtensibleNamedUnion(String value) { + this.value = value; + } + + /** + * Creates or finds a StringExtensibleNamedUnion. + * + * @param value a value to look for. + * @return the corresponding StringExtensibleNamedUnion. + * @throws IllegalArgumentException if value is null. + */ + @Metadata(generated = true) + public static StringExtensibleNamedUnion fromValue(String value) { + if (value == null) { + throw new IllegalArgumentException("'value' cannot be null."); + } + return VALUES.computeIfAbsent(value, NEW_INSTANCE); + } + + /** + * Gets known StringExtensibleNamedUnion values. + * + * @return Known StringExtensibleNamedUnion values. + */ + @Metadata(generated = true) + public static Collection values() { + return new ArrayList<>(VALUES.values()); + } + + /** + * Gets the value of the StringExtensibleNamedUnion instance. + * + * @return the value of the StringExtensibleNamedUnion instance. + */ + @Metadata(generated = true) + @Override + public String getValue() { + return this.value; + } + + @Metadata(generated = true) + @Override + public String toString() { + return Objects.toString(this.value); + } + + @Metadata(generated = true) + @Override + public boolean equals(Object obj) { + return this == obj; + } + + @Metadata(generated = true) + @Override + public int hashCode() { + return Objects.hashCode(this.value); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringsOnlyClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringsOnlyClient.java new file mode 100644 index 0000000000..b63231d7dd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/StringsOnlyClient.java @@ -0,0 +1,105 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.implementation.SendRequest9; +import type.union.implementation.StringsOnliesImpl; + +/** + * Initializes a new instance of the synchronous UnionClient type. + */ +@ServiceClient(builder = UnionClientBuilder.class) +public final class StringsOnlyClient { + @Metadata(generated = true) + private final StringsOnliesImpl serviceClient; + + /** + * Initializes an instance of StringsOnlyClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + StringsOnlyClient(StringsOnliesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(a/b/c) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response getWithResponse(RequestOptions requestOptions) { + return this.serviceClient.getWithResponse(requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(a/b/c) (Required)
+     * }
+     * }
+     * 
+ * + * @param sendRequest9 The sendRequest9 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response sendWithResponse(BinaryData sendRequest9, RequestOptions requestOptions) { + return this.serviceClient.sendWithResponse(sendRequest9, requestOptions); + } + + /** + * The get operation. + * + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public GetResponse9 get() { + // Generated convenience method for getWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getWithResponse(requestOptions).getValue(); + } + + /** + * The send operation. + * + * @param prop The prop parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Metadata(generated = true) + public void send(GetResponseProp4 prop) { + // Generated convenience method for sendWithResponse + RequestOptions requestOptions = new RequestOptions(); + SendRequest9 sendRequest9Obj = new SendRequest9(prop); + BinaryData sendRequest9 = BinaryData.fromObject(sendRequest9Obj); + sendWithResponse(sendRequest9, requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/UnionClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/UnionClientBuilder.java new file mode 100644 index 0000000000..e2437e73b9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/UnionClientBuilder.java @@ -0,0 +1,341 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import type.union.implementation.UnionClientImpl; + +/** + * A builder for creating a new instance of the UnionClient type. + */ +@ServiceClientBuilder( + serviceClients = { + StringsOnlyClient.class, + StringExtensibleClient.class, + StringExtensibleNamedClient.class, + IntsOnlyClient.class, + FloatsOnlyClient.class, + ModelsOnlyClient.class, + EnumsOnlyClient.class, + StringAndArrayClient.class, + MixedLiteralsClient.class, + MixedTypesClient.class }) +public final class UnionClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the UnionClientBuilder. + */ + @Metadata(generated = true) + public UnionClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UnionClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UnionClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UnionClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UnionClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UnionClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UnionClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UnionClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UnionClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public UnionClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Builds an instance of UnionClientImpl with the provided parameters. + * + * @return an instance of UnionClientImpl. + */ + @Metadata(generated = true) + private UnionClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + String localEndpoint = (endpoint != null) ? endpoint : "http://localhost:3000"; + UnionClientImpl client = new UnionClientImpl(localPipeline, localEndpoint); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of StringsOnlyClient class. + * + * @return an instance of StringsOnlyClient. + */ + @Metadata(generated = true) + public StringsOnlyClient buildStringsOnlyClient() { + return new StringsOnlyClient(buildInnerClient().getStringsOnlies()); + } + + /** + * Builds an instance of StringExtensibleClient class. + * + * @return an instance of StringExtensibleClient. + */ + @Metadata(generated = true) + public StringExtensibleClient buildStringExtensibleClient() { + return new StringExtensibleClient(buildInnerClient().getStringExtensibles()); + } + + /** + * Builds an instance of StringExtensibleNamedClient class. + * + * @return an instance of StringExtensibleNamedClient. + */ + @Metadata(generated = true) + public StringExtensibleNamedClient buildStringExtensibleNamedClient() { + return new StringExtensibleNamedClient(buildInnerClient().getStringExtensibleNameds()); + } + + /** + * Builds an instance of IntsOnlyClient class. + * + * @return an instance of IntsOnlyClient. + */ + @Metadata(generated = true) + public IntsOnlyClient buildIntsOnlyClient() { + return new IntsOnlyClient(buildInnerClient().getIntsOnlies()); + } + + /** + * Builds an instance of FloatsOnlyClient class. + * + * @return an instance of FloatsOnlyClient. + */ + @Metadata(generated = true) + public FloatsOnlyClient buildFloatsOnlyClient() { + return new FloatsOnlyClient(buildInnerClient().getFloatsOnlies()); + } + + /** + * Builds an instance of ModelsOnlyClient class. + * + * @return an instance of ModelsOnlyClient. + */ + @Metadata(generated = true) + public ModelsOnlyClient buildModelsOnlyClient() { + return new ModelsOnlyClient(buildInnerClient().getModelsOnlies()); + } + + /** + * Builds an instance of EnumsOnlyClient class. + * + * @return an instance of EnumsOnlyClient. + */ + @Metadata(generated = true) + public EnumsOnlyClient buildEnumsOnlyClient() { + return new EnumsOnlyClient(buildInnerClient().getEnumsOnlies()); + } + + /** + * Builds an instance of StringAndArrayClient class. + * + * @return an instance of StringAndArrayClient. + */ + @Metadata(generated = true) + public StringAndArrayClient buildStringAndArrayClient() { + return new StringAndArrayClient(buildInnerClient().getStringAndArrays()); + } + + /** + * Builds an instance of MixedLiteralsClient class. + * + * @return an instance of MixedLiteralsClient. + */ + @Metadata(generated = true) + public MixedLiteralsClient buildMixedLiteralsClient() { + return new MixedLiteralsClient(buildInnerClient().getMixedLiterals()); + } + + /** + * Builds an instance of MixedTypesClient class. + * + * @return an instance of MixedTypesClient. + */ + @Metadata(generated = true) + public MixedTypesClient buildMixedTypesClient() { + return new MixedTypesClient(buildInnerClient().getMixedTypes()); + } + + private static final ClientLogger LOGGER = new ClientLogger(UnionClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/EnumsOnliesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/EnumsOnliesImpl.java new file mode 100644 index 0000000000..bbd240d47e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/EnumsOnliesImpl.java @@ -0,0 +1,111 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.GetResponse3; + +/** + * An instance of this class provides access to all the operations defined in EnumsOnlies. + */ +public final class EnumsOnliesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final EnumsOnliesService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of EnumsOnliesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + EnumsOnliesImpl(UnionClientImpl client) { + this.service = RestProxy.create(EnumsOnliesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientEnumsOnlies to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "UnionClientEnumsOnli", host = "{endpoint}") + public interface EnumsOnliesService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/union/enums-only", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/type/union/enums-only", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest3, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop (Required): {
+     *         lr: String(left/right/up/down) (Required)
+     *         ud: String(up/down) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop (Required): {
+     *         lr: String(left/right/up/down) (Required)
+     *         ud: String(up/down) (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param sendRequest3 The sendRequest3 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response sendWithResponse(BinaryData sendRequest3, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest3, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/FloatsOnliesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/FloatsOnliesImpl.java new file mode 100644 index 0000000000..25e0b5f127 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/FloatsOnliesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.GetResponse5; + +/** + * An instance of this class provides access to all the operations defined in FloatsOnlies. + */ +public final class FloatsOnliesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final FloatsOnliesService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of FloatsOnliesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + FloatsOnliesImpl(UnionClientImpl client) { + this.service = RestProxy.create(FloatsOnliesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientFloatsOnlies to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "UnionClientFloatsOnl", host = "{endpoint}") + public interface FloatsOnliesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/union/floats-only", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/type/union/floats-only", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest5, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(1.1/2.2/3.3) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(1.1/2.2/3.3) (Required)
+     * }
+     * }
+     * 
+ * + * @param sendRequest5 The sendRequest5 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response sendWithResponse(BinaryData sendRequest5, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest5, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/IntsOnliesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/IntsOnliesImpl.java new file mode 100644 index 0000000000..34996c02ab --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/IntsOnliesImpl.java @@ -0,0 +1,102 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.GetResponse6; + +/** + * An instance of this class provides access to all the operations defined in IntsOnlies. + */ +public final class IntsOnliesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final IntsOnliesService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of IntsOnliesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + IntsOnliesImpl(UnionClientImpl client) { + this.service = RestProxy.create(IntsOnliesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientIntsOnlies to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "UnionClientIntsOnlie", host = "{endpoint}") + public interface IntsOnliesService { + @HttpRequestInformation(method = HttpMethod.GET, path = "/type/union/ints-only", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.POST, path = "/type/union/ints-only", expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest6, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(1/2/3) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(1/2/3) (Required)
+     * }
+     * }
+     * 
+ * + * @param sendRequest6 The sendRequest6 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response sendWithResponse(BinaryData sendRequest6, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest6, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/MixedLiteralsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/MixedLiteralsImpl.java new file mode 100644 index 0000000000..1cec279b61 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/MixedLiteralsImpl.java @@ -0,0 +1,118 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.GetResponse1; + +/** + * An instance of this class provides access to all the operations defined in MixedLiterals. + */ +public final class MixedLiteralsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final MixedLiteralsService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of MixedLiteralsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + MixedLiteralsImpl(UnionClientImpl client) { + this.service = RestProxy.create(MixedLiteralsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientMixedLiterals to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "UnionClientMixedLite", host = "{endpoint}") + public interface MixedLiteralsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/union/mixed-literals", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/type/union/mixed-literals", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest1, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop (Required): {
+     *         stringLiteral: BinaryData (Required)
+     *         intLiteral: BinaryData (Required)
+     *         floatLiteral: BinaryData (Required)
+     *         booleanLiteral: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop (Required): {
+     *         stringLiteral: BinaryData (Required)
+     *         intLiteral: BinaryData (Required)
+     *         floatLiteral: BinaryData (Required)
+     *         booleanLiteral: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param sendRequest1 The sendRequest1 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response sendWithResponse(BinaryData sendRequest1, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest1, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/MixedTypesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/MixedTypesImpl.java new file mode 100644 index 0000000000..0bc22583e6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/MixedTypesImpl.java @@ -0,0 +1,124 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.GetResponse; + +/** + * An instance of this class provides access to all the operations defined in MixedTypes. + */ +public final class MixedTypesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final MixedTypesService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of MixedTypesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + MixedTypesImpl(UnionClientImpl client) { + this.service = RestProxy.create(MixedTypesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientMixedTypes to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "UnionClientMixedType", host = "{endpoint}") + public interface MixedTypesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/union/mixed-types", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/type/union/mixed-types", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop (Required): {
+     *         model: BinaryData (Required)
+     *         literal: BinaryData (Required)
+     *         int: BinaryData (Required)
+     *         boolean: BinaryData (Required)
+     *         array (Required): [
+     *             BinaryData (Required)
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop (Required): {
+     *         model: BinaryData (Required)
+     *         literal: BinaryData (Required)
+     *         int: BinaryData (Required)
+     *         boolean: BinaryData (Required)
+     *         array (Required): [
+     *             BinaryData (Required)
+     *         ]
+     *     }
+     * }
+     * }
+     * 
+ * + * @param sendRequest The sendRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response sendWithResponse(BinaryData sendRequest, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/ModelsOnliesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/ModelsOnliesImpl.java new file mode 100644 index 0000000000..a0b364cef9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/ModelsOnliesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.GetResponse4; + +/** + * An instance of this class provides access to all the operations defined in ModelsOnlies. + */ +public final class ModelsOnliesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ModelsOnliesService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of ModelsOnliesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + ModelsOnliesImpl(UnionClientImpl client) { + this.service = RestProxy.create(ModelsOnliesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientModelsOnlies to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "UnionClientModelsOnl", host = "{endpoint}") + public interface ModelsOnliesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/union/models-only", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/type/union/models-only", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest4, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param sendRequest4 The sendRequest4 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response sendWithResponse(BinaryData sendRequest4, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest4, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest.java new file mode 100644 index 0000000000..817f793baf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import type.union.MixedTypesCases; + +/** + * The SendRequest model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SendRequest implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final MixedTypesCases prop; + + /** + * Creates an instance of SendRequest class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + public SendRequest(MixedTypesCases prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public MixedTypesCases getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest 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 SendRequest. + */ + @Metadata(generated = true) + public static SendRequest fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MixedTypesCases prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = MixedTypesCases.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new SendRequest(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest1.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest1.java new file mode 100644 index 0000000000..c1def5ade8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest1.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import type.union.MixedLiteralsCases; + +/** + * The SendRequest1 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SendRequest1 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final MixedLiteralsCases prop; + + /** + * Creates an instance of SendRequest1 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + public SendRequest1(MixedLiteralsCases prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public MixedLiteralsCases getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest1 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest1 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 SendRequest1. + */ + @Metadata(generated = true) + public static SendRequest1 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + MixedLiteralsCases prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = MixedLiteralsCases.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new SendRequest1(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest2.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest2.java new file mode 100644 index 0000000000..0cf61115c1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest2.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import type.union.StringAndArrayCases; + +/** + * The SendRequest2 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SendRequest2 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final StringAndArrayCases prop; + + /** + * Creates an instance of SendRequest2 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + public SendRequest2(StringAndArrayCases prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public StringAndArrayCases getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest2 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest2 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 SendRequest2. + */ + @Metadata(generated = true) + public static SendRequest2 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StringAndArrayCases prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = StringAndArrayCases.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new SendRequest2(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest3.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest3.java new file mode 100644 index 0000000000..3b1956bc68 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest3.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import type.union.EnumsOnlyCases; + +/** + * The SendRequest3 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SendRequest3 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final EnumsOnlyCases prop; + + /** + * Creates an instance of SendRequest3 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + public SendRequest3(EnumsOnlyCases prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public EnumsOnlyCases getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeJsonField("prop", this.prop); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest3 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest3 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 SendRequest3. + */ + @Metadata(generated = true) + public static SendRequest3 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + EnumsOnlyCases prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = EnumsOnlyCases.fromJson(reader); + } else { + reader.skipChildren(); + } + } + return new SendRequest3(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest4.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest4.java new file mode 100644 index 0000000000..981f5a241e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest4.java @@ -0,0 +1,83 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; + +/** + * The SendRequest4 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SendRequest4 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final BinaryData prop; + + /** + * Creates an instance of SendRequest4 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + public SendRequest4(BinaryData prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public BinaryData getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeFieldName("prop"); + this.prop.writeTo(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest4 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest4 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 SendRequest4. + */ + @Metadata(generated = true) + public static SendRequest4 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + BinaryData prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new SendRequest4(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest5.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest5.java new file mode 100644 index 0000000000..f6dbd30ab7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest5.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import type.union.GetResponseProp1; + +/** + * The SendRequest5 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SendRequest5 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final GetResponseProp1 prop; + + /** + * Creates an instance of SendRequest5 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + public SendRequest5(GetResponseProp1 prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public GetResponseProp1 getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("prop", this.prop == null ? null : this.prop.toDouble()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest5 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest5 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 SendRequest5. + */ + @Metadata(generated = true) + public static SendRequest5 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GetResponseProp1 prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = GetResponseProp1.fromDouble(reader.getDouble()); + } else { + reader.skipChildren(); + } + } + return new SendRequest5(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest6.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest6.java new file mode 100644 index 0000000000..f8470c82a0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest6.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import type.union.GetResponseProp2; + +/** + * The SendRequest6 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SendRequest6 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final GetResponseProp2 prop; + + /** + * Creates an instance of SendRequest6 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + public SendRequest6(GetResponseProp2 prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public GetResponseProp2 getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeNumberField("prop", this.prop == null ? null : this.prop.toInt()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest6 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest6 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 SendRequest6. + */ + @Metadata(generated = true) + public static SendRequest6 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GetResponseProp2 prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = GetResponseProp2.fromInt(reader.getInt()); + } else { + reader.skipChildren(); + } + } + return new SendRequest6(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest7.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest7.java new file mode 100644 index 0000000000..594a35676e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest7.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import type.union.StringExtensibleNamedUnion; + +/** + * The SendRequest7 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SendRequest7 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final StringExtensibleNamedUnion prop; + + /** + * Creates an instance of SendRequest7 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + public SendRequest7(StringExtensibleNamedUnion prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public StringExtensibleNamedUnion getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop == null ? null : this.prop.getValue()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest7 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest7 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 SendRequest7. + */ + @Metadata(generated = true) + public static SendRequest7 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + StringExtensibleNamedUnion prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = StringExtensibleNamedUnion.fromValue(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new SendRequest7(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest8.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest8.java new file mode 100644 index 0000000000..44cef6932f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest8.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import type.union.GetResponseProp3; + +/** + * The SendRequest8 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SendRequest8 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final GetResponseProp3 prop; + + /** + * Creates an instance of SendRequest8 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + public SendRequest8(GetResponseProp3 prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public GetResponseProp3 getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop == null ? null : this.prop.getValue()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest8 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest8 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 SendRequest8. + */ + @Metadata(generated = true) + public static SendRequest8 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GetResponseProp3 prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = GetResponseProp3.fromValue(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new SendRequest8(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest9.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest9.java new file mode 100644 index 0000000000..e6284b457c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/SendRequest9.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; +import type.union.GetResponseProp4; + +/** + * The SendRequest9 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class SendRequest9 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final GetResponseProp4 prop; + + /** + * Creates an instance of SendRequest9 class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + public SendRequest9(GetResponseProp4 prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public GetResponseProp4 getProp() { + return this.prop; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop == null ? null : this.prop.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of SendRequest9 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of SendRequest9 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 SendRequest9. + */ + @Metadata(generated = true) + public static SendRequest9 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + GetResponseProp4 prop = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = GetResponseProp4.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new SendRequest9(prop); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/StringAndArraysImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/StringAndArraysImpl.java new file mode 100644 index 0000000000..8bcc06eeb4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/StringAndArraysImpl.java @@ -0,0 +1,114 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.GetResponse2; + +/** + * An instance of this class provides access to all the operations defined in StringAndArrays. + */ +public final class StringAndArraysImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringAndArraysService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of StringAndArraysImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringAndArraysImpl(UnionClientImpl client) { + this.service = RestProxy.create(StringAndArraysService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientStringAndArrays to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "UnionClientStringAnd", host = "{endpoint}") + public interface StringAndArraysService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/union/string-and-array", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/type/union/string-and-array", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest2, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop (Required): {
+     *         string: BinaryData (Required)
+     *         array: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop (Required): {
+     *         string: BinaryData (Required)
+     *         array: BinaryData (Required)
+     *     }
+     * }
+     * }
+     * 
+ * + * @param sendRequest2 The sendRequest2 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response sendWithResponse(BinaryData sendRequest2, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest2, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/StringExtensibleNamedsImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/StringExtensibleNamedsImpl.java new file mode 100644 index 0000000000..bad8f1b2b3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/StringExtensibleNamedsImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.GetResponse7; + +/** + * An instance of this class provides access to all the operations defined in StringExtensibleNameds. + */ +public final class StringExtensibleNamedsImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringExtensibleNamedsService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of StringExtensibleNamedsImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringExtensibleNamedsImpl(UnionClientImpl client) { + this.service = RestProxy.create(StringExtensibleNamedsService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientStringExtensibleNameds to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "UnionClientStringExt", host = "{endpoint}") + public interface StringExtensibleNamedsService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/union/string-extensible-named", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/type/union/string-extensible-named", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest7, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(b/c) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(b/c) (Required)
+     * }
+     * }
+     * 
+ * + * @param sendRequest7 The sendRequest7 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response sendWithResponse(BinaryData sendRequest7, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest7, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/StringExtensiblesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/StringExtensiblesImpl.java new file mode 100644 index 0000000000..29f7ef8491 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/StringExtensiblesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.GetResponse8; + +/** + * An instance of this class provides access to all the operations defined in StringExtensibles. + */ +public final class StringExtensiblesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringExtensiblesService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of StringExtensiblesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringExtensiblesImpl(UnionClientImpl client) { + this.service = RestProxy.create(StringExtensiblesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientStringExtensibles to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "UnionClientStringExt", host = "{endpoint}") + public interface StringExtensiblesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/union/string-extensible", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/type/union/string-extensible", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest8, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(b/c) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(b/c) (Required)
+     * }
+     * }
+     * 
+ * + * @param sendRequest8 The sendRequest8 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response sendWithResponse(BinaryData sendRequest8, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest8, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/StringsOnliesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/StringsOnliesImpl.java new file mode 100644 index 0000000000..215233b2ef --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/StringsOnliesImpl.java @@ -0,0 +1,108 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import type.union.GetResponse9; + +/** + * An instance of this class provides access to all the operations defined in StringsOnlies. + */ +public final class StringsOnliesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final StringsOnliesService service; + + /** + * The service client containing this operation class. + */ + private final UnionClientImpl client; + + /** + * Initializes an instance of StringsOnliesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + StringsOnliesImpl(UnionClientImpl client) { + this.service = RestProxy.create(StringsOnliesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * The interface defining all the services for UnionClientStringsOnlies to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "UnionClientStringsOn", host = "{endpoint}") + public interface StringsOnliesService { + @HttpRequestInformation( + method = HttpMethod.GET, + path = "/type/union/strings-only", + expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response getSync(@HostParam("endpoint") String endpoint, @HeaderParam("Accept") String accept, + RequestOptions requestOptions); + + @HttpRequestInformation( + method = HttpMethod.POST, + path = "/type/union/strings-only", + expectedStatusCodes = { 204 }) + @UnexpectedResponseExceptionDetail + Response sendSync(@HostParam("endpoint") String endpoint, @HeaderParam("Content-Type") String contentType, + @BodyParam("application/json") BinaryData sendRequest9, RequestOptions requestOptions); + } + + /** + * The get operation. + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(a/b/c) (Required)
+     * }
+     * }
+     * 
+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response getWithResponse(RequestOptions requestOptions) { + final String accept = "application/json"; + return service.getSync(this.client.getEndpoint(), accept, requestOptions); + } + + /** + * The send operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String(a/b/c) (Required)
+     * }
+     * }
+     * 
+ * + * @param sendRequest9 The sendRequest9 parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response sendWithResponse(BinaryData sendRequest9, RequestOptions requestOptions) { + final String contentType = "application/json"; + return service.sendSync(this.client.getEndpoint(), contentType, sendRequest9, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/UnionClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/UnionClientImpl.java new file mode 100644 index 0000000000..02ae532d04 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/UnionClientImpl.java @@ -0,0 +1,199 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package type.union.implementation; + +import io.clientcore.core.http.pipeline.HttpPipeline; + +/** + * Initializes a new instance of the UnionClient type. + */ +public final class UnionClientImpl { + /** + * Service host. + */ + private final String endpoint; + + /** + * Gets Service host. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * 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 StringsOnliesImpl object to access its operations. + */ + private final StringsOnliesImpl stringsOnlies; + + /** + * Gets the StringsOnliesImpl object to access its operations. + * + * @return the StringsOnliesImpl object. + */ + public StringsOnliesImpl getStringsOnlies() { + return this.stringsOnlies; + } + + /** + * The StringExtensiblesImpl object to access its operations. + */ + private final StringExtensiblesImpl stringExtensibles; + + /** + * Gets the StringExtensiblesImpl object to access its operations. + * + * @return the StringExtensiblesImpl object. + */ + public StringExtensiblesImpl getStringExtensibles() { + return this.stringExtensibles; + } + + /** + * The StringExtensibleNamedsImpl object to access its operations. + */ + private final StringExtensibleNamedsImpl stringExtensibleNameds; + + /** + * Gets the StringExtensibleNamedsImpl object to access its operations. + * + * @return the StringExtensibleNamedsImpl object. + */ + public StringExtensibleNamedsImpl getStringExtensibleNameds() { + return this.stringExtensibleNameds; + } + + /** + * The IntsOnliesImpl object to access its operations. + */ + private final IntsOnliesImpl intsOnlies; + + /** + * Gets the IntsOnliesImpl object to access its operations. + * + * @return the IntsOnliesImpl object. + */ + public IntsOnliesImpl getIntsOnlies() { + return this.intsOnlies; + } + + /** + * The FloatsOnliesImpl object to access its operations. + */ + private final FloatsOnliesImpl floatsOnlies; + + /** + * Gets the FloatsOnliesImpl object to access its operations. + * + * @return the FloatsOnliesImpl object. + */ + public FloatsOnliesImpl getFloatsOnlies() { + return this.floatsOnlies; + } + + /** + * The ModelsOnliesImpl object to access its operations. + */ + private final ModelsOnliesImpl modelsOnlies; + + /** + * Gets the ModelsOnliesImpl object to access its operations. + * + * @return the ModelsOnliesImpl object. + */ + public ModelsOnliesImpl getModelsOnlies() { + return this.modelsOnlies; + } + + /** + * The EnumsOnliesImpl object to access its operations. + */ + private final EnumsOnliesImpl enumsOnlies; + + /** + * Gets the EnumsOnliesImpl object to access its operations. + * + * @return the EnumsOnliesImpl object. + */ + public EnumsOnliesImpl getEnumsOnlies() { + return this.enumsOnlies; + } + + /** + * The StringAndArraysImpl object to access its operations. + */ + private final StringAndArraysImpl stringAndArrays; + + /** + * Gets the StringAndArraysImpl object to access its operations. + * + * @return the StringAndArraysImpl object. + */ + public StringAndArraysImpl getStringAndArrays() { + return this.stringAndArrays; + } + + /** + * The MixedLiteralsImpl object to access its operations. + */ + private final MixedLiteralsImpl mixedLiterals; + + /** + * Gets the MixedLiteralsImpl object to access its operations. + * + * @return the MixedLiteralsImpl object. + */ + public MixedLiteralsImpl getMixedLiterals() { + return this.mixedLiterals; + } + + /** + * The MixedTypesImpl object to access its operations. + */ + private final MixedTypesImpl mixedTypes; + + /** + * Gets the MixedTypesImpl object to access its operations. + * + * @return the MixedTypesImpl object. + */ + public MixedTypesImpl getMixedTypes() { + return this.mixedTypes; + } + + /** + * Initializes an instance of UnionClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Service host. + */ + public UnionClientImpl(HttpPipeline httpPipeline, String endpoint) { + this.endpoint = "http://localhost:3000"; + this.httpPipeline = httpPipeline; + this.stringsOnlies = new StringsOnliesImpl(this); + this.stringExtensibles = new StringExtensiblesImpl(this); + this.stringExtensibleNameds = new StringExtensibleNamedsImpl(this); + this.intsOnlies = new IntsOnliesImpl(this); + this.floatsOnlies = new FloatsOnliesImpl(this); + this.modelsOnlies = new ModelsOnliesImpl(this); + this.enumsOnlies = new EnumsOnliesImpl(this); + this.stringAndArrays = new StringAndArraysImpl(this); + this.mixedLiterals = new MixedLiteralsImpl(this); + this.mixedTypes = new MixedTypesImpl(this); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/package-info.java new file mode 100644 index 0000000000..51f45edb70 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Union. + * Describe scenarios for various combinations of unions. + */ +package type.union.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/package-info.java new file mode 100644 index 0000000000..46d8f8ce87 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/type/union/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Union. + * Describe scenarios for various combinations of unions. + */ +package type.union; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/AddedClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/AddedClient.java new file mode 100644 index 0000000000..2290007067 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/AddedClient.java @@ -0,0 +1,136 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.added; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import versioning.added.implementation.AddedClientImpl; + +/** + * Initializes a new instance of the synchronous AddedClient type. + */ +@ServiceClient(builder = AddedClientBuilder.class) +public final class AddedClient { + @Metadata(generated = true) + private final AddedClientImpl serviceClient; + + /** + * Initializes an instance of AddedClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + AddedClient(AddedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The v1 operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV1/enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV1/enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param headerV2 The headerV2 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 service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response v1WithResponse(String headerV2, BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.v1WithResponse(headerV2, body, requestOptions); + } + + /** + * The v2 operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response v2WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.v2WithResponse(body, requestOptions); + } + + /** + * The v1 operation. + * + * @param headerV2 The headerV2 parameter. + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public ModelV1 v1(String headerV2, ModelV1 body) { + // Generated convenience method for v1WithResponse + RequestOptions requestOptions = new RequestOptions(); + return v1WithResponse(headerV2, BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The v2 operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public ModelV2 v2(ModelV2 body) { + // Generated convenience method for v2WithResponse + RequestOptions requestOptions = new RequestOptions(); + return v2WithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/AddedClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/AddedClientBuilder.java new file mode 100644 index 0000000000..3c23e0fd38 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/AddedClientBuilder.java @@ -0,0 +1,289 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.added; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import versioning.added.implementation.AddedClientImpl; + +/** + * A builder for creating a new instance of the AddedClient type. + */ +@ServiceClientBuilder(serviceClients = { AddedClient.class, InterfaceV2Client.class }) +public final class AddedClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the AddedClientBuilder. + */ + @Metadata(generated = true) + public AddedClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AddedClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AddedClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AddedClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AddedClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AddedClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AddedClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AddedClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AddedClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public AddedClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Need to be set as 'v1' or 'v2' in client. + */ + @Metadata(generated = true) + private Versions version; + + /** + * Sets Need to be set as 'v1' or 'v2' in client. + * + * @param version the version value. + * @return the AddedClientBuilder. + */ + @Metadata(generated = true) + public AddedClientBuilder version(Versions version) { + this.version = version; + return this; + } + + /* + * Service version + */ + @Metadata(generated = true) + private AddedServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the AddedClientBuilder. + */ + @Metadata(generated = true) + public AddedClientBuilder serviceVersion(AddedServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /** + * Builds an instance of AddedClientImpl with the provided parameters. + * + * @return an instance of AddedClientImpl. + */ + @Metadata(generated = true) + private AddedClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + AddedServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : AddedServiceVersion.getLatest(); + AddedClientImpl client = new AddedClientImpl(localPipeline, this.endpoint, this.version, localServiceVersion); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(version, "'version' cannot be null."); + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of AddedClient class. + * + * @return an instance of AddedClient. + */ + @Metadata(generated = true) + public AddedClient buildClient() { + return new AddedClient(buildInnerClient()); + } + + /** + * Builds an instance of InterfaceV2Client class. + * + * @return an instance of InterfaceV2Client. + */ + @Metadata(generated = true) + public InterfaceV2Client buildInterfaceV2Client() { + return new InterfaceV2Client(buildInnerClient().getInterfaceV2s()); + } + + private static final ClientLogger LOGGER = new ClientLogger(AddedClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/AddedServiceVersion.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/AddedServiceVersion.java new file mode 100644 index 0000000000..2d5ec70447 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/AddedServiceVersion.java @@ -0,0 +1,43 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.added; + +import io.clientcore.core.http.models.ServiceVersion; + +/** + * Service version of AddedClient. + */ +public enum AddedServiceVersion implements ServiceVersion { + /** + * Enum value v1. + */ + V1("v1"), + + /** + * Enum value v2. + */ + V2("v2"); + + private final String version; + + AddedServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link AddedServiceVersion}. + */ + public static AddedServiceVersion getLatest() { + return V2; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/EnumV1.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/EnumV1.java new file mode 100644 index 0000000000..5988dcadee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/EnumV1.java @@ -0,0 +1,54 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.added; + +/** + * Defines values for EnumV1. + */ +public enum EnumV1 { + /** + * Enum value enumMemberV1. + */ + ENUM_MEMBER_V1("enumMemberV1"), + + /** + * Enum value enumMemberV2. + */ + ENUM_MEMBER_V2("enumMemberV2"); + + /** + * The actual serialized value for a EnumV1 instance. + */ + private final String value; + + EnumV1(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a EnumV1 instance. + * + * @param value the serialized value to parse. + * @return the parsed EnumV1 object, or null if unable to parse. + */ + public static EnumV1 fromString(String value) { + if (value == null) { + return null; + } + EnumV1[] items = EnumV1.values(); + for (EnumV1 item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/EnumV2.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/EnumV2.java new file mode 100644 index 0000000000..0b642c2c04 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/EnumV2.java @@ -0,0 +1,49 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.added; + +/** + * Defines values for EnumV2. + */ +public enum EnumV2 { + /** + * Enum value enumMember. + */ + ENUM_MEMBER("enumMember"); + + /** + * The actual serialized value for a EnumV2 instance. + */ + private final String value; + + EnumV2(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a EnumV2 instance. + * + * @param value the serialized value to parse. + * @return the parsed EnumV2 object, or null if unable to parse. + */ + public static EnumV2 fromString(String value) { + if (value == null) { + return null; + } + EnumV2[] items = EnumV2.values(); + for (EnumV2 item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/InterfaceV2Client.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/InterfaceV2Client.java new file mode 100644 index 0000000000..db609953e0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/InterfaceV2Client.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.added; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import versioning.added.implementation.InterfaceV2sImpl; + +/** + * Initializes a new instance of the synchronous AddedClient type. + */ +@ServiceClient(builder = AddedClientBuilder.class) +public final class InterfaceV2Client { + @Metadata(generated = true) + private final InterfaceV2sImpl serviceClient; + + /** + * Initializes an instance of InterfaceV2Client class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + InterfaceV2Client(InterfaceV2sImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The v2InInterface operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response v2InInterfaceWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.v2InInterfaceWithResponse(body, requestOptions); + } + + /** + * The v2InInterface operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public ModelV2 v2InInterface(ModelV2 body) { + // Generated convenience method for v2InInterfaceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return v2InInterfaceWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/ModelV1.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/ModelV1.java new file mode 100644 index 0000000000..6d42a37489 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/ModelV1.java @@ -0,0 +1,127 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.added; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; + +/** + * The ModelV1 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class ModelV1 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final String prop; + + /* + * The enumProp property. + */ + @Metadata(generated = true) + private final EnumV1 enumProp; + + /* + * The unionProp property. + */ + @Metadata(generated = true) + private final BinaryData unionProp; + + /** + * Creates an instance of ModelV1 class. + * + * @param prop the prop value to set. + * @param enumProp the enumProp value to set. + * @param unionProp the unionProp value to set. + */ + @Metadata(generated = true) + public ModelV1(String prop, EnumV1 enumProp, BinaryData unionProp) { + this.prop = prop; + this.enumProp = enumProp; + this.unionProp = unionProp; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public String getProp() { + return this.prop; + } + + /** + * Get the enumProp property: The enumProp property. + * + * @return the enumProp value. + */ + @Metadata(generated = true) + public EnumV1 getEnumProp() { + return this.enumProp; + } + + /** + * Get the unionProp property: The unionProp property. + * + * @return the unionProp value. + */ + @Metadata(generated = true) + public BinaryData getUnionProp() { + return this.unionProp; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop); + jsonWriter.writeStringField("enumProp", this.enumProp == null ? null : this.enumProp.toString()); + jsonWriter.writeFieldName("unionProp"); + this.unionProp.writeTo(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ModelV1 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ModelV1 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 ModelV1. + */ + @Metadata(generated = true) + public static ModelV1 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String prop = null; + EnumV1 enumProp = null; + BinaryData unionProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = reader.getString(); + } else if ("enumProp".equals(fieldName)) { + enumProp = EnumV1.fromString(reader.getString()); + } else if ("unionProp".equals(fieldName)) { + unionProp = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new ModelV1(prop, enumProp, unionProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/ModelV2.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/ModelV2.java new file mode 100644 index 0000000000..763631b2de --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/ModelV2.java @@ -0,0 +1,127 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.added; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; + +/** + * The ModelV2 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class ModelV2 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final String prop; + + /* + * The enumProp property. + */ + @Metadata(generated = true) + private final EnumV2 enumProp; + + /* + * The unionProp property. + */ + @Metadata(generated = true) + private final BinaryData unionProp; + + /** + * Creates an instance of ModelV2 class. + * + * @param prop the prop value to set. + * @param enumProp the enumProp value to set. + * @param unionProp the unionProp value to set. + */ + @Metadata(generated = true) + public ModelV2(String prop, EnumV2 enumProp, BinaryData unionProp) { + this.prop = prop; + this.enumProp = enumProp; + this.unionProp = unionProp; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public String getProp() { + return this.prop; + } + + /** + * Get the enumProp property: The enumProp property. + * + * @return the enumProp value. + */ + @Metadata(generated = true) + public EnumV2 getEnumProp() { + return this.enumProp; + } + + /** + * Get the unionProp property: The unionProp property. + * + * @return the unionProp value. + */ + @Metadata(generated = true) + public BinaryData getUnionProp() { + return this.unionProp; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop); + jsonWriter.writeStringField("enumProp", this.enumProp == null ? null : this.enumProp.toString()); + jsonWriter.writeFieldName("unionProp"); + this.unionProp.writeTo(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ModelV2 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ModelV2 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 ModelV2. + */ + @Metadata(generated = true) + public static ModelV2 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String prop = null; + EnumV2 enumProp = null; + BinaryData unionProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = reader.getString(); + } else if ("enumProp".equals(fieldName)) { + enumProp = EnumV2.fromString(reader.getString()); + } else if ("unionProp".equals(fieldName)) { + unionProp = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new ModelV2(prop, enumProp, unionProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/Versions.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/Versions.java new file mode 100644 index 0000000000..45576312e2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/Versions.java @@ -0,0 +1,54 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.added; + +/** + * The version of the API. + */ +public enum Versions { + /** + * The version v1. + */ + V1("v1"), + + /** + * The version v2. + */ + V2("v2"); + + /** + * The actual serialized value for a Versions instance. + */ + private final String value; + + Versions(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a Versions instance. + * + * @param value the serialized value to parse. + * @return the parsed Versions object, or null if unable to parse. + */ + public static Versions fromString(String value) { + if (value == null) { + return null; + } + Versions[] items = Versions.values(); + for (Versions item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/implementation/AddedClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/implementation/AddedClientImpl.java new file mode 100644 index 0000000000..41935a4491 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/implementation/AddedClientImpl.java @@ -0,0 +1,214 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.added.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.util.binarydata.BinaryData; +import versioning.added.AddedServiceVersion; +import versioning.added.ModelV1; +import versioning.added.ModelV2; +import versioning.added.Versions; + +/** + * Initializes a new instance of the AddedClient type. + */ +public final class AddedClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final AddedClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Need to be set as 'v1' or 'v2' in client. + */ + private final Versions version; + + /** + * Gets Need to be set as 'v1' or 'v2' in client. + * + * @return the version value. + */ + public Versions getVersion() { + return this.version; + } + + /** + * Service version. + */ + private final AddedServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public AddedServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 InterfaceV2sImpl object to access its operations. + */ + private final InterfaceV2sImpl interfaceV2s; + + /** + * Gets the InterfaceV2sImpl object to access its operations. + * + * @return the InterfaceV2sImpl object. + */ + public InterfaceV2sImpl getInterfaceV2s() { + return this.interfaceV2s; + } + + /** + * Initializes an instance of AddedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public AddedClientImpl(HttpPipeline httpPipeline, String endpoint, Versions version, + AddedServiceVersion serviceVersion) { + this.endpoint = endpoint; + this.version = version; + this.serviceVersion = AddedServiceVersion.getLatest(); + this.httpPipeline = httpPipeline; + this.interfaceV2s = new InterfaceV2sImpl(this); + this.service = RestProxy.create(AddedClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for AddedClient to be used by the proxy service to perform REST calls. + */ + @ServiceInterface(name = "AddedClient", host = "{endpoint}/versioning/added/api-version:{version}") + public interface AddedClientService { + @HttpRequestInformation(method = HttpMethod.POST, path = "/v1", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response v1Sync(@HostParam("endpoint") String endpoint, @HostParam("version") Versions version, + @HeaderParam("header-v2") String headerV2, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.POST, path = "/v2", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response v2Sync(@HostParam("endpoint") String endpoint, @HostParam("version") Versions version, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The v1 operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV1/enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV1/enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param headerV2 The headerV2 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 service returns an error. + * @return the response. + */ + public Response v1WithResponse(String headerV2, BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.v1Sync(this.getEndpoint(), this.getVersion(), headerV2, contentType, accept, body, + requestOptions); + } + + /** + * The v2 operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response v2WithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.v2Sync(this.getEndpoint(), this.getVersion(), contentType, accept, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/implementation/InterfaceV2sImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/implementation/InterfaceV2sImpl.java new file mode 100644 index 0000000000..ffd1354c80 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/implementation/InterfaceV2sImpl.java @@ -0,0 +1,105 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.added.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import versioning.added.AddedServiceVersion; +import versioning.added.ModelV2; +import versioning.added.Versions; + +/** + * An instance of this class provides access to all the operations defined in InterfaceV2s. + */ +public final class InterfaceV2sImpl { + /** + * The proxy service used to perform REST calls. + */ + private final InterfaceV2sService service; + + /** + * The service client containing this operation class. + */ + private final AddedClientImpl client; + + /** + * Initializes an instance of InterfaceV2sImpl. + * + * @param client the instance of the service client containing this operation class. + */ + InterfaceV2sImpl(AddedClientImpl client) { + this.service = RestProxy.create(InterfaceV2sService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public AddedServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for AddedClientInterfaceV2s to be used by the proxy service to perform + * REST calls. + */ + @ServiceInterface(name = "AddedClientInterface", host = "{endpoint}/versioning/added/api-version:{version}") + public interface InterfaceV2sService { + @HttpRequestInformation(method = HttpMethod.POST, path = "/interface-v2/v2", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response v2InInterfaceSync(@HostParam("endpoint") String endpoint, + @HostParam("version") Versions version, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * The v2InInterface operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response v2InInterfaceWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.v2InInterfaceSync(this.client.getEndpoint(), this.client.getVersion(), contentType, accept, body, + requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/implementation/package-info.java new file mode 100644 index 0000000000..6700836dcd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Added. + * Test for the `@added` decorator. + */ +package versioning.added.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/package-info.java new file mode 100644 index 0000000000..902f20cc9d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/added/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Added. + * Test for the `@added` decorator. + */ +package versioning.added; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/MadeOptionalClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/MadeOptionalClient.java new file mode 100644 index 0000000000..dc32d95b42 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/MadeOptionalClient.java @@ -0,0 +1,107 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.madeoptional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import versioning.madeoptional.implementation.MadeOptionalClientImpl; + +/** + * Initializes a new instance of the synchronous MadeOptionalClient type. + */ +@ServiceClient(builder = MadeOptionalClientBuilder.class) +public final class MadeOptionalClient { + @Metadata(generated = true) + private final MadeOptionalClientImpl serviceClient; + + /** + * Initializes an instance of MadeOptionalClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + MadeOptionalClient(MadeOptionalClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The test operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
paramStringNoThe param parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response testWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.testWithResponse(body, requestOptions); + } + + /** + * The test operation. + * + * @param body The body parameter. + * @param param The param parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public TestModel test(TestModel body, String param) { + // Generated convenience method for testWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (param != null) { + requestOptions.addQueryParam("param", param); + } + return testWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * The test operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public TestModel test(TestModel body) { + // Generated convenience method for testWithResponse + RequestOptions requestOptions = new RequestOptions(); + return testWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/MadeOptionalClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/MadeOptionalClientBuilder.java new file mode 100644 index 0000000000..8f8a00e530 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/MadeOptionalClientBuilder.java @@ -0,0 +1,281 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.madeoptional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import versioning.madeoptional.implementation.MadeOptionalClientImpl; + +/** + * A builder for creating a new instance of the MadeOptionalClient type. + */ +@ServiceClientBuilder(serviceClients = { MadeOptionalClient.class }) +public final class MadeOptionalClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the MadeOptionalClientBuilder. + */ + @Metadata(generated = true) + public MadeOptionalClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MadeOptionalClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MadeOptionalClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MadeOptionalClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MadeOptionalClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MadeOptionalClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MadeOptionalClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MadeOptionalClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MadeOptionalClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public MadeOptionalClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Need to be set as 'v1' or 'v2' in client. + */ + @Metadata(generated = true) + private Versions version; + + /** + * Sets Need to be set as 'v1' or 'v2' in client. + * + * @param version the version value. + * @return the MadeOptionalClientBuilder. + */ + @Metadata(generated = true) + public MadeOptionalClientBuilder version(Versions version) { + this.version = version; + return this; + } + + /* + * Service version + */ + @Metadata(generated = true) + private MadeOptionalServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the MadeOptionalClientBuilder. + */ + @Metadata(generated = true) + public MadeOptionalClientBuilder serviceVersion(MadeOptionalServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /** + * Builds an instance of MadeOptionalClientImpl with the provided parameters. + * + * @return an instance of MadeOptionalClientImpl. + */ + @Metadata(generated = true) + private MadeOptionalClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + MadeOptionalServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : MadeOptionalServiceVersion.getLatest(); + MadeOptionalClientImpl client + = new MadeOptionalClientImpl(localPipeline, this.endpoint, this.version, localServiceVersion); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(version, "'version' cannot be null."); + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of MadeOptionalClient class. + * + * @return an instance of MadeOptionalClient. + */ + @Metadata(generated = true) + public MadeOptionalClient buildClient() { + return new MadeOptionalClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(MadeOptionalClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/MadeOptionalServiceVersion.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/MadeOptionalServiceVersion.java new file mode 100644 index 0000000000..46f8ac22ed --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/MadeOptionalServiceVersion.java @@ -0,0 +1,43 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.madeoptional; + +import io.clientcore.core.http.models.ServiceVersion; + +/** + * Service version of MadeOptionalClient. + */ +public enum MadeOptionalServiceVersion implements ServiceVersion { + /** + * Enum value v1. + */ + V1("v1"), + + /** + * Enum value v2. + */ + V2("v2"); + + private final String version; + + MadeOptionalServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link MadeOptionalServiceVersion}. + */ + public static MadeOptionalServiceVersion getLatest() { + return V2; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/TestModel.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/TestModel.java new file mode 100644 index 0000000000..2a0fcfaa2b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/TestModel.java @@ -0,0 +1,116 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.madeoptional; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The TestModel model. + */ +@Metadata(conditions = { TypeConditions.FLUENT }) +public final class TestModel implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final String prop; + + /* + * The changedProp property. + */ + @Metadata(generated = true) + private String changedProp; + + /** + * Creates an instance of TestModel class. + * + * @param prop the prop value to set. + */ + @Metadata(generated = true) + public TestModel(String prop) { + this.prop = prop; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public String getProp() { + return this.prop; + } + + /** + * Get the changedProp property: The changedProp property. + * + * @return the changedProp value. + */ + @Metadata(generated = true) + public String getChangedProp() { + return this.changedProp; + } + + /** + * Set the changedProp property: The changedProp property. + * + * @param changedProp the changedProp value to set. + * @return the TestModel object itself. + */ + @Metadata(generated = true) + public TestModel setChangedProp(String changedProp) { + this.changedProp = changedProp; + return this; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop); + jsonWriter.writeStringField("changedProp", this.changedProp); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TestModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TestModel 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 TestModel. + */ + @Metadata(generated = true) + public static TestModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String prop = null; + String changedProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = reader.getString(); + } else if ("changedProp".equals(fieldName)) { + changedProp = reader.getString(); + } else { + reader.skipChildren(); + } + } + TestModel deserializedTestModel = new TestModel(prop); + deserializedTestModel.changedProp = changedProp; + + return deserializedTestModel; + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/Versions.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/Versions.java new file mode 100644 index 0000000000..360049bae6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/Versions.java @@ -0,0 +1,54 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.madeoptional; + +/** + * The version of the API. + */ +public enum Versions { + /** + * The version v1. + */ + V1("v1"), + + /** + * The version v2. + */ + V2("v2"); + + /** + * The actual serialized value for a Versions instance. + */ + private final String value; + + Versions(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a Versions instance. + * + * @param value the serialized value to parse. + * @return the parsed Versions object, or null if unable to parse. + */ + public static Versions fromString(String value) { + if (value == null) { + return null; + } + Versions[] items = Versions.values(); + for (Versions item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/implementation/MadeOptionalClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/implementation/MadeOptionalClientImpl.java new file mode 100644 index 0000000000..203daafb3f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/implementation/MadeOptionalClientImpl.java @@ -0,0 +1,158 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.madeoptional.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.util.binarydata.BinaryData; +import versioning.madeoptional.MadeOptionalServiceVersion; +import versioning.madeoptional.TestModel; +import versioning.madeoptional.Versions; + +/** + * Initializes a new instance of the MadeOptionalClient type. + */ +public final class MadeOptionalClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final MadeOptionalClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Need to be set as 'v1' or 'v2' in client. + */ + private final Versions version; + + /** + * Gets Need to be set as 'v1' or 'v2' in client. + * + * @return the version value. + */ + public Versions getVersion() { + return this.version; + } + + /** + * Service version. + */ + private final MadeOptionalServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public MadeOptionalServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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; + } + + /** + * Initializes an instance of MadeOptionalClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public MadeOptionalClientImpl(HttpPipeline httpPipeline, String endpoint, Versions version, + MadeOptionalServiceVersion serviceVersion) { + this.endpoint = endpoint; + this.version = version; + this.serviceVersion = MadeOptionalServiceVersion.getLatest(); + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(MadeOptionalClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for MadeOptionalClient to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "MadeOptionalClient", host = "{endpoint}/versioning/made-optional/api-version:{version}") + public interface MadeOptionalClientService { + @HttpRequestInformation(method = HttpMethod.POST, path = "/test", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response testSync(@HostParam("endpoint") String endpoint, @HostParam("version") Versions version, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The test operation. + *

Query Parameters

+ * + * + * + * + *
Query Parameters
NameTypeRequiredDescription
paramStringNoThe param parameter
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Optional)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Optional)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response testWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.testSync(this.getEndpoint(), this.getVersion(), contentType, accept, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/implementation/package-info.java new file mode 100644 index 0000000000..2bbcc1c077 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for MadeOptional. + * Test for the `@madeOptional` decorator. + */ +package versioning.madeoptional.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/package-info.java new file mode 100644 index 0000000000..9f68346a6c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/madeoptional/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for MadeOptional. + * Test for the `@madeOptional` decorator. + */ +package versioning.madeoptional; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/EnumV2.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/EnumV2.java new file mode 100644 index 0000000000..f7f4eb217e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/EnumV2.java @@ -0,0 +1,49 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.removed; + +/** + * Defines values for EnumV2. + */ +public enum EnumV2 { + /** + * Enum value enumMemberV2. + */ + ENUM_MEMBER_V2("enumMemberV2"); + + /** + * The actual serialized value for a EnumV2 instance. + */ + private final String value; + + EnumV2(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a EnumV2 instance. + * + * @param value the serialized value to parse. + * @return the parsed EnumV2 object, or null if unable to parse. + */ + public static EnumV2 fromString(String value) { + if (value == null) { + return null; + } + EnumV2[] items = EnumV2.values(); + for (EnumV2 item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/EnumV3.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/EnumV3.java new file mode 100644 index 0000000000..deb7c655da --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/EnumV3.java @@ -0,0 +1,54 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.removed; + +/** + * Defines values for EnumV3. + */ +public enum EnumV3 { + /** + * Enum value enumMemberV1. + */ + ENUM_MEMBER_V1("enumMemberV1"), + + /** + * Enum value enumMemberV2Preview. + */ + ENUM_MEMBER_V2PREVIEW("enumMemberV2Preview"); + + /** + * The actual serialized value for a EnumV3 instance. + */ + private final String value; + + EnumV3(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a EnumV3 instance. + * + * @param value the serialized value to parse. + * @return the parsed EnumV3 object, or null if unable to parse. + */ + public static EnumV3 fromString(String value) { + if (value == null) { + return null; + } + EnumV3[] items = EnumV3.values(); + for (EnumV3 item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/ModelV2.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/ModelV2.java new file mode 100644 index 0000000000..d01012ec03 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/ModelV2.java @@ -0,0 +1,127 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.removed; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; + +/** + * The ModelV2 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class ModelV2 implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final String prop; + + /* + * The enumProp property. + */ + @Metadata(generated = true) + private final EnumV2 enumProp; + + /* + * The unionProp property. + */ + @Metadata(generated = true) + private final BinaryData unionProp; + + /** + * Creates an instance of ModelV2 class. + * + * @param prop the prop value to set. + * @param enumProp the enumProp value to set. + * @param unionProp the unionProp value to set. + */ + @Metadata(generated = true) + public ModelV2(String prop, EnumV2 enumProp, BinaryData unionProp) { + this.prop = prop; + this.enumProp = enumProp; + this.unionProp = unionProp; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public String getProp() { + return this.prop; + } + + /** + * Get the enumProp property: The enumProp property. + * + * @return the enumProp value. + */ + @Metadata(generated = true) + public EnumV2 getEnumProp() { + return this.enumProp; + } + + /** + * Get the unionProp property: The unionProp property. + * + * @return the unionProp value. + */ + @Metadata(generated = true) + public BinaryData getUnionProp() { + return this.unionProp; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop); + jsonWriter.writeStringField("enumProp", this.enumProp == null ? null : this.enumProp.toString()); + jsonWriter.writeFieldName("unionProp"); + this.unionProp.writeTo(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ModelV2 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ModelV2 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 ModelV2. + */ + @Metadata(generated = true) + public static ModelV2 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String prop = null; + EnumV2 enumProp = null; + BinaryData unionProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = reader.getString(); + } else if ("enumProp".equals(fieldName)) { + enumProp = EnumV2.fromString(reader.getString()); + } else if ("unionProp".equals(fieldName)) { + unionProp = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new ModelV2(prop, enumProp, unionProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/ModelV3.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/ModelV3.java new file mode 100644 index 0000000000..752e17d739 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/ModelV3.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.removed; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The ModelV3 model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class ModelV3 implements JsonSerializable { + /* + * The id property. + */ + @Metadata(generated = true) + private final String id; + + /* + * The enumProp property. + */ + @Metadata(generated = true) + private final EnumV3 enumProp; + + /** + * Creates an instance of ModelV3 class. + * + * @param id the id value to set. + * @param enumProp the enumProp value to set. + */ + @Metadata(generated = true) + public ModelV3(String id, EnumV3 enumProp) { + this.id = id; + this.enumProp = enumProp; + } + + /** + * Get the id property: The id property. + * + * @return the id value. + */ + @Metadata(generated = true) + public String getId() { + return this.id; + } + + /** + * Get the enumProp property: The enumProp property. + * + * @return the enumProp value. + */ + @Metadata(generated = true) + public EnumV3 getEnumProp() { + return this.enumProp; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("id", this.id); + jsonWriter.writeStringField("enumProp", this.enumProp == null ? null : this.enumProp.toString()); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of ModelV3 from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of ModelV3 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 ModelV3. + */ + @Metadata(generated = true) + public static ModelV3 fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String id = null; + EnumV3 enumProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("id".equals(fieldName)) { + id = reader.getString(); + } else if ("enumProp".equals(fieldName)) { + enumProp = EnumV3.fromString(reader.getString()); + } else { + reader.skipChildren(); + } + } + return new ModelV3(id, enumProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/RemovedClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/RemovedClient.java new file mode 100644 index 0000000000..e052235376 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/RemovedClient.java @@ -0,0 +1,132 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.removed; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import versioning.removed.implementation.RemovedClientImpl; + +/** + * Initializes a new instance of the synchronous RemovedClient type. + */ +@ServiceClient(builder = RemovedClientBuilder.class) +public final class RemovedClient { + @Metadata(generated = true) + private final RemovedClientImpl serviceClient; + + /** + * Initializes an instance of RemovedClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + RemovedClient(RemovedClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The v2 operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response v2WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.v2WithResponse(body, requestOptions); + } + + /** + * This operation will pass different paths and different request bodies based on different versions. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     enumProp: String(enumMemberV1/enumMemberV2Preview) (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     enumProp: String(enumMemberV1/enumMemberV2Preview) (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response modelV3WithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.modelV3WithResponse(body, requestOptions); + } + + /** + * The v2 operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public ModelV2 v2(ModelV2 body) { + // Generated convenience method for v2WithResponse + RequestOptions requestOptions = new RequestOptions(); + return v2WithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } + + /** + * This operation will pass different paths and different request bodies based on different versions. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public ModelV3 modelV3(ModelV3 body) { + // Generated convenience method for modelV3WithResponse + RequestOptions requestOptions = new RequestOptions(); + return modelV3WithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/RemovedClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/RemovedClientBuilder.java new file mode 100644 index 0000000000..ed235b0073 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/RemovedClientBuilder.java @@ -0,0 +1,280 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.removed; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import versioning.removed.implementation.RemovedClientImpl; + +/** + * A builder for creating a new instance of the RemovedClient type. + */ +@ServiceClientBuilder(serviceClients = { RemovedClient.class }) +public final class RemovedClientBuilder implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the RemovedClientBuilder. + */ + @Metadata(generated = true) + public RemovedClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RemovedClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RemovedClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RemovedClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RemovedClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RemovedClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RemovedClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RemovedClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RemovedClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RemovedClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Need to be set as 'v1', 'v2preview' or 'v2' in client. + */ + @Metadata(generated = true) + private Versions version; + + /** + * Sets Need to be set as 'v1', 'v2preview' or 'v2' in client. + * + * @param version the version value. + * @return the RemovedClientBuilder. + */ + @Metadata(generated = true) + public RemovedClientBuilder version(Versions version) { + this.version = version; + return this; + } + + /* + * Service version + */ + @Metadata(generated = true) + private RemovedServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the RemovedClientBuilder. + */ + @Metadata(generated = true) + public RemovedClientBuilder serviceVersion(RemovedServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /** + * Builds an instance of RemovedClientImpl with the provided parameters. + * + * @return an instance of RemovedClientImpl. + */ + @Metadata(generated = true) + private RemovedClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + RemovedServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : RemovedServiceVersion.getLatest(); + RemovedClientImpl client + = new RemovedClientImpl(localPipeline, this.endpoint, this.version, localServiceVersion); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(version, "'version' cannot be null."); + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of RemovedClient class. + * + * @return an instance of RemovedClient. + */ + @Metadata(generated = true) + public RemovedClient buildClient() { + return new RemovedClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(RemovedClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/RemovedServiceVersion.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/RemovedServiceVersion.java new file mode 100644 index 0000000000..23b08c8597 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/RemovedServiceVersion.java @@ -0,0 +1,48 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.removed; + +import io.clientcore.core.http.models.ServiceVersion; + +/** + * Service version of RemovedClient. + */ +public enum RemovedServiceVersion implements ServiceVersion { + /** + * Enum value v1. + */ + V1("v1"), + + /** + * Enum value v2preview. + */ + V2PREVIEW("v2preview"), + + /** + * Enum value v2. + */ + V2("v2"); + + private final String version; + + RemovedServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link RemovedServiceVersion}. + */ + public static RemovedServiceVersion getLatest() { + return V2; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/Versions.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/Versions.java new file mode 100644 index 0000000000..c11bf6eca6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/Versions.java @@ -0,0 +1,59 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.removed; + +/** + * The version of the API. + */ +public enum Versions { + /** + * The version v1. + */ + V1("v1"), + + /** + * The V2 Preview version. + */ + V2PREVIEW("v2preview"), + + /** + * The version v2. + */ + V2("v2"); + + /** + * The actual serialized value for a Versions instance. + */ + private final String value; + + Versions(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a Versions instance. + * + * @param value the serialized value to parse. + * @return the parsed Versions object, or null if unable to parse. + */ + public static Versions fromString(String value) { + if (value == null) { + return null; + } + Versions[] items = Versions.values(); + for (Versions item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/implementation/RemovedClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/implementation/RemovedClientImpl.java new file mode 100644 index 0000000000..266609fc7a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/implementation/RemovedClientImpl.java @@ -0,0 +1,194 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.removed.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.util.binarydata.BinaryData; +import versioning.removed.ModelV2; +import versioning.removed.ModelV3; +import versioning.removed.RemovedServiceVersion; +import versioning.removed.Versions; + +/** + * Initializes a new instance of the RemovedClient type. + */ +public final class RemovedClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RemovedClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Need to be set as 'v1', 'v2preview' or 'v2' in client. + */ + private final Versions version; + + /** + * Gets Need to be set as 'v1', 'v2preview' or 'v2' in client. + * + * @return the version value. + */ + public Versions getVersion() { + return this.version; + } + + /** + * Service version. + */ + private final RemovedServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public RemovedServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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; + } + + /** + * Initializes an instance of RemovedClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1', 'v2preview' or 'v2' in client. + * @param serviceVersion Service version. + */ + public RemovedClientImpl(HttpPipeline httpPipeline, String endpoint, Versions version, + RemovedServiceVersion serviceVersion) { + this.endpoint = endpoint; + this.version = version; + this.serviceVersion = RemovedServiceVersion.getLatest(); + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(RemovedClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for RemovedClient to be used by the proxy service to perform REST calls. + */ + @ServiceInterface(name = "RemovedClient", host = "{endpoint}/versioning/removed/api-version:{version}") + public interface RemovedClientService { + @HttpRequestInformation(method = HttpMethod.POST, path = "/v2", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response v2Sync(@HostParam("endpoint") String endpoint, @HostParam("version") Versions version, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + + @HttpRequestInformation(method = HttpMethod.POST, path = "/v3", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response modelV3Sync(@HostParam("endpoint") String endpoint, @HostParam("version") Versions version, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The v2 operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     enumProp: String(enumMemberV2) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response v2WithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.v2Sync(this.getEndpoint(), this.getVersion(), contentType, accept, body, requestOptions); + } + + /** + * This operation will pass different paths and different request bodies based on different versions. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     enumProp: String(enumMemberV1/enumMemberV2Preview) (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     id: String (Required)
+     *     enumProp: String(enumMemberV1/enumMemberV2Preview) (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response modelV3WithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.modelV3Sync(this.getEndpoint(), this.getVersion(), contentType, accept, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/implementation/package-info.java new file mode 100644 index 0000000000..6ebf2ef26d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for Removed. + * Test for the `@removed` decorator. + */ +package versioning.removed.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/package-info.java new file mode 100644 index 0000000000..1f1e43a412 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/removed/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for Removed. + * Test for the `@removed` decorator. + */ +package versioning.removed; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/NewEnum.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/NewEnum.java new file mode 100644 index 0000000000..8ced0f4570 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/NewEnum.java @@ -0,0 +1,49 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.renamedfrom; + +/** + * Defines values for NewEnum. + */ +public enum NewEnum { + /** + * Enum value newEnumMember. + */ + NEW_ENUM_MEMBER("newEnumMember"); + + /** + * The actual serialized value for a NewEnum instance. + */ + private final String value; + + NewEnum(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a NewEnum instance. + * + * @param value the serialized value to parse. + * @return the parsed NewEnum object, or null if unable to parse. + */ + public static NewEnum fromString(String value) { + if (value == null) { + return null; + } + NewEnum[] items = NewEnum.values(); + for (NewEnum item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/NewInterfaceClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/NewInterfaceClient.java new file mode 100644 index 0000000000..369bbed0b7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/NewInterfaceClient.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.renamedfrom; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import versioning.renamedfrom.implementation.NewInterfacesImpl; + +/** + * Initializes a new instance of the synchronous RenamedFromClient type. + */ +@ServiceClient(builder = RenamedFromClientBuilder.class) +public final class NewInterfaceClient { + @Metadata(generated = true) + private final NewInterfacesImpl serviceClient; + + /** + * Initializes an instance of NewInterfaceClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + NewInterfaceClient(NewInterfacesImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The newOpInNewInterface operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response newOpInNewInterfaceWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.newOpInNewInterfaceWithResponse(body, requestOptions); + } + + /** + * The newOpInNewInterface operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public NewModel newOpInNewInterface(NewModel body) { + // Generated convenience method for newOpInNewInterfaceWithResponse + RequestOptions requestOptions = new RequestOptions(); + return newOpInNewInterfaceWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/NewModel.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/NewModel.java new file mode 100644 index 0000000000..bbce73db41 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/NewModel.java @@ -0,0 +1,127 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.renamedfrom; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; + +/** + * The NewModel model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class NewModel implements JsonSerializable { + /* + * The newProp property. + */ + @Metadata(generated = true) + private final String newProp; + + /* + * The enumProp property. + */ + @Metadata(generated = true) + private final NewEnum enumProp; + + /* + * The unionProp property. + */ + @Metadata(generated = true) + private final BinaryData unionProp; + + /** + * Creates an instance of NewModel class. + * + * @param newProp the newProp value to set. + * @param enumProp the enumProp value to set. + * @param unionProp the unionProp value to set. + */ + @Metadata(generated = true) + public NewModel(String newProp, NewEnum enumProp, BinaryData unionProp) { + this.newProp = newProp; + this.enumProp = enumProp; + this.unionProp = unionProp; + } + + /** + * Get the newProp property: The newProp property. + * + * @return the newProp value. + */ + @Metadata(generated = true) + public String getNewProp() { + return this.newProp; + } + + /** + * Get the enumProp property: The enumProp property. + * + * @return the enumProp value. + */ + @Metadata(generated = true) + public NewEnum getEnumProp() { + return this.enumProp; + } + + /** + * Get the unionProp property: The unionProp property. + * + * @return the unionProp value. + */ + @Metadata(generated = true) + public BinaryData getUnionProp() { + return this.unionProp; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("newProp", this.newProp); + jsonWriter.writeStringField("enumProp", this.enumProp == null ? null : this.enumProp.toString()); + jsonWriter.writeFieldName("unionProp"); + this.unionProp.writeTo(jsonWriter); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of NewModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of NewModel 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 NewModel. + */ + @Metadata(generated = true) + public static NewModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String newProp = null; + NewEnum enumProp = null; + BinaryData unionProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("newProp".equals(fieldName)) { + newProp = reader.getString(); + } else if ("enumProp".equals(fieldName)) { + enumProp = NewEnum.fromString(reader.getString()); + } else if ("unionProp".equals(fieldName)) { + unionProp = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped())); + } else { + reader.skipChildren(); + } + } + return new NewModel(newProp, enumProp, unionProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/RenamedFromClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/RenamedFromClient.java new file mode 100644 index 0000000000..df754448af --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/RenamedFromClient.java @@ -0,0 +1,84 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.renamedfrom; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import versioning.renamedfrom.implementation.RenamedFromClientImpl; + +/** + * Initializes a new instance of the synchronous RenamedFromClient type. + */ +@ServiceClient(builder = RenamedFromClientBuilder.class) +public final class RenamedFromClient { + @Metadata(generated = true) + private final RenamedFromClientImpl serviceClient; + + /** + * Initializes an instance of RenamedFromClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + RenamedFromClient(RenamedFromClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The newOp operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param newQuery The newQuery 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 service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response newOpWithResponse(String newQuery, BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.newOpWithResponse(newQuery, body, requestOptions); + } + + /** + * The newOp operation. + * + * @param newQuery The newQuery parameter. + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public NewModel newOp(String newQuery, NewModel body) { + // Generated convenience method for newOpWithResponse + RequestOptions requestOptions = new RequestOptions(); + return newOpWithResponse(newQuery, BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/RenamedFromClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/RenamedFromClientBuilder.java new file mode 100644 index 0000000000..d2b9274bc1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/RenamedFromClientBuilder.java @@ -0,0 +1,291 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.renamedfrom; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import versioning.renamedfrom.implementation.RenamedFromClientImpl; + +/** + * A builder for creating a new instance of the RenamedFromClient type. + */ +@ServiceClientBuilder(serviceClients = { RenamedFromClient.class, NewInterfaceClient.class }) +public final class RenamedFromClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the RenamedFromClientBuilder. + */ + @Metadata(generated = true) + public RenamedFromClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RenamedFromClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RenamedFromClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RenamedFromClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RenamedFromClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RenamedFromClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RenamedFromClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RenamedFromClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RenamedFromClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public RenamedFromClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Need to be set as 'v1' or 'v2' in client. + */ + @Metadata(generated = true) + private Versions version; + + /** + * Sets Need to be set as 'v1' or 'v2' in client. + * + * @param version the version value. + * @return the RenamedFromClientBuilder. + */ + @Metadata(generated = true) + public RenamedFromClientBuilder version(Versions version) { + this.version = version; + return this; + } + + /* + * Service version + */ + @Metadata(generated = true) + private RenamedFromServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the RenamedFromClientBuilder. + */ + @Metadata(generated = true) + public RenamedFromClientBuilder serviceVersion(RenamedFromServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /** + * Builds an instance of RenamedFromClientImpl with the provided parameters. + * + * @return an instance of RenamedFromClientImpl. + */ + @Metadata(generated = true) + private RenamedFromClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + RenamedFromServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : RenamedFromServiceVersion.getLatest(); + RenamedFromClientImpl client + = new RenamedFromClientImpl(localPipeline, this.endpoint, this.version, localServiceVersion); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(version, "'version' cannot be null."); + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of RenamedFromClient class. + * + * @return an instance of RenamedFromClient. + */ + @Metadata(generated = true) + public RenamedFromClient buildClient() { + return new RenamedFromClient(buildInnerClient()); + } + + /** + * Builds an instance of NewInterfaceClient class. + * + * @return an instance of NewInterfaceClient. + */ + @Metadata(generated = true) + public NewInterfaceClient buildNewInterfaceClient() { + return new NewInterfaceClient(buildInnerClient().getNewInterfaces()); + } + + private static final ClientLogger LOGGER = new ClientLogger(RenamedFromClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/RenamedFromServiceVersion.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/RenamedFromServiceVersion.java new file mode 100644 index 0000000000..db8768b7fb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/RenamedFromServiceVersion.java @@ -0,0 +1,43 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.renamedfrom; + +import io.clientcore.core.http.models.ServiceVersion; + +/** + * Service version of RenamedFromClient. + */ +public enum RenamedFromServiceVersion implements ServiceVersion { + /** + * Enum value v1. + */ + V1("v1"), + + /** + * Enum value v2. + */ + V2("v2"); + + private final String version; + + RenamedFromServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link RenamedFromServiceVersion}. + */ + public static RenamedFromServiceVersion getLatest() { + return V2; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/Versions.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/Versions.java new file mode 100644 index 0000000000..372be5a541 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/Versions.java @@ -0,0 +1,54 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.renamedfrom; + +/** + * The version of the API. + */ +public enum Versions { + /** + * The version v1. + */ + V1("v1"), + + /** + * The version v2. + */ + V2("v2"); + + /** + * The actual serialized value for a Versions instance. + */ + private final String value; + + Versions(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a Versions instance. + * + * @param value the serialized value to parse. + * @return the parsed Versions object, or null if unable to parse. + */ + public static Versions fromString(String value) { + if (value == null) { + return null; + } + Versions[] items = Versions.values(); + for (Versions item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/implementation/NewInterfacesImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/implementation/NewInterfacesImpl.java new file mode 100644 index 0000000000..1398da54c3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/implementation/NewInterfacesImpl.java @@ -0,0 +1,105 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.renamedfrom.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import versioning.renamedfrom.NewModel; +import versioning.renamedfrom.RenamedFromServiceVersion; +import versioning.renamedfrom.Versions; + +/** + * An instance of this class provides access to all the operations defined in NewInterfaces. + */ +public final class NewInterfacesImpl { + /** + * The proxy service used to perform REST calls. + */ + private final NewInterfacesService service; + + /** + * The service client containing this operation class. + */ + private final RenamedFromClientImpl client; + + /** + * Initializes an instance of NewInterfacesImpl. + * + * @param client the instance of the service client containing this operation class. + */ + NewInterfacesImpl(RenamedFromClientImpl client) { + this.service = RestProxy.create(NewInterfacesService.class, client.getHttpPipeline()); + this.client = client; + } + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public RenamedFromServiceVersion getServiceVersion() { + return client.getServiceVersion(); + } + + /** + * The interface defining all the services for RenamedFromClientNewInterfaces to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface(name = "RenamedFromClientNew", host = "{endpoint}/versioning/renamed-from/api-version:{version}") + public interface NewInterfacesService { + @HttpRequestInformation(method = HttpMethod.POST, path = "/interface/test", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response newOpInNewInterfaceSync(@HostParam("endpoint") String endpoint, + @HostParam("version") Versions version, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * The newOpInNewInterface operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return the response. + */ + public Response newOpInNewInterfaceWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.newOpInNewInterfaceSync(this.client.getEndpoint(), this.client.getVersion(), contentType, accept, + body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/implementation/RenamedFromClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/implementation/RenamedFromClientImpl.java new file mode 100644 index 0000000000..e27ec85f1a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/implementation/RenamedFromClientImpl.java @@ -0,0 +1,172 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.renamedfrom.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.QueryParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.util.binarydata.BinaryData; +import versioning.renamedfrom.NewModel; +import versioning.renamedfrom.RenamedFromServiceVersion; +import versioning.renamedfrom.Versions; + +/** + * Initializes a new instance of the RenamedFromClient type. + */ +public final class RenamedFromClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final RenamedFromClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Need to be set as 'v1' or 'v2' in client. + */ + private final Versions version; + + /** + * Gets Need to be set as 'v1' or 'v2' in client. + * + * @return the version value. + */ + public Versions getVersion() { + return this.version; + } + + /** + * Service version. + */ + private final RenamedFromServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public RenamedFromServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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 NewInterfacesImpl object to access its operations. + */ + private final NewInterfacesImpl newInterfaces; + + /** + * Gets the NewInterfacesImpl object to access its operations. + * + * @return the NewInterfacesImpl object. + */ + public NewInterfacesImpl getNewInterfaces() { + return this.newInterfaces; + } + + /** + * Initializes an instance of RenamedFromClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public RenamedFromClientImpl(HttpPipeline httpPipeline, String endpoint, Versions version, + RenamedFromServiceVersion serviceVersion) { + this.endpoint = endpoint; + this.version = version; + this.serviceVersion = RenamedFromServiceVersion.getLatest(); + this.httpPipeline = httpPipeline; + this.newInterfaces = new NewInterfacesImpl(this); + this.service = RestProxy.create(RenamedFromClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for RenamedFromClient to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface(name = "RenamedFromClient", host = "{endpoint}/versioning/renamed-from/api-version:{version}") + public interface RenamedFromClientService { + @HttpRequestInformation(method = HttpMethod.POST, path = "/test", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response newOpSync(@HostParam("endpoint") String endpoint, @HostParam("version") Versions version, + @QueryParam("newQuery") String newQuery, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * The newOp operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     newProp: String (Required)
+     *     enumProp: String(newEnumMember) (Required)
+     *     unionProp: BinaryData (Required)
+     * }
+     * }
+     * 
+ * + * @param newQuery The newQuery 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 service returns an error. + * @return the response. + */ + public Response newOpWithResponse(String newQuery, BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.newOpSync(this.getEndpoint(), this.getVersion(), newQuery, contentType, accept, body, + requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/implementation/package-info.java new file mode 100644 index 0000000000..7daeaef56f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for RenamedFrom. + * Test for the `@renamedFrom` decorator. + */ +package versioning.renamedfrom.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/package-info.java new file mode 100644 index 0000000000..154377458d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/renamedfrom/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for RenamedFrom. + * Test for the `@renamedFrom` decorator. + */ +package versioning.renamedfrom; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/ReturnTypeChangedFromClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/ReturnTypeChangedFromClient.java new file mode 100644 index 0000000000..1d387158ed --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/ReturnTypeChangedFromClient.java @@ -0,0 +1,74 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.returntypechangedfrom; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import versioning.returntypechangedfrom.implementation.ReturnTypeChangedFromClientImpl; + +/** + * Initializes a new instance of the synchronous ReturnTypeChangedFromClient type. + */ +@ServiceClient(builder = ReturnTypeChangedFromClientBuilder.class) +public final class ReturnTypeChangedFromClient { + @Metadata(generated = true) + private final ReturnTypeChangedFromClientImpl serviceClient; + + /** + * Initializes an instance of ReturnTypeChangedFromClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + ReturnTypeChangedFromClient(ReturnTypeChangedFromClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The test operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * String
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * String
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a sequence of textual characters. + */ + @Metadata(generated = true) + public Response testWithResponse(BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.testWithResponse(body, requestOptions); + } + + /** + * The test operation. + * + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a sequence of textual characters. + */ + @Metadata(generated = true) + public String test(String body) { + // Generated convenience method for testWithResponse + RequestOptions requestOptions = new RequestOptions(); + return testWithResponse(BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/ReturnTypeChangedFromClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/ReturnTypeChangedFromClientBuilder.java new file mode 100644 index 0000000000..d3866d0a09 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/ReturnTypeChangedFromClientBuilder.java @@ -0,0 +1,281 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.returntypechangedfrom; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import versioning.returntypechangedfrom.implementation.ReturnTypeChangedFromClientImpl; + +/** + * A builder for creating a new instance of the ReturnTypeChangedFromClient type. + */ +@ServiceClientBuilder(serviceClients = { ReturnTypeChangedFromClient.class }) +public final class ReturnTypeChangedFromClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the ReturnTypeChangedFromClientBuilder. + */ + @Metadata(generated = true) + public ReturnTypeChangedFromClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ReturnTypeChangedFromClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ReturnTypeChangedFromClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ReturnTypeChangedFromClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ReturnTypeChangedFromClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ReturnTypeChangedFromClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ReturnTypeChangedFromClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ReturnTypeChangedFromClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ReturnTypeChangedFromClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public ReturnTypeChangedFromClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Need to be set as 'v1' or 'v2' in client. + */ + @Metadata(generated = true) + private Versions version; + + /** + * Sets Need to be set as 'v1' or 'v2' in client. + * + * @param version the version value. + * @return the ReturnTypeChangedFromClientBuilder. + */ + @Metadata(generated = true) + public ReturnTypeChangedFromClientBuilder version(Versions version) { + this.version = version; + return this; + } + + /* + * Service version + */ + @Metadata(generated = true) + private ReturnTypeChangedFromServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the ReturnTypeChangedFromClientBuilder. + */ + @Metadata(generated = true) + public ReturnTypeChangedFromClientBuilder serviceVersion(ReturnTypeChangedFromServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /** + * Builds an instance of ReturnTypeChangedFromClientImpl with the provided parameters. + * + * @return an instance of ReturnTypeChangedFromClientImpl. + */ + @Metadata(generated = true) + private ReturnTypeChangedFromClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + ReturnTypeChangedFromServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : ReturnTypeChangedFromServiceVersion.getLatest(); + ReturnTypeChangedFromClientImpl client + = new ReturnTypeChangedFromClientImpl(localPipeline, this.endpoint, this.version, localServiceVersion); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(version, "'version' cannot be null."); + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of ReturnTypeChangedFromClient class. + * + * @return an instance of ReturnTypeChangedFromClient. + */ + @Metadata(generated = true) + public ReturnTypeChangedFromClient buildClient() { + return new ReturnTypeChangedFromClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(ReturnTypeChangedFromClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/ReturnTypeChangedFromServiceVersion.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/ReturnTypeChangedFromServiceVersion.java new file mode 100644 index 0000000000..1a5f85cf39 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/ReturnTypeChangedFromServiceVersion.java @@ -0,0 +1,43 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.returntypechangedfrom; + +import io.clientcore.core.http.models.ServiceVersion; + +/** + * Service version of ReturnTypeChangedFromClient. + */ +public enum ReturnTypeChangedFromServiceVersion implements ServiceVersion { + /** + * Enum value v1. + */ + V1("v1"), + + /** + * Enum value v2. + */ + V2("v2"); + + private final String version; + + ReturnTypeChangedFromServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link ReturnTypeChangedFromServiceVersion}. + */ + public static ReturnTypeChangedFromServiceVersion getLatest() { + return V2; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/Versions.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/Versions.java new file mode 100644 index 0000000000..70f04b5020 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/Versions.java @@ -0,0 +1,54 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.returntypechangedfrom; + +/** + * The version of the API. + */ +public enum Versions { + /** + * The version v1. + */ + V1("v1"), + + /** + * The version v2. + */ + V2("v2"); + + /** + * The actual serialized value for a Versions instance. + */ + private final String value; + + Versions(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a Versions instance. + * + * @param value the serialized value to parse. + * @return the parsed Versions object, or null if unable to parse. + */ + public static Versions fromString(String value) { + if (value == null) { + return null; + } + Versions[] items = Versions.values(); + for (Versions item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/implementation/ReturnTypeChangedFromClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/implementation/ReturnTypeChangedFromClientImpl.java new file mode 100644 index 0000000000..5bd4bf4492 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/implementation/ReturnTypeChangedFromClientImpl.java @@ -0,0 +1,146 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.returntypechangedfrom.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.util.binarydata.BinaryData; +import versioning.returntypechangedfrom.ReturnTypeChangedFromServiceVersion; +import versioning.returntypechangedfrom.Versions; + +/** + * Initializes a new instance of the ReturnTypeChangedFromClient type. + */ +public final class ReturnTypeChangedFromClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final ReturnTypeChangedFromClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Need to be set as 'v1' or 'v2' in client. + */ + private final Versions version; + + /** + * Gets Need to be set as 'v1' or 'v2' in client. + * + * @return the version value. + */ + public Versions getVersion() { + return this.version; + } + + /** + * Service version. + */ + private final ReturnTypeChangedFromServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public ReturnTypeChangedFromServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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; + } + + /** + * Initializes an instance of ReturnTypeChangedFromClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public ReturnTypeChangedFromClientImpl(HttpPipeline httpPipeline, String endpoint, Versions version, + ReturnTypeChangedFromServiceVersion serviceVersion) { + this.endpoint = endpoint; + this.version = version; + this.serviceVersion = ReturnTypeChangedFromServiceVersion.getLatest(); + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(ReturnTypeChangedFromClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for ReturnTypeChangedFromClient to be used by the proxy service to + * perform REST calls. + */ + @ServiceInterface( + name = "ReturnTypeChangedFro", + host = "{endpoint}/versioning/return-type-changed-from/api-version:{version}") + public interface ReturnTypeChangedFromClientService { + @HttpRequestInformation(method = HttpMethod.POST, path = "/test", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response testSync(@HostParam("endpoint") String endpoint, @HostParam("version") Versions version, + @HeaderParam("Content-Type") String contentType, @HeaderParam("Accept") String accept, + @BodyParam("application/json") BinaryData body, RequestOptions requestOptions); + } + + /** + * The test operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * String
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * String
+     * }
+     * 
+ * + * @param body The body parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the service returns an error. + * @return a sequence of textual characters. + */ + public Response testWithResponse(BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.testSync(this.getEndpoint(), this.getVersion(), contentType, accept, body, requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/implementation/package-info.java new file mode 100644 index 0000000000..23d34cb3dd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for ReturnTypeChangedFrom. + * Test for the `@returnTypeChangedFrom` decorator. + */ +package versioning.returntypechangedfrom.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/package-info.java new file mode 100644 index 0000000000..b5184ee2d2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/returntypechangedfrom/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for ReturnTypeChangedFrom. + * Test for the `@returnTypeChangedFrom` decorator. + */ +package versioning.returntypechangedfrom; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/TestModel.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/TestModel.java new file mode 100644 index 0000000000..61a2e1e104 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/TestModel.java @@ -0,0 +1,103 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.typechangedfrom; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.TypeConditions; +import io.clientcore.core.serialization.json.JsonReader; +import io.clientcore.core.serialization.json.JsonSerializable; +import io.clientcore.core.serialization.json.JsonToken; +import io.clientcore.core.serialization.json.JsonWriter; +import java.io.IOException; + +/** + * The TestModel model. + */ +@Metadata(conditions = { TypeConditions.IMMUTABLE }) +public final class TestModel implements JsonSerializable { + /* + * The prop property. + */ + @Metadata(generated = true) + private final String prop; + + /* + * The changedProp property. + */ + @Metadata(generated = true) + private final String changedProp; + + /** + * Creates an instance of TestModel class. + * + * @param prop the prop value to set. + * @param changedProp the changedProp value to set. + */ + @Metadata(generated = true) + public TestModel(String prop, String changedProp) { + this.prop = prop; + this.changedProp = changedProp; + } + + /** + * Get the prop property: The prop property. + * + * @return the prop value. + */ + @Metadata(generated = true) + public String getProp() { + return this.prop; + } + + /** + * Get the changedProp property: The changedProp property. + * + * @return the changedProp value. + */ + @Metadata(generated = true) + public String getChangedProp() { + return this.changedProp; + } + + /** + * {@inheritDoc} + */ + @Metadata(generated = true) + @Override + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { + jsonWriter.writeStartObject(); + jsonWriter.writeStringField("prop", this.prop); + jsonWriter.writeStringField("changedProp", this.changedProp); + return jsonWriter.writeEndObject(); + } + + /** + * Reads an instance of TestModel from the JsonReader. + * + * @param jsonReader The JsonReader being read. + * @return An instance of TestModel 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 TestModel. + */ + @Metadata(generated = true) + public static TestModel fromJson(JsonReader jsonReader) throws IOException { + return jsonReader.readObject(reader -> { + String prop = null; + String changedProp = null; + while (reader.nextToken() != JsonToken.END_OBJECT) { + String fieldName = reader.getFieldName(); + reader.nextToken(); + + if ("prop".equals(fieldName)) { + prop = reader.getString(); + } else if ("changedProp".equals(fieldName)) { + changedProp = reader.getString(); + } else { + reader.skipChildren(); + } + } + return new TestModel(prop, changedProp); + }); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/TypeChangedFromClient.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/TypeChangedFromClient.java new file mode 100644 index 0000000000..8823530f85 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/TypeChangedFromClient.java @@ -0,0 +1,82 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.typechangedfrom; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClient; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.util.binarydata.BinaryData; +import versioning.typechangedfrom.implementation.TypeChangedFromClientImpl; + +/** + * Initializes a new instance of the synchronous TypeChangedFromClient type. + */ +@ServiceClient(builder = TypeChangedFromClientBuilder.class) +public final class TypeChangedFromClient { + @Metadata(generated = true) + private final TypeChangedFromClientImpl serviceClient; + + /** + * Initializes an instance of TypeChangedFromClient class. + * + * @param serviceClient the service client implementation. + */ + @Metadata(generated = true) + TypeChangedFromClient(TypeChangedFromClientImpl serviceClient) { + this.serviceClient = serviceClient; + } + + /** + * The test operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Required)
+     * }
+     * }
+     * 
+ * + * @param param The param 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 service returns an error. + * @return the response. + */ + @Metadata(generated = true) + public Response testWithResponse(String param, BinaryData body, RequestOptions requestOptions) { + return this.serviceClient.testWithResponse(param, body, requestOptions); + } + + /** + * The test operation. + * + * @param param The param parameter. + * @param body The body parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the service returns an error. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Metadata(generated = true) + public TestModel test(String param, TestModel body) { + // Generated convenience method for testWithResponse + RequestOptions requestOptions = new RequestOptions(); + return testWithResponse(param, BinaryData.fromObject(body), requestOptions).getValue(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/TypeChangedFromClientBuilder.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/TypeChangedFromClientBuilder.java new file mode 100644 index 0000000000..5e6a581b6f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/TypeChangedFromClientBuilder.java @@ -0,0 +1,281 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.typechangedfrom; + +import io.clientcore.core.annotation.Metadata; +import io.clientcore.core.annotation.ServiceClientBuilder; +import io.clientcore.core.http.client.HttpClient; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRedirectOptions; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.http.models.ProxyOptions; +import io.clientcore.core.http.pipeline.HttpLoggingPolicy; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.http.pipeline.HttpPipelineBuilder; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.http.pipeline.HttpRedirectPolicy; +import io.clientcore.core.http.pipeline.HttpRetryPolicy; +import io.clientcore.core.models.traits.ConfigurationTrait; +import io.clientcore.core.models.traits.EndpointTrait; +import io.clientcore.core.models.traits.HttpTrait; +import io.clientcore.core.models.traits.ProxyTrait; +import io.clientcore.core.util.ClientLogger; +import io.clientcore.core.util.configuration.Configuration; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import versioning.typechangedfrom.implementation.TypeChangedFromClientImpl; + +/** + * A builder for creating a new instance of the TypeChangedFromClient type. + */ +@ServiceClientBuilder(serviceClients = { TypeChangedFromClient.class }) +public final class TypeChangedFromClientBuilder + implements HttpTrait, ProxyTrait, + ConfigurationTrait, EndpointTrait { + @Metadata(generated = true) + private static final String SDK_NAME = "name"; + + @Metadata(generated = true) + private static final String SDK_VERSION = "version"; + + @Metadata(generated = true) + private final List pipelinePolicies; + + /** + * Create an instance of the TypeChangedFromClientBuilder. + */ + @Metadata(generated = true) + public TypeChangedFromClientBuilder() { + this.pipelinePolicies = new ArrayList<>(); + } + + /* + * The HTTP pipeline to send requests through. + */ + @Metadata(generated = true) + private HttpPipeline pipeline; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public TypeChangedFromClientBuilder httpPipeline(HttpPipeline pipeline) { + if (this.pipeline != null && pipeline == null) { + LOGGER.atInfo().log("HttpPipeline is being set to 'null' when it was previously configured."); + } + this.pipeline = pipeline; + return this; + } + + /* + * The HTTP client used to send the request. + */ + @Metadata(generated = true) + private HttpClient httpClient; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public TypeChangedFromClientBuilder httpClient(HttpClient httpClient) { + this.httpClient = httpClient; + return this; + } + + /* + * The logging configuration for HTTP requests and responses. + */ + @Metadata(generated = true) + private HttpLogOptions httpLogOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public TypeChangedFromClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) { + this.httpLogOptions = httpLogOptions; + return this; + } + + /* + * The retry options to configure retry policy for failed requests. + */ + @Metadata(generated = true) + private HttpRetryOptions retryOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public TypeChangedFromClientBuilder httpRetryOptions(HttpRetryOptions retryOptions) { + this.retryOptions = retryOptions; + return this; + } + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public TypeChangedFromClientBuilder addHttpPipelinePolicy(HttpPipelinePolicy customPolicy) { + Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null."); + pipelinePolicies.add(customPolicy); + return this; + } + + /* + * The redirect options to configure redirect policy + */ + @Metadata(generated = true) + private HttpRedirectOptions redirectOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public TypeChangedFromClientBuilder httpRedirectOptions(HttpRedirectOptions redirectOptions) { + this.redirectOptions = redirectOptions; + return this; + } + + /* + * The proxy options used during construction of the service client. + */ + @Metadata(generated = true) + private ProxyOptions proxyOptions; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public TypeChangedFromClientBuilder proxyOptions(ProxyOptions proxyOptions) { + this.proxyOptions = proxyOptions; + return this; + } + + /* + * The configuration store that is used during construction of the service client. + */ + @Metadata(generated = true) + private Configuration configuration; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public TypeChangedFromClientBuilder configuration(Configuration configuration) { + this.configuration = configuration; + return this; + } + + /* + * The service endpoint + */ + @Metadata(generated = true) + private String endpoint; + + /** + * {@inheritDoc}. + */ + @Metadata(generated = true) + @Override + public TypeChangedFromClientBuilder endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /* + * Need to be set as 'v1' or 'v2' in client. + */ + @Metadata(generated = true) + private Versions version; + + /** + * Sets Need to be set as 'v1' or 'v2' in client. + * + * @param version the version value. + * @return the TypeChangedFromClientBuilder. + */ + @Metadata(generated = true) + public TypeChangedFromClientBuilder version(Versions version) { + this.version = version; + return this; + } + + /* + * Service version + */ + @Metadata(generated = true) + private TypeChangedFromServiceVersion serviceVersion; + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the TypeChangedFromClientBuilder. + */ + @Metadata(generated = true) + public TypeChangedFromClientBuilder serviceVersion(TypeChangedFromServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } + + /** + * Builds an instance of TypeChangedFromClientImpl with the provided parameters. + * + * @return an instance of TypeChangedFromClientImpl. + */ + @Metadata(generated = true) + private TypeChangedFromClientImpl buildInnerClient() { + this.validateClient(); + HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); + TypeChangedFromServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : TypeChangedFromServiceVersion.getLatest(); + TypeChangedFromClientImpl client + = new TypeChangedFromClientImpl(localPipeline, this.endpoint, this.version, localServiceVersion); + return client; + } + + @Metadata(generated = true) + private void validateClient() { + // This method is invoked from 'buildInnerClient'/'buildClient' method. + // Developer can customize this method, to validate that the necessary conditions are met for the new client. + Objects.requireNonNull(endpoint, "'endpoint' cannot be null."); + Objects.requireNonNull(version, "'version' cannot be null."); + } + + @Metadata(generated = true) + private HttpPipeline createHttpPipeline() { + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; + HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions; + HttpPipelineBuilder httpPipelineBuilder = new HttpPipelineBuilder(); + List policies = new ArrayList<>(); + policies.add(redirectOptions == null ? new HttpRedirectPolicy() : new HttpRedirectPolicy(redirectOptions)); + policies.add(retryOptions == null ? new HttpRetryPolicy() : new HttpRetryPolicy(retryOptions)); + this.pipelinePolicies.stream().forEach(p -> policies.add(p)); + policies.add(new HttpLoggingPolicy(localHttpLogOptions)); + httpPipelineBuilder.policies(policies.toArray(new HttpPipelinePolicy[0])); + return httpPipelineBuilder.build(); + } + + /** + * Builds an instance of TypeChangedFromClient class. + * + * @return an instance of TypeChangedFromClient. + */ + @Metadata(generated = true) + public TypeChangedFromClient buildClient() { + return new TypeChangedFromClient(buildInnerClient()); + } + + private static final ClientLogger LOGGER = new ClientLogger(TypeChangedFromClientBuilder.class); +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/TypeChangedFromServiceVersion.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/TypeChangedFromServiceVersion.java new file mode 100644 index 0000000000..c37f39f2c4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/TypeChangedFromServiceVersion.java @@ -0,0 +1,43 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.typechangedfrom; + +import io.clientcore.core.http.models.ServiceVersion; + +/** + * Service version of TypeChangedFromClient. + */ +public enum TypeChangedFromServiceVersion implements ServiceVersion { + /** + * Enum value v1. + */ + V1("v1"), + + /** + * Enum value v2. + */ + V2("v2"); + + private final String version; + + TypeChangedFromServiceVersion(String version) { + this.version = version; + } + + /** + * {@inheritDoc} + */ + @Override + public String getVersion() { + return this.version; + } + + /** + * Gets the latest service version supported by this client library. + * + * @return The latest {@link TypeChangedFromServiceVersion}. + */ + public static TypeChangedFromServiceVersion getLatest() { + return V2; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/Versions.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/Versions.java new file mode 100644 index 0000000000..26cb163044 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/Versions.java @@ -0,0 +1,54 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.typechangedfrom; + +/** + * The version of the API. + */ +public enum Versions { + /** + * The version v1. + */ + V1("v1"), + + /** + * The version v2. + */ + V2("v2"); + + /** + * The actual serialized value for a Versions instance. + */ + private final String value; + + Versions(String value) { + this.value = value; + } + + /** + * Parses a serialized value to a Versions instance. + * + * @param value the serialized value to parse. + * @return the parsed Versions object, or null if unable to parse. + */ + public static Versions fromString(String value) { + if (value == null) { + return null; + } + Versions[] items = Versions.values(); + for (Versions item : items) { + if (item.toString().equalsIgnoreCase(value)) { + return item; + } + } + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return this.value; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/implementation/TypeChangedFromClientImpl.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/implementation/TypeChangedFromClientImpl.java new file mode 100644 index 0000000000..e1d8ac1ae5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/implementation/TypeChangedFromClientImpl.java @@ -0,0 +1,157 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +package versioning.typechangedfrom.implementation; + +import io.clientcore.core.annotation.ServiceInterface; +import io.clientcore.core.http.RestProxy; +import io.clientcore.core.http.annotation.BodyParam; +import io.clientcore.core.http.annotation.HeaderParam; +import io.clientcore.core.http.annotation.HostParam; +import io.clientcore.core.http.annotation.HttpRequestInformation; +import io.clientcore.core.http.annotation.QueryParam; +import io.clientcore.core.http.annotation.UnexpectedResponseExceptionDetail; +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpMethod; +import io.clientcore.core.http.models.RequestOptions; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipeline; +import io.clientcore.core.util.binarydata.BinaryData; +import versioning.typechangedfrom.TestModel; +import versioning.typechangedfrom.TypeChangedFromServiceVersion; +import versioning.typechangedfrom.Versions; + +/** + * Initializes a new instance of the TypeChangedFromClient type. + */ +public final class TypeChangedFromClientImpl { + /** + * The proxy service used to perform REST calls. + */ + private final TypeChangedFromClientService service; + + /** + * Need to be set as 'http://localhost:3000' in client. + */ + private final String endpoint; + + /** + * Gets Need to be set as 'http://localhost:3000' in client. + * + * @return the endpoint value. + */ + public String getEndpoint() { + return this.endpoint; + } + + /** + * Need to be set as 'v1' or 'v2' in client. + */ + private final Versions version; + + /** + * Gets Need to be set as 'v1' or 'v2' in client. + * + * @return the version value. + */ + public Versions getVersion() { + return this.version; + } + + /** + * Service version. + */ + private final TypeChangedFromServiceVersion serviceVersion; + + /** + * Gets Service version. + * + * @return the serviceVersion value. + */ + public TypeChangedFromServiceVersion getServiceVersion() { + return this.serviceVersion; + } + + /** + * 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; + } + + /** + * Initializes an instance of TypeChangedFromClient client. + * + * @param httpPipeline The HTTP pipeline to send requests through. + * @param endpoint Need to be set as 'http://localhost:3000' in client. + * @param version Need to be set as 'v1' or 'v2' in client. + * @param serviceVersion Service version. + */ + public TypeChangedFromClientImpl(HttpPipeline httpPipeline, String endpoint, Versions version, + TypeChangedFromServiceVersion serviceVersion) { + this.endpoint = endpoint; + this.version = version; + this.serviceVersion = TypeChangedFromServiceVersion.getLatest(); + this.httpPipeline = httpPipeline; + this.service = RestProxy.create(TypeChangedFromClientService.class, this.httpPipeline); + } + + /** + * The interface defining all the services for TypeChangedFromClient to be used by the proxy service to perform REST + * calls. + */ + @ServiceInterface( + name = "TypeChangedFromClien", + host = "{endpoint}/versioning/type-changed-from/api-version:{version}") + public interface TypeChangedFromClientService { + @HttpRequestInformation(method = HttpMethod.POST, path = "/test", expectedStatusCodes = { 200 }) + @UnexpectedResponseExceptionDetail + Response testSync(@HostParam("endpoint") String endpoint, @HostParam("version") Versions version, + @QueryParam("param") String param, @HeaderParam("Content-Type") String contentType, + @HeaderParam("Accept") String accept, @BodyParam("application/json") BinaryData body, + RequestOptions requestOptions); + } + + /** + * The test operation. + *

Request Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Required)
+     * }
+     * }
+     * 
+ * + *

Response Body Schema

+ * + *
+     * {@code
+     * {
+     *     prop: String (Required)
+     *     changedProp: String (Required)
+     * }
+     * }
+     * 
+ * + * @param param The param 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 service returns an error. + * @return the response. + */ + public Response testWithResponse(String param, BinaryData body, RequestOptions requestOptions) { + final String contentType = "application/json"; + final String accept = "application/json"; + return service.testSync(this.getEndpoint(), this.getVersion(), param, contentType, accept, body, + requestOptions); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/implementation/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/implementation/package-info.java new file mode 100644 index 0000000000..b1ef29ca58 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/implementation/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the implementations for TypeChangedFrom. + * Test for the `@typeChangedFrom` decorator. + */ +package versioning.typechangedfrom.implementation; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/package-info.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/package-info.java new file mode 100644 index 0000000000..84d3a4b8b5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/java/versioning/typechangedfrom/package-info.java @@ -0,0 +1,7 @@ +// Code generated by Microsoft (R) TypeSpec Code Generator. + +/** + * Package containing the classes for TypeChangedFrom. + * Test for the `@typeChangedFrom` decorator. + */ +package versioning.typechangedfrom; diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/authentication-apikey_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/authentication-apikey_apiview_properties.json new file mode 100644 index 0000000000..4e27e9dc5a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/authentication-apikey_apiview_properties.json @@ -0,0 +1,12 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "authentication.apikey.ApiKeyClient": "Authentication.ApiKey", + "authentication.apikey.ApiKeyClient.invalid": "Authentication.ApiKey.invalid", + "authentication.apikey.ApiKeyClient.invalidWithResponse": "Authentication.ApiKey.invalid", + "authentication.apikey.ApiKeyClient.valid": "Authentication.ApiKey.valid", + "authentication.apikey.ApiKeyClient.validWithResponse": "Authentication.ApiKey.valid", + "authentication.apikey.ApiKeyClientBuilder": "Authentication.ApiKey", + "authentication.apikey.InvalidAuth": "Authentication.ApiKey.InvalidAuth" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/authentication-http-custom_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/authentication-http-custom_apiview_properties.json new file mode 100644 index 0000000000..9628386d39 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/authentication-http-custom_apiview_properties.json @@ -0,0 +1,12 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "authentication.http.custom.CustomClient": "Authentication.Http.Custom", + "authentication.http.custom.CustomClient.invalid": "Authentication.Http.Custom.invalid", + "authentication.http.custom.CustomClient.invalidWithResponse": "Authentication.Http.Custom.invalid", + "authentication.http.custom.CustomClient.valid": "Authentication.Http.Custom.valid", + "authentication.http.custom.CustomClient.validWithResponse": "Authentication.Http.Custom.valid", + "authentication.http.custom.CustomClientBuilder": "Authentication.Http.Custom", + "authentication.http.custom.InvalidAuth": "Authentication.Http.Custom.InvalidAuth" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/encode-numeric_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/encode-numeric_apiview_properties.json new file mode 100644 index 0000000000..01cb5e257e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/encode-numeric_apiview_properties.json @@ -0,0 +1,16 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "encode.numeric.NumericClient": "Encode.Numeric.Property", + "encode.numeric.NumericClient.safeintAsString": "Encode.Numeric.Property.safeintAsString", + "encode.numeric.NumericClient.safeintAsStringWithResponse": "Encode.Numeric.Property.safeintAsString", + "encode.numeric.NumericClient.uint32AsStringOptional": "Encode.Numeric.Property.uint32AsStringOptional", + "encode.numeric.NumericClient.uint32AsStringOptionalWithResponse": "Encode.Numeric.Property.uint32AsStringOptional", + "encode.numeric.NumericClient.uint8AsString": "Encode.Numeric.Property.uint8AsString", + "encode.numeric.NumericClient.uint8AsStringWithResponse": "Encode.Numeric.Property.uint8AsString", + "encode.numeric.NumericClientBuilder": "Encode.Numeric", + "encode.numeric.property.SafeintAsStringProperty": "Encode.Numeric.Property.SafeintAsStringProperty", + "encode.numeric.property.Uint32AsStringProperty": "Encode.Numeric.Property.Uint32AsStringProperty", + "encode.numeric.property.Uint8AsStringProperty": "Encode.Numeric.Property.Uint8AsStringProperty" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-basic_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-basic_apiview_properties.json new file mode 100644 index 0000000000..882b2b9d52 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-basic_apiview_properties.json @@ -0,0 +1,14 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "parameters.basic.BasicClientBuilder": "Parameters.Basic", + "parameters.basic.ExplicitBodyClient": "Parameters.Basic.ExplicitBody", + "parameters.basic.ExplicitBodyClient.simple": "Parameters.Basic.ExplicitBody.simple", + "parameters.basic.ExplicitBodyClient.simpleWithResponse": "Parameters.Basic.ExplicitBody.simple", + "parameters.basic.ImplicitBodyClient": "Parameters.Basic.ImplicitBody", + "parameters.basic.ImplicitBodyClient.simple": "Parameters.Basic.ImplicitBody.simple", + "parameters.basic.ImplicitBodyClient.simpleWithResponse": "Parameters.Basic.ImplicitBody.simple", + "parameters.basic.explicitbody.User": "Parameters.Basic.ExplicitBody.User", + "parameters.basic.implicitbody.implementation.SimpleRequest": "Parameters.Basic.ImplicitBody.simple.Request.anonymous" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-bodyoptionality_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-bodyoptionality_apiview_properties.json new file mode 100644 index 0000000000..1ce3a35a81 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-bodyoptionality_apiview_properties.json @@ -0,0 +1,17 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "parameters.bodyoptionality.BodyModel": "Parameters.BodyOptionality.BodyModel", + "parameters.bodyoptionality.BodyOptionalityClient": "Parameters.BodyOptionality", + "parameters.bodyoptionality.BodyOptionalityClient.requiredExplicit": "Parameters.BodyOptionality.requiredExplicit", + "parameters.bodyoptionality.BodyOptionalityClient.requiredExplicitWithResponse": "Parameters.BodyOptionality.requiredExplicit", + "parameters.bodyoptionality.BodyOptionalityClient.requiredImplicit": "Parameters.BodyOptionality.requiredImplicit", + "parameters.bodyoptionality.BodyOptionalityClient.requiredImplicitWithResponse": "Parameters.BodyOptionality.requiredImplicit", + "parameters.bodyoptionality.BodyOptionalityClientBuilder": "Parameters.BodyOptionality", + "parameters.bodyoptionality.OptionalExplicitClient": "Parameters.BodyOptionality.OptionalExplicit", + "parameters.bodyoptionality.OptionalExplicitClient.omit": "Parameters.BodyOptionality.OptionalExplicit.omit", + "parameters.bodyoptionality.OptionalExplicitClient.omitWithResponse": "Parameters.BodyOptionality.OptionalExplicit.omit", + "parameters.bodyoptionality.OptionalExplicitClient.set": "Parameters.BodyOptionality.OptionalExplicit.set", + "parameters.bodyoptionality.OptionalExplicitClient.setWithResponse": "Parameters.BodyOptionality.OptionalExplicit.set" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-collectionformat_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-collectionformat_apiview_properties.json new file mode 100644 index 0000000000..28cdf238ae --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-collectionformat_apiview_properties.json @@ -0,0 +1,20 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "parameters.collectionformat.CollectionFormatClientBuilder": "Parameters.CollectionFormat", + "parameters.collectionformat.HeaderClient": "Parameters.CollectionFormat.Header", + "parameters.collectionformat.HeaderClient.csv": "Parameters.CollectionFormat.Header.csv", + "parameters.collectionformat.HeaderClient.csvWithResponse": "Parameters.CollectionFormat.Header.csv", + "parameters.collectionformat.QueryClient": "Parameters.CollectionFormat.Query", + "parameters.collectionformat.QueryClient.csv": "Parameters.CollectionFormat.Query.csv", + "parameters.collectionformat.QueryClient.csvWithResponse": "Parameters.CollectionFormat.Query.csv", + "parameters.collectionformat.QueryClient.multi": "Parameters.CollectionFormat.Query.multi", + "parameters.collectionformat.QueryClient.multiWithResponse": "Parameters.CollectionFormat.Query.multi", + "parameters.collectionformat.QueryClient.pipes": "Parameters.CollectionFormat.Query.pipes", + "parameters.collectionformat.QueryClient.pipesWithResponse": "Parameters.CollectionFormat.Query.pipes", + "parameters.collectionformat.QueryClient.ssv": "Parameters.CollectionFormat.Query.ssv", + "parameters.collectionformat.QueryClient.ssvWithResponse": "Parameters.CollectionFormat.Query.ssv", + "parameters.collectionformat.QueryClient.tsv": "Parameters.CollectionFormat.Query.tsv", + "parameters.collectionformat.QueryClient.tsvWithResponse": "Parameters.CollectionFormat.Query.tsv" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-spread_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-spread_apiview_properties.json new file mode 100644 index 0000000000..66c4fb1589 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/parameters-spread_apiview_properties.json @@ -0,0 +1,35 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "parameters.spread.AliasClient": "Parameters.Spread.Alias", + "parameters.spread.AliasClient.spreadAsRequestBody": "Parameters.Spread.Alias.spreadAsRequestBody", + "parameters.spread.AliasClient.spreadAsRequestBodyWithResponse": "Parameters.Spread.Alias.spreadAsRequestBody", + "parameters.spread.AliasClient.spreadAsRequestParameter": "Parameters.Spread.Alias.spreadAsRequestParameter", + "parameters.spread.AliasClient.spreadAsRequestParameterWithResponse": "Parameters.Spread.Alias.spreadAsRequestParameter", + "parameters.spread.AliasClient.spreadParameterWithInnerAlias": "Parameters.Spread.Alias.spreadParameterWithInnerAlias", + "parameters.spread.AliasClient.spreadParameterWithInnerAliasWithResponse": "Parameters.Spread.Alias.spreadParameterWithInnerAlias", + "parameters.spread.AliasClient.spreadParameterWithInnerModel": "Parameters.Spread.Alias.spreadParameterWithInnerModel", + "parameters.spread.AliasClient.spreadParameterWithInnerModelWithResponse": "Parameters.Spread.Alias.spreadParameterWithInnerModel", + "parameters.spread.AliasClient.spreadWithMultipleParameters": "Parameters.Spread.Alias.spreadWithMultipleParameters", + "parameters.spread.AliasClient.spreadWithMultipleParametersWithResponse": "Parameters.Spread.Alias.spreadWithMultipleParameters", + "parameters.spread.ModelClient": "Parameters.Spread.Model", + "parameters.spread.ModelClient.spreadAsRequestBody": "Parameters.Spread.Model.spreadAsRequestBody", + "parameters.spread.ModelClient.spreadAsRequestBodyWithResponse": "Parameters.Spread.Model.spreadAsRequestBody", + "parameters.spread.ModelClient.spreadCompositeRequest": "Parameters.Spread.Model.spreadCompositeRequest", + "parameters.spread.ModelClient.spreadCompositeRequestMix": "Parameters.Spread.Model.spreadCompositeRequestMix", + "parameters.spread.ModelClient.spreadCompositeRequestMixWithResponse": "Parameters.Spread.Model.spreadCompositeRequestMix", + "parameters.spread.ModelClient.spreadCompositeRequestOnlyWithBody": "Parameters.Spread.Model.spreadCompositeRequestOnlyWithBody", + "parameters.spread.ModelClient.spreadCompositeRequestOnlyWithBodyWithResponse": "Parameters.Spread.Model.spreadCompositeRequestOnlyWithBody", + "parameters.spread.ModelClient.spreadCompositeRequestWithResponse": "Parameters.Spread.Model.spreadCompositeRequest", + "parameters.spread.ModelClient.spreadCompositeRequestWithoutBody": "Parameters.Spread.Model.spreadCompositeRequestWithoutBody", + "parameters.spread.ModelClient.spreadCompositeRequestWithoutBodyWithResponse": "Parameters.Spread.Model.spreadCompositeRequestWithoutBody", + "parameters.spread.SpreadClientBuilder": "Parameters.Spread", + "parameters.spread.alias.implementation.SpreadAsRequestBodyRequest": "Parameters.Spread.Alias.spreadAsRequestBody.Request.anonymous", + "parameters.spread.implementation.SpreadAsRequestParameterRequest": "Parameters.Spread.Alias.spreadAsRequestParameter.Request.anonymous", + "parameters.spread.implementation.SpreadCompositeRequestMixRequest": "Parameters.Spread.Model.spreadCompositeRequestMix.Request.anonymous", + "parameters.spread.implementation.SpreadParameterWithInnerAliasRequest": "Parameters.Spread.Alias.spreadParameterWithInnerAlias.Request.anonymous", + "parameters.spread.implementation.SpreadParameterWithInnerModelRequest": "Parameters.Spread.Alias.spreadParameterWithInnerModel.Request.anonymous", + "parameters.spread.implementation.SpreadWithMultipleParametersRequest": "Parameters.Spread.Alias.spreadWithMultipleParameters.Request.anonymous", + "parameters.spread.model.BodyParameter": "Parameters.Spread.Model.BodyParameter" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-contentnegotiation_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-contentnegotiation_apiview_properties.json new file mode 100644 index 0000000000..5f534764d1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-contentnegotiation_apiview_properties.json @@ -0,0 +1,17 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "payload.contentnegotiation.ContentNegotiationClientBuilder": "Payload.ContentNegotiation", + "payload.contentnegotiation.DifferentBodyClient": "Payload.ContentNegotiation.DifferentBody", + "payload.contentnegotiation.DifferentBodyClient.getAvatarAsJson": "Payload.ContentNegotiation.DifferentBody.getAvatarAsJson", + "payload.contentnegotiation.DifferentBodyClient.getAvatarAsJsonWithResponse": "Payload.ContentNegotiation.DifferentBody.getAvatarAsJson", + "payload.contentnegotiation.DifferentBodyClient.getAvatarAsPng": "Payload.ContentNegotiation.DifferentBody.getAvatarAsPng", + "payload.contentnegotiation.DifferentBodyClient.getAvatarAsPngWithResponse": "Payload.ContentNegotiation.DifferentBody.getAvatarAsPng", + "payload.contentnegotiation.SameBodyClient": "Payload.ContentNegotiation.SameBody", + "payload.contentnegotiation.SameBodyClient.getAvatarAsJpeg": "Payload.ContentNegotiation.SameBody.getAvatarAsJpeg", + "payload.contentnegotiation.SameBodyClient.getAvatarAsJpegWithResponse": "Payload.ContentNegotiation.SameBody.getAvatarAsJpeg", + "payload.contentnegotiation.SameBodyClient.getAvatarAsPng": "Payload.ContentNegotiation.SameBody.getAvatarAsPng", + "payload.contentnegotiation.SameBodyClient.getAvatarAsPngWithResponse": "Payload.ContentNegotiation.SameBody.getAvatarAsPng", + "payload.contentnegotiation.differentbody.PngImageAsJson": "Payload.ContentNegotiation.DifferentBody.PngImageAsJson" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-jsonmergepatch_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-jsonmergepatch_apiview_properties.json new file mode 100644 index 0000000000..f8cdc575f9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-jsonmergepatch_apiview_properties.json @@ -0,0 +1,16 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "payload.jsonmergepatch.InnerModel": "Payload.JsonMergePatch.InnerModel", + "payload.jsonmergepatch.JsonMergePatchClient": "Payload.JsonMergePatch", + "payload.jsonmergepatch.JsonMergePatchClient.createResource": "Payload.JsonMergePatch.createResource", + "payload.jsonmergepatch.JsonMergePatchClient.createResourceWithResponse": "Payload.JsonMergePatch.createResource", + "payload.jsonmergepatch.JsonMergePatchClient.updateOptionalResource": "Payload.JsonMergePatch.updateOptionalResource", + "payload.jsonmergepatch.JsonMergePatchClient.updateOptionalResourceWithResponse": "Payload.JsonMergePatch.updateOptionalResource", + "payload.jsonmergepatch.JsonMergePatchClient.updateResource": "Payload.JsonMergePatch.updateResource", + "payload.jsonmergepatch.JsonMergePatchClient.updateResourceWithResponse": "Payload.JsonMergePatch.updateResource", + "payload.jsonmergepatch.JsonMergePatchClientBuilder": "Payload.JsonMergePatch", + "payload.jsonmergepatch.Resource": "Payload.JsonMergePatch.Resource", + "payload.jsonmergepatch.ResourcePatch": "Payload.JsonMergePatch.ResourcePatch" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-mediatype_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-mediatype_apiview_properties.json new file mode 100644 index 0000000000..295243426e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-mediatype_apiview_properties.json @@ -0,0 +1,15 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "payload.mediatype.MediaTypeClient": "Payload.MediaType.StringBody", + "payload.mediatype.MediaTypeClient.getAsJson": "Payload.MediaType.StringBody.getAsJson", + "payload.mediatype.MediaTypeClient.getAsJsonWithResponse": "Payload.MediaType.StringBody.getAsJson", + "payload.mediatype.MediaTypeClient.getAsText": "Payload.MediaType.StringBody.getAsText", + "payload.mediatype.MediaTypeClient.getAsTextWithResponse": "Payload.MediaType.StringBody.getAsText", + "payload.mediatype.MediaTypeClient.sendAsJson": "Payload.MediaType.StringBody.sendAsJson", + "payload.mediatype.MediaTypeClient.sendAsJsonWithResponse": "Payload.MediaType.StringBody.sendAsJson", + "payload.mediatype.MediaTypeClient.sendAsText": "Payload.MediaType.StringBody.sendAsText", + "payload.mediatype.MediaTypeClient.sendAsTextWithResponse": "Payload.MediaType.StringBody.sendAsText", + "payload.mediatype.MediaTypeClientBuilder": "Payload.MediaType" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-multipart_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-multipart_apiview_properties.json new file mode 100644 index 0000000000..176cfed183 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-multipart_apiview_properties.json @@ -0,0 +1,52 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "payload.multipart.Address": "Payload.MultiPart.Address", + "payload.multipart.BinaryArrayPartsRequest": "Payload.MultiPart.BinaryArrayPartsRequest", + "payload.multipart.ComplexHttpPartsModelRequest": "Payload.MultiPart.ComplexHttpPartsModelRequest", + "payload.multipart.ComplexPartsRequest": "Payload.MultiPart.ComplexPartsRequest", + "payload.multipart.FileOptionalContentType": "Payload.MultiPart.FileOptionalContentType", + "payload.multipart.FileRequiredMetaData": "Payload.MultiPart.FileRequiredMetaData", + "payload.multipart.FileSpecificContentType": "Payload.MultiPart.FileSpecificContentType", + "payload.multipart.FileWithHttpPartOptionalContentTypeRequest": "Payload.MultiPart.FileWithHttpPartOptionalContentTypeRequest", + "payload.multipart.FileWithHttpPartRequiredContentTypeRequest": "Payload.MultiPart.FileWithHttpPartRequiredContentTypeRequest", + "payload.multipart.FileWithHttpPartSpecificContentTypeRequest": "Payload.MultiPart.FileWithHttpPartSpecificContentTypeRequest", + "payload.multipart.FormDataClient": "Payload.MultiPart.FormData", + "payload.multipart.FormDataClient.anonymousModel": "Payload.MultiPart.FormData.anonymousModel", + "payload.multipart.FormDataClient.anonymousModelWithResponse": "Payload.MultiPart.FormData.anonymousModel", + "payload.multipart.FormDataClient.basic": "Payload.MultiPart.FormData.basic", + "payload.multipart.FormDataClient.basicWithResponse": "Payload.MultiPart.FormData.basic", + "payload.multipart.FormDataClient.binaryArrayParts": "Payload.MultiPart.FormData.binaryArrayParts", + "payload.multipart.FormDataClient.binaryArrayPartsWithResponse": "Payload.MultiPart.FormData.binaryArrayParts", + "payload.multipart.FormDataClient.checkFileNameAndContentType": "Payload.MultiPart.FormData.checkFileNameAndContentType", + "payload.multipart.FormDataClient.checkFileNameAndContentTypeWithResponse": "Payload.MultiPart.FormData.checkFileNameAndContentType", + "payload.multipart.FormDataClient.fileArrayAndBasic": "Payload.MultiPart.FormData.fileArrayAndBasic", + "payload.multipart.FormDataClient.fileArrayAndBasicWithResponse": "Payload.MultiPart.FormData.fileArrayAndBasic", + "payload.multipart.FormDataClient.jsonPart": "Payload.MultiPart.FormData.jsonPart", + "payload.multipart.FormDataClient.jsonPartWithResponse": "Payload.MultiPart.FormData.jsonPart", + "payload.multipart.FormDataClient.multiBinaryParts": "Payload.MultiPart.FormData.multiBinaryParts", + "payload.multipart.FormDataClient.multiBinaryPartsWithResponse": "Payload.MultiPart.FormData.multiBinaryParts", + "payload.multipart.FormDataHttpPartsClient": "Payload.MultiPart.FormData.HttpParts", + "payload.multipart.FormDataHttpPartsClient.jsonArrayAndFileArray": "Payload.MultiPart.FormData.HttpParts.jsonArrayAndFileArray", + "payload.multipart.FormDataHttpPartsClient.jsonArrayAndFileArrayWithResponse": "Payload.MultiPart.FormData.HttpParts.jsonArrayAndFileArray", + "payload.multipart.FormDataHttpPartsContentTypeClient": "Payload.MultiPart.FormData.HttpParts.ContentType", + "payload.multipart.FormDataHttpPartsContentTypeClient.imageJpegContentType": "Payload.MultiPart.FormData.HttpParts.ContentType.imageJpegContentType", + "payload.multipart.FormDataHttpPartsContentTypeClient.imageJpegContentTypeWithResponse": "Payload.MultiPart.FormData.HttpParts.ContentType.imageJpegContentType", + "payload.multipart.FormDataHttpPartsContentTypeClient.optionalContentType": "Payload.MultiPart.FormData.HttpParts.ContentType.optionalContentType", + "payload.multipart.FormDataHttpPartsContentTypeClient.optionalContentTypeWithResponse": "Payload.MultiPart.FormData.HttpParts.ContentType.optionalContentType", + "payload.multipart.FormDataHttpPartsContentTypeClient.requiredContentType": "Payload.MultiPart.FormData.HttpParts.ContentType.requiredContentType", + "payload.multipart.FormDataHttpPartsContentTypeClient.requiredContentTypeWithResponse": "Payload.MultiPart.FormData.HttpParts.ContentType.requiredContentType", + "payload.multipart.FormDataHttpPartsNonStringClient": "Payload.MultiPart.FormData.HttpParts.NonString", + "payload.multipart.FormDataHttpPartsNonStringClient.floatMethod": "Payload.MultiPart.FormData.HttpParts.NonString.float", + "payload.multipart.FormDataHttpPartsNonStringClient.floatMethodWithResponse": "Payload.MultiPart.FormData.HttpParts.NonString.float", + "payload.multipart.JsonPartRequest": "Payload.MultiPart.JsonPartRequest", + "payload.multipart.MultiBinaryPartsRequest": "Payload.MultiPart.MultiBinaryPartsRequest", + "payload.multipart.MultiPartClientBuilder": "Payload.MultiPart", + "payload.multipart.MultiPartRequest": "Payload.MultiPart.MultiPartRequest", + "payload.multipart.PictureFileDetails": null, + "payload.multipart.PicturesFileDetails": null, + "payload.multipart.ProfileImageFileDetails": null, + "payload.multipart.formdata.httpparts.nonstring.FloatRequest": "Payload.MultiPart.FormData.HttpParts.NonString.float.Request.anonymous", + "payload.multipart.implementation.AnonymousModelRequest": "Payload.MultiPart.FormData.anonymousModel.Request.anonymous" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-pageable_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-pageable_apiview_properties.json new file mode 100644 index 0000000000..e3fe3b7cf3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/payload-pageable_apiview_properties.json @@ -0,0 +1,12 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "payload.pageable.PageableClient": "Payload.Pageable.ServerDrivenPagination", + "payload.pageable.PageableClient.link": "Payload.Pageable.ServerDrivenPagination.link", + "payload.pageable.PageableClient.linkWithResponse": "Payload.Pageable.ServerDrivenPagination.link", + "payload.pageable.PageableClientBuilder": "Payload.Pageable", + "payload.pageable.Pet": "Payload.Pageable.Pet", + "payload.pageable.serverdrivenpagination.LinkResponse": "Payload.Pageable.ServerDrivenPagination.link.Response.anonymous", + "payload.pageable.serverdrivenpagination.LinkResponseLinks": "Payload.Pageable.ServerDrivenPagination.link.Response.links.anonymous" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/routes_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/routes_apiview_properties.json new file mode 100644 index 0000000000..a2a57970d5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/routes_apiview_properties.json @@ -0,0 +1,115 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "routes.InInterfaceClient": "Routes.InInterface", + "routes.InInterfaceClient.fixed": "Routes.InInterface.fixed", + "routes.InInterfaceClient.fixedWithResponse": "Routes.InInterface.fixed", + "routes.PathParametersClient": "Routes.PathParameters", + "routes.PathParametersClient.annotationOnly": "Routes.PathParameters.annotationOnly", + "routes.PathParametersClient.annotationOnlyWithResponse": "Routes.PathParameters.annotationOnly", + "routes.PathParametersClient.explicit": "Routes.PathParameters.explicit", + "routes.PathParametersClient.explicitWithResponse": "Routes.PathParameters.explicit", + "routes.PathParametersClient.templateOnly": "Routes.PathParameters.templateOnly", + "routes.PathParametersClient.templateOnlyWithResponse": "Routes.PathParameters.templateOnly", + "routes.PathParametersLabelExpansionExplodeClient": "Routes.PathParameters.LabelExpansion.Explode", + "routes.PathParametersLabelExpansionExplodeClient.array": "Routes.PathParameters.LabelExpansion.Explode.array", + "routes.PathParametersLabelExpansionExplodeClient.arrayWithResponse": "Routes.PathParameters.LabelExpansion.Explode.array", + "routes.PathParametersLabelExpansionExplodeClient.primitive": "Routes.PathParameters.LabelExpansion.Explode.primitive", + "routes.PathParametersLabelExpansionExplodeClient.primitiveWithResponse": "Routes.PathParameters.LabelExpansion.Explode.primitive", + "routes.PathParametersLabelExpansionExplodeClient.record": "Routes.PathParameters.LabelExpansion.Explode.record", + "routes.PathParametersLabelExpansionExplodeClient.recordWithResponse": "Routes.PathParameters.LabelExpansion.Explode.record", + "routes.PathParametersLabelExpansionStandardClient": "Routes.PathParameters.LabelExpansion.Standard", + "routes.PathParametersLabelExpansionStandardClient.array": "Routes.PathParameters.LabelExpansion.Standard.array", + "routes.PathParametersLabelExpansionStandardClient.arrayWithResponse": "Routes.PathParameters.LabelExpansion.Standard.array", + "routes.PathParametersLabelExpansionStandardClient.primitive": "Routes.PathParameters.LabelExpansion.Standard.primitive", + "routes.PathParametersLabelExpansionStandardClient.primitiveWithResponse": "Routes.PathParameters.LabelExpansion.Standard.primitive", + "routes.PathParametersLabelExpansionStandardClient.record": "Routes.PathParameters.LabelExpansion.Standard.record", + "routes.PathParametersLabelExpansionStandardClient.recordWithResponse": "Routes.PathParameters.LabelExpansion.Standard.record", + "routes.PathParametersMatrixExpansionExplodeClient": "Routes.PathParameters.MatrixExpansion.Explode", + "routes.PathParametersMatrixExpansionExplodeClient.array": "Routes.PathParameters.MatrixExpansion.Explode.array", + "routes.PathParametersMatrixExpansionExplodeClient.arrayWithResponse": "Routes.PathParameters.MatrixExpansion.Explode.array", + "routes.PathParametersMatrixExpansionExplodeClient.primitive": "Routes.PathParameters.MatrixExpansion.Explode.primitive", + "routes.PathParametersMatrixExpansionExplodeClient.primitiveWithResponse": "Routes.PathParameters.MatrixExpansion.Explode.primitive", + "routes.PathParametersMatrixExpansionExplodeClient.record": "Routes.PathParameters.MatrixExpansion.Explode.record", + "routes.PathParametersMatrixExpansionExplodeClient.recordWithResponse": "Routes.PathParameters.MatrixExpansion.Explode.record", + "routes.PathParametersMatrixExpansionStandardClient": "Routes.PathParameters.MatrixExpansion.Standard", + "routes.PathParametersMatrixExpansionStandardClient.array": "Routes.PathParameters.MatrixExpansion.Standard.array", + "routes.PathParametersMatrixExpansionStandardClient.arrayWithResponse": "Routes.PathParameters.MatrixExpansion.Standard.array", + "routes.PathParametersMatrixExpansionStandardClient.primitive": "Routes.PathParameters.MatrixExpansion.Standard.primitive", + "routes.PathParametersMatrixExpansionStandardClient.primitiveWithResponse": "Routes.PathParameters.MatrixExpansion.Standard.primitive", + "routes.PathParametersMatrixExpansionStandardClient.record": "Routes.PathParameters.MatrixExpansion.Standard.record", + "routes.PathParametersMatrixExpansionStandardClient.recordWithResponse": "Routes.PathParameters.MatrixExpansion.Standard.record", + "routes.PathParametersPathExpansionExplodeClient": "Routes.PathParameters.PathExpansion.Explode", + "routes.PathParametersPathExpansionExplodeClient.array": "Routes.PathParameters.PathExpansion.Explode.array", + "routes.PathParametersPathExpansionExplodeClient.arrayWithResponse": "Routes.PathParameters.PathExpansion.Explode.array", + "routes.PathParametersPathExpansionExplodeClient.primitive": "Routes.PathParameters.PathExpansion.Explode.primitive", + "routes.PathParametersPathExpansionExplodeClient.primitiveWithResponse": "Routes.PathParameters.PathExpansion.Explode.primitive", + "routes.PathParametersPathExpansionExplodeClient.record": "Routes.PathParameters.PathExpansion.Explode.record", + "routes.PathParametersPathExpansionExplodeClient.recordWithResponse": "Routes.PathParameters.PathExpansion.Explode.record", + "routes.PathParametersPathExpansionStandardClient": "Routes.PathParameters.PathExpansion.Standard", + "routes.PathParametersPathExpansionStandardClient.array": "Routes.PathParameters.PathExpansion.Standard.array", + "routes.PathParametersPathExpansionStandardClient.arrayWithResponse": "Routes.PathParameters.PathExpansion.Standard.array", + "routes.PathParametersPathExpansionStandardClient.primitive": "Routes.PathParameters.PathExpansion.Standard.primitive", + "routes.PathParametersPathExpansionStandardClient.primitiveWithResponse": "Routes.PathParameters.PathExpansion.Standard.primitive", + "routes.PathParametersPathExpansionStandardClient.record": "Routes.PathParameters.PathExpansion.Standard.record", + "routes.PathParametersPathExpansionStandardClient.recordWithResponse": "Routes.PathParameters.PathExpansion.Standard.record", + "routes.PathParametersReservedExpansionClient": "Routes.PathParameters.ReservedExpansion", + "routes.PathParametersReservedExpansionClient.annotation": "Routes.PathParameters.ReservedExpansion.annotation", + "routes.PathParametersReservedExpansionClient.annotationWithResponse": "Routes.PathParameters.ReservedExpansion.annotation", + "routes.PathParametersReservedExpansionClient.template": "Routes.PathParameters.ReservedExpansion.template", + "routes.PathParametersReservedExpansionClient.templateWithResponse": "Routes.PathParameters.ReservedExpansion.template", + "routes.PathParametersSimpleExpansionExplodeClient": "Routes.PathParameters.SimpleExpansion.Explode", + "routes.PathParametersSimpleExpansionExplodeClient.array": "Routes.PathParameters.SimpleExpansion.Explode.array", + "routes.PathParametersSimpleExpansionExplodeClient.arrayWithResponse": "Routes.PathParameters.SimpleExpansion.Explode.array", + "routes.PathParametersSimpleExpansionExplodeClient.primitive": "Routes.PathParameters.SimpleExpansion.Explode.primitive", + "routes.PathParametersSimpleExpansionExplodeClient.primitiveWithResponse": "Routes.PathParameters.SimpleExpansion.Explode.primitive", + "routes.PathParametersSimpleExpansionExplodeClient.record": "Routes.PathParameters.SimpleExpansion.Explode.record", + "routes.PathParametersSimpleExpansionExplodeClient.recordWithResponse": "Routes.PathParameters.SimpleExpansion.Explode.record", + "routes.PathParametersSimpleExpansionStandardClient": "Routes.PathParameters.SimpleExpansion.Standard", + "routes.PathParametersSimpleExpansionStandardClient.array": "Routes.PathParameters.SimpleExpansion.Standard.array", + "routes.PathParametersSimpleExpansionStandardClient.arrayWithResponse": "Routes.PathParameters.SimpleExpansion.Standard.array", + "routes.PathParametersSimpleExpansionStandardClient.primitive": "Routes.PathParameters.SimpleExpansion.Standard.primitive", + "routes.PathParametersSimpleExpansionStandardClient.primitiveWithResponse": "Routes.PathParameters.SimpleExpansion.Standard.primitive", + "routes.PathParametersSimpleExpansionStandardClient.record": "Routes.PathParameters.SimpleExpansion.Standard.record", + "routes.PathParametersSimpleExpansionStandardClient.recordWithResponse": "Routes.PathParameters.SimpleExpansion.Standard.record", + "routes.QueryParametersClient": "Routes.QueryParameters", + "routes.QueryParametersClient.annotationOnly": "Routes.QueryParameters.annotationOnly", + "routes.QueryParametersClient.annotationOnlyWithResponse": "Routes.QueryParameters.annotationOnly", + "routes.QueryParametersClient.explicit": "Routes.QueryParameters.explicit", + "routes.QueryParametersClient.explicitWithResponse": "Routes.QueryParameters.explicit", + "routes.QueryParametersClient.templateOnly": "Routes.QueryParameters.templateOnly", + "routes.QueryParametersClient.templateOnlyWithResponse": "Routes.QueryParameters.templateOnly", + "routes.QueryParametersQueryContinuationExplodeClient": "Routes.QueryParameters.QueryContinuation.Explode", + "routes.QueryParametersQueryContinuationExplodeClient.array": "Routes.QueryParameters.QueryContinuation.Explode.array", + "routes.QueryParametersQueryContinuationExplodeClient.arrayWithResponse": "Routes.QueryParameters.QueryContinuation.Explode.array", + "routes.QueryParametersQueryContinuationExplodeClient.primitive": "Routes.QueryParameters.QueryContinuation.Explode.primitive", + "routes.QueryParametersQueryContinuationExplodeClient.primitiveWithResponse": "Routes.QueryParameters.QueryContinuation.Explode.primitive", + "routes.QueryParametersQueryContinuationExplodeClient.record": "Routes.QueryParameters.QueryContinuation.Explode.record", + "routes.QueryParametersQueryContinuationExplodeClient.recordWithResponse": "Routes.QueryParameters.QueryContinuation.Explode.record", + "routes.QueryParametersQueryContinuationStandardClient": "Routes.QueryParameters.QueryContinuation.Standard", + "routes.QueryParametersQueryContinuationStandardClient.array": "Routes.QueryParameters.QueryContinuation.Standard.array", + "routes.QueryParametersQueryContinuationStandardClient.arrayWithResponse": "Routes.QueryParameters.QueryContinuation.Standard.array", + "routes.QueryParametersQueryContinuationStandardClient.primitive": "Routes.QueryParameters.QueryContinuation.Standard.primitive", + "routes.QueryParametersQueryContinuationStandardClient.primitiveWithResponse": "Routes.QueryParameters.QueryContinuation.Standard.primitive", + "routes.QueryParametersQueryContinuationStandardClient.record": "Routes.QueryParameters.QueryContinuation.Standard.record", + "routes.QueryParametersQueryContinuationStandardClient.recordWithResponse": "Routes.QueryParameters.QueryContinuation.Standard.record", + "routes.QueryParametersQueryExpansionExplodeClient": "Routes.QueryParameters.QueryExpansion.Explode", + "routes.QueryParametersQueryExpansionExplodeClient.array": "Routes.QueryParameters.QueryExpansion.Explode.array", + "routes.QueryParametersQueryExpansionExplodeClient.arrayWithResponse": "Routes.QueryParameters.QueryExpansion.Explode.array", + "routes.QueryParametersQueryExpansionExplodeClient.primitive": "Routes.QueryParameters.QueryExpansion.Explode.primitive", + "routes.QueryParametersQueryExpansionExplodeClient.primitiveWithResponse": "Routes.QueryParameters.QueryExpansion.Explode.primitive", + "routes.QueryParametersQueryExpansionExplodeClient.record": "Routes.QueryParameters.QueryExpansion.Explode.record", + "routes.QueryParametersQueryExpansionExplodeClient.recordWithResponse": "Routes.QueryParameters.QueryExpansion.Explode.record", + "routes.QueryParametersQueryExpansionStandardClient": "Routes.QueryParameters.QueryExpansion.Standard", + "routes.QueryParametersQueryExpansionStandardClient.array": "Routes.QueryParameters.QueryExpansion.Standard.array", + "routes.QueryParametersQueryExpansionStandardClient.arrayWithResponse": "Routes.QueryParameters.QueryExpansion.Standard.array", + "routes.QueryParametersQueryExpansionStandardClient.primitive": "Routes.QueryParameters.QueryExpansion.Standard.primitive", + "routes.QueryParametersQueryExpansionStandardClient.primitiveWithResponse": "Routes.QueryParameters.QueryExpansion.Standard.primitive", + "routes.QueryParametersQueryExpansionStandardClient.record": "Routes.QueryParameters.QueryExpansion.Standard.record", + "routes.QueryParametersQueryExpansionStandardClient.recordWithResponse": "Routes.QueryParameters.QueryExpansion.Standard.record", + "routes.RoutesClient": "Routes", + "routes.RoutesClient.fixed": "Routes.fixed", + "routes.RoutesClient.fixedWithResponse": "Routes.fixed", + "routes.RoutesClientBuilder": "Routes" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/serialization-encodedname-json_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/serialization-encodedname-json_apiview_properties.json new file mode 100644 index 0000000000..ed8bbd1857 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/serialization-encodedname-json_apiview_properties.json @@ -0,0 +1,12 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "serialization.encodedname.json.JsonClient": "Serialization.EncodedName.Json.Property", + "serialization.encodedname.json.JsonClient.get": "Serialization.EncodedName.Json.Property.get", + "serialization.encodedname.json.JsonClient.getWithResponse": "Serialization.EncodedName.Json.Property.get", + "serialization.encodedname.json.JsonClient.send": "Serialization.EncodedName.Json.Property.send", + "serialization.encodedname.json.JsonClient.sendWithResponse": "Serialization.EncodedName.Json.Property.send", + "serialization.encodedname.json.JsonClientBuilder": "Serialization.EncodedName.Json", + "serialization.encodedname.json.property.JsonEncodedNameModel": "Serialization.EncodedName.Json.Property.JsonEncodedNameModel" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-endpoint-notdefined_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-endpoint-notdefined_apiview_properties.json new file mode 100644 index 0000000000..18c7c10389 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-endpoint-notdefined_apiview_properties.json @@ -0,0 +1,9 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "server.endpoint.notdefined.NotDefinedClient": "Server.Endpoint.NotDefined", + "server.endpoint.notdefined.NotDefinedClient.valid": "Server.Endpoint.NotDefined.valid", + "server.endpoint.notdefined.NotDefinedClient.validWithResponse": "Server.Endpoint.NotDefined.valid", + "server.endpoint.notdefined.NotDefinedClientBuilder": "Server.Endpoint.NotDefined" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-path-multiple_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-path-multiple_apiview_properties.json new file mode 100644 index 0000000000..ede059ec0f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-path-multiple_apiview_properties.json @@ -0,0 +1,11 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "server.path.multiple.MultipleClient": "Server.Path.Multiple", + "server.path.multiple.MultipleClient.noOperationParams": "Server.Path.Multiple.noOperationParams", + "server.path.multiple.MultipleClient.noOperationParamsWithResponse": "Server.Path.Multiple.noOperationParams", + "server.path.multiple.MultipleClient.withOperationPathParam": "Server.Path.Multiple.withOperationPathParam", + "server.path.multiple.MultipleClient.withOperationPathParamWithResponse": "Server.Path.Multiple.withOperationPathParam", + "server.path.multiple.MultipleClientBuilder": "Server.Path.Multiple" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-path-single_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-path-single_apiview_properties.json new file mode 100644 index 0000000000..e6ece2ca2c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-path-single_apiview_properties.json @@ -0,0 +1,9 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "server.path.single.SingleClient": "Server.Path.Single", + "server.path.single.SingleClient.myOp": "Server.Path.Single.myOp", + "server.path.single.SingleClient.myOpWithResponse": "Server.Path.Single.myOp", + "server.path.single.SingleClientBuilder": "Server.Path.Single" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-versions-notversioned_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-versions-notversioned_apiview_properties.json new file mode 100644 index 0000000000..de7235127e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-versions-notversioned_apiview_properties.json @@ -0,0 +1,13 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "server.versions.notversioned.NotVersionedClient": "Server.Versions.NotVersioned", + "server.versions.notversioned.NotVersionedClient.withPathApiVersion": "Server.Versions.NotVersioned.withPathApiVersion", + "server.versions.notversioned.NotVersionedClient.withPathApiVersionWithResponse": "Server.Versions.NotVersioned.withPathApiVersion", + "server.versions.notversioned.NotVersionedClient.withQueryApiVersion": "Server.Versions.NotVersioned.withQueryApiVersion", + "server.versions.notversioned.NotVersionedClient.withQueryApiVersionWithResponse": "Server.Versions.NotVersioned.withQueryApiVersion", + "server.versions.notversioned.NotVersionedClient.withoutApiVersion": "Server.Versions.NotVersioned.withoutApiVersion", + "server.versions.notversioned.NotVersionedClient.withoutApiVersionWithResponse": "Server.Versions.NotVersioned.withoutApiVersion", + "server.versions.notversioned.NotVersionedClientBuilder": "Server.Versions.NotVersioned" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-versions-versioned_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-versions-versioned_apiview_properties.json new file mode 100644 index 0000000000..85f5ebfe3e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/server-versions-versioned_apiview_properties.json @@ -0,0 +1,15 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "server.versions.versioned.VersionedClient": "Server.Versions.Versioned", + "server.versions.versioned.VersionedClient.withPathApiVersion": "Server.Versions.Versioned.withPathApiVersion", + "server.versions.versioned.VersionedClient.withPathApiVersionWithResponse": "Server.Versions.Versioned.withPathApiVersion", + "server.versions.versioned.VersionedClient.withQueryApiVersion": "Server.Versions.Versioned.withQueryApiVersion", + "server.versions.versioned.VersionedClient.withQueryApiVersionWithResponse": "Server.Versions.Versioned.withQueryApiVersion", + "server.versions.versioned.VersionedClient.withQueryOldApiVersion": "Server.Versions.Versioned.withQueryOldApiVersion", + "server.versions.versioned.VersionedClient.withQueryOldApiVersionWithResponse": "Server.Versions.Versioned.withQueryOldApiVersion", + "server.versions.versioned.VersionedClient.withoutApiVersion": "Server.Versions.Versioned.withoutApiVersion", + "server.versions.versioned.VersionedClient.withoutApiVersionWithResponse": "Server.Versions.Versioned.withoutApiVersion", + "server.versions.versioned.VersionedClientBuilder": "Server.Versions.Versioned" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/specialwords_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/specialwords_apiview_properties.json new file mode 100644 index 0000000000..af09fa0a21 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/specialwords_apiview_properties.json @@ -0,0 +1,244 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "specialwords.ModelPropertiesClient": "SpecialWords.ModelProperties", + "specialwords.ModelPropertiesClient.sameAsModel": "SpecialWords.ModelProperties.sameAsModel", + "specialwords.ModelPropertiesClient.sameAsModelWithResponse": "SpecialWords.ModelProperties.sameAsModel", + "specialwords.ModelsClient": "SpecialWords.Models", + "specialwords.ModelsClient.withAnd": "SpecialWords.Models.withAnd", + "specialwords.ModelsClient.withAndWithResponse": "SpecialWords.Models.withAnd", + "specialwords.ModelsClient.withAs": "SpecialWords.Models.withAs", + "specialwords.ModelsClient.withAsWithResponse": "SpecialWords.Models.withAs", + "specialwords.ModelsClient.withAssert": "SpecialWords.Models.withAssert", + "specialwords.ModelsClient.withAssertWithResponse": "SpecialWords.Models.withAssert", + "specialwords.ModelsClient.withAsyncWithResponse": "SpecialWords.Models.withAsync", + "specialwords.ModelsClient.withAwait": "SpecialWords.Models.withAwait", + "specialwords.ModelsClient.withAwaitWithResponse": "SpecialWords.Models.withAwait", + "specialwords.ModelsClient.withBreak": "SpecialWords.Models.withBreak", + "specialwords.ModelsClient.withBreakWithResponse": "SpecialWords.Models.withBreak", + "specialwords.ModelsClient.withClass": "SpecialWords.Models.withClass", + "specialwords.ModelsClient.withClassWithResponse": "SpecialWords.Models.withClass", + "specialwords.ModelsClient.withConstructor": "SpecialWords.Models.withConstructor", + "specialwords.ModelsClient.withConstructorWithResponse": "SpecialWords.Models.withConstructor", + "specialwords.ModelsClient.withContinue": "SpecialWords.Models.withContinue", + "specialwords.ModelsClient.withContinueWithResponse": "SpecialWords.Models.withContinue", + "specialwords.ModelsClient.withDef": "SpecialWords.Models.withDef", + "specialwords.ModelsClient.withDefWithResponse": "SpecialWords.Models.withDef", + "specialwords.ModelsClient.withDel": "SpecialWords.Models.withDel", + "specialwords.ModelsClient.withDelWithResponse": "SpecialWords.Models.withDel", + "specialwords.ModelsClient.withElif": "SpecialWords.Models.withElif", + "specialwords.ModelsClient.withElifWithResponse": "SpecialWords.Models.withElif", + "specialwords.ModelsClient.withElse": "SpecialWords.Models.withElse", + "specialwords.ModelsClient.withElseWithResponse": "SpecialWords.Models.withElse", + "specialwords.ModelsClient.withExcept": "SpecialWords.Models.withExcept", + "specialwords.ModelsClient.withExceptWithResponse": "SpecialWords.Models.withExcept", + "specialwords.ModelsClient.withExec": "SpecialWords.Models.withExec", + "specialwords.ModelsClient.withExecWithResponse": "SpecialWords.Models.withExec", + "specialwords.ModelsClient.withFinally": "SpecialWords.Models.withFinally", + "specialwords.ModelsClient.withFinallyWithResponse": "SpecialWords.Models.withFinally", + "specialwords.ModelsClient.withFor": "SpecialWords.Models.withFor", + "specialwords.ModelsClient.withForWithResponse": "SpecialWords.Models.withFor", + "specialwords.ModelsClient.withFrom": "SpecialWords.Models.withFrom", + "specialwords.ModelsClient.withFromWithResponse": "SpecialWords.Models.withFrom", + "specialwords.ModelsClient.withGlobal": "SpecialWords.Models.withGlobal", + "specialwords.ModelsClient.withGlobalWithResponse": "SpecialWords.Models.withGlobal", + "specialwords.ModelsClient.withIf": "SpecialWords.Models.withIf", + "specialwords.ModelsClient.withIfWithResponse": "SpecialWords.Models.withIf", + "specialwords.ModelsClient.withImport": "SpecialWords.Models.withImport", + "specialwords.ModelsClient.withImportWithResponse": "SpecialWords.Models.withImport", + "specialwords.ModelsClient.withIn": "SpecialWords.Models.withIn", + "specialwords.ModelsClient.withInWithResponse": "SpecialWords.Models.withIn", + "specialwords.ModelsClient.withIs": "SpecialWords.Models.withIs", + "specialwords.ModelsClient.withIsWithResponse": "SpecialWords.Models.withIs", + "specialwords.ModelsClient.withLambda": "SpecialWords.Models.withLambda", + "specialwords.ModelsClient.withLambdaWithResponse": "SpecialWords.Models.withLambda", + "specialwords.ModelsClient.withNot": "SpecialWords.Models.withNot", + "specialwords.ModelsClient.withNotWithResponse": "SpecialWords.Models.withNot", + "specialwords.ModelsClient.withOr": "SpecialWords.Models.withOr", + "specialwords.ModelsClient.withOrWithResponse": "SpecialWords.Models.withOr", + "specialwords.ModelsClient.withPass": "SpecialWords.Models.withPass", + "specialwords.ModelsClient.withPassWithResponse": "SpecialWords.Models.withPass", + "specialwords.ModelsClient.withRaise": "SpecialWords.Models.withRaise", + "specialwords.ModelsClient.withRaiseWithResponse": "SpecialWords.Models.withRaise", + "specialwords.ModelsClient.withReturn": "SpecialWords.Models.withReturn", + "specialwords.ModelsClient.withReturnWithResponse": "SpecialWords.Models.withReturn", + "specialwords.ModelsClient.withTry": "SpecialWords.Models.withTry", + "specialwords.ModelsClient.withTryWithResponse": "SpecialWords.Models.withTry", + "specialwords.ModelsClient.withWhile": "SpecialWords.Models.withWhile", + "specialwords.ModelsClient.withWhileWithResponse": "SpecialWords.Models.withWhile", + "specialwords.ModelsClient.withWith": "SpecialWords.Models.withWith", + "specialwords.ModelsClient.withWithWithResponse": "SpecialWords.Models.withWith", + "specialwords.ModelsClient.withYield": "SpecialWords.Models.withYield", + "specialwords.ModelsClient.withYieldWithResponse": "SpecialWords.Models.withYield", + "specialwords.OperationsClient": "SpecialWords.Operations", + "specialwords.OperationsClient.and": "SpecialWords.Operations.and", + "specialwords.OperationsClient.andWithResponse": "SpecialWords.Operations.and", + "specialwords.OperationsClient.as": "SpecialWords.Operations.as", + "specialwords.OperationsClient.asWithResponse": "SpecialWords.Operations.as", + "specialwords.OperationsClient.assertMethod": "SpecialWords.Operations.assert", + "specialwords.OperationsClient.assertMethodWithResponse": "SpecialWords.Operations.assert", + "specialwords.OperationsClient.async": "SpecialWords.Operations.async", + "specialwords.OperationsClient.asyncWithResponse": "SpecialWords.Operations.async", + "specialwords.OperationsClient.await": "SpecialWords.Operations.await", + "specialwords.OperationsClient.awaitWithResponse": "SpecialWords.Operations.await", + "specialwords.OperationsClient.breakMethod": "SpecialWords.Operations.break", + "specialwords.OperationsClient.breakMethodWithResponse": "SpecialWords.Operations.break", + "specialwords.OperationsClient.classMethod": "SpecialWords.Operations.class", + "specialwords.OperationsClient.classMethodWithResponse": "SpecialWords.Operations.class", + "specialwords.OperationsClient.constructor": "SpecialWords.Operations.constructor", + "specialwords.OperationsClient.constructorWithResponse": "SpecialWords.Operations.constructor", + "specialwords.OperationsClient.continueMethod": "SpecialWords.Operations.continue", + "specialwords.OperationsClient.continueMethodWithResponse": "SpecialWords.Operations.continue", + "specialwords.OperationsClient.def": "SpecialWords.Operations.def", + "specialwords.OperationsClient.defWithResponse": "SpecialWords.Operations.def", + "specialwords.OperationsClient.del": "SpecialWords.Operations.del", + "specialwords.OperationsClient.delWithResponse": "SpecialWords.Operations.del", + "specialwords.OperationsClient.elif": "SpecialWords.Operations.elif", + "specialwords.OperationsClient.elifWithResponse": "SpecialWords.Operations.elif", + "specialwords.OperationsClient.elseMethod": "SpecialWords.Operations.else", + "specialwords.OperationsClient.elseMethodWithResponse": "SpecialWords.Operations.else", + "specialwords.OperationsClient.except": "SpecialWords.Operations.except", + "specialwords.OperationsClient.exceptWithResponse": "SpecialWords.Operations.except", + "specialwords.OperationsClient.exec": "SpecialWords.Operations.exec", + "specialwords.OperationsClient.execWithResponse": "SpecialWords.Operations.exec", + "specialwords.OperationsClient.finallyMethod": "SpecialWords.Operations.finally", + "specialwords.OperationsClient.finallyMethodWithResponse": "SpecialWords.Operations.finally", + "specialwords.OperationsClient.forMethod": "SpecialWords.Operations.for", + "specialwords.OperationsClient.forMethodWithResponse": "SpecialWords.Operations.for", + "specialwords.OperationsClient.from": "SpecialWords.Operations.from", + "specialwords.OperationsClient.fromWithResponse": "SpecialWords.Operations.from", + "specialwords.OperationsClient.global": "SpecialWords.Operations.global", + "specialwords.OperationsClient.globalWithResponse": "SpecialWords.Operations.global", + "specialwords.OperationsClient.ifMethod": "SpecialWords.Operations.if", + "specialwords.OperationsClient.ifMethodWithResponse": "SpecialWords.Operations.if", + "specialwords.OperationsClient.importMethod": "SpecialWords.Operations.import", + "specialwords.OperationsClient.importMethodWithResponse": "SpecialWords.Operations.import", + "specialwords.OperationsClient.in": "SpecialWords.Operations.in", + "specialwords.OperationsClient.inWithResponse": "SpecialWords.Operations.in", + "specialwords.OperationsClient.is": "SpecialWords.Operations.is", + "specialwords.OperationsClient.isWithResponse": "SpecialWords.Operations.is", + "specialwords.OperationsClient.lambda": "SpecialWords.Operations.lambda", + "specialwords.OperationsClient.lambdaWithResponse": "SpecialWords.Operations.lambda", + "specialwords.OperationsClient.not": "SpecialWords.Operations.not", + "specialwords.OperationsClient.notWithResponse": "SpecialWords.Operations.not", + "specialwords.OperationsClient.or": "SpecialWords.Operations.or", + "specialwords.OperationsClient.orWithResponse": "SpecialWords.Operations.or", + "specialwords.OperationsClient.pass": "SpecialWords.Operations.pass", + "specialwords.OperationsClient.passWithResponse": "SpecialWords.Operations.pass", + "specialwords.OperationsClient.raise": "SpecialWords.Operations.raise", + "specialwords.OperationsClient.raiseWithResponse": "SpecialWords.Operations.raise", + "specialwords.OperationsClient.returnMethod": "SpecialWords.Operations.return", + "specialwords.OperationsClient.returnMethodWithResponse": "SpecialWords.Operations.return", + "specialwords.OperationsClient.tryMethod": "SpecialWords.Operations.try", + "specialwords.OperationsClient.tryMethodWithResponse": "SpecialWords.Operations.try", + "specialwords.OperationsClient.whileMethod": "SpecialWords.Operations.while", + "specialwords.OperationsClient.whileMethodWithResponse": "SpecialWords.Operations.while", + "specialwords.OperationsClient.with": "SpecialWords.Operations.with", + "specialwords.OperationsClient.withWithResponse": "SpecialWords.Operations.with", + "specialwords.OperationsClient.yield": "SpecialWords.Operations.yield", + "specialwords.OperationsClient.yieldWithResponse": "SpecialWords.Operations.yield", + "specialwords.ParametersClient": "SpecialWords.Parameters", + "specialwords.ParametersClient.withAnd": "SpecialWords.Parameters.withAnd", + "specialwords.ParametersClient.withAndWithResponse": "SpecialWords.Parameters.withAnd", + "specialwords.ParametersClient.withAs": "SpecialWords.Parameters.withAs", + "specialwords.ParametersClient.withAsWithResponse": "SpecialWords.Parameters.withAs", + "specialwords.ParametersClient.withAssert": "SpecialWords.Parameters.withAssert", + "specialwords.ParametersClient.withAssertWithResponse": "SpecialWords.Parameters.withAssert", + "specialwords.ParametersClient.withAsyncWithResponse": "SpecialWords.Parameters.withAsync", + "specialwords.ParametersClient.withAwait": "SpecialWords.Parameters.withAwait", + "specialwords.ParametersClient.withAwaitWithResponse": "SpecialWords.Parameters.withAwait", + "specialwords.ParametersClient.withBreak": "SpecialWords.Parameters.withBreak", + "specialwords.ParametersClient.withBreakWithResponse": "SpecialWords.Parameters.withBreak", + "specialwords.ParametersClient.withCancellationToken": "SpecialWords.Parameters.withCancellationToken", + "specialwords.ParametersClient.withCancellationTokenWithResponse": "SpecialWords.Parameters.withCancellationToken", + "specialwords.ParametersClient.withClass": "SpecialWords.Parameters.withClass", + "specialwords.ParametersClient.withClassWithResponse": "SpecialWords.Parameters.withClass", + "specialwords.ParametersClient.withConstructor": "SpecialWords.Parameters.withConstructor", + "specialwords.ParametersClient.withConstructorWithResponse": "SpecialWords.Parameters.withConstructor", + "specialwords.ParametersClient.withContinue": "SpecialWords.Parameters.withContinue", + "specialwords.ParametersClient.withContinueWithResponse": "SpecialWords.Parameters.withContinue", + "specialwords.ParametersClient.withDef": "SpecialWords.Parameters.withDef", + "specialwords.ParametersClient.withDefWithResponse": "SpecialWords.Parameters.withDef", + "specialwords.ParametersClient.withDel": "SpecialWords.Parameters.withDel", + "specialwords.ParametersClient.withDelWithResponse": "SpecialWords.Parameters.withDel", + "specialwords.ParametersClient.withElif": "SpecialWords.Parameters.withElif", + "specialwords.ParametersClient.withElifWithResponse": "SpecialWords.Parameters.withElif", + "specialwords.ParametersClient.withElse": "SpecialWords.Parameters.withElse", + "specialwords.ParametersClient.withElseWithResponse": "SpecialWords.Parameters.withElse", + "specialwords.ParametersClient.withExcept": "SpecialWords.Parameters.withExcept", + "specialwords.ParametersClient.withExceptWithResponse": "SpecialWords.Parameters.withExcept", + "specialwords.ParametersClient.withExec": "SpecialWords.Parameters.withExec", + "specialwords.ParametersClient.withExecWithResponse": "SpecialWords.Parameters.withExec", + "specialwords.ParametersClient.withFinally": "SpecialWords.Parameters.withFinally", + "specialwords.ParametersClient.withFinallyWithResponse": "SpecialWords.Parameters.withFinally", + "specialwords.ParametersClient.withFor": "SpecialWords.Parameters.withFor", + "specialwords.ParametersClient.withForWithResponse": "SpecialWords.Parameters.withFor", + "specialwords.ParametersClient.withFrom": "SpecialWords.Parameters.withFrom", + "specialwords.ParametersClient.withFromWithResponse": "SpecialWords.Parameters.withFrom", + "specialwords.ParametersClient.withGlobal": "SpecialWords.Parameters.withGlobal", + "specialwords.ParametersClient.withGlobalWithResponse": "SpecialWords.Parameters.withGlobal", + "specialwords.ParametersClient.withIf": "SpecialWords.Parameters.withIf", + "specialwords.ParametersClient.withIfWithResponse": "SpecialWords.Parameters.withIf", + "specialwords.ParametersClient.withImport": "SpecialWords.Parameters.withImport", + "specialwords.ParametersClient.withImportWithResponse": "SpecialWords.Parameters.withImport", + "specialwords.ParametersClient.withIn": "SpecialWords.Parameters.withIn", + "specialwords.ParametersClient.withInWithResponse": "SpecialWords.Parameters.withIn", + "specialwords.ParametersClient.withIs": "SpecialWords.Parameters.withIs", + "specialwords.ParametersClient.withIsWithResponse": "SpecialWords.Parameters.withIs", + "specialwords.ParametersClient.withLambda": "SpecialWords.Parameters.withLambda", + "specialwords.ParametersClient.withLambdaWithResponse": "SpecialWords.Parameters.withLambda", + "specialwords.ParametersClient.withNot": "SpecialWords.Parameters.withNot", + "specialwords.ParametersClient.withNotWithResponse": "SpecialWords.Parameters.withNot", + "specialwords.ParametersClient.withOr": "SpecialWords.Parameters.withOr", + "specialwords.ParametersClient.withOrWithResponse": "SpecialWords.Parameters.withOr", + "specialwords.ParametersClient.withPass": "SpecialWords.Parameters.withPass", + "specialwords.ParametersClient.withPassWithResponse": "SpecialWords.Parameters.withPass", + "specialwords.ParametersClient.withRaise": "SpecialWords.Parameters.withRaise", + "specialwords.ParametersClient.withRaiseWithResponse": "SpecialWords.Parameters.withRaise", + "specialwords.ParametersClient.withReturn": "SpecialWords.Parameters.withReturn", + "specialwords.ParametersClient.withReturnWithResponse": "SpecialWords.Parameters.withReturn", + "specialwords.ParametersClient.withTry": "SpecialWords.Parameters.withTry", + "specialwords.ParametersClient.withTryWithResponse": "SpecialWords.Parameters.withTry", + "specialwords.ParametersClient.withWhile": "SpecialWords.Parameters.withWhile", + "specialwords.ParametersClient.withWhileWithResponse": "SpecialWords.Parameters.withWhile", + "specialwords.ParametersClient.withWith": "SpecialWords.Parameters.withWith", + "specialwords.ParametersClient.withWithWithResponse": "SpecialWords.Parameters.withWith", + "specialwords.ParametersClient.withYield": "SpecialWords.Parameters.withYield", + "specialwords.ParametersClient.withYieldWithResponse": "SpecialWords.Parameters.withYield", + "specialwords.SpecialWordsClientBuilder": "SpecialWords", + "specialwords.modelproperties.SameAsModel": "SpecialWords.ModelProperties.SameAsModel", + "specialwords.models.And": "SpecialWords.Models.and", + "specialwords.models.As": "SpecialWords.Models.as", + "specialwords.models.Assert": "SpecialWords.Models.assert", + "specialwords.models.Async": "SpecialWords.Models.async", + "specialwords.models.Await": "SpecialWords.Models.await", + "specialwords.models.Break": "SpecialWords.Models.break", + "specialwords.models.ClassModel": "SpecialWords.Models.class", + "specialwords.models.Constructor": "SpecialWords.Models.constructor", + "specialwords.models.Continue": "SpecialWords.Models.continue", + "specialwords.models.Def": "SpecialWords.Models.def", + "specialwords.models.Del": "SpecialWords.Models.del", + "specialwords.models.Elif": "SpecialWords.Models.elif", + "specialwords.models.Else": "SpecialWords.Models.else", + "specialwords.models.Except": "SpecialWords.Models.except", + "specialwords.models.Exec": "SpecialWords.Models.exec", + "specialwords.models.Finally": "SpecialWords.Models.finally", + "specialwords.models.For": "SpecialWords.Models.for", + "specialwords.models.From": "SpecialWords.Models.from", + "specialwords.models.Global": "SpecialWords.Models.global", + "specialwords.models.If": "SpecialWords.Models.if", + "specialwords.models.Import": "SpecialWords.Models.import", + "specialwords.models.In": "SpecialWords.Models.in", + "specialwords.models.Is": "SpecialWords.Models.is", + "specialwords.models.Lambda": "SpecialWords.Models.lambda", + "specialwords.models.Not": "SpecialWords.Models.not", + "specialwords.models.Or": "SpecialWords.Models.or", + "specialwords.models.Pass": "SpecialWords.Models.pass", + "specialwords.models.Raise": "SpecialWords.Models.raise", + "specialwords.models.Return": "SpecialWords.Models.return", + "specialwords.models.Try": "SpecialWords.Models.try", + "specialwords.models.While": "SpecialWords.Models.while", + "specialwords.models.With": "SpecialWords.Models.with", + "specialwords.models.Yield": "SpecialWords.Models.yield" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-array_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-array_apiview_properties.json new file mode 100644 index 0000000000..35f040a1a9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-array_apiview_properties.json @@ -0,0 +1,77 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.array.ArrayClientBuilder": "Type.Array", + "type.array.BooleanValueClient": "Type.Array.BooleanValue", + "type.array.BooleanValueClient.get": "Type.Array.BooleanValue.get", + "type.array.BooleanValueClient.getWithResponse": "Type.Array.BooleanValue.get", + "type.array.BooleanValueClient.put": "Type.Array.BooleanValue.put", + "type.array.BooleanValueClient.putWithResponse": "Type.Array.BooleanValue.put", + "type.array.DatetimeValueClient": "Type.Array.DatetimeValue", + "type.array.DatetimeValueClient.get": "Type.Array.DatetimeValue.get", + "type.array.DatetimeValueClient.getWithResponse": "Type.Array.DatetimeValue.get", + "type.array.DatetimeValueClient.put": "Type.Array.DatetimeValue.put", + "type.array.DatetimeValueClient.putWithResponse": "Type.Array.DatetimeValue.put", + "type.array.DurationValueClient": "Type.Array.DurationValue", + "type.array.DurationValueClient.get": "Type.Array.DurationValue.get", + "type.array.DurationValueClient.getWithResponse": "Type.Array.DurationValue.get", + "type.array.DurationValueClient.put": "Type.Array.DurationValue.put", + "type.array.DurationValueClient.putWithResponse": "Type.Array.DurationValue.put", + "type.array.Float32ValueClient": "Type.Array.Float32Value", + "type.array.Float32ValueClient.get": "Type.Array.Float32Value.get", + "type.array.Float32ValueClient.getWithResponse": "Type.Array.Float32Value.get", + "type.array.Float32ValueClient.put": "Type.Array.Float32Value.put", + "type.array.Float32ValueClient.putWithResponse": "Type.Array.Float32Value.put", + "type.array.InnerModel": "Type.Array.InnerModel", + "type.array.Int32ValueClient": "Type.Array.Int32Value", + "type.array.Int32ValueClient.get": "Type.Array.Int32Value.get", + "type.array.Int32ValueClient.getWithResponse": "Type.Array.Int32Value.get", + "type.array.Int32ValueClient.put": "Type.Array.Int32Value.put", + "type.array.Int32ValueClient.putWithResponse": "Type.Array.Int32Value.put", + "type.array.Int64ValueClient": "Type.Array.Int64Value", + "type.array.Int64ValueClient.get": "Type.Array.Int64Value.get", + "type.array.Int64ValueClient.getWithResponse": "Type.Array.Int64Value.get", + "type.array.Int64ValueClient.put": "Type.Array.Int64Value.put", + "type.array.Int64ValueClient.putWithResponse": "Type.Array.Int64Value.put", + "type.array.ModelValueClient": "Type.Array.ModelValue", + "type.array.ModelValueClient.get": "Type.Array.ModelValue.get", + "type.array.ModelValueClient.getWithResponse": "Type.Array.ModelValue.get", + "type.array.ModelValueClient.put": "Type.Array.ModelValue.put", + "type.array.ModelValueClient.putWithResponse": "Type.Array.ModelValue.put", + "type.array.NullableBooleanValueClient": "Type.Array.NullableBooleanValue", + "type.array.NullableBooleanValueClient.get": "Type.Array.NullableBooleanValue.get", + "type.array.NullableBooleanValueClient.getWithResponse": "Type.Array.NullableBooleanValue.get", + "type.array.NullableBooleanValueClient.put": "Type.Array.NullableBooleanValue.put", + "type.array.NullableBooleanValueClient.putWithResponse": "Type.Array.NullableBooleanValue.put", + "type.array.NullableFloatValueClient": "Type.Array.NullableFloatValue", + "type.array.NullableFloatValueClient.get": "Type.Array.NullableFloatValue.get", + "type.array.NullableFloatValueClient.getWithResponse": "Type.Array.NullableFloatValue.get", + "type.array.NullableFloatValueClient.put": "Type.Array.NullableFloatValue.put", + "type.array.NullableFloatValueClient.putWithResponse": "Type.Array.NullableFloatValue.put", + "type.array.NullableInt32ValueClient": "Type.Array.NullableInt32Value", + "type.array.NullableInt32ValueClient.get": "Type.Array.NullableInt32Value.get", + "type.array.NullableInt32ValueClient.getWithResponse": "Type.Array.NullableInt32Value.get", + "type.array.NullableInt32ValueClient.put": "Type.Array.NullableInt32Value.put", + "type.array.NullableInt32ValueClient.putWithResponse": "Type.Array.NullableInt32Value.put", + "type.array.NullableModelValueClient": "Type.Array.NullableModelValue", + "type.array.NullableModelValueClient.get": "Type.Array.NullableModelValue.get", + "type.array.NullableModelValueClient.getWithResponse": "Type.Array.NullableModelValue.get", + "type.array.NullableModelValueClient.put": "Type.Array.NullableModelValue.put", + "type.array.NullableModelValueClient.putWithResponse": "Type.Array.NullableModelValue.put", + "type.array.NullableStringValueClient": "Type.Array.NullableStringValue", + "type.array.NullableStringValueClient.get": "Type.Array.NullableStringValue.get", + "type.array.NullableStringValueClient.getWithResponse": "Type.Array.NullableStringValue.get", + "type.array.NullableStringValueClient.put": "Type.Array.NullableStringValue.put", + "type.array.NullableStringValueClient.putWithResponse": "Type.Array.NullableStringValue.put", + "type.array.StringValueClient": "Type.Array.StringValue", + "type.array.StringValueClient.get": "Type.Array.StringValue.get", + "type.array.StringValueClient.getWithResponse": "Type.Array.StringValue.get", + "type.array.StringValueClient.put": "Type.Array.StringValue.put", + "type.array.StringValueClient.putWithResponse": "Type.Array.StringValue.put", + "type.array.UnknownValueClient": "Type.Array.UnknownValue", + "type.array.UnknownValueClient.get": "Type.Array.UnknownValue.get", + "type.array.UnknownValueClient.getWithResponse": "Type.Array.UnknownValue.get", + "type.array.UnknownValueClient.put": "Type.Array.UnknownValue.put", + "type.array.UnknownValueClient.putWithResponse": "Type.Array.UnknownValue.put" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-dictionary_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-dictionary_apiview_properties.json new file mode 100644 index 0000000000..e117716666 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-dictionary_apiview_properties.json @@ -0,0 +1,62 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.dictionary.BooleanValueClient": "Type.Dictionary.BooleanValue", + "type.dictionary.BooleanValueClient.get": "Type.Dictionary.BooleanValue.get", + "type.dictionary.BooleanValueClient.getWithResponse": "Type.Dictionary.BooleanValue.get", + "type.dictionary.BooleanValueClient.put": "Type.Dictionary.BooleanValue.put", + "type.dictionary.BooleanValueClient.putWithResponse": "Type.Dictionary.BooleanValue.put", + "type.dictionary.DatetimeValueClient": "Type.Dictionary.DatetimeValue", + "type.dictionary.DatetimeValueClient.get": "Type.Dictionary.DatetimeValue.get", + "type.dictionary.DatetimeValueClient.getWithResponse": "Type.Dictionary.DatetimeValue.get", + "type.dictionary.DatetimeValueClient.put": "Type.Dictionary.DatetimeValue.put", + "type.dictionary.DatetimeValueClient.putWithResponse": "Type.Dictionary.DatetimeValue.put", + "type.dictionary.DictionaryClientBuilder": "Type.Dictionary", + "type.dictionary.DurationValueClient": "Type.Dictionary.DurationValue", + "type.dictionary.DurationValueClient.get": "Type.Dictionary.DurationValue.get", + "type.dictionary.DurationValueClient.getWithResponse": "Type.Dictionary.DurationValue.get", + "type.dictionary.DurationValueClient.put": "Type.Dictionary.DurationValue.put", + "type.dictionary.DurationValueClient.putWithResponse": "Type.Dictionary.DurationValue.put", + "type.dictionary.Float32ValueClient": "Type.Dictionary.Float32Value", + "type.dictionary.Float32ValueClient.get": "Type.Dictionary.Float32Value.get", + "type.dictionary.Float32ValueClient.getWithResponse": "Type.Dictionary.Float32Value.get", + "type.dictionary.Float32ValueClient.put": "Type.Dictionary.Float32Value.put", + "type.dictionary.Float32ValueClient.putWithResponse": "Type.Dictionary.Float32Value.put", + "type.dictionary.InnerModel": "Type.Dictionary.InnerModel", + "type.dictionary.Int32ValueClient": "Type.Dictionary.Int32Value", + "type.dictionary.Int32ValueClient.get": "Type.Dictionary.Int32Value.get", + "type.dictionary.Int32ValueClient.getWithResponse": "Type.Dictionary.Int32Value.get", + "type.dictionary.Int32ValueClient.put": "Type.Dictionary.Int32Value.put", + "type.dictionary.Int32ValueClient.putWithResponse": "Type.Dictionary.Int32Value.put", + "type.dictionary.Int64ValueClient": "Type.Dictionary.Int64Value", + "type.dictionary.Int64ValueClient.get": "Type.Dictionary.Int64Value.get", + "type.dictionary.Int64ValueClient.getWithResponse": "Type.Dictionary.Int64Value.get", + "type.dictionary.Int64ValueClient.put": "Type.Dictionary.Int64Value.put", + "type.dictionary.Int64ValueClient.putWithResponse": "Type.Dictionary.Int64Value.put", + "type.dictionary.ModelValueClient": "Type.Dictionary.ModelValue", + "type.dictionary.ModelValueClient.get": "Type.Dictionary.ModelValue.get", + "type.dictionary.ModelValueClient.getWithResponse": "Type.Dictionary.ModelValue.get", + "type.dictionary.ModelValueClient.put": "Type.Dictionary.ModelValue.put", + "type.dictionary.ModelValueClient.putWithResponse": "Type.Dictionary.ModelValue.put", + "type.dictionary.NullableFloatValueClient": "Type.Dictionary.NullableFloatValue", + "type.dictionary.NullableFloatValueClient.get": "Type.Dictionary.NullableFloatValue.get", + "type.dictionary.NullableFloatValueClient.getWithResponse": "Type.Dictionary.NullableFloatValue.get", + "type.dictionary.NullableFloatValueClient.put": "Type.Dictionary.NullableFloatValue.put", + "type.dictionary.NullableFloatValueClient.putWithResponse": "Type.Dictionary.NullableFloatValue.put", + "type.dictionary.RecursiveModelValueClient": "Type.Dictionary.RecursiveModelValue", + "type.dictionary.RecursiveModelValueClient.get": "Type.Dictionary.RecursiveModelValue.get", + "type.dictionary.RecursiveModelValueClient.getWithResponse": "Type.Dictionary.RecursiveModelValue.get", + "type.dictionary.RecursiveModelValueClient.put": "Type.Dictionary.RecursiveModelValue.put", + "type.dictionary.RecursiveModelValueClient.putWithResponse": "Type.Dictionary.RecursiveModelValue.put", + "type.dictionary.StringValueClient": "Type.Dictionary.StringValue", + "type.dictionary.StringValueClient.get": "Type.Dictionary.StringValue.get", + "type.dictionary.StringValueClient.getWithResponse": "Type.Dictionary.StringValue.get", + "type.dictionary.StringValueClient.put": "Type.Dictionary.StringValue.put", + "type.dictionary.StringValueClient.putWithResponse": "Type.Dictionary.StringValue.put", + "type.dictionary.UnknownValueClient": "Type.Dictionary.UnknownValue", + "type.dictionary.UnknownValueClient.get": "Type.Dictionary.UnknownValue.get", + "type.dictionary.UnknownValueClient.getWithResponse": "Type.Dictionary.UnknownValue.get", + "type.dictionary.UnknownValueClient.put": "Type.Dictionary.UnknownValue.put", + "type.dictionary.UnknownValueClient.putWithResponse": "Type.Dictionary.UnknownValue.put" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-enums-extensible_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-enums-extensible_apiview_properties.json new file mode 100644 index 0000000000..e2779ebb2c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-enums-extensible_apiview_properties.json @@ -0,0 +1,16 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.enums.extensible.DaysOfWeekExtensibleEnum": "Type.Enum.Extensible.DaysOfWeekExtensibleEnum", + "type.enums.extensible.ExtensibleClient": "Type.Enum.Extensible.String", + "type.enums.extensible.ExtensibleClient.getKnownValue": "Type.Enum.Extensible.String.getKnownValue", + "type.enums.extensible.ExtensibleClient.getKnownValueWithResponse": "Type.Enum.Extensible.String.getKnownValue", + "type.enums.extensible.ExtensibleClient.getUnknownValue": "Type.Enum.Extensible.String.getUnknownValue", + "type.enums.extensible.ExtensibleClient.getUnknownValueWithResponse": "Type.Enum.Extensible.String.getUnknownValue", + "type.enums.extensible.ExtensibleClient.putKnownValue": "Type.Enum.Extensible.String.putKnownValue", + "type.enums.extensible.ExtensibleClient.putKnownValueWithResponse": "Type.Enum.Extensible.String.putKnownValue", + "type.enums.extensible.ExtensibleClient.putUnknownValue": "Type.Enum.Extensible.String.putUnknownValue", + "type.enums.extensible.ExtensibleClient.putUnknownValueWithResponse": "Type.Enum.Extensible.String.putUnknownValue", + "type.enums.extensible.ExtensibleClientBuilder": "Type.Enum.Extensible" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-enums-fixed_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-enums-fixed_apiview_properties.json new file mode 100644 index 0000000000..d639729739 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-enums-fixed_apiview_properties.json @@ -0,0 +1,14 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.enums.fixed.DaysOfWeekEnum": "Type.Enum.Fixed.DaysOfWeekEnum", + "type.enums.fixed.FixedClient": "Type.Enum.Fixed.String", + "type.enums.fixed.FixedClient.getKnownValue": "Type.Enum.Fixed.String.getKnownValue", + "type.enums.fixed.FixedClient.getKnownValueWithResponse": "Type.Enum.Fixed.String.getKnownValue", + "type.enums.fixed.FixedClient.putKnownValue": "Type.Enum.Fixed.String.putKnownValue", + "type.enums.fixed.FixedClient.putKnownValueWithResponse": "Type.Enum.Fixed.String.putKnownValue", + "type.enums.fixed.FixedClient.putUnknownValue": "Type.Enum.Fixed.String.putUnknownValue", + "type.enums.fixed.FixedClient.putUnknownValueWithResponse": "Type.Enum.Fixed.String.putUnknownValue", + "type.enums.fixed.FixedClientBuilder": "Type.Enum.Fixed" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-empty_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-empty_apiview_properties.json new file mode 100644 index 0000000000..67b44a9052 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-empty_apiview_properties.json @@ -0,0 +1,16 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.model.empty.EmptyClient": "Type.Model.Empty", + "type.model.empty.EmptyClient.getEmpty": "Type.Model.Empty.getEmpty", + "type.model.empty.EmptyClient.getEmptyWithResponse": "Type.Model.Empty.getEmpty", + "type.model.empty.EmptyClient.postRoundTripEmpty": "Type.Model.Empty.postRoundTripEmpty", + "type.model.empty.EmptyClient.postRoundTripEmptyWithResponse": "Type.Model.Empty.postRoundTripEmpty", + "type.model.empty.EmptyClient.putEmpty": "Type.Model.Empty.putEmpty", + "type.model.empty.EmptyClient.putEmptyWithResponse": "Type.Model.Empty.putEmpty", + "type.model.empty.EmptyClientBuilder": "Type.Model.Empty", + "type.model.empty.EmptyInput": "Type.Model.Empty.EmptyInput", + "type.model.empty.EmptyInputOutput": "Type.Model.Empty.EmptyInputOutput", + "type.model.empty.EmptyOutput": "Type.Model.Empty.EmptyOutput" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-enumdiscriminator_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-enumdiscriminator_apiview_properties.json new file mode 100644 index 0000000000..b672db30a4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-enumdiscriminator_apiview_properties.json @@ -0,0 +1,29 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.model.inheritance.enumdiscriminator.Cobra": "Type.Model.Inheritance.EnumDiscriminator.Cobra", + "type.model.inheritance.enumdiscriminator.Dog": "Type.Model.Inheritance.EnumDiscriminator.Dog", + "type.model.inheritance.enumdiscriminator.DogKind": "Type.Model.Inheritance.EnumDiscriminator.DogKind", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient": "Type.Model.Inheritance.EnumDiscriminator", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getExtensibleModel": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModel", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getExtensibleModelMissingDiscriminator": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModelMissingDiscriminator", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getExtensibleModelMissingDiscriminatorWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModelMissingDiscriminator", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getExtensibleModelWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModel", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getExtensibleModelWrongDiscriminator": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModelWrongDiscriminator", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getExtensibleModelWrongDiscriminatorWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getExtensibleModelWrongDiscriminator", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getFixedModel": "Type.Model.Inheritance.EnumDiscriminator.getFixedModel", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getFixedModelMissingDiscriminator": "Type.Model.Inheritance.EnumDiscriminator.getFixedModelMissingDiscriminator", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getFixedModelMissingDiscriminatorWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getFixedModelMissingDiscriminator", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getFixedModelWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getFixedModel", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getFixedModelWrongDiscriminator": "Type.Model.Inheritance.EnumDiscriminator.getFixedModelWrongDiscriminator", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.getFixedModelWrongDiscriminatorWithResponse": "Type.Model.Inheritance.EnumDiscriminator.getFixedModelWrongDiscriminator", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.putExtensibleModel": "Type.Model.Inheritance.EnumDiscriminator.putExtensibleModel", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.putExtensibleModelWithResponse": "Type.Model.Inheritance.EnumDiscriminator.putExtensibleModel", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.putFixedModel": "Type.Model.Inheritance.EnumDiscriminator.putFixedModel", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient.putFixedModelWithResponse": "Type.Model.Inheritance.EnumDiscriminator.putFixedModel", + "type.model.inheritance.enumdiscriminator.EnumDiscriminatorClientBuilder": "Type.Model.Inheritance.EnumDiscriminator", + "type.model.inheritance.enumdiscriminator.Golden": "Type.Model.Inheritance.EnumDiscriminator.Golden", + "type.model.inheritance.enumdiscriminator.Snake": "Type.Model.Inheritance.EnumDiscriminator.Snake", + "type.model.inheritance.enumdiscriminator.SnakeKind": "Type.Model.Inheritance.EnumDiscriminator.SnakeKind" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-nesteddiscriminator_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-nesteddiscriminator_apiview_properties.json new file mode 100644 index 0000000000..aab326625d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-nesteddiscriminator_apiview_properties.json @@ -0,0 +1,24 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.model.inheritance.nesteddiscriminator.Fish": "Type.Model.Inheritance.NestedDiscriminator.Fish", + "type.model.inheritance.nesteddiscriminator.GoblinShark": "Type.Model.Inheritance.NestedDiscriminator.GoblinShark", + "type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient": "Type.Model.Inheritance.NestedDiscriminator", + "type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.getMissingDiscriminator": "Type.Model.Inheritance.NestedDiscriminator.getMissingDiscriminator", + "type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.getMissingDiscriminatorWithResponse": "Type.Model.Inheritance.NestedDiscriminator.getMissingDiscriminator", + "type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.getModel": "Type.Model.Inheritance.NestedDiscriminator.getModel", + "type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.getModelWithResponse": "Type.Model.Inheritance.NestedDiscriminator.getModel", + "type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.getRecursiveModel": "Type.Model.Inheritance.NestedDiscriminator.getRecursiveModel", + "type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.getRecursiveModelWithResponse": "Type.Model.Inheritance.NestedDiscriminator.getRecursiveModel", + "type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.getWrongDiscriminator": "Type.Model.Inheritance.NestedDiscriminator.getWrongDiscriminator", + "type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.getWrongDiscriminatorWithResponse": "Type.Model.Inheritance.NestedDiscriminator.getWrongDiscriminator", + "type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.putModel": "Type.Model.Inheritance.NestedDiscriminator.putModel", + "type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.putModelWithResponse": "Type.Model.Inheritance.NestedDiscriminator.putModel", + "type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.putRecursiveModel": "Type.Model.Inheritance.NestedDiscriminator.putRecursiveModel", + "type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient.putRecursiveModelWithResponse": "Type.Model.Inheritance.NestedDiscriminator.putRecursiveModel", + "type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClientBuilder": "Type.Model.Inheritance.NestedDiscriminator", + "type.model.inheritance.nesteddiscriminator.Salmon": "Type.Model.Inheritance.NestedDiscriminator.Salmon", + "type.model.inheritance.nesteddiscriminator.SawShark": "Type.Model.Inheritance.NestedDiscriminator.SawShark", + "type.model.inheritance.nesteddiscriminator.Shark": "Type.Model.Inheritance.NestedDiscriminator.Shark" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-notdiscriminated_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-notdiscriminated_apiview_properties.json new file mode 100644 index 0000000000..79f7ba5614 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-notdiscriminated_apiview_properties.json @@ -0,0 +1,16 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.model.inheritance.notdiscriminated.Cat": "Type.Model.Inheritance.NotDiscriminated.Cat", + "type.model.inheritance.notdiscriminated.NotDiscriminatedClient": "Type.Model.Inheritance.NotDiscriminated", + "type.model.inheritance.notdiscriminated.NotDiscriminatedClient.getValid": "Type.Model.Inheritance.NotDiscriminated.getValid", + "type.model.inheritance.notdiscriminated.NotDiscriminatedClient.getValidWithResponse": "Type.Model.Inheritance.NotDiscriminated.getValid", + "type.model.inheritance.notdiscriminated.NotDiscriminatedClient.postValid": "Type.Model.Inheritance.NotDiscriminated.postValid", + "type.model.inheritance.notdiscriminated.NotDiscriminatedClient.postValidWithResponse": "Type.Model.Inheritance.NotDiscriminated.postValid", + "type.model.inheritance.notdiscriminated.NotDiscriminatedClient.putValid": "Type.Model.Inheritance.NotDiscriminated.putValid", + "type.model.inheritance.notdiscriminated.NotDiscriminatedClient.putValidWithResponse": "Type.Model.Inheritance.NotDiscriminated.putValid", + "type.model.inheritance.notdiscriminated.NotDiscriminatedClientBuilder": "Type.Model.Inheritance.NotDiscriminated", + "type.model.inheritance.notdiscriminated.Pet": "Type.Model.Inheritance.NotDiscriminated.Pet", + "type.model.inheritance.notdiscriminated.Siamese": "Type.Model.Inheritance.NotDiscriminated.Siamese" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-recursive_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-recursive_apiview_properties.json new file mode 100644 index 0000000000..bce7c49fc3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-recursive_apiview_properties.json @@ -0,0 +1,13 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.model.inheritance.recursive.Element": "Type.Model.Inheritance.Recursive.Element", + "type.model.inheritance.recursive.Extension": "Type.Model.Inheritance.Recursive.Extension", + "type.model.inheritance.recursive.RecursiveClient": "Type.Model.Inheritance.Recursive", + "type.model.inheritance.recursive.RecursiveClient.get": "Type.Model.Inheritance.Recursive.get", + "type.model.inheritance.recursive.RecursiveClient.getWithResponse": "Type.Model.Inheritance.Recursive.get", + "type.model.inheritance.recursive.RecursiveClient.put": "Type.Model.Inheritance.Recursive.put", + "type.model.inheritance.recursive.RecursiveClient.putWithResponse": "Type.Model.Inheritance.Recursive.put", + "type.model.inheritance.recursive.RecursiveClientBuilder": "Type.Model.Inheritance.Recursive" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_apiview_properties.json new file mode 100644 index 0000000000..1294fc4a0b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-inheritance-singlediscriminator_apiview_properties.json @@ -0,0 +1,28 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.model.inheritance.singlediscriminator.Bird": "Type.Model.Inheritance.SingleDiscriminator.Bird", + "type.model.inheritance.singlediscriminator.Dinosaur": "Type.Model.Inheritance.SingleDiscriminator.Dinosaur", + "type.model.inheritance.singlediscriminator.Eagle": "Type.Model.Inheritance.SingleDiscriminator.Eagle", + "type.model.inheritance.singlediscriminator.Goose": "Type.Model.Inheritance.SingleDiscriminator.Goose", + "type.model.inheritance.singlediscriminator.SeaGull": "Type.Model.Inheritance.SingleDiscriminator.SeaGull", + "type.model.inheritance.singlediscriminator.SingleDiscriminatorClient": "Type.Model.Inheritance.SingleDiscriminator", + "type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getLegacyModel": "Type.Model.Inheritance.SingleDiscriminator.getLegacyModel", + "type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getLegacyModelWithResponse": "Type.Model.Inheritance.SingleDiscriminator.getLegacyModel", + "type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getMissingDiscriminator": "Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator", + "type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getMissingDiscriminatorWithResponse": "Type.Model.Inheritance.SingleDiscriminator.getMissingDiscriminator", + "type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getModel": "Type.Model.Inheritance.SingleDiscriminator.getModel", + "type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getModelWithResponse": "Type.Model.Inheritance.SingleDiscriminator.getModel", + "type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getRecursiveModel": "Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel", + "type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getRecursiveModelWithResponse": "Type.Model.Inheritance.SingleDiscriminator.getRecursiveModel", + "type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getWrongDiscriminator": "Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator", + "type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.getWrongDiscriminatorWithResponse": "Type.Model.Inheritance.SingleDiscriminator.getWrongDiscriminator", + "type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putModel": "Type.Model.Inheritance.SingleDiscriminator.putModel", + "type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putModelWithResponse": "Type.Model.Inheritance.SingleDiscriminator.putModel", + "type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putRecursiveModel": "Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel", + "type.model.inheritance.singlediscriminator.SingleDiscriminatorClient.putRecursiveModelWithResponse": "Type.Model.Inheritance.SingleDiscriminator.putRecursiveModel", + "type.model.inheritance.singlediscriminator.SingleDiscriminatorClientBuilder": "Type.Model.Inheritance.SingleDiscriminator", + "type.model.inheritance.singlediscriminator.Sparrow": "Type.Model.Inheritance.SingleDiscriminator.Sparrow", + "type.model.inheritance.singlediscriminator.TRex": "Type.Model.Inheritance.SingleDiscriminator.TRex" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-usage_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-usage_apiview_properties.json new file mode 100644 index 0000000000..841ad00b0c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-usage_apiview_properties.json @@ -0,0 +1,16 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.model.usage.InputOutputRecord": "Type.Model.Usage.InputOutputRecord", + "type.model.usage.InputRecord": "Type.Model.Usage.InputRecord", + "type.model.usage.OutputRecord": "Type.Model.Usage.OutputRecord", + "type.model.usage.UsageClient": "Type.Model.Usage", + "type.model.usage.UsageClient.input": "Type.Model.Usage.input", + "type.model.usage.UsageClient.inputAndOutput": "Type.Model.Usage.inputAndOutput", + "type.model.usage.UsageClient.inputAndOutputWithResponse": "Type.Model.Usage.inputAndOutput", + "type.model.usage.UsageClient.inputWithResponse": "Type.Model.Usage.input", + "type.model.usage.UsageClient.output": "Type.Model.Usage.output", + "type.model.usage.UsageClient.outputWithResponse": "Type.Model.Usage.output", + "type.model.usage.UsageClientBuilder": "Type.Model.Usage" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-visibility_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-visibility_apiview_properties.json new file mode 100644 index 0000000000..ae6386c825 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-model-visibility_apiview_properties.json @@ -0,0 +1,23 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.model.visibility.ReadOnlyModel": "Type.Model.Visibility.ReadOnlyModel", + "type.model.visibility.VisibilityClient": "Type.Model.Visibility", + "type.model.visibility.VisibilityClient.deleteModel": "Type.Model.Visibility.deleteModel", + "type.model.visibility.VisibilityClient.deleteModelWithResponse": "Type.Model.Visibility.deleteModel", + "type.model.visibility.VisibilityClient.getModel": "Type.Model.Visibility.getModel", + "type.model.visibility.VisibilityClient.getModelWithResponse": "Type.Model.Visibility.getModel", + "type.model.visibility.VisibilityClient.headModel": "Type.Model.Visibility.headModel", + "type.model.visibility.VisibilityClient.headModelWithResponse": "Type.Model.Visibility.headModel", + "type.model.visibility.VisibilityClient.patchModel": "Type.Model.Visibility.patchModel", + "type.model.visibility.VisibilityClient.patchModelWithResponse": "Type.Model.Visibility.patchModel", + "type.model.visibility.VisibilityClient.postModel": "Type.Model.Visibility.postModel", + "type.model.visibility.VisibilityClient.postModelWithResponse": "Type.Model.Visibility.postModel", + "type.model.visibility.VisibilityClient.putModel": "Type.Model.Visibility.putModel", + "type.model.visibility.VisibilityClient.putModelWithResponse": "Type.Model.Visibility.putModel", + "type.model.visibility.VisibilityClient.putReadOnlyModel": "Type.Model.Visibility.putReadOnlyModel", + "type.model.visibility.VisibilityClient.putReadOnlyModelWithResponse": "Type.Model.Visibility.putReadOnlyModel", + "type.model.visibility.VisibilityClientBuilder": "Type.Model.Visibility", + "type.model.visibility.VisibilityModel": "Type.Model.Visibility.VisibilityModel" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-property-additionalproperties_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-property-additionalproperties_apiview_properties.json new file mode 100644 index 0000000000..1da123727e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-property-additionalproperties_apiview_properties.json @@ -0,0 +1,204 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.property.additionalproperties.AdditionalPropertiesClientBuilder": "Type.Property.AdditionalProperties", + "type.property.additionalproperties.DifferentSpreadFloatDerived": "Type.Property.AdditionalProperties.DifferentSpreadFloatDerived", + "type.property.additionalproperties.DifferentSpreadFloatRecord": "Type.Property.AdditionalProperties.DifferentSpreadFloatRecord", + "type.property.additionalproperties.DifferentSpreadModelArrayDerived": "Type.Property.AdditionalProperties.DifferentSpreadModelArrayDerived", + "type.property.additionalproperties.DifferentSpreadModelArrayRecord": "Type.Property.AdditionalProperties.DifferentSpreadModelArrayRecord", + "type.property.additionalproperties.DifferentSpreadModelDerived": "Type.Property.AdditionalProperties.DifferentSpreadModelDerived", + "type.property.additionalproperties.DifferentSpreadModelRecord": "Type.Property.AdditionalProperties.DifferentSpreadModelRecord", + "type.property.additionalproperties.DifferentSpreadStringDerived": "Type.Property.AdditionalProperties.DifferentSpreadStringDerived", + "type.property.additionalproperties.DifferentSpreadStringRecord": "Type.Property.AdditionalProperties.DifferentSpreadStringRecord", + "type.property.additionalproperties.ExtendsDifferentSpreadFloatClient": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadFloat", + "type.property.additionalproperties.ExtendsDifferentSpreadFloatClient.get": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadFloat.get", + "type.property.additionalproperties.ExtendsDifferentSpreadFloatClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadFloat.get", + "type.property.additionalproperties.ExtendsDifferentSpreadFloatClient.put": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadFloat.put", + "type.property.additionalproperties.ExtendsDifferentSpreadFloatClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadFloat.put", + "type.property.additionalproperties.ExtendsDifferentSpreadModelArrayClient": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModelArray", + "type.property.additionalproperties.ExtendsDifferentSpreadModelArrayClient.get": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModelArray.get", + "type.property.additionalproperties.ExtendsDifferentSpreadModelArrayClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModelArray.get", + "type.property.additionalproperties.ExtendsDifferentSpreadModelArrayClient.put": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModelArray.put", + "type.property.additionalproperties.ExtendsDifferentSpreadModelArrayClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModelArray.put", + "type.property.additionalproperties.ExtendsDifferentSpreadModelClient": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModel", + "type.property.additionalproperties.ExtendsDifferentSpreadModelClient.get": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModel.get", + "type.property.additionalproperties.ExtendsDifferentSpreadModelClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModel.get", + "type.property.additionalproperties.ExtendsDifferentSpreadModelClient.put": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModel.put", + "type.property.additionalproperties.ExtendsDifferentSpreadModelClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadModel.put", + "type.property.additionalproperties.ExtendsDifferentSpreadStringClient": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadString", + "type.property.additionalproperties.ExtendsDifferentSpreadStringClient.get": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadString.get", + "type.property.additionalproperties.ExtendsDifferentSpreadStringClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadString.get", + "type.property.additionalproperties.ExtendsDifferentSpreadStringClient.put": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadString.put", + "type.property.additionalproperties.ExtendsDifferentSpreadStringClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsDifferentSpreadString.put", + "type.property.additionalproperties.ExtendsFloatAdditionalProperties": "Type.Property.AdditionalProperties.ExtendsFloatAdditionalProperties", + "type.property.additionalproperties.ExtendsFloatClient": "Type.Property.AdditionalProperties.ExtendsFloat", + "type.property.additionalproperties.ExtendsFloatClient.get": "Type.Property.AdditionalProperties.ExtendsFloat.get", + "type.property.additionalproperties.ExtendsFloatClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsFloat.get", + "type.property.additionalproperties.ExtendsFloatClient.put": "Type.Property.AdditionalProperties.ExtendsFloat.put", + "type.property.additionalproperties.ExtendsFloatClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsFloat.put", + "type.property.additionalproperties.ExtendsModelAdditionalProperties": "Type.Property.AdditionalProperties.ExtendsModelAdditionalProperties", + "type.property.additionalproperties.ExtendsModelArrayAdditionalProperties": "Type.Property.AdditionalProperties.ExtendsModelArrayAdditionalProperties", + "type.property.additionalproperties.ExtendsModelArrayClient": "Type.Property.AdditionalProperties.ExtendsModelArray", + "type.property.additionalproperties.ExtendsModelArrayClient.get": "Type.Property.AdditionalProperties.ExtendsModelArray.get", + "type.property.additionalproperties.ExtendsModelArrayClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsModelArray.get", + "type.property.additionalproperties.ExtendsModelArrayClient.put": "Type.Property.AdditionalProperties.ExtendsModelArray.put", + "type.property.additionalproperties.ExtendsModelArrayClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsModelArray.put", + "type.property.additionalproperties.ExtendsModelClient": "Type.Property.AdditionalProperties.ExtendsModel", + "type.property.additionalproperties.ExtendsModelClient.get": "Type.Property.AdditionalProperties.ExtendsModel.get", + "type.property.additionalproperties.ExtendsModelClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsModel.get", + "type.property.additionalproperties.ExtendsModelClient.put": "Type.Property.AdditionalProperties.ExtendsModel.put", + "type.property.additionalproperties.ExtendsModelClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsModel.put", + "type.property.additionalproperties.ExtendsStringAdditionalProperties": "Type.Property.AdditionalProperties.ExtendsStringAdditionalProperties", + "type.property.additionalproperties.ExtendsStringClient": "Type.Property.AdditionalProperties.ExtendsString", + "type.property.additionalproperties.ExtendsStringClient.get": "Type.Property.AdditionalProperties.ExtendsString.get", + "type.property.additionalproperties.ExtendsStringClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsString.get", + "type.property.additionalproperties.ExtendsStringClient.put": "Type.Property.AdditionalProperties.ExtendsString.put", + "type.property.additionalproperties.ExtendsStringClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsString.put", + "type.property.additionalproperties.ExtendsUnknownAdditionalProperties": "Type.Property.AdditionalProperties.ExtendsUnknownAdditionalProperties", + "type.property.additionalproperties.ExtendsUnknownAdditionalPropertiesDerived": "Type.Property.AdditionalProperties.ExtendsUnknownAdditionalPropertiesDerived", + "type.property.additionalproperties.ExtendsUnknownAdditionalPropertiesDiscriminated": "Type.Property.AdditionalProperties.ExtendsUnknownAdditionalPropertiesDiscriminated", + "type.property.additionalproperties.ExtendsUnknownAdditionalPropertiesDiscriminatedDerived": "Type.Property.AdditionalProperties.ExtendsUnknownAdditionalPropertiesDiscriminatedDerived", + "type.property.additionalproperties.ExtendsUnknownClient": "Type.Property.AdditionalProperties.ExtendsUnknown", + "type.property.additionalproperties.ExtendsUnknownClient.get": "Type.Property.AdditionalProperties.ExtendsUnknown.get", + "type.property.additionalproperties.ExtendsUnknownClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknown.get", + "type.property.additionalproperties.ExtendsUnknownClient.put": "Type.Property.AdditionalProperties.ExtendsUnknown.put", + "type.property.additionalproperties.ExtendsUnknownClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknown.put", + "type.property.additionalproperties.ExtendsUnknownDerivedClient": "Type.Property.AdditionalProperties.ExtendsUnknownDerived", + "type.property.additionalproperties.ExtendsUnknownDerivedClient.get": "Type.Property.AdditionalProperties.ExtendsUnknownDerived.get", + "type.property.additionalproperties.ExtendsUnknownDerivedClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknownDerived.get", + "type.property.additionalproperties.ExtendsUnknownDerivedClient.put": "Type.Property.AdditionalProperties.ExtendsUnknownDerived.put", + "type.property.additionalproperties.ExtendsUnknownDerivedClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknownDerived.put", + "type.property.additionalproperties.ExtendsUnknownDiscriminatedClient": "Type.Property.AdditionalProperties.ExtendsUnknownDiscriminated", + "type.property.additionalproperties.ExtendsUnknownDiscriminatedClient.get": "Type.Property.AdditionalProperties.ExtendsUnknownDiscriminated.get", + "type.property.additionalproperties.ExtendsUnknownDiscriminatedClient.getWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknownDiscriminated.get", + "type.property.additionalproperties.ExtendsUnknownDiscriminatedClient.put": "Type.Property.AdditionalProperties.ExtendsUnknownDiscriminated.put", + "type.property.additionalproperties.ExtendsUnknownDiscriminatedClient.putWithResponse": "Type.Property.AdditionalProperties.ExtendsUnknownDiscriminated.put", + "type.property.additionalproperties.IsFloatAdditionalProperties": "Type.Property.AdditionalProperties.IsFloatAdditionalProperties", + "type.property.additionalproperties.IsFloatClient": "Type.Property.AdditionalProperties.IsFloat", + "type.property.additionalproperties.IsFloatClient.get": "Type.Property.AdditionalProperties.IsFloat.get", + "type.property.additionalproperties.IsFloatClient.getWithResponse": "Type.Property.AdditionalProperties.IsFloat.get", + "type.property.additionalproperties.IsFloatClient.put": "Type.Property.AdditionalProperties.IsFloat.put", + "type.property.additionalproperties.IsFloatClient.putWithResponse": "Type.Property.AdditionalProperties.IsFloat.put", + "type.property.additionalproperties.IsModelAdditionalProperties": "Type.Property.AdditionalProperties.IsModelAdditionalProperties", + "type.property.additionalproperties.IsModelArrayAdditionalProperties": "Type.Property.AdditionalProperties.IsModelArrayAdditionalProperties", + "type.property.additionalproperties.IsModelArrayClient": "Type.Property.AdditionalProperties.IsModelArray", + "type.property.additionalproperties.IsModelArrayClient.get": "Type.Property.AdditionalProperties.IsModelArray.get", + "type.property.additionalproperties.IsModelArrayClient.getWithResponse": "Type.Property.AdditionalProperties.IsModelArray.get", + "type.property.additionalproperties.IsModelArrayClient.put": "Type.Property.AdditionalProperties.IsModelArray.put", + "type.property.additionalproperties.IsModelArrayClient.putWithResponse": "Type.Property.AdditionalProperties.IsModelArray.put", + "type.property.additionalproperties.IsModelClient": "Type.Property.AdditionalProperties.IsModel", + "type.property.additionalproperties.IsModelClient.get": "Type.Property.AdditionalProperties.IsModel.get", + "type.property.additionalproperties.IsModelClient.getWithResponse": "Type.Property.AdditionalProperties.IsModel.get", + "type.property.additionalproperties.IsModelClient.put": "Type.Property.AdditionalProperties.IsModel.put", + "type.property.additionalproperties.IsModelClient.putWithResponse": "Type.Property.AdditionalProperties.IsModel.put", + "type.property.additionalproperties.IsStringAdditionalProperties": "Type.Property.AdditionalProperties.IsStringAdditionalProperties", + "type.property.additionalproperties.IsStringClient": "Type.Property.AdditionalProperties.IsString", + "type.property.additionalproperties.IsStringClient.get": "Type.Property.AdditionalProperties.IsString.get", + "type.property.additionalproperties.IsStringClient.getWithResponse": "Type.Property.AdditionalProperties.IsString.get", + "type.property.additionalproperties.IsStringClient.put": "Type.Property.AdditionalProperties.IsString.put", + "type.property.additionalproperties.IsStringClient.putWithResponse": "Type.Property.AdditionalProperties.IsString.put", + "type.property.additionalproperties.IsUnknownAdditionalProperties": "Type.Property.AdditionalProperties.IsUnknownAdditionalProperties", + "type.property.additionalproperties.IsUnknownAdditionalPropertiesDerived": "Type.Property.AdditionalProperties.IsUnknownAdditionalPropertiesDerived", + "type.property.additionalproperties.IsUnknownAdditionalPropertiesDiscriminated": "Type.Property.AdditionalProperties.IsUnknownAdditionalPropertiesDiscriminated", + "type.property.additionalproperties.IsUnknownAdditionalPropertiesDiscriminatedDerived": "Type.Property.AdditionalProperties.IsUnknownAdditionalPropertiesDiscriminatedDerived", + "type.property.additionalproperties.IsUnknownClient": "Type.Property.AdditionalProperties.IsUnknown", + "type.property.additionalproperties.IsUnknownClient.get": "Type.Property.AdditionalProperties.IsUnknown.get", + "type.property.additionalproperties.IsUnknownClient.getWithResponse": "Type.Property.AdditionalProperties.IsUnknown.get", + "type.property.additionalproperties.IsUnknownClient.put": "Type.Property.AdditionalProperties.IsUnknown.put", + "type.property.additionalproperties.IsUnknownClient.putWithResponse": "Type.Property.AdditionalProperties.IsUnknown.put", + "type.property.additionalproperties.IsUnknownDerivedClient": "Type.Property.AdditionalProperties.IsUnknownDerived", + "type.property.additionalproperties.IsUnknownDerivedClient.get": "Type.Property.AdditionalProperties.IsUnknownDerived.get", + "type.property.additionalproperties.IsUnknownDerivedClient.getWithResponse": "Type.Property.AdditionalProperties.IsUnknownDerived.get", + "type.property.additionalproperties.IsUnknownDerivedClient.put": "Type.Property.AdditionalProperties.IsUnknownDerived.put", + "type.property.additionalproperties.IsUnknownDerivedClient.putWithResponse": "Type.Property.AdditionalProperties.IsUnknownDerived.put", + "type.property.additionalproperties.IsUnknownDiscriminatedClient": "Type.Property.AdditionalProperties.IsUnknownDiscriminated", + "type.property.additionalproperties.IsUnknownDiscriminatedClient.get": "Type.Property.AdditionalProperties.IsUnknownDiscriminated.get", + "type.property.additionalproperties.IsUnknownDiscriminatedClient.getWithResponse": "Type.Property.AdditionalProperties.IsUnknownDiscriminated.get", + "type.property.additionalproperties.IsUnknownDiscriminatedClient.put": "Type.Property.AdditionalProperties.IsUnknownDiscriminated.put", + "type.property.additionalproperties.IsUnknownDiscriminatedClient.putWithResponse": "Type.Property.AdditionalProperties.IsUnknownDiscriminated.put", + "type.property.additionalproperties.ModelForRecord": "Type.Property.AdditionalProperties.ModelForRecord", + "type.property.additionalproperties.MultipleSpreadClient": "Type.Property.AdditionalProperties.MultipleSpread", + "type.property.additionalproperties.MultipleSpreadClient.get": "Type.Property.AdditionalProperties.MultipleSpread.get", + "type.property.additionalproperties.MultipleSpreadClient.getWithResponse": "Type.Property.AdditionalProperties.MultipleSpread.get", + "type.property.additionalproperties.MultipleSpreadClient.put": "Type.Property.AdditionalProperties.MultipleSpread.put", + "type.property.additionalproperties.MultipleSpreadClient.putWithResponse": "Type.Property.AdditionalProperties.MultipleSpread.put", + "type.property.additionalproperties.MultipleSpreadRecord": "Type.Property.AdditionalProperties.MultipleSpreadRecord", + "type.property.additionalproperties.SpreadDifferentFloatClient": "Type.Property.AdditionalProperties.SpreadDifferentFloat", + "type.property.additionalproperties.SpreadDifferentFloatClient.get": "Type.Property.AdditionalProperties.SpreadDifferentFloat.get", + "type.property.additionalproperties.SpreadDifferentFloatClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentFloat.get", + "type.property.additionalproperties.SpreadDifferentFloatClient.put": "Type.Property.AdditionalProperties.SpreadDifferentFloat.put", + "type.property.additionalproperties.SpreadDifferentFloatClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentFloat.put", + "type.property.additionalproperties.SpreadDifferentModelArrayClient": "Type.Property.AdditionalProperties.SpreadDifferentModelArray", + "type.property.additionalproperties.SpreadDifferentModelArrayClient.get": "Type.Property.AdditionalProperties.SpreadDifferentModelArray.get", + "type.property.additionalproperties.SpreadDifferentModelArrayClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentModelArray.get", + "type.property.additionalproperties.SpreadDifferentModelArrayClient.put": "Type.Property.AdditionalProperties.SpreadDifferentModelArray.put", + "type.property.additionalproperties.SpreadDifferentModelArrayClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentModelArray.put", + "type.property.additionalproperties.SpreadDifferentModelClient": "Type.Property.AdditionalProperties.SpreadDifferentModel", + "type.property.additionalproperties.SpreadDifferentModelClient.get": "Type.Property.AdditionalProperties.SpreadDifferentModel.get", + "type.property.additionalproperties.SpreadDifferentModelClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentModel.get", + "type.property.additionalproperties.SpreadDifferentModelClient.put": "Type.Property.AdditionalProperties.SpreadDifferentModel.put", + "type.property.additionalproperties.SpreadDifferentModelClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentModel.put", + "type.property.additionalproperties.SpreadDifferentStringClient": "Type.Property.AdditionalProperties.SpreadDifferentString", + "type.property.additionalproperties.SpreadDifferentStringClient.get": "Type.Property.AdditionalProperties.SpreadDifferentString.get", + "type.property.additionalproperties.SpreadDifferentStringClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentString.get", + "type.property.additionalproperties.SpreadDifferentStringClient.put": "Type.Property.AdditionalProperties.SpreadDifferentString.put", + "type.property.additionalproperties.SpreadDifferentStringClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadDifferentString.put", + "type.property.additionalproperties.SpreadFloatClient": "Type.Property.AdditionalProperties.SpreadFloat", + "type.property.additionalproperties.SpreadFloatClient.get": "Type.Property.AdditionalProperties.SpreadFloat.get", + "type.property.additionalproperties.SpreadFloatClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadFloat.get", + "type.property.additionalproperties.SpreadFloatClient.put": "Type.Property.AdditionalProperties.SpreadFloat.put", + "type.property.additionalproperties.SpreadFloatClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadFloat.put", + "type.property.additionalproperties.SpreadFloatRecord": "Type.Property.AdditionalProperties.SpreadFloatRecord", + "type.property.additionalproperties.SpreadModelArrayClient": "Type.Property.AdditionalProperties.SpreadModelArray", + "type.property.additionalproperties.SpreadModelArrayClient.get": "Type.Property.AdditionalProperties.SpreadModelArray.get", + "type.property.additionalproperties.SpreadModelArrayClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadModelArray.get", + "type.property.additionalproperties.SpreadModelArrayClient.put": "Type.Property.AdditionalProperties.SpreadModelArray.put", + "type.property.additionalproperties.SpreadModelArrayClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadModelArray.put", + "type.property.additionalproperties.SpreadModelArrayRecord": "Type.Property.AdditionalProperties.SpreadModelArrayRecord", + "type.property.additionalproperties.SpreadModelClient": "Type.Property.AdditionalProperties.SpreadModel", + "type.property.additionalproperties.SpreadModelClient.get": "Type.Property.AdditionalProperties.SpreadModel.get", + "type.property.additionalproperties.SpreadModelClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadModel.get", + "type.property.additionalproperties.SpreadModelClient.put": "Type.Property.AdditionalProperties.SpreadModel.put", + "type.property.additionalproperties.SpreadModelClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadModel.put", + "type.property.additionalproperties.SpreadModelRecord": "Type.Property.AdditionalProperties.SpreadModelRecord", + "type.property.additionalproperties.SpreadRecordDiscriminatedUnionClient": "Type.Property.AdditionalProperties.SpreadRecordDiscriminatedUnion", + "type.property.additionalproperties.SpreadRecordDiscriminatedUnionClient.get": "Type.Property.AdditionalProperties.SpreadRecordDiscriminatedUnion.get", + "type.property.additionalproperties.SpreadRecordDiscriminatedUnionClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadRecordDiscriminatedUnion.get", + "type.property.additionalproperties.SpreadRecordDiscriminatedUnionClient.put": "Type.Property.AdditionalProperties.SpreadRecordDiscriminatedUnion.put", + "type.property.additionalproperties.SpreadRecordDiscriminatedUnionClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadRecordDiscriminatedUnion.put", + "type.property.additionalproperties.SpreadRecordForDiscriminatedUnion": "Type.Property.AdditionalProperties.SpreadRecordForDiscriminatedUnion", + "type.property.additionalproperties.SpreadRecordForNonDiscriminatedUnion": "Type.Property.AdditionalProperties.SpreadRecordForNonDiscriminatedUnion", + "type.property.additionalproperties.SpreadRecordForNonDiscriminatedUnion2": "Type.Property.AdditionalProperties.SpreadRecordForNonDiscriminatedUnion2", + "type.property.additionalproperties.SpreadRecordForNonDiscriminatedUnion3": "Type.Property.AdditionalProperties.SpreadRecordForNonDiscriminatedUnion3", + "type.property.additionalproperties.SpreadRecordForUnion": "Type.Property.AdditionalProperties.SpreadRecordForUnion", + "type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion2Client": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion2", + "type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion2Client.get": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion2.get", + "type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion2Client.getWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion2.get", + "type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion2Client.put": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion2.put", + "type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion2Client.putWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion2.put", + "type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion3Client": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion3", + "type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion3Client.get": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion3.get", + "type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion3Client.getWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion3.get", + "type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion3Client.put": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion3.put", + "type.property.additionalproperties.SpreadRecordNonDiscriminatedUnion3Client.putWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion3.put", + "type.property.additionalproperties.SpreadRecordNonDiscriminatedUnionClient": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion", + "type.property.additionalproperties.SpreadRecordNonDiscriminatedUnionClient.get": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion.get", + "type.property.additionalproperties.SpreadRecordNonDiscriminatedUnionClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion.get", + "type.property.additionalproperties.SpreadRecordNonDiscriminatedUnionClient.put": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion.put", + "type.property.additionalproperties.SpreadRecordNonDiscriminatedUnionClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadRecordNonDiscriminatedUnion.put", + "type.property.additionalproperties.SpreadRecordUnionClient": "Type.Property.AdditionalProperties.SpreadRecordUnion", + "type.property.additionalproperties.SpreadRecordUnionClient.get": "Type.Property.AdditionalProperties.SpreadRecordUnion.get", + "type.property.additionalproperties.SpreadRecordUnionClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadRecordUnion.get", + "type.property.additionalproperties.SpreadRecordUnionClient.put": "Type.Property.AdditionalProperties.SpreadRecordUnion.put", + "type.property.additionalproperties.SpreadRecordUnionClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadRecordUnion.put", + "type.property.additionalproperties.SpreadStringClient": "Type.Property.AdditionalProperties.SpreadString", + "type.property.additionalproperties.SpreadStringClient.get": "Type.Property.AdditionalProperties.SpreadString.get", + "type.property.additionalproperties.SpreadStringClient.getWithResponse": "Type.Property.AdditionalProperties.SpreadString.get", + "type.property.additionalproperties.SpreadStringClient.put": "Type.Property.AdditionalProperties.SpreadString.put", + "type.property.additionalproperties.SpreadStringClient.putWithResponse": "Type.Property.AdditionalProperties.SpreadString.put", + "type.property.additionalproperties.SpreadStringRecord": "Type.Property.AdditionalProperties.SpreadStringRecord", + "type.property.additionalproperties.WidgetData0": "Type.Property.AdditionalProperties.WidgetData0", + "type.property.additionalproperties.WidgetData1": "Type.Property.AdditionalProperties.WidgetData1", + "type.property.additionalproperties.WidgetData2": "Type.Property.AdditionalProperties.WidgetData2" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-property-nullable_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-property-nullable_apiview_properties.json new file mode 100644 index 0000000000..78dc64d3d5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-property-nullable_apiview_properties.json @@ -0,0 +1,77 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.property.nullable.BytesClient": "Type.Property.Nullable.Bytes", + "type.property.nullable.BytesClient.getNonNull": "Type.Property.Nullable.Bytes.getNonNull", + "type.property.nullable.BytesClient.getNonNullWithResponse": "Type.Property.Nullable.Bytes.getNonNull", + "type.property.nullable.BytesClient.getNull": "Type.Property.Nullable.Bytes.getNull", + "type.property.nullable.BytesClient.getNullWithResponse": "Type.Property.Nullable.Bytes.getNull", + "type.property.nullable.BytesClient.patchNonNull": "Type.Property.Nullable.Bytes.patchNonNull", + "type.property.nullable.BytesClient.patchNonNullWithResponse": "Type.Property.Nullable.Bytes.patchNonNull", + "type.property.nullable.BytesClient.patchNull": "Type.Property.Nullable.Bytes.patchNull", + "type.property.nullable.BytesClient.patchNullWithResponse": "Type.Property.Nullable.Bytes.patchNull", + "type.property.nullable.BytesProperty": "Type.Property.Nullable.BytesProperty", + "type.property.nullable.CollectionsByteClient": "Type.Property.Nullable.CollectionsByte", + "type.property.nullable.CollectionsByteClient.getNonNull": "Type.Property.Nullable.CollectionsByte.getNonNull", + "type.property.nullable.CollectionsByteClient.getNonNullWithResponse": "Type.Property.Nullable.CollectionsByte.getNonNull", + "type.property.nullable.CollectionsByteClient.getNull": "Type.Property.Nullable.CollectionsByte.getNull", + "type.property.nullable.CollectionsByteClient.getNullWithResponse": "Type.Property.Nullable.CollectionsByte.getNull", + "type.property.nullable.CollectionsByteClient.patchNonNull": "Type.Property.Nullable.CollectionsByte.patchNonNull", + "type.property.nullable.CollectionsByteClient.patchNonNullWithResponse": "Type.Property.Nullable.CollectionsByte.patchNonNull", + "type.property.nullable.CollectionsByteClient.patchNull": "Type.Property.Nullable.CollectionsByte.patchNull", + "type.property.nullable.CollectionsByteClient.patchNullWithResponse": "Type.Property.Nullable.CollectionsByte.patchNull", + "type.property.nullable.CollectionsByteProperty": "Type.Property.Nullable.CollectionsByteProperty", + "type.property.nullable.CollectionsModelClient": "Type.Property.Nullable.CollectionsModel", + "type.property.nullable.CollectionsModelClient.getNonNull": "Type.Property.Nullable.CollectionsModel.getNonNull", + "type.property.nullable.CollectionsModelClient.getNonNullWithResponse": "Type.Property.Nullable.CollectionsModel.getNonNull", + "type.property.nullable.CollectionsModelClient.getNull": "Type.Property.Nullable.CollectionsModel.getNull", + "type.property.nullable.CollectionsModelClient.getNullWithResponse": "Type.Property.Nullable.CollectionsModel.getNull", + "type.property.nullable.CollectionsModelClient.patchNonNull": "Type.Property.Nullable.CollectionsModel.patchNonNull", + "type.property.nullable.CollectionsModelClient.patchNonNullWithResponse": "Type.Property.Nullable.CollectionsModel.patchNonNull", + "type.property.nullable.CollectionsModelClient.patchNull": "Type.Property.Nullable.CollectionsModel.patchNull", + "type.property.nullable.CollectionsModelClient.patchNullWithResponse": "Type.Property.Nullable.CollectionsModel.patchNull", + "type.property.nullable.CollectionsModelProperty": "Type.Property.Nullable.CollectionsModelProperty", + "type.property.nullable.CollectionsStringClient": "Type.Property.Nullable.CollectionsString", + "type.property.nullable.CollectionsStringClient.getNonNull": "Type.Property.Nullable.CollectionsString.getNonNull", + "type.property.nullable.CollectionsStringClient.getNonNullWithResponse": "Type.Property.Nullable.CollectionsString.getNonNull", + "type.property.nullable.CollectionsStringClient.getNull": "Type.Property.Nullable.CollectionsString.getNull", + "type.property.nullable.CollectionsStringClient.getNullWithResponse": "Type.Property.Nullable.CollectionsString.getNull", + "type.property.nullable.CollectionsStringClient.patchNonNull": "Type.Property.Nullable.CollectionsString.patchNonNull", + "type.property.nullable.CollectionsStringClient.patchNonNullWithResponse": "Type.Property.Nullable.CollectionsString.patchNonNull", + "type.property.nullable.CollectionsStringClient.patchNull": "Type.Property.Nullable.CollectionsString.patchNull", + "type.property.nullable.CollectionsStringClient.patchNullWithResponse": "Type.Property.Nullable.CollectionsString.patchNull", + "type.property.nullable.CollectionsStringProperty": "Type.Property.Nullable.CollectionsStringProperty", + "type.property.nullable.DatetimeOperationClient": "Type.Property.Nullable.Datetime", + "type.property.nullable.DatetimeOperationClient.getNonNull": "Type.Property.Nullable.Datetime.getNonNull", + "type.property.nullable.DatetimeOperationClient.getNonNullWithResponse": "Type.Property.Nullable.Datetime.getNonNull", + "type.property.nullable.DatetimeOperationClient.getNull": "Type.Property.Nullable.Datetime.getNull", + "type.property.nullable.DatetimeOperationClient.getNullWithResponse": "Type.Property.Nullable.Datetime.getNull", + "type.property.nullable.DatetimeOperationClient.patchNonNull": "Type.Property.Nullable.Datetime.patchNonNull", + "type.property.nullable.DatetimeOperationClient.patchNonNullWithResponse": "Type.Property.Nullable.Datetime.patchNonNull", + "type.property.nullable.DatetimeOperationClient.patchNull": "Type.Property.Nullable.Datetime.patchNull", + "type.property.nullable.DatetimeOperationClient.patchNullWithResponse": "Type.Property.Nullable.Datetime.patchNull", + "type.property.nullable.DatetimeProperty": "Type.Property.Nullable.DatetimeProperty", + "type.property.nullable.DurationOperationClient": "Type.Property.Nullable.Duration", + "type.property.nullable.DurationOperationClient.getNonNull": "Type.Property.Nullable.Duration.getNonNull", + "type.property.nullable.DurationOperationClient.getNonNullWithResponse": "Type.Property.Nullable.Duration.getNonNull", + "type.property.nullable.DurationOperationClient.getNull": "Type.Property.Nullable.Duration.getNull", + "type.property.nullable.DurationOperationClient.getNullWithResponse": "Type.Property.Nullable.Duration.getNull", + "type.property.nullable.DurationOperationClient.patchNonNull": "Type.Property.Nullable.Duration.patchNonNull", + "type.property.nullable.DurationOperationClient.patchNonNullWithResponse": "Type.Property.Nullable.Duration.patchNonNull", + "type.property.nullable.DurationOperationClient.patchNull": "Type.Property.Nullable.Duration.patchNull", + "type.property.nullable.DurationOperationClient.patchNullWithResponse": "Type.Property.Nullable.Duration.patchNull", + "type.property.nullable.DurationProperty": "Type.Property.Nullable.DurationProperty", + "type.property.nullable.InnerModel": "Type.Property.Nullable.InnerModel", + "type.property.nullable.NullableClientBuilder": "Type.Property.Nullable", + "type.property.nullable.StringOperationClient": "Type.Property.Nullable.String", + "type.property.nullable.StringOperationClient.getNonNull": "Type.Property.Nullable.String.getNonNull", + "type.property.nullable.StringOperationClient.getNonNullWithResponse": "Type.Property.Nullable.String.getNonNull", + "type.property.nullable.StringOperationClient.getNull": "Type.Property.Nullable.String.getNull", + "type.property.nullable.StringOperationClient.getNullWithResponse": "Type.Property.Nullable.String.getNull", + "type.property.nullable.StringOperationClient.patchNonNull": "Type.Property.Nullable.String.patchNonNull", + "type.property.nullable.StringOperationClient.patchNonNullWithResponse": "Type.Property.Nullable.String.patchNonNull", + "type.property.nullable.StringOperationClient.patchNull": "Type.Property.Nullable.String.patchNull", + "type.property.nullable.StringOperationClient.patchNullWithResponse": "Type.Property.Nullable.String.patchNull", + "type.property.nullable.StringProperty": "Type.Property.Nullable.StringProperty" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-property-optional_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-property-optional_apiview_properties.json new file mode 100644 index 0000000000..88c5c4bb20 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-property-optional_apiview_properties.json @@ -0,0 +1,173 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.property.optional.BooleanLiteralClient": "Type.Property.Optional.BooleanLiteral", + "type.property.optional.BooleanLiteralClient.getAll": "Type.Property.Optional.BooleanLiteral.getAll", + "type.property.optional.BooleanLiteralClient.getAllWithResponse": "Type.Property.Optional.BooleanLiteral.getAll", + "type.property.optional.BooleanLiteralClient.getDefault": "Type.Property.Optional.BooleanLiteral.getDefault", + "type.property.optional.BooleanLiteralClient.getDefaultWithResponse": "Type.Property.Optional.BooleanLiteral.getDefault", + "type.property.optional.BooleanLiteralClient.putAll": "Type.Property.Optional.BooleanLiteral.putAll", + "type.property.optional.BooleanLiteralClient.putAllWithResponse": "Type.Property.Optional.BooleanLiteral.putAll", + "type.property.optional.BooleanLiteralClient.putDefault": "Type.Property.Optional.BooleanLiteral.putDefault", + "type.property.optional.BooleanLiteralClient.putDefaultWithResponse": "Type.Property.Optional.BooleanLiteral.putDefault", + "type.property.optional.BooleanLiteralProperty": "Type.Property.Optional.BooleanLiteralProperty", + "type.property.optional.BooleanLiteralPropertyProperty": null, + "type.property.optional.BytesClient": "Type.Property.Optional.Bytes", + "type.property.optional.BytesClient.getAll": "Type.Property.Optional.Bytes.getAll", + "type.property.optional.BytesClient.getAllWithResponse": "Type.Property.Optional.Bytes.getAll", + "type.property.optional.BytesClient.getDefault": "Type.Property.Optional.Bytes.getDefault", + "type.property.optional.BytesClient.getDefaultWithResponse": "Type.Property.Optional.Bytes.getDefault", + "type.property.optional.BytesClient.putAll": "Type.Property.Optional.Bytes.putAll", + "type.property.optional.BytesClient.putAllWithResponse": "Type.Property.Optional.Bytes.putAll", + "type.property.optional.BytesClient.putDefault": "Type.Property.Optional.Bytes.putDefault", + "type.property.optional.BytesClient.putDefaultWithResponse": "Type.Property.Optional.Bytes.putDefault", + "type.property.optional.BytesProperty": "Type.Property.Optional.BytesProperty", + "type.property.optional.CollectionsByteClient": "Type.Property.Optional.CollectionsByte", + "type.property.optional.CollectionsByteClient.getAll": "Type.Property.Optional.CollectionsByte.getAll", + "type.property.optional.CollectionsByteClient.getAllWithResponse": "Type.Property.Optional.CollectionsByte.getAll", + "type.property.optional.CollectionsByteClient.getDefault": "Type.Property.Optional.CollectionsByte.getDefault", + "type.property.optional.CollectionsByteClient.getDefaultWithResponse": "Type.Property.Optional.CollectionsByte.getDefault", + "type.property.optional.CollectionsByteClient.putAll": "Type.Property.Optional.CollectionsByte.putAll", + "type.property.optional.CollectionsByteClient.putAllWithResponse": "Type.Property.Optional.CollectionsByte.putAll", + "type.property.optional.CollectionsByteClient.putDefault": "Type.Property.Optional.CollectionsByte.putDefault", + "type.property.optional.CollectionsByteClient.putDefaultWithResponse": "Type.Property.Optional.CollectionsByte.putDefault", + "type.property.optional.CollectionsByteProperty": "Type.Property.Optional.CollectionsByteProperty", + "type.property.optional.CollectionsModelClient": "Type.Property.Optional.CollectionsModel", + "type.property.optional.CollectionsModelClient.getAll": "Type.Property.Optional.CollectionsModel.getAll", + "type.property.optional.CollectionsModelClient.getAllWithResponse": "Type.Property.Optional.CollectionsModel.getAll", + "type.property.optional.CollectionsModelClient.getDefault": "Type.Property.Optional.CollectionsModel.getDefault", + "type.property.optional.CollectionsModelClient.getDefaultWithResponse": "Type.Property.Optional.CollectionsModel.getDefault", + "type.property.optional.CollectionsModelClient.putAll": "Type.Property.Optional.CollectionsModel.putAll", + "type.property.optional.CollectionsModelClient.putAllWithResponse": "Type.Property.Optional.CollectionsModel.putAll", + "type.property.optional.CollectionsModelClient.putDefault": "Type.Property.Optional.CollectionsModel.putDefault", + "type.property.optional.CollectionsModelClient.putDefaultWithResponse": "Type.Property.Optional.CollectionsModel.putDefault", + "type.property.optional.CollectionsModelProperty": "Type.Property.Optional.CollectionsModelProperty", + "type.property.optional.DatetimeOperationClient": "Type.Property.Optional.Datetime", + "type.property.optional.DatetimeOperationClient.getAll": "Type.Property.Optional.Datetime.getAll", + "type.property.optional.DatetimeOperationClient.getAllWithResponse": "Type.Property.Optional.Datetime.getAll", + "type.property.optional.DatetimeOperationClient.getDefault": "Type.Property.Optional.Datetime.getDefault", + "type.property.optional.DatetimeOperationClient.getDefaultWithResponse": "Type.Property.Optional.Datetime.getDefault", + "type.property.optional.DatetimeOperationClient.putAll": "Type.Property.Optional.Datetime.putAll", + "type.property.optional.DatetimeOperationClient.putAllWithResponse": "Type.Property.Optional.Datetime.putAll", + "type.property.optional.DatetimeOperationClient.putDefault": "Type.Property.Optional.Datetime.putDefault", + "type.property.optional.DatetimeOperationClient.putDefaultWithResponse": "Type.Property.Optional.Datetime.putDefault", + "type.property.optional.DatetimeProperty": "Type.Property.Optional.DatetimeProperty", + "type.property.optional.DurationOperationClient": "Type.Property.Optional.Duration", + "type.property.optional.DurationOperationClient.getAll": "Type.Property.Optional.Duration.getAll", + "type.property.optional.DurationOperationClient.getAllWithResponse": "Type.Property.Optional.Duration.getAll", + "type.property.optional.DurationOperationClient.getDefault": "Type.Property.Optional.Duration.getDefault", + "type.property.optional.DurationOperationClient.getDefaultWithResponse": "Type.Property.Optional.Duration.getDefault", + "type.property.optional.DurationOperationClient.putAll": "Type.Property.Optional.Duration.putAll", + "type.property.optional.DurationOperationClient.putAllWithResponse": "Type.Property.Optional.Duration.putAll", + "type.property.optional.DurationOperationClient.putDefault": "Type.Property.Optional.Duration.putDefault", + "type.property.optional.DurationOperationClient.putDefaultWithResponse": "Type.Property.Optional.Duration.putDefault", + "type.property.optional.DurationProperty": "Type.Property.Optional.DurationProperty", + "type.property.optional.FloatLiteralClient": "Type.Property.Optional.FloatLiteral", + "type.property.optional.FloatLiteralClient.getAll": "Type.Property.Optional.FloatLiteral.getAll", + "type.property.optional.FloatLiteralClient.getAllWithResponse": "Type.Property.Optional.FloatLiteral.getAll", + "type.property.optional.FloatLiteralClient.getDefault": "Type.Property.Optional.FloatLiteral.getDefault", + "type.property.optional.FloatLiteralClient.getDefaultWithResponse": "Type.Property.Optional.FloatLiteral.getDefault", + "type.property.optional.FloatLiteralClient.putAll": "Type.Property.Optional.FloatLiteral.putAll", + "type.property.optional.FloatLiteralClient.putAllWithResponse": "Type.Property.Optional.FloatLiteral.putAll", + "type.property.optional.FloatLiteralClient.putDefault": "Type.Property.Optional.FloatLiteral.putDefault", + "type.property.optional.FloatLiteralClient.putDefaultWithResponse": "Type.Property.Optional.FloatLiteral.putDefault", + "type.property.optional.FloatLiteralProperty": "Type.Property.Optional.FloatLiteralProperty", + "type.property.optional.FloatLiteralPropertyProperty": null, + "type.property.optional.IntLiteralClient": "Type.Property.Optional.IntLiteral", + "type.property.optional.IntLiteralClient.getAll": "Type.Property.Optional.IntLiteral.getAll", + "type.property.optional.IntLiteralClient.getAllWithResponse": "Type.Property.Optional.IntLiteral.getAll", + "type.property.optional.IntLiteralClient.getDefault": "Type.Property.Optional.IntLiteral.getDefault", + "type.property.optional.IntLiteralClient.getDefaultWithResponse": "Type.Property.Optional.IntLiteral.getDefault", + "type.property.optional.IntLiteralClient.putAll": "Type.Property.Optional.IntLiteral.putAll", + "type.property.optional.IntLiteralClient.putAllWithResponse": "Type.Property.Optional.IntLiteral.putAll", + "type.property.optional.IntLiteralClient.putDefault": "Type.Property.Optional.IntLiteral.putDefault", + "type.property.optional.IntLiteralClient.putDefaultWithResponse": "Type.Property.Optional.IntLiteral.putDefault", + "type.property.optional.IntLiteralProperty": "Type.Property.Optional.IntLiteralProperty", + "type.property.optional.IntLiteralPropertyProperty": null, + "type.property.optional.OptionalClientBuilder": "Type.Property.Optional", + "type.property.optional.PlainDateClient": "Type.Property.Optional.PlainDate", + "type.property.optional.PlainDateClient.getAll": "Type.Property.Optional.PlainDate.getAll", + "type.property.optional.PlainDateClient.getAllWithResponse": "Type.Property.Optional.PlainDate.getAll", + "type.property.optional.PlainDateClient.getDefault": "Type.Property.Optional.PlainDate.getDefault", + "type.property.optional.PlainDateClient.getDefaultWithResponse": "Type.Property.Optional.PlainDate.getDefault", + "type.property.optional.PlainDateClient.putAll": "Type.Property.Optional.PlainDate.putAll", + "type.property.optional.PlainDateClient.putAllWithResponse": "Type.Property.Optional.PlainDate.putAll", + "type.property.optional.PlainDateClient.putDefault": "Type.Property.Optional.PlainDate.putDefault", + "type.property.optional.PlainDateClient.putDefaultWithResponse": "Type.Property.Optional.PlainDate.putDefault", + "type.property.optional.PlainDateProperty": "Type.Property.Optional.PlainDateProperty", + "type.property.optional.PlainTimeClient": "Type.Property.Optional.PlainTime", + "type.property.optional.PlainTimeClient.getAll": "Type.Property.Optional.PlainTime.getAll", + "type.property.optional.PlainTimeClient.getAllWithResponse": "Type.Property.Optional.PlainTime.getAll", + "type.property.optional.PlainTimeClient.getDefault": "Type.Property.Optional.PlainTime.getDefault", + "type.property.optional.PlainTimeClient.getDefaultWithResponse": "Type.Property.Optional.PlainTime.getDefault", + "type.property.optional.PlainTimeClient.putAll": "Type.Property.Optional.PlainTime.putAll", + "type.property.optional.PlainTimeClient.putAllWithResponse": "Type.Property.Optional.PlainTime.putAll", + "type.property.optional.PlainTimeClient.putDefault": "Type.Property.Optional.PlainTime.putDefault", + "type.property.optional.PlainTimeClient.putDefaultWithResponse": "Type.Property.Optional.PlainTime.putDefault", + "type.property.optional.PlainTimeProperty": "Type.Property.Optional.PlainTimeProperty", + "type.property.optional.RequiredAndOptionalClient": "Type.Property.Optional.RequiredAndOptional", + "type.property.optional.RequiredAndOptionalClient.getAll": "Type.Property.Optional.RequiredAndOptional.getAll", + "type.property.optional.RequiredAndOptionalClient.getAllWithResponse": "Type.Property.Optional.RequiredAndOptional.getAll", + "type.property.optional.RequiredAndOptionalClient.getRequiredOnly": "Type.Property.Optional.RequiredAndOptional.getRequiredOnly", + "type.property.optional.RequiredAndOptionalClient.getRequiredOnlyWithResponse": "Type.Property.Optional.RequiredAndOptional.getRequiredOnly", + "type.property.optional.RequiredAndOptionalClient.putAll": "Type.Property.Optional.RequiredAndOptional.putAll", + "type.property.optional.RequiredAndOptionalClient.putAllWithResponse": "Type.Property.Optional.RequiredAndOptional.putAll", + "type.property.optional.RequiredAndOptionalClient.putRequiredOnly": "Type.Property.Optional.RequiredAndOptional.putRequiredOnly", + "type.property.optional.RequiredAndOptionalClient.putRequiredOnlyWithResponse": "Type.Property.Optional.RequiredAndOptional.putRequiredOnly", + "type.property.optional.RequiredAndOptionalProperty": "Type.Property.Optional.RequiredAndOptionalProperty", + "type.property.optional.StringLiteralClient": "Type.Property.Optional.StringLiteral", + "type.property.optional.StringLiteralClient.getAll": "Type.Property.Optional.StringLiteral.getAll", + "type.property.optional.StringLiteralClient.getAllWithResponse": "Type.Property.Optional.StringLiteral.getAll", + "type.property.optional.StringLiteralClient.getDefault": "Type.Property.Optional.StringLiteral.getDefault", + "type.property.optional.StringLiteralClient.getDefaultWithResponse": "Type.Property.Optional.StringLiteral.getDefault", + "type.property.optional.StringLiteralClient.putAll": "Type.Property.Optional.StringLiteral.putAll", + "type.property.optional.StringLiteralClient.putAllWithResponse": "Type.Property.Optional.StringLiteral.putAll", + "type.property.optional.StringLiteralClient.putDefault": "Type.Property.Optional.StringLiteral.putDefault", + "type.property.optional.StringLiteralClient.putDefaultWithResponse": "Type.Property.Optional.StringLiteral.putDefault", + "type.property.optional.StringLiteralProperty": "Type.Property.Optional.StringLiteralProperty", + "type.property.optional.StringLiteralPropertyProperty": null, + "type.property.optional.StringOperationClient": "Type.Property.Optional.String", + "type.property.optional.StringOperationClient.getAll": "Type.Property.Optional.String.getAll", + "type.property.optional.StringOperationClient.getAllWithResponse": "Type.Property.Optional.String.getAll", + "type.property.optional.StringOperationClient.getDefault": "Type.Property.Optional.String.getDefault", + "type.property.optional.StringOperationClient.getDefaultWithResponse": "Type.Property.Optional.String.getDefault", + "type.property.optional.StringOperationClient.putAll": "Type.Property.Optional.String.putAll", + "type.property.optional.StringOperationClient.putAllWithResponse": "Type.Property.Optional.String.putAll", + "type.property.optional.StringOperationClient.putDefault": "Type.Property.Optional.String.putDefault", + "type.property.optional.StringOperationClient.putDefaultWithResponse": "Type.Property.Optional.String.putDefault", + "type.property.optional.StringProperty": "Type.Property.Optional.StringProperty", + "type.property.optional.UnionFloatLiteralClient": "Type.Property.Optional.UnionFloatLiteral", + "type.property.optional.UnionFloatLiteralClient.getAll": "Type.Property.Optional.UnionFloatLiteral.getAll", + "type.property.optional.UnionFloatLiteralClient.getAllWithResponse": "Type.Property.Optional.UnionFloatLiteral.getAll", + "type.property.optional.UnionFloatLiteralClient.getDefault": "Type.Property.Optional.UnionFloatLiteral.getDefault", + "type.property.optional.UnionFloatLiteralClient.getDefaultWithResponse": "Type.Property.Optional.UnionFloatLiteral.getDefault", + "type.property.optional.UnionFloatLiteralClient.putAll": "Type.Property.Optional.UnionFloatLiteral.putAll", + "type.property.optional.UnionFloatLiteralClient.putAllWithResponse": "Type.Property.Optional.UnionFloatLiteral.putAll", + "type.property.optional.UnionFloatLiteralClient.putDefault": "Type.Property.Optional.UnionFloatLiteral.putDefault", + "type.property.optional.UnionFloatLiteralClient.putDefaultWithResponse": "Type.Property.Optional.UnionFloatLiteral.putDefault", + "type.property.optional.UnionFloatLiteralProperty": "Type.Property.Optional.UnionFloatLiteralProperty", + "type.property.optional.UnionFloatLiteralPropertyProperty": "Type.Property.Optional.UnionFloatLiteralProperty.property.anonymous", + "type.property.optional.UnionIntLiteralClient": "Type.Property.Optional.UnionIntLiteral", + "type.property.optional.UnionIntLiteralClient.getAll": "Type.Property.Optional.UnionIntLiteral.getAll", + "type.property.optional.UnionIntLiteralClient.getAllWithResponse": "Type.Property.Optional.UnionIntLiteral.getAll", + "type.property.optional.UnionIntLiteralClient.getDefault": "Type.Property.Optional.UnionIntLiteral.getDefault", + "type.property.optional.UnionIntLiteralClient.getDefaultWithResponse": "Type.Property.Optional.UnionIntLiteral.getDefault", + "type.property.optional.UnionIntLiteralClient.putAll": "Type.Property.Optional.UnionIntLiteral.putAll", + "type.property.optional.UnionIntLiteralClient.putAllWithResponse": "Type.Property.Optional.UnionIntLiteral.putAll", + "type.property.optional.UnionIntLiteralClient.putDefault": "Type.Property.Optional.UnionIntLiteral.putDefault", + "type.property.optional.UnionIntLiteralClient.putDefaultWithResponse": "Type.Property.Optional.UnionIntLiteral.putDefault", + "type.property.optional.UnionIntLiteralProperty": "Type.Property.Optional.UnionIntLiteralProperty", + "type.property.optional.UnionIntLiteralPropertyProperty": "Type.Property.Optional.UnionIntLiteralProperty.property.anonymous", + "type.property.optional.UnionStringLiteralClient": "Type.Property.Optional.UnionStringLiteral", + "type.property.optional.UnionStringLiteralClient.getAll": "Type.Property.Optional.UnionStringLiteral.getAll", + "type.property.optional.UnionStringLiteralClient.getAllWithResponse": "Type.Property.Optional.UnionStringLiteral.getAll", + "type.property.optional.UnionStringLiteralClient.getDefault": "Type.Property.Optional.UnionStringLiteral.getDefault", + "type.property.optional.UnionStringLiteralClient.getDefaultWithResponse": "Type.Property.Optional.UnionStringLiteral.getDefault", + "type.property.optional.UnionStringLiteralClient.putAll": "Type.Property.Optional.UnionStringLiteral.putAll", + "type.property.optional.UnionStringLiteralClient.putAllWithResponse": "Type.Property.Optional.UnionStringLiteral.putAll", + "type.property.optional.UnionStringLiteralClient.putDefault": "Type.Property.Optional.UnionStringLiteral.putDefault", + "type.property.optional.UnionStringLiteralClient.putDefaultWithResponse": "Type.Property.Optional.UnionStringLiteral.putDefault", + "type.property.optional.UnionStringLiteralProperty": "Type.Property.Optional.UnionStringLiteralProperty", + "type.property.optional.UnionStringLiteralPropertyProperty": "Type.Property.Optional.UnionStringLiteralProperty.property.anonymous" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-property-valuetypes_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-property-valuetypes_apiview_properties.json new file mode 100644 index 0000000000..a0d7828eeb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-property-valuetypes_apiview_properties.json @@ -0,0 +1,187 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.property.valuetypes.BooleanLiteralClient": "Type.Property.ValueTypes.BooleanLiteral", + "type.property.valuetypes.BooleanLiteralClient.get": "Type.Property.ValueTypes.BooleanLiteral.get", + "type.property.valuetypes.BooleanLiteralClient.getWithResponse": "Type.Property.ValueTypes.BooleanLiteral.get", + "type.property.valuetypes.BooleanLiteralClient.put": "Type.Property.ValueTypes.BooleanLiteral.put", + "type.property.valuetypes.BooleanLiteralClient.putWithResponse": "Type.Property.ValueTypes.BooleanLiteral.put", + "type.property.valuetypes.BooleanLiteralProperty": "Type.Property.ValueTypes.BooleanLiteralProperty", + "type.property.valuetypes.BooleanOperationClient": "Type.Property.ValueTypes.Boolean", + "type.property.valuetypes.BooleanOperationClient.get": "Type.Property.ValueTypes.Boolean.get", + "type.property.valuetypes.BooleanOperationClient.getWithResponse": "Type.Property.ValueTypes.Boolean.get", + "type.property.valuetypes.BooleanOperationClient.put": "Type.Property.ValueTypes.Boolean.put", + "type.property.valuetypes.BooleanOperationClient.putWithResponse": "Type.Property.ValueTypes.Boolean.put", + "type.property.valuetypes.BooleanProperty": "Type.Property.ValueTypes.BooleanProperty", + "type.property.valuetypes.BytesClient": "Type.Property.ValueTypes.Bytes", + "type.property.valuetypes.BytesClient.get": "Type.Property.ValueTypes.Bytes.get", + "type.property.valuetypes.BytesClient.getWithResponse": "Type.Property.ValueTypes.Bytes.get", + "type.property.valuetypes.BytesClient.put": "Type.Property.ValueTypes.Bytes.put", + "type.property.valuetypes.BytesClient.putWithResponse": "Type.Property.ValueTypes.Bytes.put", + "type.property.valuetypes.BytesProperty": "Type.Property.ValueTypes.BytesProperty", + "type.property.valuetypes.CollectionsIntClient": "Type.Property.ValueTypes.CollectionsInt", + "type.property.valuetypes.CollectionsIntClient.get": "Type.Property.ValueTypes.CollectionsInt.get", + "type.property.valuetypes.CollectionsIntClient.getWithResponse": "Type.Property.ValueTypes.CollectionsInt.get", + "type.property.valuetypes.CollectionsIntClient.put": "Type.Property.ValueTypes.CollectionsInt.put", + "type.property.valuetypes.CollectionsIntClient.putWithResponse": "Type.Property.ValueTypes.CollectionsInt.put", + "type.property.valuetypes.CollectionsIntProperty": "Type.Property.ValueTypes.CollectionsIntProperty", + "type.property.valuetypes.CollectionsModelClient": "Type.Property.ValueTypes.CollectionsModel", + "type.property.valuetypes.CollectionsModelClient.get": "Type.Property.ValueTypes.CollectionsModel.get", + "type.property.valuetypes.CollectionsModelClient.getWithResponse": "Type.Property.ValueTypes.CollectionsModel.get", + "type.property.valuetypes.CollectionsModelClient.put": "Type.Property.ValueTypes.CollectionsModel.put", + "type.property.valuetypes.CollectionsModelClient.putWithResponse": "Type.Property.ValueTypes.CollectionsModel.put", + "type.property.valuetypes.CollectionsModelProperty": "Type.Property.ValueTypes.CollectionsModelProperty", + "type.property.valuetypes.CollectionsStringClient": "Type.Property.ValueTypes.CollectionsString", + "type.property.valuetypes.CollectionsStringClient.get": "Type.Property.ValueTypes.CollectionsString.get", + "type.property.valuetypes.CollectionsStringClient.getWithResponse": "Type.Property.ValueTypes.CollectionsString.get", + "type.property.valuetypes.CollectionsStringClient.put": "Type.Property.ValueTypes.CollectionsString.put", + "type.property.valuetypes.CollectionsStringClient.putWithResponse": "Type.Property.ValueTypes.CollectionsString.put", + "type.property.valuetypes.CollectionsStringProperty": "Type.Property.ValueTypes.CollectionsStringProperty", + "type.property.valuetypes.DatetimeOperationClient": "Type.Property.ValueTypes.Datetime", + "type.property.valuetypes.DatetimeOperationClient.get": "Type.Property.ValueTypes.Datetime.get", + "type.property.valuetypes.DatetimeOperationClient.getWithResponse": "Type.Property.ValueTypes.Datetime.get", + "type.property.valuetypes.DatetimeOperationClient.put": "Type.Property.ValueTypes.Datetime.put", + "type.property.valuetypes.DatetimeOperationClient.putWithResponse": "Type.Property.ValueTypes.Datetime.put", + "type.property.valuetypes.DatetimeProperty": "Type.Property.ValueTypes.DatetimeProperty", + "type.property.valuetypes.Decimal128Client": "Type.Property.ValueTypes.Decimal128", + "type.property.valuetypes.Decimal128Client.get": "Type.Property.ValueTypes.Decimal128.get", + "type.property.valuetypes.Decimal128Client.getWithResponse": "Type.Property.ValueTypes.Decimal128.get", + "type.property.valuetypes.Decimal128Client.put": "Type.Property.ValueTypes.Decimal128.put", + "type.property.valuetypes.Decimal128Client.putWithResponse": "Type.Property.ValueTypes.Decimal128.put", + "type.property.valuetypes.Decimal128Property": "Type.Property.ValueTypes.Decimal128Property", + "type.property.valuetypes.DecimalClient": "Type.Property.ValueTypes.Decimal", + "type.property.valuetypes.DecimalClient.get": "Type.Property.ValueTypes.Decimal.get", + "type.property.valuetypes.DecimalClient.getWithResponse": "Type.Property.ValueTypes.Decimal.get", + "type.property.valuetypes.DecimalClient.put": "Type.Property.ValueTypes.Decimal.put", + "type.property.valuetypes.DecimalClient.putWithResponse": "Type.Property.ValueTypes.Decimal.put", + "type.property.valuetypes.DecimalProperty": "Type.Property.ValueTypes.DecimalProperty", + "type.property.valuetypes.DictionaryStringClient": "Type.Property.ValueTypes.DictionaryString", + "type.property.valuetypes.DictionaryStringClient.get": "Type.Property.ValueTypes.DictionaryString.get", + "type.property.valuetypes.DictionaryStringClient.getWithResponse": "Type.Property.ValueTypes.DictionaryString.get", + "type.property.valuetypes.DictionaryStringClient.put": "Type.Property.ValueTypes.DictionaryString.put", + "type.property.valuetypes.DictionaryStringClient.putWithResponse": "Type.Property.ValueTypes.DictionaryString.put", + "type.property.valuetypes.DictionaryStringProperty": "Type.Property.ValueTypes.DictionaryStringProperty", + "type.property.valuetypes.DurationOperationClient": "Type.Property.ValueTypes.Duration", + "type.property.valuetypes.DurationOperationClient.get": "Type.Property.ValueTypes.Duration.get", + "type.property.valuetypes.DurationOperationClient.getWithResponse": "Type.Property.ValueTypes.Duration.get", + "type.property.valuetypes.DurationOperationClient.put": "Type.Property.ValueTypes.Duration.put", + "type.property.valuetypes.DurationOperationClient.putWithResponse": "Type.Property.ValueTypes.Duration.put", + "type.property.valuetypes.DurationProperty": "Type.Property.ValueTypes.DurationProperty", + "type.property.valuetypes.EnumClient": "Type.Property.ValueTypes.Enum", + "type.property.valuetypes.EnumClient.get": "Type.Property.ValueTypes.Enum.get", + "type.property.valuetypes.EnumClient.getWithResponse": "Type.Property.ValueTypes.Enum.get", + "type.property.valuetypes.EnumClient.put": "Type.Property.ValueTypes.Enum.put", + "type.property.valuetypes.EnumClient.putWithResponse": "Type.Property.ValueTypes.Enum.put", + "type.property.valuetypes.EnumProperty": "Type.Property.ValueTypes.EnumProperty", + "type.property.valuetypes.ExtendedEnum": "Type.Property.ValueTypes.ExtendedEnum", + "type.property.valuetypes.ExtensibleEnumClient": "Type.Property.ValueTypes.ExtensibleEnum", + "type.property.valuetypes.ExtensibleEnumClient.get": "Type.Property.ValueTypes.ExtensibleEnum.get", + "type.property.valuetypes.ExtensibleEnumClient.getWithResponse": "Type.Property.ValueTypes.ExtensibleEnum.get", + "type.property.valuetypes.ExtensibleEnumClient.put": "Type.Property.ValueTypes.ExtensibleEnum.put", + "type.property.valuetypes.ExtensibleEnumClient.putWithResponse": "Type.Property.ValueTypes.ExtensibleEnum.put", + "type.property.valuetypes.ExtensibleEnumProperty": "Type.Property.ValueTypes.ExtensibleEnumProperty", + "type.property.valuetypes.FixedInnerEnum": "Type.Property.ValueTypes.FixedInnerEnum", + "type.property.valuetypes.FloatLiteralClient": "Type.Property.ValueTypes.FloatLiteral", + "type.property.valuetypes.FloatLiteralClient.get": "Type.Property.ValueTypes.FloatLiteral.get", + "type.property.valuetypes.FloatLiteralClient.getWithResponse": "Type.Property.ValueTypes.FloatLiteral.get", + "type.property.valuetypes.FloatLiteralClient.put": "Type.Property.ValueTypes.FloatLiteral.put", + "type.property.valuetypes.FloatLiteralClient.putWithResponse": "Type.Property.ValueTypes.FloatLiteral.put", + "type.property.valuetypes.FloatLiteralProperty": "Type.Property.ValueTypes.FloatLiteralProperty", + "type.property.valuetypes.FloatOperationClient": "Type.Property.ValueTypes.Float", + "type.property.valuetypes.FloatOperationClient.get": "Type.Property.ValueTypes.Float.get", + "type.property.valuetypes.FloatOperationClient.getWithResponse": "Type.Property.ValueTypes.Float.get", + "type.property.valuetypes.FloatOperationClient.put": "Type.Property.ValueTypes.Float.put", + "type.property.valuetypes.FloatOperationClient.putWithResponse": "Type.Property.ValueTypes.Float.put", + "type.property.valuetypes.FloatProperty": "Type.Property.ValueTypes.FloatProperty", + "type.property.valuetypes.InnerEnum": "Type.Property.ValueTypes.InnerEnum", + "type.property.valuetypes.InnerModel": "Type.Property.ValueTypes.InnerModel", + "type.property.valuetypes.IntClient": "Type.Property.ValueTypes.Int", + "type.property.valuetypes.IntClient.get": "Type.Property.ValueTypes.Int.get", + "type.property.valuetypes.IntClient.getWithResponse": "Type.Property.ValueTypes.Int.get", + "type.property.valuetypes.IntClient.put": "Type.Property.ValueTypes.Int.put", + "type.property.valuetypes.IntClient.putWithResponse": "Type.Property.ValueTypes.Int.put", + "type.property.valuetypes.IntLiteralClient": "Type.Property.ValueTypes.IntLiteral", + "type.property.valuetypes.IntLiteralClient.get": "Type.Property.ValueTypes.IntLiteral.get", + "type.property.valuetypes.IntLiteralClient.getWithResponse": "Type.Property.ValueTypes.IntLiteral.get", + "type.property.valuetypes.IntLiteralClient.put": "Type.Property.ValueTypes.IntLiteral.put", + "type.property.valuetypes.IntLiteralClient.putWithResponse": "Type.Property.ValueTypes.IntLiteral.put", + "type.property.valuetypes.IntLiteralProperty": "Type.Property.ValueTypes.IntLiteralProperty", + "type.property.valuetypes.IntProperty": "Type.Property.ValueTypes.IntProperty", + "type.property.valuetypes.ModelClient": "Type.Property.ValueTypes.Model", + "type.property.valuetypes.ModelClient.get": "Type.Property.ValueTypes.Model.get", + "type.property.valuetypes.ModelClient.getWithResponse": "Type.Property.ValueTypes.Model.get", + "type.property.valuetypes.ModelClient.put": "Type.Property.ValueTypes.Model.put", + "type.property.valuetypes.ModelClient.putWithResponse": "Type.Property.ValueTypes.Model.put", + "type.property.valuetypes.ModelProperty": "Type.Property.ValueTypes.ModelProperty", + "type.property.valuetypes.NeverClient": "Type.Property.ValueTypes.Never", + "type.property.valuetypes.NeverClient.get": "Type.Property.ValueTypes.Never.get", + "type.property.valuetypes.NeverClient.getWithResponse": "Type.Property.ValueTypes.Never.get", + "type.property.valuetypes.NeverClient.put": "Type.Property.ValueTypes.Never.put", + "type.property.valuetypes.NeverClient.putWithResponse": "Type.Property.ValueTypes.Never.put", + "type.property.valuetypes.NeverProperty": "Type.Property.ValueTypes.NeverProperty", + "type.property.valuetypes.StringLiteralClient": "Type.Property.ValueTypes.StringLiteral", + "type.property.valuetypes.StringLiteralClient.get": "Type.Property.ValueTypes.StringLiteral.get", + "type.property.valuetypes.StringLiteralClient.getWithResponse": "Type.Property.ValueTypes.StringLiteral.get", + "type.property.valuetypes.StringLiteralClient.put": "Type.Property.ValueTypes.StringLiteral.put", + "type.property.valuetypes.StringLiteralClient.putWithResponse": "Type.Property.ValueTypes.StringLiteral.put", + "type.property.valuetypes.StringLiteralProperty": "Type.Property.ValueTypes.StringLiteralProperty", + "type.property.valuetypes.StringOperationClient": "Type.Property.ValueTypes.String", + "type.property.valuetypes.StringOperationClient.get": "Type.Property.ValueTypes.String.get", + "type.property.valuetypes.StringOperationClient.getWithResponse": "Type.Property.ValueTypes.String.get", + "type.property.valuetypes.StringOperationClient.put": "Type.Property.ValueTypes.String.put", + "type.property.valuetypes.StringOperationClient.putWithResponse": "Type.Property.ValueTypes.String.put", + "type.property.valuetypes.StringProperty": "Type.Property.ValueTypes.StringProperty", + "type.property.valuetypes.UnionEnumValueClient": "Type.Property.ValueTypes.UnionEnumValue", + "type.property.valuetypes.UnionEnumValueClient.get": "Type.Property.ValueTypes.UnionEnumValue.get", + "type.property.valuetypes.UnionEnumValueClient.getWithResponse": "Type.Property.ValueTypes.UnionEnumValue.get", + "type.property.valuetypes.UnionEnumValueClient.put": "Type.Property.ValueTypes.UnionEnumValue.put", + "type.property.valuetypes.UnionEnumValueClient.putWithResponse": "Type.Property.ValueTypes.UnionEnumValue.put", + "type.property.valuetypes.UnionEnumValueProperty": "Type.Property.ValueTypes.UnionEnumValueProperty", + "type.property.valuetypes.UnionFloatLiteralClient": "Type.Property.ValueTypes.UnionFloatLiteral", + "type.property.valuetypes.UnionFloatLiteralClient.get": "Type.Property.ValueTypes.UnionFloatLiteral.get", + "type.property.valuetypes.UnionFloatLiteralClient.getWithResponse": "Type.Property.ValueTypes.UnionFloatLiteral.get", + "type.property.valuetypes.UnionFloatLiteralClient.put": "Type.Property.ValueTypes.UnionFloatLiteral.put", + "type.property.valuetypes.UnionFloatLiteralClient.putWithResponse": "Type.Property.ValueTypes.UnionFloatLiteral.put", + "type.property.valuetypes.UnionFloatLiteralProperty": "Type.Property.ValueTypes.UnionFloatLiteralProperty", + "type.property.valuetypes.UnionFloatLiteralPropertyProperty": "Type.Property.ValueTypes.UnionFloatLiteralProperty.property.anonymous", + "type.property.valuetypes.UnionIntLiteralClient": "Type.Property.ValueTypes.UnionIntLiteral", + "type.property.valuetypes.UnionIntLiteralClient.get": "Type.Property.ValueTypes.UnionIntLiteral.get", + "type.property.valuetypes.UnionIntLiteralClient.getWithResponse": "Type.Property.ValueTypes.UnionIntLiteral.get", + "type.property.valuetypes.UnionIntLiteralClient.put": "Type.Property.ValueTypes.UnionIntLiteral.put", + "type.property.valuetypes.UnionIntLiteralClient.putWithResponse": "Type.Property.ValueTypes.UnionIntLiteral.put", + "type.property.valuetypes.UnionIntLiteralProperty": "Type.Property.ValueTypes.UnionIntLiteralProperty", + "type.property.valuetypes.UnionIntLiteralPropertyProperty": "Type.Property.ValueTypes.UnionIntLiteralProperty.property.anonymous", + "type.property.valuetypes.UnionStringLiteralClient": "Type.Property.ValueTypes.UnionStringLiteral", + "type.property.valuetypes.UnionStringLiteralClient.get": "Type.Property.ValueTypes.UnionStringLiteral.get", + "type.property.valuetypes.UnionStringLiteralClient.getWithResponse": "Type.Property.ValueTypes.UnionStringLiteral.get", + "type.property.valuetypes.UnionStringLiteralClient.put": "Type.Property.ValueTypes.UnionStringLiteral.put", + "type.property.valuetypes.UnionStringLiteralClient.putWithResponse": "Type.Property.ValueTypes.UnionStringLiteral.put", + "type.property.valuetypes.UnionStringLiteralProperty": "Type.Property.ValueTypes.UnionStringLiteralProperty", + "type.property.valuetypes.UnionStringLiteralPropertyProperty": "Type.Property.ValueTypes.UnionStringLiteralProperty.property.anonymous", + "type.property.valuetypes.UnknownArrayClient": "Type.Property.ValueTypes.UnknownArray", + "type.property.valuetypes.UnknownArrayClient.get": "Type.Property.ValueTypes.UnknownArray.get", + "type.property.valuetypes.UnknownArrayClient.getWithResponse": "Type.Property.ValueTypes.UnknownArray.get", + "type.property.valuetypes.UnknownArrayClient.put": "Type.Property.ValueTypes.UnknownArray.put", + "type.property.valuetypes.UnknownArrayClient.putWithResponse": "Type.Property.ValueTypes.UnknownArray.put", + "type.property.valuetypes.UnknownArrayProperty": "Type.Property.ValueTypes.UnknownArrayProperty", + "type.property.valuetypes.UnknownDictClient": "Type.Property.ValueTypes.UnknownDict", + "type.property.valuetypes.UnknownDictClient.get": "Type.Property.ValueTypes.UnknownDict.get", + "type.property.valuetypes.UnknownDictClient.getWithResponse": "Type.Property.ValueTypes.UnknownDict.get", + "type.property.valuetypes.UnknownDictClient.put": "Type.Property.ValueTypes.UnknownDict.put", + "type.property.valuetypes.UnknownDictClient.putWithResponse": "Type.Property.ValueTypes.UnknownDict.put", + "type.property.valuetypes.UnknownDictProperty": "Type.Property.ValueTypes.UnknownDictProperty", + "type.property.valuetypes.UnknownIntClient": "Type.Property.ValueTypes.UnknownInt", + "type.property.valuetypes.UnknownIntClient.get": "Type.Property.ValueTypes.UnknownInt.get", + "type.property.valuetypes.UnknownIntClient.getWithResponse": "Type.Property.ValueTypes.UnknownInt.get", + "type.property.valuetypes.UnknownIntClient.put": "Type.Property.ValueTypes.UnknownInt.put", + "type.property.valuetypes.UnknownIntClient.putWithResponse": "Type.Property.ValueTypes.UnknownInt.put", + "type.property.valuetypes.UnknownIntProperty": "Type.Property.ValueTypes.UnknownIntProperty", + "type.property.valuetypes.UnknownStringClient": "Type.Property.ValueTypes.UnknownString", + "type.property.valuetypes.UnknownStringClient.get": "Type.Property.ValueTypes.UnknownString.get", + "type.property.valuetypes.UnknownStringClient.getWithResponse": "Type.Property.ValueTypes.UnknownString.get", + "type.property.valuetypes.UnknownStringClient.put": "Type.Property.ValueTypes.UnknownString.put", + "type.property.valuetypes.UnknownStringClient.putWithResponse": "Type.Property.ValueTypes.UnknownString.put", + "type.property.valuetypes.UnknownStringProperty": "Type.Property.ValueTypes.UnknownStringProperty", + "type.property.valuetypes.ValueTypesClientBuilder": "Type.Property.ValueTypes" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-scalar_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-scalar_apiview_properties.json new file mode 100644 index 0000000000..e6be933df4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-scalar_apiview_properties.json @@ -0,0 +1,45 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.scalar.BooleanOperationClient": "Type.Scalar.Boolean", + "type.scalar.BooleanOperationClient.get": "Type.Scalar.Boolean.get", + "type.scalar.BooleanOperationClient.getWithResponse": "Type.Scalar.Boolean.get", + "type.scalar.BooleanOperationClient.put": "Type.Scalar.Boolean.put", + "type.scalar.BooleanOperationClient.putWithResponse": "Type.Scalar.Boolean.put", + "type.scalar.Decimal128TypeClient": "Type.Scalar.Decimal128Type", + "type.scalar.Decimal128TypeClient.requestBody": "Type.Scalar.Decimal128Type.requestBody", + "type.scalar.Decimal128TypeClient.requestBodyWithResponse": "Type.Scalar.Decimal128Type.requestBody", + "type.scalar.Decimal128TypeClient.requestParameter": "Type.Scalar.Decimal128Type.requestParameter", + "type.scalar.Decimal128TypeClient.requestParameterWithResponse": "Type.Scalar.Decimal128Type.requestParameter", + "type.scalar.Decimal128TypeClient.responseBody": "Type.Scalar.Decimal128Type.responseBody", + "type.scalar.Decimal128TypeClient.responseBodyWithResponse": "Type.Scalar.Decimal128Type.responseBody", + "type.scalar.Decimal128VerifyClient": "Type.Scalar.Decimal128Verify", + "type.scalar.Decimal128VerifyClient.prepareVerify": "Type.Scalar.Decimal128Verify.prepareVerify", + "type.scalar.Decimal128VerifyClient.prepareVerifyWithResponse": "Type.Scalar.Decimal128Verify.prepareVerify", + "type.scalar.Decimal128VerifyClient.verify": "Type.Scalar.Decimal128Verify.verify", + "type.scalar.Decimal128VerifyClient.verifyWithResponse": "Type.Scalar.Decimal128Verify.verify", + "type.scalar.DecimalTypeClient": "Type.Scalar.DecimalType", + "type.scalar.DecimalTypeClient.requestBody": "Type.Scalar.DecimalType.requestBody", + "type.scalar.DecimalTypeClient.requestBodyWithResponse": "Type.Scalar.DecimalType.requestBody", + "type.scalar.DecimalTypeClient.requestParameter": "Type.Scalar.DecimalType.requestParameter", + "type.scalar.DecimalTypeClient.requestParameterWithResponse": "Type.Scalar.DecimalType.requestParameter", + "type.scalar.DecimalTypeClient.responseBody": "Type.Scalar.DecimalType.responseBody", + "type.scalar.DecimalTypeClient.responseBodyWithResponse": "Type.Scalar.DecimalType.responseBody", + "type.scalar.DecimalVerifyClient": "Type.Scalar.DecimalVerify", + "type.scalar.DecimalVerifyClient.prepareVerify": "Type.Scalar.DecimalVerify.prepareVerify", + "type.scalar.DecimalVerifyClient.prepareVerifyWithResponse": "Type.Scalar.DecimalVerify.prepareVerify", + "type.scalar.DecimalVerifyClient.verify": "Type.Scalar.DecimalVerify.verify", + "type.scalar.DecimalVerifyClient.verifyWithResponse": "Type.Scalar.DecimalVerify.verify", + "type.scalar.ScalarClientBuilder": "Type.Scalar", + "type.scalar.StringOperationClient": "Type.Scalar.String", + "type.scalar.StringOperationClient.get": "Type.Scalar.String.get", + "type.scalar.StringOperationClient.getWithResponse": "Type.Scalar.String.get", + "type.scalar.StringOperationClient.put": "Type.Scalar.String.put", + "type.scalar.StringOperationClient.putWithResponse": "Type.Scalar.String.put", + "type.scalar.UnknownClient": "Type.Scalar.Unknown", + "type.scalar.UnknownClient.get": "Type.Scalar.Unknown.get", + "type.scalar.UnknownClient.getWithResponse": "Type.Scalar.Unknown.get", + "type.scalar.UnknownClient.put": "Type.Scalar.Unknown.put", + "type.scalar.UnknownClient.putWithResponse": "Type.Scalar.Unknown.put" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-union_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-union_apiview_properties.json new file mode 100644 index 0000000000..f63d0112b7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/type-union_apiview_properties.json @@ -0,0 +1,89 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "type.union.Cat": "Type.Union.Cat", + "type.union.Dog": "Type.Union.Dog", + "type.union.EnumsOnlyCases": "Type.Union.EnumsOnlyCases", + "type.union.EnumsOnlyCasesLr": "Type.Union.EnumsOnlyCases.lr.anonymous", + "type.union.EnumsOnlyCasesUd": "Type.Union.EnumsOnlyCases.ud.anonymous", + "type.union.EnumsOnlyClient": "Type.Union.EnumsOnly", + "type.union.EnumsOnlyClient.get": "Type.Union.EnumsOnly.get", + "type.union.EnumsOnlyClient.getWithResponse": "Type.Union.EnumsOnly.get", + "type.union.EnumsOnlyClient.send": "Type.Union.EnumsOnly.send", + "type.union.EnumsOnlyClient.sendWithResponse": "Type.Union.EnumsOnly.send", + "type.union.FloatsOnlyClient": "Type.Union.FloatsOnly", + "type.union.FloatsOnlyClient.get": "Type.Union.FloatsOnly.get", + "type.union.FloatsOnlyClient.getWithResponse": "Type.Union.FloatsOnly.get", + "type.union.FloatsOnlyClient.send": "Type.Union.FloatsOnly.send", + "type.union.FloatsOnlyClient.sendWithResponse": "Type.Union.FloatsOnly.send", + "type.union.GetResponse": "Type.Union.get.Response.anonymous", + "type.union.GetResponse1": "Type.Union.get.Response.anonymous", + "type.union.GetResponse2": "Type.Union.get.Response.anonymous", + "type.union.GetResponse3": "Type.Union.get.Response.anonymous", + "type.union.GetResponse4": "Type.Union.get.Response.anonymous", + "type.union.GetResponse5": "Type.Union.get.Response.anonymous", + "type.union.GetResponse6": "Type.Union.get.Response.anonymous", + "type.union.GetResponse7": "Type.Union.get.Response.anonymous", + "type.union.GetResponse8": "Type.Union.get.Response.anonymous", + "type.union.GetResponse9": "Type.Union.get.Response.anonymous", + "type.union.GetResponseProp1": "Type.Union.get.Response.prop.anonymous", + "type.union.GetResponseProp2": "Type.Union.get.Response.prop.anonymous", + "type.union.GetResponseProp3": "Type.Union.get.Response.prop.anonymous", + "type.union.GetResponseProp4": "Type.Union.get.Response.prop.anonymous", + "type.union.IntsOnlyClient": "Type.Union.IntsOnly", + "type.union.IntsOnlyClient.get": "Type.Union.IntsOnly.get", + "type.union.IntsOnlyClient.getWithResponse": "Type.Union.IntsOnly.get", + "type.union.IntsOnlyClient.send": "Type.Union.IntsOnly.send", + "type.union.IntsOnlyClient.sendWithResponse": "Type.Union.IntsOnly.send", + "type.union.MixedLiteralsCases": "Type.Union.MixedLiteralsCases", + "type.union.MixedLiteralsClient": "Type.Union.MixedLiterals", + "type.union.MixedLiteralsClient.get": "Type.Union.MixedLiterals.get", + "type.union.MixedLiteralsClient.getWithResponse": "Type.Union.MixedLiterals.get", + "type.union.MixedLiteralsClient.send": "Type.Union.MixedLiterals.send", + "type.union.MixedLiteralsClient.sendWithResponse": "Type.Union.MixedLiterals.send", + "type.union.MixedTypesCases": "Type.Union.MixedTypesCases", + "type.union.MixedTypesClient": "Type.Union.MixedTypes", + "type.union.MixedTypesClient.get": "Type.Union.MixedTypes.get", + "type.union.MixedTypesClient.getWithResponse": "Type.Union.MixedTypes.get", + "type.union.MixedTypesClient.send": "Type.Union.MixedTypes.send", + "type.union.MixedTypesClient.sendWithResponse": "Type.Union.MixedTypes.send", + "type.union.ModelsOnlyClient": "Type.Union.ModelsOnly", + "type.union.ModelsOnlyClient.get": "Type.Union.ModelsOnly.get", + "type.union.ModelsOnlyClient.getWithResponse": "Type.Union.ModelsOnly.get", + "type.union.ModelsOnlyClient.send": "Type.Union.ModelsOnly.send", + "type.union.ModelsOnlyClient.sendWithResponse": "Type.Union.ModelsOnly.send", + "type.union.StringAndArrayCases": "Type.Union.StringAndArrayCases", + "type.union.StringAndArrayClient": "Type.Union.StringAndArray", + "type.union.StringAndArrayClient.get": "Type.Union.StringAndArray.get", + "type.union.StringAndArrayClient.getWithResponse": "Type.Union.StringAndArray.get", + "type.union.StringAndArrayClient.send": "Type.Union.StringAndArray.send", + "type.union.StringAndArrayClient.sendWithResponse": "Type.Union.StringAndArray.send", + "type.union.StringExtensibleClient": "Type.Union.StringExtensible", + "type.union.StringExtensibleClient.get": "Type.Union.StringExtensible.get", + "type.union.StringExtensibleClient.getWithResponse": "Type.Union.StringExtensible.get", + "type.union.StringExtensibleClient.send": "Type.Union.StringExtensible.send", + "type.union.StringExtensibleClient.sendWithResponse": "Type.Union.StringExtensible.send", + "type.union.StringExtensibleNamedClient": "Type.Union.StringExtensibleNamed", + "type.union.StringExtensibleNamedClient.get": "Type.Union.StringExtensibleNamed.get", + "type.union.StringExtensibleNamedClient.getWithResponse": "Type.Union.StringExtensibleNamed.get", + "type.union.StringExtensibleNamedClient.send": "Type.Union.StringExtensibleNamed.send", + "type.union.StringExtensibleNamedClient.sendWithResponse": "Type.Union.StringExtensibleNamed.send", + "type.union.StringExtensibleNamedUnion": "Type.Union.StringExtensibleNamedUnion", + "type.union.StringsOnlyClient": "Type.Union.StringsOnly", + "type.union.StringsOnlyClient.get": "Type.Union.StringsOnly.get", + "type.union.StringsOnlyClient.getWithResponse": "Type.Union.StringsOnly.get", + "type.union.StringsOnlyClient.send": "Type.Union.StringsOnly.send", + "type.union.StringsOnlyClient.sendWithResponse": "Type.Union.StringsOnly.send", + "type.union.UnionClientBuilder": "Type.Union", + "type.union.implementation.SendRequest": "Type.Union.send.Request.anonymous", + "type.union.implementation.SendRequest1": "Type.Union.send.Request.anonymous", + "type.union.implementation.SendRequest2": "Type.Union.send.Request.anonymous", + "type.union.implementation.SendRequest3": "Type.Union.send.Request.anonymous", + "type.union.implementation.SendRequest4": "Type.Union.send.Request.anonymous", + "type.union.implementation.SendRequest5": "Type.Union.send.Request.anonymous", + "type.union.implementation.SendRequest6": "Type.Union.send.Request.anonymous", + "type.union.implementation.SendRequest7": "Type.Union.send.Request.anonymous", + "type.union.implementation.SendRequest8": "Type.Union.send.Request.anonymous", + "type.union.implementation.SendRequest9": "Type.Union.send.Request.anonymous" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-added_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-added_apiview_properties.json new file mode 100644 index 0000000000..6f9081a43d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-added_apiview_properties.json @@ -0,0 +1,19 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "versioning.added.AddedClient": "Versioning.Added", + "versioning.added.AddedClient.v1": "Versioning.Added.v1", + "versioning.added.AddedClient.v1WithResponse": "Versioning.Added.v1", + "versioning.added.AddedClient.v2": "Versioning.Added.v2", + "versioning.added.AddedClient.v2WithResponse": "Versioning.Added.v2", + "versioning.added.AddedClientBuilder": "Versioning.Added", + "versioning.added.EnumV1": "Versioning.Added.EnumV1", + "versioning.added.EnumV2": "Versioning.Added.EnumV2", + "versioning.added.InterfaceV2Client": "Versioning.Added.InterfaceV2", + "versioning.added.InterfaceV2Client.v2InInterface": "Versioning.Added.InterfaceV2.v2InInterface", + "versioning.added.InterfaceV2Client.v2InInterfaceWithResponse": "Versioning.Added.InterfaceV2.v2InInterface", + "versioning.added.ModelV1": "Versioning.Added.ModelV1", + "versioning.added.ModelV2": "Versioning.Added.ModelV2", + "versioning.added.Versions": "Versioning.Added.Versions" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-madeoptional_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-madeoptional_apiview_properties.json new file mode 100644 index 0000000000..606a8a8ca8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-madeoptional_apiview_properties.json @@ -0,0 +1,11 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "versioning.madeoptional.MadeOptionalClient": "Versioning.MadeOptional", + "versioning.madeoptional.MadeOptionalClient.test": "Versioning.MadeOptional.test", + "versioning.madeoptional.MadeOptionalClient.testWithResponse": "Versioning.MadeOptional.test", + "versioning.madeoptional.MadeOptionalClientBuilder": "Versioning.MadeOptional", + "versioning.madeoptional.TestModel": "Versioning.MadeOptional.TestModel", + "versioning.madeoptional.Versions": "Versioning.MadeOptional.Versions" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-removed_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-removed_apiview_properties.json new file mode 100644 index 0000000000..f00470bb3c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-removed_apiview_properties.json @@ -0,0 +1,16 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "versioning.removed.EnumV2": "Versioning.Removed.EnumV2", + "versioning.removed.EnumV3": "Versioning.Removed.EnumV3", + "versioning.removed.ModelV2": "Versioning.Removed.ModelV2", + "versioning.removed.ModelV3": "Versioning.Removed.ModelV3", + "versioning.removed.RemovedClient": "Versioning.Removed", + "versioning.removed.RemovedClient.modelV3": "Versioning.Removed.modelV3", + "versioning.removed.RemovedClient.modelV3WithResponse": "Versioning.Removed.modelV3", + "versioning.removed.RemovedClient.v2": "Versioning.Removed.v2", + "versioning.removed.RemovedClient.v2WithResponse": "Versioning.Removed.v2", + "versioning.removed.RemovedClientBuilder": "Versioning.Removed", + "versioning.removed.Versions": "Versioning.Removed.Versions" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-renamedfrom_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-renamedfrom_apiview_properties.json new file mode 100644 index 0000000000..3d1af4cca0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-renamedfrom_apiview_properties.json @@ -0,0 +1,15 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "versioning.renamedfrom.NewEnum": "Versioning.RenamedFrom.NewEnum", + "versioning.renamedfrom.NewInterfaceClient": "Versioning.RenamedFrom.NewInterface", + "versioning.renamedfrom.NewInterfaceClient.newOpInNewInterface": "Versioning.RenamedFrom.NewInterface.newOpInNewInterface", + "versioning.renamedfrom.NewInterfaceClient.newOpInNewInterfaceWithResponse": "Versioning.RenamedFrom.NewInterface.newOpInNewInterface", + "versioning.renamedfrom.NewModel": "Versioning.RenamedFrom.NewModel", + "versioning.renamedfrom.RenamedFromClient": "Versioning.RenamedFrom", + "versioning.renamedfrom.RenamedFromClient.newOp": "Versioning.RenamedFrom.newOp", + "versioning.renamedfrom.RenamedFromClient.newOpWithResponse": "Versioning.RenamedFrom.newOp", + "versioning.renamedfrom.RenamedFromClientBuilder": "Versioning.RenamedFrom", + "versioning.renamedfrom.Versions": "Versioning.RenamedFrom.Versions" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-returntypechangedfrom_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-returntypechangedfrom_apiview_properties.json new file mode 100644 index 0000000000..fbb8fea8a1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-returntypechangedfrom_apiview_properties.json @@ -0,0 +1,10 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "versioning.returntypechangedfrom.ReturnTypeChangedFromClient": "Versioning.ReturnTypeChangedFrom", + "versioning.returntypechangedfrom.ReturnTypeChangedFromClient.test": "Versioning.ReturnTypeChangedFrom.test", + "versioning.returntypechangedfrom.ReturnTypeChangedFromClient.testWithResponse": "Versioning.ReturnTypeChangedFrom.test", + "versioning.returntypechangedfrom.ReturnTypeChangedFromClientBuilder": "Versioning.ReturnTypeChangedFrom", + "versioning.returntypechangedfrom.Versions": "Versioning.ReturnTypeChangedFrom.Versions" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-typechangedfrom_apiview_properties.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-typechangedfrom_apiview_properties.json new file mode 100644 index 0000000000..26b4b00628 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/main/resources/META-INF/versioning-typechangedfrom_apiview_properties.json @@ -0,0 +1,11 @@ +{ + "flavor": "generic", + "CrossLanguageDefinitionId": { + "versioning.typechangedfrom.TestModel": "Versioning.TypeChangedFrom.TestModel", + "versioning.typechangedfrom.TypeChangedFromClient": "Versioning.TypeChangedFrom", + "versioning.typechangedfrom.TypeChangedFromClient.test": "Versioning.TypeChangedFrom.test", + "versioning.typechangedfrom.TypeChangedFromClient.testWithResponse": "Versioning.TypeChangedFrom.test", + "versioning.typechangedfrom.TypeChangedFromClientBuilder": "Versioning.TypeChangedFrom", + "versioning.typechangedfrom.Versions": "Versioning.TypeChangedFrom.Versions" + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/authentication/apikey/ApiKeyTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/authentication/apikey/ApiKeyTests.java new file mode 100644 index 0000000000..3343d8a9ba --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/authentication/apikey/ApiKeyTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package authentication.apikey; + +import io.clientcore.core.credential.KeyCredential; +import io.clientcore.core.http.exception.HttpResponseException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ApiKeyTests { + + @Test + public void testValid() { + ApiKeyClient client = new ApiKeyClientBuilder().credential(new KeyCredential("valid-key")).buildClient(); + + client.valid(); + } + + @Test + public void testInvalid() { + ApiKeyClient client = new ApiKeyClientBuilder().credential(new KeyCredential("invalid-key")).buildClient(); + + // assert HttpResponseException + Assertions.assertThrows(HttpResponseException.class, client::invalid); + // assert statusCode 403 + try { + client.invalid(); + } catch (HttpResponseException e) { + Assertions.assertEquals(403, e.getResponse().getStatusCode()); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/authentication/http/custom/CustomAuthTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/authentication/http/custom/CustomAuthTests.java new file mode 100644 index 0000000000..a1bbb8578a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/authentication/http/custom/CustomAuthTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package authentication.http.custom; + +import io.clientcore.core.credential.KeyCredential; +import io.clientcore.core.http.exception.HttpResponseException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class CustomAuthTests { + + @Test + public void testValid() { + CustomClient client = new CustomClientBuilder().credential(new KeyCredential("valid-key")).buildClient(); + + client.valid(); + } + + @Test + public void testInvalid() { + CustomClient client = new CustomClientBuilder().credential(new KeyCredential("invalid-key")).buildClient(); + + // assert HttpResponseException + Assertions.assertThrows(HttpResponseException.class, client::invalid); + // assert statusCode 403 + try { + client.invalid(); + } catch (HttpResponseException e) { + Assertions.assertEquals(403, e.getResponse().getStatusCode()); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/encode/numeric/StringEncodeTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/encode/numeric/StringEncodeTests.java new file mode 100644 index 0000000000..c14a0f83ab --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/encode/numeric/StringEncodeTests.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package encode.numeric; + +import encode.numeric.property.SafeintAsStringProperty; +import encode.numeric.property.Uint32AsStringProperty; +import encode.numeric.property.Uint8AsStringProperty; +import org.junit.jupiter.api.Test; + +public class StringEncodeTests { + + private final NumericClient client = new NumericClientBuilder().buildNumericClient(); + + @Test + public void testIntEncodedAsString() { + client.safeintAsString(new SafeintAsStringProperty(10000000000L)); + + client.uint32AsStringOptional(new Uint32AsStringProperty().setValue(1)); + + client.uint8AsString(new Uint8AsStringProperty(255)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/org/utils/BinaryDataUtils.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/org/utils/BinaryDataUtils.java new file mode 100644 index 0000000000..4f63271bc1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/org/utils/BinaryDataUtils.java @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package org.utils; + +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; +import org.junit.jupiter.api.Assertions; + +public class BinaryDataUtils { + + public static void assertMapEquals(Map left, Map right) { + Assertions.assertEquals(left.size(), right.size()); + for (String key : left.keySet()) { + BinaryData leftValue = left.get(key); + BinaryData rightValue = right.get(key); + Assertions.assertArrayEquals(leftValue.toBytes(), rightValue.toBytes()); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/org/utils/FileUtils.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/org/utils/FileUtils.java new file mode 100644 index 0000000000..f002da96f9 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/org/utils/FileUtils.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package org.utils; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class FileUtils { + + private FileUtils() { + } + + public static Path getJpgFile() { + return Paths.get("node_modules/@typespec/http-specs/assets/image.jpg"); + } + + public static Path getPngFile() { + return Paths.get("node_modules/@typespec/http-specs/assets/image.png"); + } + + public static byte[] getJpgBytes() { + try { + return Files.readAllBytes(getJpgFile()); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public static byte[] getPngBytes() { + try { + return Files.readAllBytes(getPngFile()); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/basic/BasicClientTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/basic/BasicClientTests.java new file mode 100644 index 0000000000..c33c52c99e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/basic/BasicClientTests.java @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package parameters.basic; + +import org.junit.jupiter.api.Test; +import parameters.basic.explicitbody.User; + +public class BasicClientTests { + private final ExplicitBodyClient explicitBodyClient = new BasicClientBuilder().buildExplicitBodyClient(); + private final ImplicitBodyClient implicitBodyClient = new BasicClientBuilder().buildImplicitBodyClient(); + + @Test + public void testBodyClient() { + explicitBodyClient.simple(new User("foo")); + implicitBodyClient.simple("foo"); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/bodyoptionality/BodyTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/bodyoptionality/BodyTests.java new file mode 100644 index 0000000000..5f736f60b3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/bodyoptionality/BodyTests.java @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package parameters.bodyoptionality; + +import io.clientcore.core.http.models.HttpHeaderName; +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.http.models.HttpRequest; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipelineNextPolicy; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import org.junit.jupiter.api.AssertionFailureBuilder; +import org.junit.jupiter.api.Test; + +public class BodyTests { + + private final ContentTypeValidationPolicy validationPolicy = new ContentTypeValidationPolicy(); + private final BodyOptionalityClient client = new BodyOptionalityClientBuilder().buildClient(); + private final OptionalExplicitClient optionalClient + = new BodyOptionalityClientBuilder().addHttpPipelinePolicy(validationPolicy) + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogOptions.HttpLogDetailLevel.BODY_AND_HEADERS)) + .buildOptionalExplicitClient(); + + private final static class ContentTypeValidationPolicy implements HttpPipelinePolicy { + private boolean contentTypeHeaderExists; + + @Override + public Response process(HttpRequest request, HttpPipelineNextPolicy nextPolicy) { + contentTypeHeaderExists = request.getHeaders().get(HttpHeaderName.CONTENT_TYPE) != null; + return nextPolicy.process(); + } + + private void validateContentTypeHeader(boolean exists) { + if (exists != contentTypeHeaderExists) { + AssertionFailureBuilder.assertionFailure() + .message("content-type header validation failed") + .expected(exists) + .actual(contentTypeHeaderExists) + .buildAndThrow(); + } + } + } + + @Test + public void testBodyOptionality() { + client.requiredExplicit(new BodyModel("foo")); + + client.requiredImplicit("foo"); + + optionalClient.set(new BodyModel("foo")); + validationPolicy.validateContentTypeHeader(true); + + // verify that content-type is not set, when there is no body parameter + optionalClient.omit(); + validationPolicy.validateContentTypeHeader(false); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/collectionformat/CollectionFormatClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/collectionformat/CollectionFormatClientTest.java new file mode 100644 index 0000000000..94b078d305 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/collectionformat/CollectionFormatClientTest.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package parameters.collectionformat; + +import java.util.Arrays; +import org.junit.jupiter.api.Test; + +class CollectionFormatClientTest { + + private final QueryClient client = new CollectionFormatClientBuilder().buildQueryClient(); + private final HeaderClient headerClient = new CollectionFormatClientBuilder().buildHeaderClient(); + + @Test + void testMulti() { + client.multi(Arrays.asList("blue", "red", "green")); + } + + @Test + void testCsv() { + client.csv(Arrays.asList("blue", "red", "green")); + } + + @Test + void testSsv() { + client.ssv(Arrays.asList("blue", "red", "green")); + } + + @Test + void testTsv() { + client.tsv(Arrays.asList("blue", "red", "green")); + } + + @Test + void testPipe() { + client.pipes(Arrays.asList("blue", "red", "green")); + } + + @Test + void testCsvHeader() { + headerClient.csv(Arrays.asList("blue", "red", "green")); + } + +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/spread/SpreadTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/spread/SpreadTests.java new file mode 100644 index 0000000000..734876b06b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/spread/SpreadTests.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package parameters.spread; + +import java.util.List; +import org.junit.jupiter.api.Test; +import parameters.spread.model.BodyParameter; + +public class SpreadTests { + + private final AliasClient aliasClient = new SpreadClientBuilder().buildAliasClient(); + private final ModelClient modelClient = new SpreadClientBuilder().buildModelClient(); + + @Test + public void testSpread() { + + aliasClient.spreadAsRequestBody("foo"); + + aliasClient.spreadAsRequestParameter("1", "bar", "foo"); + + aliasClient.spreadWithMultipleParameters("1", "bar", "foo", List.of(1, 2), 1, List.of("foo", "bar")); + + aliasClient.spreadParameterWithInnerAlias("1", "bar", "foo", 1); + + aliasClient.spreadParameterWithInnerModel("1", "bar", "foo"); + } + + @Test + public void testModel() { + + modelClient.spreadAsRequestBody("foo"); + modelClient.spreadCompositeRequestOnlyWithBody(new BodyParameter("foo")); + modelClient.spreadCompositeRequestWithoutBody("foo", "bar"); + modelClient.spreadCompositeRequest("foo", "bar", new BodyParameter("foo")); + modelClient.spreadCompositeRequestMix("foo", "bar", "foo"); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/payload/contentnegotiation/SharedRouteTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/payload/contentnegotiation/SharedRouteTests.java new file mode 100644 index 0000000000..22f072204a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/payload/contentnegotiation/SharedRouteTests.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package payload.contentnegotiation; + +import io.clientcore.core.http.models.HttpLogOptions; +import io.clientcore.core.util.binarydata.BinaryData; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.utils.FileUtils; +import payload.contentnegotiation.differentbody.PngImageAsJson; + +public class SharedRouteTests { + + private final SameBodyClient client1 = new ContentNegotiationClientBuilder().buildSameBodyClient(); + private final DifferentBodyClient client2 = new ContentNegotiationClientBuilder() + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogOptions.HttpLogDetailLevel.BODY_AND_HEADERS)) + .buildDifferentBodyClient(); + + @Test + public void testContentNegotiation() { + byte[] jpgBytes = FileUtils.getJpgBytes(); + byte[] pngBytes = FileUtils.getPngBytes(); + + BinaryData jpeg = client1.getAvatarAsJpeg(); + Assertions.assertNotNull(jpeg); + Assertions.assertArrayEquals(jpgBytes, jpeg.toBytes()); + + BinaryData png = client1.getAvatarAsPng(); + Assertions.assertNotNull(png); + Assertions.assertArrayEquals(pngBytes, png.toBytes()); + + PngImageAsJson pngJson = client2.getAvatarAsJson(); + Assertions.assertNotNull(pngJson.getContent()); + Assertions.assertArrayEquals(pngBytes, pngJson.getContent()); + + png = client2.getAvatarAsPng(); + Assertions.assertNotNull(png); + Assertions.assertArrayEquals(pngBytes, png.toBytes()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/payload/jsonmergepatch/JsonMergePatchClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/payload/jsonmergepatch/JsonMergePatchClientTest.java new file mode 100644 index 0000000000..1015e7e16e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/payload/jsonmergepatch/JsonMergePatchClientTest.java @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package payload.jsonmergepatch; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.Test; + +public class JsonMergePatchClientTest { + + private final JsonMergePatchClient client = new JsonMergePatchClientBuilder().buildClient(); + + @Test + public void createAndUpdateResource() { + // create resource + Resource resource = buildResource(); + client.createResource(resource); + // update resource + ResourcePatch resourcePatch = buildResourcePatchWithNullProperties(); + client.updateResource(resourcePatch); + } + + @Test + public void updateOptionalResource() { + ResourcePatch resourcePatch = buildResourcePatchWithNullProperties(); + client.updateOptionalResource(resourcePatch); + } + + private static Resource buildResource() { + InnerModel innerModel = new InnerModel(); + innerModel.setName("InnerMadge"); + innerModel.setDescription("innerDesc"); + Map map = new HashMap<>(); + map.put("key", innerModel); + List array = Arrays.asList(innerModel); + Resource resource = new Resource("Madge"); + resource.setArray(array); + resource.setMap(map); + resource.setDescription("desc"); + resource.setIntValue(1); + resource.setFloatValue(1.1); + resource.setInnerModel(innerModel); + resource.setIntArray(Arrays.asList(1, 2, 3)); + return resource; + } + + private static ResourcePatch buildResourcePatchWithNullProperties() { + ResourcePatch resourcePatch = new ResourcePatch(); + resourcePatch.setDescription(null); + resourcePatch.setMap(new HashMap<>()); + resourcePatch.getMap().put("key", new InnerModel().setDescription(null)); + resourcePatch.getMap().put("key2", null); + resourcePatch.setArray(null); + resourcePatch.setInnerModel(null); + resourcePatch.setIntValue(null); + resourcePatch.setFloatValue(null); + resourcePatch.setInnerModel(null); + resourcePatch.setIntArray(null); + return resourcePatch; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/payload/mediatype/MediaTypeTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/payload/mediatype/MediaTypeTests.java new file mode 100644 index 0000000000..3a964f758d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/payload/mediatype/MediaTypeTests.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package payload.mediatype; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +public class MediaTypeTests { + + private final MediaTypeClient client = new MediaTypeClientBuilder().buildMediaTypeClient(); + + @Test + @Disabled("java.lang.UnsupportedOperationException: None of the provided serializers support the format: TEXT..") + public void test() { + client.sendAsJson(client.getAsJson()); + + String text = client.getAsText(); + Assertions.assertEquals("{cat}", text); + client.sendAsText(text); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/payload/multipart/MultipartTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/payload/multipart/MultipartTests.java new file mode 100644 index 0000000000..35071c479d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/payload/multipart/MultipartTests.java @@ -0,0 +1,258 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package payload.multipart; + +import io.clientcore.core.http.models.HttpRequest; +import io.clientcore.core.http.models.Response; +import io.clientcore.core.http.pipeline.HttpPipelineNextPolicy; +import io.clientcore.core.http.pipeline.HttpPipelinePolicy; +import io.clientcore.core.util.binarydata.BinaryData; +import java.nio.charset.StandardCharsets; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.utils.FileUtils; +import payload.multipart.formdata.httpparts.nonstring.FloatRequest; + +public class MultipartTests { + + private final MultipartFilenameValidationPolicy validationPolicy = new MultipartFilenameValidationPolicy(); + + private final FormDataClient client + = new MultiPartClientBuilder().addHttpPipelinePolicy(validationPolicy).buildFormDataClient(); + + private final FormDataHttpPartsContentTypeClient httpPartContentTypeClient + = new MultiPartClientBuilder().addHttpPipelinePolicy(validationPolicy) + .buildFormDataHttpPartsContentTypeClient(); + + private static final Path FILE = FileUtils.getJpgFile(); + + private static final Path PNG_FILE = FileUtils.getPngFile(); + + private static final String FILENAME = "image"; + private static final String FILE_CONTENT_TYPE = "application/octet-stream"; + + private final static class KpmAlgorithm { + private static int indexOf(byte[] data, int start, int stop, byte[] pattern) { + if (data == null || pattern == null) + return -1; + + int[] failure = computeFailure(pattern); + + int j = 0; + + for (int i = start; i < stop; i++) { + while (j > 0 && (pattern[j] != '*' && pattern[j] != data[i])) { + j = failure[j - 1]; + } + if (pattern[j] == '*' || pattern[j] == data[i]) { + j++; + } + if (j == pattern.length) { + return i - pattern.length + 1; + } + } + return -1; + } + + private static int[] computeFailure(byte[] pattern) { + int[] failure = new int[pattern.length]; + + int j = 0; + for (int i = 1; i < pattern.length; i++) { + while (j > 0 && pattern[j] != pattern[i]) { + j = failure[j - 1]; + } + if (pattern[j] == pattern[i]) { + j++; + } + failure[i] = j; + } + + return failure; + } + } + + private final static class MultipartFilenameValidationPolicy implements HttpPipelinePolicy { + private final List filenames = new ArrayList<>(); + private final List contentTypes = new ArrayList<>(); + + private final static Pattern FILENAME_PATTERN = Pattern.compile("filename=\"(.*?)\""); + private final static Pattern CONTENT_TYPE_PATTERN = Pattern.compile("Content-Type:\\s*(.*)"); + + @Override + public Response process(HttpRequest request, HttpPipelineNextPolicy nextPolicy) { + filenames.clear(); + byte[] body = request.getBody().toBytes(); + int start = 0; + int stop = body.length; + byte[] pattern = "Content-Disposition:".getBytes(StandardCharsets.UTF_8); + + int index; + while ((index = KpmAlgorithm.indexOf(body, start, stop, pattern)) >= 0) { + int posNewLine; + for (posNewLine = index; posNewLine < stop; ++posNewLine) { + if (body[posNewLine] == 10 || body[posNewLine] == 13) { + // newline + String line = new String(body, index, posNewLine - index, StandardCharsets.UTF_8); + Matcher matcher = FILENAME_PATTERN.matcher(line); + if (matcher.find()) { + filenames.add(matcher.group(1)); + } + break; + } + } + start = posNewLine + 1; + } + + start = 0; + byte[] contentTypePattern = "Content-Type:".getBytes(StandardCharsets.UTF_8); + + while ((index = KpmAlgorithm.indexOf(body, start, stop, contentTypePattern)) >= 0) { + int posNewLine; + for (posNewLine = index; posNewLine < stop; ++posNewLine) { + if (body[posNewLine] == 10 || body[posNewLine] == 13) { + // newline + String line = new String(body, index, posNewLine - index, StandardCharsets.UTF_8); + Matcher matcher = CONTENT_TYPE_PATTERN.matcher(line); + if (matcher.find()) { + contentTypes.add(matcher.group(1)); + } + break; + } + } + start = posNewLine + 1; + } + + // reset the body to compensate here consuming all the data + request.setBody(BinaryData.fromBytes(body)); + return nextPolicy.process(); + } + + private void validateFilenames(String... filenames) { + Assertions.assertEquals(Arrays.asList(filenames), this.filenames); + } + + private void validateContentTypes(String... contentTypes) { + Assertions.assertEquals(Arrays.asList(contentTypes), this.contentTypes); + } + } + + @Test + public void testBasic() { + MultiPartRequest request = new MultiPartRequest("123", + new ProfileImageFileDetails(BinaryData.fromFile(FILE)).setFilename("image.jpg")); + + client.basic(request); + } + + @Test + public void testJson() { + client.jsonPart(new JsonPartRequest(new Address("X"), + new ProfileImageFileDetails(BinaryData.fromFile(FILE)).setFilename("image.jpg"))); + } + + // JSON array removed from cadl-ranch +// @Test +// public void testJsonArray() { +// client.jsonArrayParts(new JsonArrayPartsRequest( +// new ProfileImageFileDetails(BinaryData.fromFile(FILE)).setFilename("image.jpg"), +// Arrays.asList(new Address("Y"), new Address("Z")))); +// } + + @Test + public void testMultipleFiles() { + client.multiBinaryParts( + new MultiBinaryPartsRequest(new ProfileImageFileDetails(BinaryData.fromFile(FILE)).setFilename("image.jpg")) + .setPicture( + new PictureFileDetails(BinaryData.fromFile(FileUtils.getPngFile())).setFilename("image.png"))); + + validationPolicy.validateFilenames("image.jpg", "image.png"); + + // "picture" be optional + client.multiBinaryParts(new MultiBinaryPartsRequest( + new ProfileImageFileDetails(BinaryData.fromFile(FILE)).setFilename("image.jpg"))); + } + + @Test + public void testFileArray() { + client.binaryArrayParts(new BinaryArrayPartsRequest("123", + Arrays.asList(new PicturesFileDetails(BinaryData.fromFile(PNG_FILE)).setFilename("image1.png"), + new PicturesFileDetails(BinaryData.fromFile(PNG_FILE)).setFilename("image2.png")))); + + validationPolicy.validateContentTypes("application/octet-stream", "application/octet-stream"); + + // filename contains non-ASCII + client.binaryArrayParts(new BinaryArrayPartsRequest("123", + Arrays.asList(new PicturesFileDetails(BinaryData.fromFile(PNG_FILE)).setFilename("voilà.png"), + new PicturesFileDetails(BinaryData.fromFile(PNG_FILE)).setFilename("ima\"\n\rge2.png")))); + + validationPolicy.validateFilenames("voilà.png", "ima%22%0A%0Dge2.png"); + } + + @Test + public void testFilenameAndContentType() { + client.checkFileNameAndContentType( + new MultiPartRequest("123", new ProfileImageFileDetails(BinaryData.fromFile(FILE)).setFilename("hello.jpg") + .setContentType("image/jpg"))); + } + + @Test + public void testComplex() { + client.fileArrayAndBasic(new ComplexPartsRequest("123", new Address("X"), + new ProfileImageFileDetails(BinaryData.fromFile(FILE)).setFilename("image.jpg"), + Arrays.asList(new PicturesFileDetails(BinaryData.fromFile(PNG_FILE)).setFilename("image1.png"), + new PicturesFileDetails(BinaryData.fromFile(PNG_FILE)).setFilename("image2.png")))); + + validationPolicy.validateFilenames("image.jpg", "image1.png", "image2.png"); + } + + @Test + public void testAnonymousModel() { + client.anonymousModel(new ProfileImageFileDetails(BinaryData.fromFile(FILE)).setFilename("image.jpg")); + } + + @Test + public void testFileWithHttpPartSpecificContentType() { + httpPartContentTypeClient.imageJpegContentType(new FileWithHttpPartSpecificContentTypeRequest( + new FileSpecificContentType(BinaryData.fromFile(FILE), "hello.jpg"))); + } + + @Test + public void testFileWithHttpPartRequiredContentType() { + httpPartContentTypeClient.requiredContentType(new FileWithHttpPartRequiredContentTypeRequest( + new FileRequiredMetaData(BinaryData.fromFile(FILE), FILENAME, "application/octet-stream"))); + } + + @Test + public void testFileWithHttpPartOptionalContentType() { + httpPartContentTypeClient.optionalContentType(new FileWithHttpPartOptionalContentTypeRequest( + new FileOptionalContentType(BinaryData.fromFile(FILE), FILENAME).setContentType(FILE_CONTENT_TYPE))); + } + + @Test + public void testComplexWithHttpPart() { + FormDataHttpPartsClient client + = new MultiPartClientBuilder().addHttpPipelinePolicy(validationPolicy).buildFormDataHttpPartsClient(); + + client.jsonArrayAndFileArray(new ComplexHttpPartsModelRequest("123", new Address("X"), + new FileRequiredMetaData(BinaryData.fromFile(FILE), FILENAME, FILE_CONTENT_TYPE), + List.of(new Address("Y"), new Address("Z")), + List.of(new FileRequiredMetaData(BinaryData.fromFile(PNG_FILE), FILENAME + "1", FILE_CONTENT_TYPE), + new FileRequiredMetaData(BinaryData.fromFile(PNG_FILE), FILENAME + "2", FILE_CONTENT_TYPE)))); + } + + @Test + public void testNonStringHttpPart() { + FormDataHttpPartsNonStringClient client = new MultiPartClientBuilder().addHttpPipelinePolicy(validationPolicy) + .buildFormDataHttpPartsNonStringClient(); + + client.floatMethod(new FloatRequest(0.5)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/routes/RouteTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/routes/RouteTests.java new file mode 100644 index 0000000000..8571eccbbe --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/routes/RouteTests.java @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package routes; + +import io.clientcore.core.http.models.HttpLogOptions; +import java.util.List; +import java.util.Set; +import org.junit.jupiter.api.Test; + +public class RouteTests { + + @Test + public void testFixed() { + new RoutesClientBuilder().buildClient().fixed(); + + new RoutesClientBuilder().buildInInterfaceClient().fixed(); + } + + @Test + public void testPath() { + var client = new RoutesClientBuilder().buildPathParametersClient(); + + client.templateOnly("a"); + + client.explicit("a"); + + client.annotationOnly("a"); + } + + @Test + public void testPathReservedExpansion() { + var client = new RoutesClientBuilder().buildPathParametersReservedExpansionClient(); + + // TODO, need enhancement in core or codegen + client.template("foo/bar baz".replace(" ", "%20")); + client.annotation("foo/bar baz".replace(" ", "%20")); + } + + @Test + public void testQuery() { + var client = new RoutesClientBuilder().buildQueryParametersClient(); + + client.templateOnly("a"); + + client.explicit("a"); + + client.annotationOnly("a"); + } + + @Test + public void testQueryExpansionStandard() { + var client = new RoutesClientBuilder().buildQueryParametersQueryExpansionStandardClient(); + + client.primitive("a"); + + client.array(List.of("a", "b")); + } + + @Test + public void testQueryExpansionContinuationStandard() { + var client = new RoutesClientBuilder().buildQueryParametersQueryContinuationStandardClient(); + + client.primitive("a"); + + client.array(List.of("a", "b")); + } + + @Test + public void testQueryExpansionExplode() { + var client = new RoutesClientBuilder().buildQueryParametersQueryExpansionExplodeClient(); + + client.primitive("a"); + + client.array(List.of("a", "b")); + } + + @Test + public void buildQueryParametersQueryContinuationExplode() { + var client = new RoutesClientBuilder() + .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogOptions.HttpLogDetailLevel.BODY_AND_HEADERS) + .setAllowedQueryParamNames(Set.of("fixed", "param"))) + .buildQueryParametersQueryContinuationExplodeClient(); + + client.primitive("a"); + + client.array(List.of("a", "b")); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/serialization/encodedname/json/JsonTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/serialization/encodedname/json/JsonTests.java new file mode 100644 index 0000000000..9b72748fee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/serialization/encodedname/json/JsonTests.java @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package serialization.encodedname.json; + +import org.junit.jupiter.api.Test; + +public class JsonTests { + + private final JsonClient client = new JsonClientBuilder().buildJsonClient(); + + @Test + public void testJson() { + client.send(client.get()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/server/endpoint/notdefined/EndpointTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/server/endpoint/notdefined/EndpointTests.java new file mode 100644 index 0000000000..8b1025d3cb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/server/endpoint/notdefined/EndpointTests.java @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package server.endpoint.notdefined; + +import org.junit.jupiter.api.Test; + +public class EndpointTests { + + @Test + public void testEndpoint() { + new NotDefinedClientBuilder().endpoint("http://localhost:3000").buildClient().valid(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/ModelClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/ModelClientTest.java new file mode 100644 index 0000000000..098e755720 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/ModelClientTest.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package specialwords; + +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Collections; +import org.junit.jupiter.api.Test; + +public class ModelClientTest { + + private final ModelsClient client = new SpecialWordsClientBuilder().buildModelsClient(); + + @Test + public void test() throws Exception { + ReflectHelper.invokeWithResponseMethods(client.getClass(), client, + BinaryData.fromObject(Collections.singletonMap("name", "ok"))); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/ModelPropertyClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/ModelPropertyClientTest.java new file mode 100644 index 0000000000..6fbc7ab3d0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/ModelPropertyClientTest.java @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package specialwords; + +import org.junit.jupiter.api.Test; +import specialwords.modelproperties.SameAsModel; + +public class ModelPropertyClientTest { + + private final ModelPropertiesClient client = new SpecialWordsClientBuilder().buildModelPropertiesClient(); + + @Test + public void test() { + client.sameAsModel(new SameAsModel("ok")); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/OperationClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/OperationClientTest.java new file mode 100644 index 0000000000..b86235c8ae --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/OperationClientTest.java @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package specialwords; + +import org.junit.jupiter.api.Test; + +public class OperationClientTest { + + private final OperationsClient client = new SpecialWordsClientBuilder().buildOperationsClient(); + + @Test + public void test() throws Exception { + ReflectHelper.invokeWithResponseMethods(client.getClass(), client); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/ParameterClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/ParameterClientTest.java new file mode 100644 index 0000000000..dbb96b19ab --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/ParameterClientTest.java @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package specialwords; + +import org.junit.jupiter.api.Test; + +public class ParameterClientTest { + + private final ParametersClient client = new SpecialWordsClientBuilder().buildParametersClient(); + + @Test + public void test() throws Exception { + ReflectHelper.invokeWithResponseMethods(client.getClass(), client, "ok"); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/ReflectHelper.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/ReflectHelper.java new file mode 100644 index 0000000000..f4145c3299 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/specialwords/ReflectHelper.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package specialwords; + +import io.clientcore.core.http.models.RequestOptions; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.stream.Stream; + +// use reflection to call mock server, as special-words test is about compiler, not runtime +class ReflectHelper { + + public static void invokeWithResponseMethods(Class clazz, Object client, Object... parameters) + throws InvocationTargetException, IllegalAccessException { + for (Method m : clazz.getDeclaredMethods()) { + if (m.getName().endsWith("WithResponse")) { + Object[] args + = Stream.concat(Arrays.stream(parameters), Stream.of((RequestOptions) null)).toArray(Object[]::new); + m.invoke(client, args); + } + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/BooleanValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/BooleanValueClientTest.java new file mode 100644 index 0000000000..0e24fb51bb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/BooleanValueClientTest.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.array; + +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class BooleanValueClientTest { + + BooleanValueClient client = new ArrayClientBuilder().buildBooleanValueClient(); + + @Test + void get() { + List response = client.get(); + Assertions.assertEquals(2, response.size()); + Assertions.assertEquals(true, response.get(0)); + Assertions.assertEquals(false, response.get(1)); + } + + @Test + void put() { + List body = Arrays.asList(true, false); + client.put(body); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/DatetimeValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/DatetimeValueClientTest.java new file mode 100644 index 0000000000..c8035e5f3f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/DatetimeValueClientTest.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.array; + +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +class DatetimeValueClientTest { + + DatetimeValueClient client = new ArrayClientBuilder().buildDatetimeValueClient(); + + @Test + void get() { + List response = client.get(); + Assertions.assertEquals(1, response.size()); + Assertions.assertEquals("2022-08-26T18:38:00Z", response.get(0)); + } + + @Test + @Disabled("Body provided doesn't match expected body,\"expected\":[\"2022-08-26T18:38:00Z\"],\"actual\":[\"2022-08-26T18:38Z\"]") + void put() { + List body = Arrays.asList(OffsetDateTime.parse("2022-08-26T18:38:00Z")); + client.put(body); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/DurationValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/DurationValueClientTest.java new file mode 100644 index 0000000000..e2690992e1 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/DurationValueClientTest.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.array; + +import java.time.Duration; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +class DurationValueClientTest { + + DurationValueClient client = new ArrayClientBuilder().buildDurationValueClient(); + + @Test + void get() { + List response = client.get(); + Assertions.assertEquals(1, response.size()); + Assertions.assertEquals("P123DT22H14M12.011S", response.get(0)); + } + + @Test + @Disabled("Body provided doesn't match expected body,\"expected\":[\"P123DT22H14M12.011S\"],\"actual\":[\"PT2974H14M12.011S\"]") + void put() { + Duration duration = Duration.parse("P123DT22H14M12.011S"); + client.put(Arrays.asList(duration)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/Float32ValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/Float32ValueClientTest.java new file mode 100644 index 0000000000..ca526e17bf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/Float32ValueClientTest.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.array; + +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class Float32ValueClientTest { + + Float32ValueClient client = new ArrayClientBuilder().buildFloat32ValueClient(); + + @Test + void get() { + List response = client.get(); + Assertions.assertEquals(1, response.size()); + Assertions.assertEquals(43.125, response.get(0)); + } + + @Test + void put() { + client.put(Arrays.asList(43.125)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/Int32ValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/Int32ValueClientTest.java new file mode 100644 index 0000000000..1f12586a50 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/Int32ValueClientTest.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.array; + +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class Int32ValueClientTest { + + Int32ValueClient client = new ArrayClientBuilder().buildInt32ValueClient(); + + @Test + void get() { + List response = client.get(); + Assertions.assertEquals(2, response.size()); + Assertions.assertEquals(1, response.get(0)); + Assertions.assertEquals(2, response.get(1)); + + } + + @Test + void put() { + client.put(Arrays.asList(1, 2)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/Int64ValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/Int64ValueClientTest.java new file mode 100644 index 0000000000..9ff408f452 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/Int64ValueClientTest.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.array; + +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class Int64ValueClientTest { + + Int64ValueClient client = new ArrayClientBuilder().buildInt64ValueClient(); + + @Test + void get() { + List response = client.get(); + Assertions.assertEquals(2, response.size()); + Assertions.assertEquals(9007199254740991L, response.get(0)); + Assertions.assertEquals(-9007199254740991L, response.get(1)); + } + + @Test + void put() { + client.put(Arrays.asList(9007199254740991L, -9007199254740991L)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/ModelValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/ModelValueClientTest.java new file mode 100644 index 0000000000..9fd0cc9987 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/ModelValueClientTest.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.array; + +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +class ModelValueClientTest { + + ModelValueClient client = new ArrayClientBuilder().buildModelValueClient(); + + @Test + @Disabled("java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class type.array.InnerModel") + void get() { + List response = client.get(); + Assertions.assertEquals(2, response.size()); + Assertions.assertEquals("hello", response.get(0).getProperty()); + Assertions.assertEquals("world", response.get(1).getProperty()); + } + + @Test + void put() { + InnerModel model1 = new InnerModel("hello"); + InnerModel model2 = new InnerModel("world"); + client.put(Arrays.asList(model1, model2)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableBooleanValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableBooleanValueClientTest.java new file mode 100644 index 0000000000..c1ce9541c4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableBooleanValueClientTest.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.array; + +import static org.junit.jupiter.api.Assertions.assertIterableEquals; + +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Test; + +public class NullableBooleanValueClientTest { + + private final NullableBooleanValueClient client = new ArrayClientBuilder().buildNullableBooleanValueClient(); + + @Test + public void get() { + List response = client.get(); + assertIterableEquals(Arrays.asList(true, null, false), response); + } + + @Test + public void put() { + List body = Arrays.asList(true, null, false); + client.put(body); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableFloatValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableFloatValueClientTest.java new file mode 100644 index 0000000000..3d155d5a71 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableFloatValueClientTest.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.array; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Test; + +class NullableFloatValueClientTest { + + NullableFloatValueClient client = new ArrayClientBuilder().buildNullableFloatValueClient(); + + @Test + void get() { + List response = client.get(); + assertEquals(Arrays.asList(1.25, null, 3), response); + } + + @Test + void put() { + List body = Arrays.asList(1.25, null, 3.0); + client.put(body); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableInt32ValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableInt32ValueClientTest.java new file mode 100644 index 0000000000..9368ea2db3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableInt32ValueClientTest.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.array; + +import static org.junit.jupiter.api.Assertions.assertIterableEquals; + +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Test; + +public class NullableInt32ValueClientTest { + + private final NullableInt32ValueClient client = new ArrayClientBuilder().buildNullableInt32ValueClient(); + + @Test + public void get() { + List response = client.get(); + assertIterableEquals(Arrays.asList(1, null, 3), response); + } + + @Test + public void put() { + List body = Arrays.asList(1, null, 3); + client.put(body); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableModelValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableModelValueClientTest.java new file mode 100644 index 0000000000..3b78e6e8df --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableModelValueClientTest.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.array; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +public class NullableModelValueClientTest { + + private final NullableModelValueClient client = new ArrayClientBuilder().buildNullableModelValueClient(); + + @Test + @Disabled("java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class type.array.InnerModel") + public void get() { + List response = client.get(); + assertEquals(3, response.size()); + assertEquals("hello", response.get(0).getProperty()); + Assertions.assertNull(response.get(1)); + assertEquals("world", response.get(2).getProperty()); + } + + @Test + public void put() { + List body = Arrays.asList(new InnerModel("hello"), null, new InnerModel("world")); + client.put(body); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableStringValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableStringValueClientTest.java new file mode 100644 index 0000000000..fb7a139687 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/NullableStringValueClientTest.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.array; + +import static org.junit.jupiter.api.Assertions.assertIterableEquals; + +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Test; + +public class NullableStringValueClientTest { + + private final NullableStringValueClient client = new ArrayClientBuilder().buildNullableStringValueClient(); + + @Test + public void get() { + List response = client.get(); + assertIterableEquals(Arrays.asList("hello", null, "world"), response); + } + + @Test + public void put() { + List body = Arrays.asList("hello", null, "world"); + client.put(body); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/StringValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/StringValueClientTest.java new file mode 100644 index 0000000000..0dd68797d2 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/StringValueClientTest.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.array; + +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class StringValueClientTest { + + StringValueClient client = new ArrayClientBuilder().buildStringValueClient(); + + @Test + void get() { + List response = client.get(); + Assertions.assertEquals(2, response.size()); + Assertions.assertEquals("hello", response.get(0)); + Assertions.assertEquals("", response.get(1)); + } + + @Test + void put() { + client.put(Arrays.asList("hello", "")); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/UnknownValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/UnknownValueClientTest.java new file mode 100644 index 0000000000..f556aff68b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/UnknownValueClientTest.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.array; + +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class UnknownValueClientTest { + + private final UnknownValueClient client = new ArrayClientBuilder().buildUnknownValueClient(); + + // BinaryData case, when use-object-for-unknown=false +// @Disabled("TODO https://github.com/Azure/autorest.java/issues/2964") +// @Test +// public void get() { +// List response = client.get(); +// Assertions.assertEquals(3, response.size()); +// Assertions.assertEquals(1, response.get(0).toObject(Integer.class)); +// Assertions.assertEquals("hello", response.get(1).toObject(String.class)); +// Assertions.assertEquals(null, response.get(2)); +// } +// +// @Test +// public void put() { +// client.put(Arrays.asList( +// BinaryData.fromObject(1), +// BinaryData.fromObject("hello"), null)); +// } + + @Test + public void get() { + List response = client.get(); + Assertions.assertEquals(3, response.size()); + Assertions.assertEquals(1, response.get(0)); + Assertions.assertEquals("hello", response.get(1)); + Assertions.assertEquals(null, response.get(2)); + } + + @Test + public void put() { + client.put(Arrays.asList(1, "hello", null)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/BooleanValueTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/BooleanValueTests.java new file mode 100644 index 0000000000..bc024b7b83 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/BooleanValueTests.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.dictionary; + +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class BooleanValueTests { + + private final BooleanValueClient client = new DictionaryClientBuilder().buildBooleanValueClient(); + private final Map expected = new HashMap<>(); + { + expected.put("k1", true); + expected.put("k2", false); + } + + @Test + public void testBooleanGet() { + Map response = client.get(); + Assertions.assertEquals(expected, response); + } + + @Test + public void testBooleanPut() { + client.put(expected); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/DatetimeValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/DatetimeValueClientTest.java new file mode 100644 index 0000000000..345eff0a90 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/DatetimeValueClientTest.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.dictionary; + +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +class DatetimeValueClientTest { + + DatetimeValueClient client = new DictionaryClientBuilder().buildDatetimeValueClient(); + + @Test + void get() { + Map response = client.get(); + Assertions.assertTrue(response.containsKey("k1")); + Assertions.assertEquals("2022-08-26T18:38:00Z", response.get("k1")); + } + + @Test + @Disabled("Body provided doesn't match expected body,\"expected\":{\"k1\":\"2022-08-26T18:38:00Z\"},\"actual\":{\"k1\":\"2022-08-26T18:38Z\"}") + void put() { + Map map = new HashMap<>(); + map.put("k1", OffsetDateTime.parse("2022-08-26T18:38Z")); + client.put(map); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/DurationValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/DurationValueClientTest.java new file mode 100644 index 0000000000..aafea29f1e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/DurationValueClientTest.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.dictionary; + +import java.time.Duration; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +class DurationValueClientTest { + + DurationValueClient client = new DictionaryClientBuilder().buildDurationValueClient(); + + @Test + void get() { + Map response = client.get(); + Assertions.assertTrue(response.containsKey("k1")); + Assertions.assertEquals("P123DT22H14M12.011S", response.get("k1")); + } + + @Test + @Disabled("Body provided doesn't match expected body, \"expected\":{\"k1\":\"P123DT22H14M12.011S\"},\"actual\":{\"k1\":\"PT2974H14M12.011S\"}") + void put() { + Map map = new HashMap<>(); + map.put("k1", Duration.parse("P123DT22H14M12.011S")); + client.put(map); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/Float32ValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/Float32ValueClientTest.java new file mode 100644 index 0000000000..8dd069f551 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/Float32ValueClientTest.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.dictionary; + +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class Float32ValueClientTest { + + Float32ValueClient client = new DictionaryClientBuilder().buildFloat32ValueClient(); + + @Test + void get() { + Map response = client.get(); + Assertions.assertTrue(response.containsKey("k1")); + Assertions.assertEquals(43.125, response.get("k1")); + } + + @Test + void put() { + Map map = new HashMap<>(); + map.put("k1", 43.125); + client.put(map); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/Int32ValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/Int32ValueClientTest.java new file mode 100644 index 0000000000..6e000c4f10 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/Int32ValueClientTest.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.dictionary; + +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class Int32ValueClientTest { + + Int32ValueClient client = new DictionaryClientBuilder().buildInt32ValueClient(); + + @Test + void get() { + Map response = client.get(); + Assertions.assertTrue(response.containsKey("k1")); + Assertions.assertEquals(1, response.get("k1")); + Assertions.assertTrue(response.containsKey("k2")); + Assertions.assertEquals(2, response.get("k2")); + } + + @Test + void put() { + Map map = new HashMap<>(); + map.put("k1", 1); + map.put("k2", 2); + client.put(map); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/Int64ValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/Int64ValueClientTest.java new file mode 100644 index 0000000000..dc1281daff --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/Int64ValueClientTest.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.dictionary; + +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class Int64ValueClientTest { + + Int64ValueClient client = new DictionaryClientBuilder().buildInt64ValueClient(); + + @Test + void get() { + Map response = client.get(); + Assertions.assertTrue(response.containsKey("k1")); + Assertions.assertEquals(9007199254740991L, response.get("k1")); + Assertions.assertTrue(response.containsKey("k2")); + Assertions.assertEquals(-9007199254740991L, response.get("k2")); + } + + @Test + void put() { + Map map = new HashMap<>(); + map.put("k1", 9007199254740991L); + map.put("k2", -9007199254740991L); + client.put(map); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/ModelValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/ModelValueClientTest.java new file mode 100644 index 0000000000..3c02a7a620 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/ModelValueClientTest.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.dictionary; + +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +class ModelValueClientTest { + + ModelValueClient client = new DictionaryClientBuilder().buildModelValueClient(); + + @Test + @Disabled("java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class type.dictionary.InnerModel") + void get() { + Map response = client.get(); + Assertions.assertTrue(response.containsKey("k1")); + InnerModel innerModel1 = response.get("k1"); + Assertions.assertEquals("hello", innerModel1.getProperty()); + Assertions.assertEquals(null, innerModel1.getChildren()); + + Assertions.assertTrue(response.containsKey("k2")); + InnerModel innerModel2 = response.get("k2"); + Assertions.assertEquals(null, innerModel2.getChildren()); + + } + + @Test + void put() { + Map map = new HashMap<>(); + InnerModel innerModel1 = new InnerModel("hello"); + map.put("k1", innerModel1); + InnerModel innerModel2 = new InnerModel("world"); + map.put("k2", innerModel2); + client.put(map); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/NullableFloatValueClientTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/NullableFloatValueClientTests.java new file mode 100644 index 0000000000..aa9d5a38c8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/NullableFloatValueClientTests.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.dictionary; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +public class NullableFloatValueClientTests { + + private final static ObjectMapper MAPPER = new ObjectMapper(); + + private final NullableFloatValueClient client = new DictionaryClientBuilder().buildNullableFloatValueClient(); + + @Test + public void get() { + + Map result = client.get(); + + Assertions.assertTrue(result.containsKey("k3")); + Assertions.assertNull(result.get("k3")); + } + + @Test + @Disabled("Cannot parse null string") + public void put() throws Exception { + MapModel model = new MapModel(); + model.map = new HashMap<>(); + model.map.put("k1", 1.25); + model.map.put("k2", 0.5); + model.map.put("k3", null); + + // Map as request does not work + // Model contains Map works, if "@JsonInclude(value = JsonInclude.Include.NON_NULL)" on that Map + // see tsp/builtin.tsp and its generated code + BinaryData requestAsModel = BinaryData.fromObject(model); + JsonNode node = MAPPER.readTree(requestAsModel.toString()).get("map"); + BinaryData request = BinaryData.fromObject(node); + + client.putWithResponse(request, null); + } + + public static class MapModel { + @JsonInclude(value = JsonInclude.Include.NON_NULL, content = JsonInclude.Include.ALWAYS) + Map map; + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/RecursiveModelValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/RecursiveModelValueClientTest.java new file mode 100644 index 0000000000..37929d572a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/RecursiveModelValueClientTest.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.dictionary; + +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +class RecursiveModelValueClientTest { + + RecursiveModelValueClient client = new DictionaryClientBuilder().buildRecursiveModelValueClient(); + + @Test + @Disabled("java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class type.dictionary.InnerModel") + void get() { + Map response = client.get(); + Assertions.assertTrue(response.containsKey("k1")); + InnerModel innerModel1 = response.get("k1"); + Assertions.assertEquals("hello", innerModel1.getProperty()); + Assertions.assertEquals(new HashMap<>(), innerModel1.getChildren()); + + Assertions.assertTrue(response.containsKey("k2")); + InnerModel innerModel2 = response.get("k2"); + Assertions.assertEquals("world", innerModel2.getProperty()); + Assertions.assertEquals("inner world", innerModel2.getChildren().get("k2.1").getProperty()); + } + + @Test + void put() { + Map map = new HashMap<>(); + InnerModel innerModel1 = new InnerModel("hello"); + innerModel1.setChildren(new HashMap<>()); + map.put("k1", innerModel1); + InnerModel innerModel2 = new InnerModel("world"); + Map children = new HashMap<>(); + children.put("k2.1", new InnerModel("inner world")); + innerModel2.setChildren(children); + map.put("k2", innerModel2); + client.put(map); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/StringValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/StringValueClientTest.java new file mode 100644 index 0000000000..6462c1d0a3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/StringValueClientTest.java @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.dictionary; + +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class StringValueClientTest { + + StringValueClient client = new DictionaryClientBuilder().buildStringValueClient(); + + @Test + void get() { + Map response = client.get(); + Assertions.assertEquals("hello", response.get("k1")); + Assertions.assertEquals("", response.get("k2")); + } + + @Test + void put() { + Map map = new HashMap<>(); + map.put("k1", "hello"); + map.put("k2", ""); + client.put(map); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/UnknownValueClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/UnknownValueClientTest.java new file mode 100644 index 0000000000..e611207540 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/dictionary/UnknownValueClientTest.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.dictionary; + +import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.NullNode; +import com.fasterxml.jackson.databind.node.ObjectNode; +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +public class UnknownValueClientTest { + + public final UnknownValueClient client = new DictionaryClientBuilder().buildUnknownValueClient(); + + // BinaryData case, when use-object-for-unknown=false +// @Disabled("TODO https://github.com/Azure/autorest.java/issues/2964") +// @Test +// public void get() { +// Map response = client.get(); +// Assertions.assertEquals(1, response.get("k1").toObject(Integer.class)); +// Assertions.assertEquals("hello", response.get("k2").toObject(String.class)); +// Assertions.assertEquals(null, response.get("k3")); +// } +// +// @Test +// public void putWithResponse() { +// ObjectNode map = JsonNodeFactory.instance.objectNode(); +// map.put("k1", 1); +// map.put("k2", "hello"); +// map.set("k3", NullNode.instance); +// client.putWithResponse(BinaryData.fromObject(map), null); +// } + + @Test + public void get() { + Map response = client.get(); + Assertions.assertEquals(1, response.get("k1")); + Assertions.assertEquals("hello", response.get("k2")); + Assertions.assertEquals(null, response.get("k3")); + } + + @Test + @Disabled("Body provided doesn't match expected body,\"expected\":{\"k1\":1,\"k2\":\"hello\",\"k3\":null},\"actual\":[[],[],[]]}") + public void putWithResponse() { + ObjectNode map = JsonNodeFactory.instance.objectNode(); + map.put("k1", 1); + map.put("k2", "hello"); + map.set("k3", NullNode.instance); + client.putWithResponse(BinaryData.fromObject(map), null); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/enums/extensible/ExtensibleClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/enums/extensible/ExtensibleClientTest.java new file mode 100644 index 0000000000..e907d73ce0 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/enums/extensible/ExtensibleClientTest.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.enums.extensible; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +class ExtensibleClientTest { + + ExtensibleClient client = new ExtensibleClientBuilder().buildExtensibleClient(); + + @Test + @Disabled("java.lang.ClassCastException: class java.lang.String cannot be cast to class type.enums.extensible.DaysOfWeekExtensibleEnum") + void getKnownValue() { + DaysOfWeekExtensibleEnum daysOfWeekExtensibleEnum = client.getKnownValue(); + Assertions.assertEquals(DaysOfWeekExtensibleEnum.MONDAY, daysOfWeekExtensibleEnum); + } + + @Test + @Disabled("java.lang.ClassCastException: class java.lang.String cannot be cast to class type.enums.extensible.DaysOfWeekExtensibleEnum") + void getUnknownValue() { + DaysOfWeekExtensibleEnum daysOfWeekExtensibleEnum = client.getUnknownValue(); + Assertions.assertEquals("Weekend", daysOfWeekExtensibleEnum.toString()); + } + + @Test + void putKnownValue() { + DaysOfWeekExtensibleEnum daysOfWeekExtensibleEnum = DaysOfWeekExtensibleEnum.MONDAY; + client.putKnownValue(daysOfWeekExtensibleEnum); + } + + @Test + void putUnknownValue() { + DaysOfWeekExtensibleEnum daysOfWeekExtensibleEnum = DaysOfWeekExtensibleEnum.fromValue("Weekend"); + client.putUnknownValue(daysOfWeekExtensibleEnum); + } + +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/enums/fixed/FixedClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/enums/fixed/FixedClientTest.java new file mode 100644 index 0000000000..43d20fcab6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/enums/fixed/FixedClientTest.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.enums.fixed; + +import io.clientcore.core.http.exception.HttpResponseException; +import io.clientcore.core.http.models.HttpRetryOptions; +import io.clientcore.core.util.binarydata.BinaryData; +import java.time.Duration; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +class FixedClientTest { + + FixedClient client + = new FixedClientBuilder().httpRetryOptions(new HttpRetryOptions(0, Duration.ZERO)).buildFixedClient(); + + @Test + @Disabled("java.lang.ClassCastException: class java.lang.String cannot be cast to class type.enums.fixed.DaysOfWeekEnum") + void getKnownValue() { + DaysOfWeekEnum daysOfWeekEnum = client.getKnownValue(); + Assertions.assertEquals(DaysOfWeekEnum.MONDAY, daysOfWeekEnum); + } + + @Test + void putKnownValue() { + client.putKnownValue(DaysOfWeekEnum.MONDAY); + } + + @Test + void putUnknownValue() { + // Not a valid test for Java, as compiler will fail at "DaysOfWeekEnum.WEEKEND" + // client.putUnknownValue(DaysOfWeekEnum.WEEKEND); + + Assertions.assertThrowsExactly(HttpResponseException.class, + () -> client.putUnknownValueWithResponse(BinaryData.fromObject("Weekend"), null)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/empty/EmptyModelTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/empty/EmptyModelTests.java new file mode 100644 index 0000000000..a9b58d8552 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/empty/EmptyModelTests.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.model.empty; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class EmptyModelTests { + + private final EmptyClient client = new EmptyClientBuilder().buildClient(); + + @Test + public void testEmptyModel() { + EmptyOutput output = client.getEmpty(); + Assertions.assertNotNull(output); + + client.putEmpty(new EmptyInput()); + + EmptyInputOutput inputOutput = client.postRoundTripEmpty(new EmptyInputOutput()); + Assertions.assertNotNull(inputOutput); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/EnumDiscriminatorTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/EnumDiscriminatorTests.java new file mode 100644 index 0000000000..b3904b2fee --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/EnumDiscriminatorTests.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.model.inheritance; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import type.model.inheritance.enumdiscriminator.Cobra; +import type.model.inheritance.enumdiscriminator.Dog; +import type.model.inheritance.enumdiscriminator.EnumDiscriminatorClient; +import type.model.inheritance.enumdiscriminator.EnumDiscriminatorClientBuilder; +import type.model.inheritance.enumdiscriminator.Golden; +import type.model.inheritance.enumdiscriminator.Snake; + +public class EnumDiscriminatorTests { + + private final EnumDiscriminatorClient client = new EnumDiscriminatorClientBuilder().buildClient(); + + @Test + public void testEnumDiscriminator() { + Snake fixedModel = client.getFixedModel(); + Assertions.assertEquals(Cobra.class, fixedModel.getClass()); + client.putFixedModel(fixedModel); + + Dog extensibleModel = client.getExtensibleModel(); + Assertions.assertEquals(Golden.class, extensibleModel.getClass()); + client.putExtensibleModel(extensibleModel); + + client.getFixedModelMissingDiscriminator(); + client.getFixedModelWrongDiscriminator(); + + client.getExtensibleModelMissingDiscriminator(); + client.getExtensibleModelWrongDiscriminator(); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/InheritanceTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/InheritanceTests.java new file mode 100644 index 0000000000..68adb4e03c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/InheritanceTests.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.model.inheritance; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import type.model.inheritance.notdiscriminated.NotDiscriminatedClient; +import type.model.inheritance.notdiscriminated.NotDiscriminatedClientBuilder; +import type.model.inheritance.notdiscriminated.Siamese; + +class InheritanceTests { + + NotDiscriminatedClient client = new NotDiscriminatedClientBuilder().buildClient(); + + @Test + void postValid() { + Siamese siamese = new Siamese("abc", 32, true); + client.postValid(siamese); + } + + @Test + void getValid() { + Siamese siamese = client.getValid(); + Assertions.assertEquals(true, siamese.isSmart()); + Assertions.assertEquals(32, siamese.getAge()); + Assertions.assertEquals("abc", siamese.getName()); + } + + @Test + void putValid() { + Siamese siamese = new Siamese("abc", 32, true); + client.putValid(siamese); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/NestedDiscriminatorTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/NestedDiscriminatorTests.java new file mode 100644 index 0000000000..185ff103ef --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/NestedDiscriminatorTests.java @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.model.inheritance; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import type.model.inheritance.nesteddiscriminator.Fish; +import type.model.inheritance.nesteddiscriminator.GoblinShark; +import type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClient; +import type.model.inheritance.nesteddiscriminator.NestedDiscriminatorClientBuilder; +import type.model.inheritance.nesteddiscriminator.Salmon; +import type.model.inheritance.nesteddiscriminator.SawShark; +import type.model.inheritance.nesteddiscriminator.Shark; + +class NestedDiscriminatorTests { + + NestedDiscriminatorClient client = new NestedDiscriminatorClientBuilder().buildClient(); + + @Test + void getModel() { + Fish fish = client.getModel(); + Assertions.assertEquals(1, fish.getAge()); + } + + @Test + void putModel() { + Shark body = new GoblinShark(1); + client.putModel(body); + } + + @Test + void getRecursiveModel() { + Salmon salmon = (Salmon) client.getRecursiveModel(); + Assertions.assertEquals(2, salmon.getFriends().size()); + Assertions.assertEquals(2, salmon.getHate().size()); + Assertions.assertEquals(SawShark.class, salmon.getPartner().getClass()); + Assertions.assertEquals(1, salmon.getAge()); + Assertions.assertEquals(2, (salmon.getPartner()).getAge()); + } + + @Test + void putRecursiveModel() { + Salmon salmon = new Salmon(1); + salmon.setPartner(new SawShark(2)); + + List friends = new ArrayList<>(); + Salmon friend1 = new Salmon(2); + friend1.setPartner(new Salmon(3)); + Map friend1Hate = new LinkedHashMap<>(); + friend1Hate.put("key1", new Salmon(4)); + friend1Hate.put("key2", new GoblinShark(2)); + friend1.setHate(friend1Hate); + friends.add(friend1); + + Shark friend2 = new GoblinShark(3); + friends.add(friend2); + salmon.setFriends(friends); + + Map salmonHate = new LinkedHashMap<>(); + salmonHate.put("key3", new SawShark(3)); + List salmonHateFriends = new ArrayList<>(); + salmonHateFriends.add(new Salmon(1)); + salmonHateFriends.add(new GoblinShark(4)); + salmonHate.put("key4", new Salmon(2).setFriends(salmonHateFriends)); + salmon.setHate(salmonHate); + + client.putRecursiveModel(salmon); + } + + @Test + void getMissingDiscriminator() { + Fish fish = client.getMissingDiscriminator(); + Assertions.assertEquals(1, fish.getAge()); + } + + @Test + void getWrongDiscriminator() { + Fish fish = client.getWrongDiscriminator(); + Assertions.assertEquals(1, fish.getAge()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/RecursiveReferenceTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/RecursiveReferenceTests.java new file mode 100644 index 0000000000..080e517e13 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/RecursiveReferenceTests.java @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.model.inheritance; + +import org.junit.jupiter.api.Test; +import type.model.inheritance.recursive.Extension; +import type.model.inheritance.recursive.RecursiveClient; +import type.model.inheritance.recursive.RecursiveClientBuilder; + +public class RecursiveReferenceTests { + + private final RecursiveClient client = new RecursiveClientBuilder().buildClient(); + + @Test + public void test() { + Extension extension = client.get(); + client.put(extension); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java new file mode 100644 index 0000000000..43453f622a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/inheritance/SingleDiscriminatorTest.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.model.inheritance; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import type.model.inheritance.singlediscriminator.Bird; +import type.model.inheritance.singlediscriminator.Eagle; +import type.model.inheritance.singlediscriminator.Goose; +import type.model.inheritance.singlediscriminator.SeaGull; +import type.model.inheritance.singlediscriminator.SingleDiscriminatorClient; +import type.model.inheritance.singlediscriminator.SingleDiscriminatorClientBuilder; +import type.model.inheritance.singlediscriminator.Sparrow; +import type.model.inheritance.singlediscriminator.TRex; + +public class SingleDiscriminatorTest { + + private final SingleDiscriminatorClient client = new SingleDiscriminatorClientBuilder().buildClient(); + + @Test + public void testSingleDiscriminator() { + Assertions.assertEquals(TRex.class, client.getLegacyModel().getClass()); + + client.getMissingDiscriminator(); + client.getWrongDiscriminator(); + + Bird model = client.getModel(); + Assertions.assertEquals(Sparrow.class, model.getClass()); + client.putModel(model); + + Eagle recursiveModel = (Eagle) client.getRecursiveModel(); + Assertions.assertEquals(Eagle.class, recursiveModel.getClass()); + Assertions.assertEquals(Goose.class, recursiveModel.getPartner().getClass()); + Assertions.assertEquals(SeaGull.class, recursiveModel.getFriends().get(0).getClass()); + Assertions.assertEquals(Sparrow.class, recursiveModel.getHate().get("key3").getClass()); + client.putRecursiveModel(recursiveModel); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/usage/ModelsUsageClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/usage/ModelsUsageClientTest.java new file mode 100644 index 0000000000..73309a089c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/usage/ModelsUsageClientTest.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.model.usage; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class ModelsUsageClientTest { + + UsageClient client = new UsageClientBuilder().buildClient(); + + @Test + void input() { + InputRecord inputRecord = new InputRecord("example-value"); + client.input(inputRecord); + } + + @Test + void output() { + OutputRecord outputRecord = client.output(); + Assertions.assertEquals("example-value", outputRecord.getRequiredProp()); + } + + @Test + void inputAndOutput() { + InputOutputRecord inputOutputRecord = new InputOutputRecord("example-value"); + InputOutputRecord response = client.inputAndOutput(inputOutputRecord); + Assertions.assertEquals("example-value", response.getRequiredProp()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/usage/UsageClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/usage/UsageClientTest.java new file mode 100644 index 0000000000..034fd6eee5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/usage/UsageClientTest.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.model.usage; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class UsageClientTest { + + UsageClient client = new UsageClientBuilder().buildClient(); + + @Test + void input() { + InputRecord inputRecord = new InputRecord("example-value"); + client.input(inputRecord); + } + + @Test + void output() { + OutputRecord outputRecord = client.output(); + Assertions.assertEquals("example-value", outputRecord.getRequiredProp()); + } + + @Test + void inputAndOutput() { + InputOutputRecord inputOutputRecord = new InputOutputRecord("example-value"); + InputOutputRecord response = client.inputAndOutput(inputOutputRecord); + Assertions.assertEquals("example-value", response.getRequiredProp()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/visibility/AutomaticClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/visibility/AutomaticClientTest.java new file mode 100644 index 0000000000..53ae2057d4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/model/visibility/AutomaticClientTest.java @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.model.visibility; + +import io.clientcore.core.http.client.HttpClient; +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +// These cases are using protocol method, we don't support automatic visibility for convenience methods yet, the tests are added for cadl-ranch coverage. +class AutomaticClientTest { + + private final VisibilityClient client + = new VisibilityClientBuilder().httpClient(HttpClient.getNewInstance()).buildClient(); + + @Test + @Disabled("Values not deep equal,\"expected\":123") + void getModel() { + // client.getModelWithResponse(BinaryData.fromString("{\"queryProp\": 123}"), null); + client.getModel(new VisibilityModel(123, null, null, null)); + } + + @Test + @Disabled("io.clientcore.core.http.exception.HttpResponseException: Status code 400, (empty body).") + void headModel() { + // client.headModelWithResponse(BinaryData.fromString("{\"queryProp\": 123}"), null); + client.headModel(new VisibilityModel(123, null, null, null)); + } + + @Test + void putModel() { + // client.putModelWithResponse(BinaryData.fromString("{\"createProp\": [\"foo\",\"bar\"], \"updateProp\": [1, + // 2]}"), null); + client.putModel(new VisibilityModel(null, Arrays.asList("foo", "bar"), Arrays.asList(1, 2), null)); + } + + @Test + void patchModel() { + // client.patchModelWithResponse(BinaryData.fromString("{\"updateProp\": [1, 2]}"), null); + client.patchModel(new VisibilityModel(null, null, Arrays.asList(1, 2), null)); + } + + @Test + void postModel() { + // client.postModelWithResponse(BinaryData.fromString("{\"createProp\": [\"foo\",\"bar\"]}"), null); + client.postModel(new VisibilityModel(null, Arrays.asList("foo", "bar"), null, null)); + } + + @Test + void deleteModel() { + // client.deleteModelWithResponse(BinaryData.fromString("{\"deleteProp\": true}"), null); + client.deleteModel(new VisibilityModel(null, null, null, true)); + } + + @Test + void putReadOnlyModel() { + ReadOnlyModel readOnlyModel = client.putReadOnlyModel(new ReadOnlyModel()); + Assertions.assertIterableEquals(Arrays.asList(1, 2, 3), readOnlyModel.getOptionalNullableIntList()); + Assertions.assertEquals("value1", readOnlyModel.getOptionalStringRecord().get("k1")); + Assertions.assertEquals("value2", readOnlyModel.getOptionalStringRecord().get("k2")); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/ExtendsTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/ExtendsTests.java new file mode 100644 index 0000000000..37890c8e06 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/ExtendsTests.java @@ -0,0 +1,229 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.additionalproperties; + +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.utils.BinaryDataUtils; + +public class ExtendsTests { + private final ExtendsFloatClient extendsFloatClient + = new AdditionalPropertiesClientBuilder().buildExtendsFloatClient(); + private final ExtendsModelArrayClient extendsModelArrayClient + = new AdditionalPropertiesClientBuilder().buildExtendsModelArrayClient(); + private final ExtendsModelClient extendsModelClient + = new AdditionalPropertiesClientBuilder().buildExtendsModelClient(); + private final ExtendsStringClient extendsStringClient + = new AdditionalPropertiesClientBuilder().buildExtendsStringClient(); + private final ExtendsUnknownClient extendsUnknownClient + = new AdditionalPropertiesClientBuilder().buildExtendsUnknownClient(); + private final ExtendsUnknownDerivedClient extendsUnknownDerivedClient + = new AdditionalPropertiesClientBuilder().buildExtendsUnknownDerivedClient(); + private final ExtendsUnknownDiscriminatedClient extendsUnknownDiscriminatedClient + = new AdditionalPropertiesClientBuilder().buildExtendsUnknownDiscriminatedClient(); + private final ExtendsDifferentSpreadStringClient extendsDifferentSpreadStringClient + = new AdditionalPropertiesClientBuilder().buildExtendsDifferentSpreadStringClient(); + private final ExtendsDifferentSpreadFloatClient extendsDifferentSpreadFloatClient + = new AdditionalPropertiesClientBuilder().buildExtendsDifferentSpreadFloatClient(); + private final ExtendsDifferentSpreadModelClient extendsDifferentSpreadModelClient + = new AdditionalPropertiesClientBuilder().buildExtendsDifferentSpreadModelClient(); + private final ExtendsDifferentSpreadModelArrayClient extendsDifferentSpreadModelArrayClient + = new AdditionalPropertiesClientBuilder().buildExtendsDifferentSpreadModelArrayClient(); + + @Test + public void testExtendsFloat() { + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", 43.125); + ExtendsFloatAdditionalProperties body = new ExtendsFloatAdditionalProperties(43.125); + body.setAdditionalProperties(propertyMap); + extendsFloatClient.put(body); + + ExtendsFloatAdditionalProperties properties = extendsFloatClient.get(); + Assertions.assertNotNull(properties); + Assertions.assertNotNull(properties.getAdditionalProperties()); + Assertions.assertEquals(43.125, properties.getId()); + Assertions.assertIterableEquals(propertyMap.entrySet(), properties.getAdditionalProperties().entrySet()); + } + + @Test + public void testExtendsModelArrayClient() { + Map> propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", Arrays.asList(new ModelForRecord("ok"), new ModelForRecord("ok"))); + ExtendsModelArrayAdditionalProperties body = new ExtendsModelArrayAdditionalProperties( + Arrays.asList(new ModelForRecord("ok"), new ModelForRecord("ok"))); + body.setAdditionalProperties(propertyMap); + extendsModelArrayClient.put(body); + + ExtendsModelArrayAdditionalProperties properties = extendsModelArrayClient.get(); + Assertions.assertNotNull(properties); + Assertions.assertNotNull(properties.getKnownProp()); + properties.getKnownProp().forEach(modelForRecord -> Assertions.assertEquals("ok", modelForRecord.getState())); + Assertions.assertNotNull(properties.getAdditionalProperties()); + Assertions.assertNotNull(properties.getAdditionalProperties().get("prop")); + properties.getAdditionalProperties() + .get("prop") + .forEach(modelForRecord -> Assertions.assertEquals("ok", modelForRecord.getState())); + } + + @Test + public void testExtendsModelClient() { + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", new ModelForRecord("ok")); + ExtendsModelAdditionalProperties body = new ExtendsModelAdditionalProperties(new ModelForRecord("ok")); + body.setAdditionalProperties(propertyMap); + extendsModelClient.put(body); + + ExtendsModelAdditionalProperties properties = extendsModelClient.get(); + Assertions.assertNotNull(properties); + Assertions.assertNotNull(properties.getKnownProp()); + Assertions.assertEquals("ok", properties.getKnownProp().getState()); + Assertions.assertNotNull(properties.getAdditionalProperties()); + Assertions.assertNotNull(properties.getAdditionalProperties().get("prop")); + Assertions.assertEquals("ok", properties.getAdditionalProperties().get("prop").getState()); + } + + @Test + public void testExtendsStringClient() { + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", "abc"); + ExtendsStringAdditionalProperties body + = new ExtendsStringAdditionalProperties("ExtendsStringAdditionalProperties"); + body.setAdditionalProperties(propertyMap); + extendsStringClient.put(body); + + ExtendsStringAdditionalProperties properties = extendsStringClient.get(); + Assertions.assertNotNull(properties); + Assertions.assertNotNull(properties.getAdditionalProperties()); + Assertions.assertEquals("ExtendsStringAdditionalProperties", properties.getName()); + Assertions.assertEquals(propertyMap, properties.getAdditionalProperties()); + } + + @Test + public void testExtendsUnknownClient() { + Map additionalProperty = new LinkedHashMap<>(); + additionalProperty.put("prop1", BinaryData.fromObject(32)); + additionalProperty.put("prop2", BinaryData.fromObject(true)); + additionalProperty.put("prop3", BinaryData.fromObject("abc")); + ExtendsUnknownAdditionalProperties body + = new ExtendsUnknownAdditionalProperties("ExtendsUnknownAdditionalProperties"); + body.setAdditionalProperties(additionalProperty); + extendsUnknownClient.put(body); + + ExtendsUnknownAdditionalProperties properties = extendsUnknownClient.get(); + Assertions.assertNotNull(properties); + Assertions.assertNotNull(properties.getAdditionalProperties()); + Assertions.assertEquals("ExtendsUnknownAdditionalProperties", properties.getName()); + BinaryDataUtils.assertMapEquals(additionalProperty, properties.getAdditionalProperties()); + } + + @Test + public void testExtendsUnknownDerivedClient() { + Map additionalProperty = new LinkedHashMap<>(); + additionalProperty.put("prop1", BinaryData.fromObject(32)); + additionalProperty.put("prop2", BinaryData.fromObject(true)); + additionalProperty.put("prop3", BinaryData.fromObject("abc")); + ExtendsUnknownAdditionalPropertiesDerived body + = new ExtendsUnknownAdditionalPropertiesDerived("ExtendsUnknownAdditionalProperties", 314).setAge(2.71875); + body.setAdditionalProperties(additionalProperty); + extendsUnknownDerivedClient.put(body); + + ExtendsUnknownAdditionalPropertiesDerived properties = extendsUnknownDerivedClient.get(); + Assertions.assertNotNull(properties); + Assertions.assertNotNull(properties.getAdditionalProperties()); + Assertions.assertEquals("ExtendsUnknownAdditionalProperties", properties.getName()); + BinaryDataUtils.assertMapEquals(additionalProperty, properties.getAdditionalProperties()); + } + + @Test + public void testExtendsUnknownDiscriminatedClient() { + Map additionalProperty = new LinkedHashMap<>(); + additionalProperty.put("prop1", BinaryData.fromObject(32)); + additionalProperty.put("prop2", BinaryData.fromObject(true)); + additionalProperty.put("prop3", BinaryData.fromObject("abc")); + ExtendsUnknownAdditionalPropertiesDiscriminatedDerived body + = new ExtendsUnknownAdditionalPropertiesDiscriminatedDerived("Derived", 314).setAge(2.71875); + body.setAdditionalProperties(additionalProperty); + extendsUnknownDiscriminatedClient.put(body); + + ExtendsUnknownAdditionalPropertiesDiscriminated properties = extendsUnknownDiscriminatedClient.get(); + Assertions.assertNotNull(properties); + Assertions.assertNotNull(properties.getAdditionalProperties()); + Assertions.assertEquals("Derived", properties.getName()); + BinaryDataUtils.assertMapEquals(additionalProperty, properties.getAdditionalProperties()); + } + + @Test + public void testExtendsDifferentSpreadString() { + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", "abc"); + DifferentSpreadStringDerived body = new DifferentSpreadStringDerived(43.125, "abc"); + body.setAdditionalProperties(propertyMap); + extendsDifferentSpreadStringClient.put(body); + + DifferentSpreadStringDerived record = extendsDifferentSpreadStringClient.get(); + Assertions.assertNotNull(record); + Assertions.assertEquals(43.125, record.getId()); + Assertions.assertEquals("abc", record.getDerivedProp()); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertEquals("abc", record.getAdditionalProperties().get("prop")); + } + + @Test + public void testExtendsDifferentSpreadFloat() { + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", 43.125); + DifferentSpreadFloatDerived body = new DifferentSpreadFloatDerived("abc", 43.125); + body.setAdditionalProperties(propertyMap); + extendsDifferentSpreadFloatClient.put(body); + + DifferentSpreadFloatDerived record = extendsDifferentSpreadFloatClient.get(); + Assertions.assertNotNull(record); + Assertions.assertEquals("abc", record.getName()); + Assertions.assertEquals(43.125, record.getDerivedProp()); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertEquals(43.125, record.getAdditionalProperties().get("prop")); + } + + @Test + public void testExtendsDifferentSpreadModel() { + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", new ModelForRecord("ok")); + DifferentSpreadModelDerived body = new DifferentSpreadModelDerived("abc", new ModelForRecord("ok")); + body.setAdditionalProperties(propertyMap); + extendsDifferentSpreadModelClient.put(body); + + DifferentSpreadModelDerived record = extendsDifferentSpreadModelClient.get(); + Assertions.assertNotNull(record); + Assertions.assertEquals("abc", record.getKnownProp()); + Assertions.assertEquals("ok", record.getDerivedProp().getState()); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop")); + Assertions.assertEquals("ok", record.getAdditionalProperties().get("prop").getState()); + } + + @Test + public void testExtendsDifferentSpreadModelArray() { + Map> propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", Arrays.asList(new ModelForRecord("ok"), new ModelForRecord("ok"))); + DifferentSpreadModelArrayDerived body = new DifferentSpreadModelArrayDerived("abc", + Arrays.asList(new ModelForRecord("ok"), new ModelForRecord("ok"))); + body.setAdditionalProperties(propertyMap); + extendsDifferentSpreadModelArrayClient.put(body); + + DifferentSpreadModelArrayDerived record = extendsDifferentSpreadModelArrayClient.get(); + Assertions.assertNotNull(record); + Assertions.assertNotNull(record.getDerivedProp()); + record.getDerivedProp().forEach(modelForRecord -> Assertions.assertEquals("ok", modelForRecord.getState())); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop")); + record.getAdditionalProperties() + .get("prop") + .forEach(modelForRecord -> Assertions.assertEquals("ok", modelForRecord.getState())); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsFloatClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsFloatClientTest.java new file mode 100644 index 0000000000..336ecf440f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsFloatClientTest.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.additionalproperties; + +import java.util.LinkedHashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class IsFloatClientTest { + private final IsFloatClient client = new AdditionalPropertiesClientBuilder().buildIsFloatClient(); + + @Test + public void testPullAndGet() { + IsFloatAdditionalProperties body = new IsFloatAdditionalProperties(43.125); + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", 43.125); + body.setAdditionalProperties(propertyMap); + client.put(body); + + IsFloatAdditionalProperties properties = client.get(); + Assertions.assertNotNull(properties); + Assertions.assertNotNull(properties.getAdditionalProperties()); + Assertions.assertIterableEquals(propertyMap.entrySet(), properties.getAdditionalProperties().entrySet()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsModelArrayClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsModelArrayClientTest.java new file mode 100644 index 0000000000..820b8f4618 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsModelArrayClientTest.java @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.additionalproperties; + +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class IsModelArrayClientTest { + private final IsModelArrayClient client = new AdditionalPropertiesClientBuilder().buildIsModelArrayClient(); + + @Test + public void testPullAndGet() { + Map> propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", Arrays.asList(new ModelForRecord("ok"), new ModelForRecord("ok"))); + IsModelArrayAdditionalProperties body + = new IsModelArrayAdditionalProperties(Arrays.asList(new ModelForRecord("ok"), new ModelForRecord("ok"))); + body.setAdditionalProperties(propertyMap); + client.put(body); + + IsModelArrayAdditionalProperties properties = client.get(); + Assertions.assertNotNull(properties); + Assertions.assertNotNull(properties.getKnownProp()); + properties.getKnownProp().forEach(modelForRecord -> Assertions.assertEquals("ok", modelForRecord.getState())); + Assertions.assertNotNull(properties.getAdditionalProperties()); + Assertions.assertNotNull(properties.getAdditionalProperties().get("prop")); + properties.getAdditionalProperties() + .get("prop") + .forEach(modelForRecord -> Assertions.assertEquals("ok", modelForRecord.getState())); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsModelClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsModelClientTest.java new file mode 100644 index 0000000000..47392c382d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsModelClientTest.java @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.additionalproperties; + +import java.util.LinkedHashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class IsModelClientTest { + private final IsModelClient client = new AdditionalPropertiesClientBuilder().buildIsModelClient(); + + @Test + public void testPullAndGet() { + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", new ModelForRecord("ok")); + IsModelAdditionalProperties body = new IsModelAdditionalProperties(new ModelForRecord("ok")); + body.setAdditionalProperties(propertyMap); + client.put(body); + + IsModelAdditionalProperties properties = client.get(); + Assertions.assertNotNull(properties); + Assertions.assertNotNull(properties.getKnownProp()); + Assertions.assertEquals("ok", properties.getKnownProp().getState()); + Assertions.assertNotNull(properties.getAdditionalProperties()); + Assertions.assertNotNull(properties.getAdditionalProperties().get("prop")); + Assertions.assertEquals("ok", properties.getAdditionalProperties().get("prop").getState()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsStringClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsStringClientTest.java new file mode 100644 index 0000000000..8766f71108 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsStringClientTest.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.additionalproperties; + +import java.util.LinkedHashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class IsStringClientTest { + private final IsStringClient client = new AdditionalPropertiesClientBuilder().buildIsStringClient(); + + @Test + public void testPullAndGet() { + IsStringAdditionalProperties body = new IsStringAdditionalProperties("IsStringAdditionalProperties"); + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", "abc"); + body.setAdditionalProperties(propertyMap); + client.put(body); + + IsStringAdditionalProperties properties = client.get(); + Assertions.assertNotNull(properties); + Assertions.assertEquals("IsStringAdditionalProperties", properties.getName()); + Assertions.assertNotNull(properties.getAdditionalProperties()); + Assertions.assertIterableEquals(propertyMap.entrySet(), properties.getAdditionalProperties().entrySet()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsUnknownClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsUnknownClientTest.java new file mode 100644 index 0000000000..37cac8b23f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/IsUnknownClientTest.java @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.additionalproperties; + +import io.clientcore.core.util.binarydata.BinaryData; +import java.util.LinkedHashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.utils.BinaryDataUtils; + +public class IsUnknownClientTest { + private final IsUnknownClient client = new AdditionalPropertiesClientBuilder().buildIsUnknownClient(); + private final IsUnknownDerivedClient isUnknownDerivedClient + = new AdditionalPropertiesClientBuilder().buildIsUnknownDerivedClient(); + private final IsUnknownDiscriminatedClient isUnknownDiscriminatedClient + = new AdditionalPropertiesClientBuilder().buildIsUnknownDiscriminatedClient(); + + @Test + public void testPullAndGet() { + IsUnknownAdditionalProperties body = new IsUnknownAdditionalProperties("IsUnknownAdditionalProperties"); + Map additionalProperty = new LinkedHashMap<>(); + additionalProperty.put("prop1", BinaryData.fromObject(32)); + additionalProperty.put("prop2", BinaryData.fromObject(true)); + additionalProperty.put("prop3", BinaryData.fromObject("abc")); + body.setAdditionalProperties(additionalProperty); + client.put(body); + + IsUnknownAdditionalProperties properties = client.get(); + Assertions.assertNotNull(properties); + Assertions.assertNotNull(properties.getAdditionalProperties()); + Assertions.assertEquals("IsUnknownAdditionalProperties", properties.getName()); + BinaryDataUtils.assertMapEquals(additionalProperty, properties.getAdditionalProperties()); + } + + @Test + public void testIsUnknownDerivedClient() { + Map additionalProperty = new LinkedHashMap<>(); + additionalProperty.put("prop1", BinaryData.fromObject(32)); + additionalProperty.put("prop2", BinaryData.fromObject(true)); + additionalProperty.put("prop3", BinaryData.fromObject("abc")); + + IsUnknownAdditionalPropertiesDerived body + = new IsUnknownAdditionalPropertiesDerived("IsUnknownAdditionalProperties", 314).setAge(2.71875); + body.setAdditionalProperties(additionalProperty); + isUnknownDerivedClient.put(body); + + IsUnknownAdditionalPropertiesDerived properties = isUnknownDerivedClient.get(); + Assertions.assertNotNull(properties); + Assertions.assertNotNull(properties.getAdditionalProperties()); + Assertions.assertEquals(2.71875, properties.getAge()); + Assertions.assertEquals(314, properties.getIndex()); + BinaryDataUtils.assertMapEquals(additionalProperty, properties.getAdditionalProperties()); + } + + @Test + public void testIsUnknownDiscriminatedClient() { + Map additionalProperty = new LinkedHashMap<>(); + additionalProperty.put("prop1", BinaryData.fromObject(32)); + additionalProperty.put("prop2", BinaryData.fromObject(true)); + additionalProperty.put("prop3", BinaryData.fromObject("abc")); + + IsUnknownAdditionalPropertiesDiscriminatedDerived body + = new IsUnknownAdditionalPropertiesDiscriminatedDerived("Derived", 314).setAge(2.71875); + body.setAdditionalProperties(additionalProperty); + isUnknownDiscriminatedClient.put(body); + + IsUnknownAdditionalPropertiesDiscriminated properties = isUnknownDiscriminatedClient.get(); + Assertions.assertNotNull(properties); + Assertions.assertNotNull(properties.getAdditionalProperties()); + Assertions.assertEquals("Derived", properties.getName()); + BinaryDataUtils.assertMapEquals(additionalProperty, properties.getAdditionalProperties()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/MultipleSpreadTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/MultipleSpreadTests.java new file mode 100644 index 0000000000..9921efe871 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/MultipleSpreadTests.java @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.additionalproperties; + +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class MultipleSpreadTests { + private final MultipleSpreadClient multipleSpreadClient + = new AdditionalPropertiesClientBuilder().buildMultipleSpreadClient(); + + @Test + public void testMultipleSpread() throws IOException { + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop1", BinaryData.fromObject("abc")); + propertyMap.put("prop2", BinaryData.fromObject(43.125)); + MultipleSpreadRecord body = new MultipleSpreadRecord(true); + body.setAdditionalProperties(propertyMap); + multipleSpreadClient.put(body); + + MultipleSpreadRecord record = multipleSpreadClient.get(); + Assertions.assertNotNull(record); + Assertions.assertTrue(record.isFlag()); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertEquals("abc", record.getAdditionalProperties().get("prop1").toObject(String.class)); + Assertions.assertEquals(43.125, record.getAdditionalProperties().get("prop2").toObject(Double.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/SpreadTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/SpreadTests.java new file mode 100644 index 0000000000..f7054e6a4a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/additionalproperties/SpreadTests.java @@ -0,0 +1,292 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.additionalproperties; + +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class SpreadTests { + private final SpreadStringClient spreadStringClient + = new AdditionalPropertiesClientBuilder().buildSpreadStringClient(); + private final SpreadFloatClient spreadFloatClient + = new AdditionalPropertiesClientBuilder().buildSpreadFloatClient(); + private final SpreadModelClient spreadModelClient + = new AdditionalPropertiesClientBuilder().buildSpreadModelClient(); + private final SpreadModelArrayClient spreadModelArrayClient + = new AdditionalPropertiesClientBuilder().buildSpreadModelArrayClient(); + private final SpreadDifferentStringClient spreadDifferentStringClient + = new AdditionalPropertiesClientBuilder().buildSpreadDifferentStringClient(); + private final SpreadDifferentFloatClient spreadDifferentFloatClient + = new AdditionalPropertiesClientBuilder().buildSpreadDifferentFloatClient(); + private final SpreadDifferentModelClient spreadDifferentModelClient + = new AdditionalPropertiesClientBuilder().buildSpreadDifferentModelClient(); + private final SpreadDifferentModelArrayClient spreadDifferentModelArrayClient + = new AdditionalPropertiesClientBuilder().buildSpreadDifferentModelArrayClient(); + private final SpreadRecordUnionClient spreadRecordUnionClient + = new AdditionalPropertiesClientBuilder().buildSpreadRecordUnionClient(); + private final SpreadRecordDiscriminatedUnionClient spreadRecordDiscriminatedUnionClient + = new AdditionalPropertiesClientBuilder().buildSpreadRecordDiscriminatedUnionClient(); + private final SpreadRecordNonDiscriminatedUnionClient spreadRecordNonDiscriminatedUnionClient + = new AdditionalPropertiesClientBuilder().buildSpreadRecordNonDiscriminatedUnionClient(); + private final SpreadRecordNonDiscriminatedUnion2Client spreadRecordNonDiscriminatedUnion2Client + = new AdditionalPropertiesClientBuilder().buildSpreadRecordNonDiscriminatedUnion2Client(); + private final SpreadRecordNonDiscriminatedUnion3Client spreadRecordNonDiscriminatedUnion3Client + = new AdditionalPropertiesClientBuilder().buildSpreadRecordNonDiscriminatedUnion3Client(); + + @Test + public void testSpreadString() { + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", "abc"); + SpreadStringRecord body = new SpreadStringRecord("SpreadSpringRecord"); + body.setAdditionalProperties(propertyMap); + spreadStringClient.put(body); + + SpreadStringRecord record = spreadStringClient.get(); + Assertions.assertNotNull(record); + Assertions.assertEquals("SpreadSpringRecord", record.getName()); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop")); + Assertions.assertEquals("abc", record.getAdditionalProperties().get("prop")); + } + + @Test + public void testSpreadFloat() { + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", 43.125); + SpreadFloatRecord body = new SpreadFloatRecord(43.125); + body.setAdditionalProperties(propertyMap); + spreadFloatClient.put(body); + + SpreadFloatRecord record = spreadFloatClient.get(); + Assertions.assertNotNull(record); + Assertions.assertEquals(43.125, record.getId()); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop")); + Assertions.assertEquals(43.125, record.getAdditionalProperties().get("prop")); + } + + @Test + public void testSpreadModel() { + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", new ModelForRecord("ok")); + SpreadModelRecord body = new SpreadModelRecord(new ModelForRecord("ok")); + body.setAdditionalProperties(propertyMap); + spreadModelClient.put(body); + + SpreadModelRecord record = spreadModelClient.get(); + Assertions.assertNotNull(record); + Assertions.assertNotNull(record.getKnownProp()); + Assertions.assertEquals("ok", record.getKnownProp().getState()); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop")); + Assertions.assertEquals("ok", record.getAdditionalProperties().get("prop").getState()); + } + + @Test + public void testSpreadModelArray() { + Map> propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", Arrays.asList(new ModelForRecord("ok"), new ModelForRecord("ok"))); + SpreadModelArrayRecord body + = new SpreadModelArrayRecord(Arrays.asList(new ModelForRecord("ok"), new ModelForRecord("ok"))); + body.setAdditionalProperties(propertyMap); + spreadModelArrayClient.put(body); + + SpreadModelArrayRecord record = spreadModelArrayClient.get(); + Assertions.assertNotNull(record); + Assertions.assertNotNull(record.getKnownProp()); + record.getKnownProp().forEach(modelForRecord -> Assertions.assertEquals("ok", modelForRecord.getState())); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop")); + record.getAdditionalProperties() + .get("prop") + .forEach(modelForRecord -> Assertions.assertEquals("ok", modelForRecord.getState())); + } + + @Test + public void testSpreadDifferentString() { + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", "abc"); + DifferentSpreadStringRecord body = new DifferentSpreadStringRecord(43.125); + body.setAdditionalProperties(propertyMap); + spreadDifferentStringClient.put(body); + + DifferentSpreadStringRecord record = spreadDifferentStringClient.get(); + Assertions.assertNotNull(record); + Assertions.assertEquals(43.125, record.getId()); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertEquals("abc", record.getAdditionalProperties().get("prop")); + } + + @Test + public void testSpreadDifferentFloat() { + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", 43.125); + DifferentSpreadFloatRecord body = new DifferentSpreadFloatRecord("abc"); + body.setAdditionalProperties(propertyMap); + spreadDifferentFloatClient.put(body); + + DifferentSpreadFloatRecord record = spreadDifferentFloatClient.get(); + Assertions.assertNotNull(record); + Assertions.assertEquals("abc", record.getName()); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertEquals(43.125, record.getAdditionalProperties().get("prop")); + } + + @Test + public void testSpreadDifferentModel() { + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", new ModelForRecord("ok")); + DifferentSpreadModelRecord body = new DifferentSpreadModelRecord("abc"); + body.setAdditionalProperties(propertyMap); + spreadDifferentModelClient.put(body); + + DifferentSpreadModelRecord record = spreadDifferentModelClient.get(); + Assertions.assertNotNull(record); + Assertions.assertEquals("abc", record.getKnownProp()); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop")); + Assertions.assertEquals("ok", record.getAdditionalProperties().get("prop").getState()); + } + + @Test + public void testSpreadDifferentModelArray() { + Map> propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop", Arrays.asList(new ModelForRecord("ok"), new ModelForRecord("ok"))); + DifferentSpreadModelArrayRecord body = new DifferentSpreadModelArrayRecord("abc"); + body.setAdditionalProperties(propertyMap); + spreadDifferentModelArrayClient.put(body); + + DifferentSpreadModelArrayRecord record = spreadDifferentModelArrayClient.get(); + Assertions.assertNotNull(record); + Assertions.assertEquals("abc", record.getKnownProp()); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop")); + record.getAdditionalProperties() + .get("prop") + .forEach(modelForRecord -> Assertions.assertEquals("ok", modelForRecord.getState())); + } + + @Test + public void testSpreadRecordUnion() throws IOException { + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop1", BinaryData.fromObject("abc")); + propertyMap.put("prop2", BinaryData.fromObject(43.125f)); + SpreadRecordForUnion body = new SpreadRecordForUnion(true); + body.setAdditionalProperties(propertyMap); + spreadRecordUnionClient.put(body); + + SpreadRecordForUnion record = spreadRecordUnionClient.get(); + Assertions.assertNotNull(record); + Assertions.assertTrue(record.isFlag()); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop1")); + Assertions.assertEquals("abc", record.getAdditionalProperties().get("prop1").toObject(String.class)); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop2")); + Assertions.assertEquals(43.125f, Float.valueOf(record.getAdditionalProperties().get("prop2").toString())); + } + + @Test + public void testSpreadRecordDiscriminatedUnion() throws IOException { + BinaryData binaryDataProp1 = BinaryData.fromObject(new WidgetData0("abc")); + BinaryData binaryDataProp2 = BinaryData.fromObject(new WidgetData1(OffsetDateTime.parse("2021-01-01T00:00:00Z")) + .setEnd(OffsetDateTime.parse("2021-01-02T00:00:00Z"))); + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop1", binaryDataProp1); + propertyMap.put("prop2", binaryDataProp2); + SpreadRecordForDiscriminatedUnion body = new SpreadRecordForDiscriminatedUnion("abc"); + body.setAdditionalProperties(propertyMap); + spreadRecordDiscriminatedUnionClient.put(body); + + SpreadRecordForDiscriminatedUnion record = spreadRecordDiscriminatedUnionClient.get(); + Assertions.assertNotNull(record); + Assertions.assertEquals("abc", record.getName()); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop1")); + Assertions.assertEquals(binaryDataProp1.toObject(Map.class), + (Map) record.getAdditionalProperties().get("prop1").toObject(Map.class)); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop2")); + Assertions.assertEquals(binaryDataProp2.toObject(Map.class), + (Map) record.getAdditionalProperties().get("prop2").toObject(Map.class)); + } + + @Test + public void testSpreadRecordNonDiscriminatedUnion() throws IOException { + BinaryData binaryDataProp1 = BinaryData.fromObject(new WidgetData0("abc")); + BinaryData binaryDataProp2 = BinaryData.fromObject(new WidgetData1(OffsetDateTime.parse("2021-01-01T00:00:00Z")) + .setEnd(OffsetDateTime.parse("2021-01-02T00:00:00Z"))); + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop1", binaryDataProp1); + propertyMap.put("prop2", binaryDataProp2); + SpreadRecordForNonDiscriminatedUnion body = new SpreadRecordForNonDiscriminatedUnion("abc"); + body.setAdditionalProperties(propertyMap); + spreadRecordNonDiscriminatedUnionClient.put(body); + + SpreadRecordForNonDiscriminatedUnion record = spreadRecordNonDiscriminatedUnionClient.get(); + Assertions.assertNotNull(record); + Assertions.assertEquals("abc", record.getName()); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop1")); + Assertions.assertEquals(binaryDataProp1.toObject(Map.class), + (Map) record.getAdditionalProperties().get("prop1").toObject(Map.class)); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop2")); + Assertions.assertEquals(binaryDataProp2.toObject(Map.class), + (Map) record.getAdditionalProperties().get("prop2").toObject(Map.class)); + } + + @Test + public void testSpreadRecordNonDiscriminatedUnion2() throws IOException { + BinaryData binaryDataProp1 = BinaryData.fromObject(new WidgetData2("2021-01-01T00:00:00Z")); + BinaryData binaryDataProp2 = BinaryData.fromObject(new WidgetData1(OffsetDateTime.parse("2021-01-01T00:00:00Z")) + .setEnd(OffsetDateTime.parse("2021-01-02T00:00:00Z"))); + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop1", binaryDataProp1); + propertyMap.put("prop2", binaryDataProp2); + SpreadRecordForNonDiscriminatedUnion2 body = new SpreadRecordForNonDiscriminatedUnion2("abc"); + body.setAdditionalProperties(propertyMap); + spreadRecordNonDiscriminatedUnion2Client.put(body); + + SpreadRecordForNonDiscriminatedUnion2 record = spreadRecordNonDiscriminatedUnion2Client.get(); + Assertions.assertNotNull(record); + Assertions.assertEquals("abc", record.getName()); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop1")); + Assertions.assertEquals(binaryDataProp1.toObject(Map.class), + (Map) record.getAdditionalProperties().get("prop1").toObject(Map.class)); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop2")); + Assertions.assertEquals(binaryDataProp2.toObject(Map.class), + (Map) record.getAdditionalProperties().get("prop2").toObject(Map.class)); + } + + @Test + public void testSpreadRecordNonDiscriminatedUnion3() throws IOException { + BinaryData binaryDataProp1 = BinaryData.fromObject( + Arrays.asList(new WidgetData2("2021-01-01T00:00:00Z"), new WidgetData2("2021-01-01T00:00:00Z"))); + BinaryData binaryDataProp2 = BinaryData.fromObject(new WidgetData1(OffsetDateTime.parse("2021-01-01T00:00:00Z")) + .setEnd(OffsetDateTime.parse("2021-01-02T00:00:00Z"))); + Map propertyMap = new LinkedHashMap<>(); + propertyMap.put("prop1", binaryDataProp1); + propertyMap.put("prop2", binaryDataProp2); + SpreadRecordForNonDiscriminatedUnion3 body = new SpreadRecordForNonDiscriminatedUnion3("abc"); + body.setAdditionalProperties(propertyMap); + spreadRecordNonDiscriminatedUnion3Client.put(body); + + SpreadRecordForNonDiscriminatedUnion3 record = spreadRecordNonDiscriminatedUnion3Client.get(); + Assertions.assertNotNull(record); + Assertions.assertEquals("abc", record.getName()); + Assertions.assertNotNull(record.getAdditionalProperties()); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop1")); + Assertions.assertIterableEquals(binaryDataProp1.toObject(List.class), + record.getAdditionalProperties().get("prop1").toObject(List.class)); + Assertions.assertNotNull(record.getAdditionalProperties().get("prop2")); + Assertions.assertEquals(binaryDataProp2.toObject(Map.class), + (Map) record.getAdditionalProperties().get("prop2").toObject(Map.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/BytesClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/BytesClientTest.java new file mode 100644 index 0000000000..ebd8894086 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/BytesClientTest.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.nullable; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class BytesClientTest { + + BytesClient client = new NullableClientBuilder().buildBytesClient(); + + @Test + void patchNonNullWithResponse() { + byte[] input = new byte[] { 104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33 }; + BytesProperty bytesProperty = new BytesProperty().setRequiredProperty("foo").setNullableProperty(input); + client.patchNonNull(bytesProperty); + } + + @Test + void patchNullWithResponse() { + client.patchNull(new BytesProperty().setRequiredProperty("foo").setNullableProperty(null)); + } + + @Test + void getNonNull() { + BytesProperty response = client.getNonNull(); + Assertions.assertNotNull(response.getNullableProperty()); + } + + @Test + void getNull() { + BytesProperty response = client.getNull(); + Assertions.assertNull(response.getNullableProperty()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/CollectionsByteClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/CollectionsByteClientTest.java new file mode 100644 index 0000000000..63af8a33f6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/CollectionsByteClientTest.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.nullable; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.util.Arrays; +import org.junit.jupiter.api.Test; + +class CollectionsByteClientTest { + + CollectionsByteClient client = new NullableClientBuilder().buildCollectionsByteClient(); + + @Test + void patchNonNullWithResponse() { + CollectionsByteProperty collectionsByteProperty = new CollectionsByteProperty().setRequiredProperty("foo") + .setNullableProperty( + Arrays.asList(new byte[] { 104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33 }, + new byte[] { 104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33 })); + client.patchNonNull(collectionsByteProperty); + } + + @Test + void patchNullWithResponse() { + client.patchNull(new CollectionsByteProperty().setRequiredProperty("foo").setNullableProperty(null)); + } + + @Test + void getNonNull() { + CollectionsByteProperty response = client.getNonNull(); + assertNotNull(response.getNullableProperty()); + } + + @Test + void getNull() { + CollectionsByteProperty response = client.getNull(); + assertNull(response.getNullableProperty()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/CollectionsModelClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/CollectionsModelClientTest.java new file mode 100644 index 0000000000..36dcb8c79c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/CollectionsModelClientTest.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.nullable; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.util.Arrays; +import org.junit.jupiter.api.Test; + +class CollectionsModelClientTest { + + CollectionsModelClient client = new NullableClientBuilder().buildCollectionsModelClient(); + + @Test + void patchNonNullWithResponse() { + CollectionsModelProperty property = new CollectionsModelProperty().setRequiredProperty("foo") + .setNullableProperty( + Arrays.asList(new InnerModel().setProperty("hello"), new InnerModel().setProperty("world"))); + client.patchNonNull(property); + } + + @Test + void patchNullWithResponse() { + client.patchNull(new CollectionsModelProperty().setRequiredProperty("foo").setNullableProperty(null)); + } + + @Test + void getNonNull() { + CollectionsModelProperty response = client.getNonNull(); + assertNotNull(response.getNullableProperty()); + } + + @Test + void getNull() { + CollectionsModelProperty response = client.getNull(); + assertNull(response.getNullableProperty()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/CollectionsStringClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/CollectionsStringClientTest.java new file mode 100644 index 0000000000..e320635a8b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/CollectionsStringClientTest.java @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.nullable; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertIterableEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.util.Arrays; +import org.junit.jupiter.api.Test; + +public class CollectionsStringClientTest { + + private final CollectionsStringClient client = new NullableClientBuilder().buildCollectionsStringClient(); + + @Test + public void patchNonNull() { + CollectionsStringProperty property = new CollectionsStringProperty().setRequiredProperty("foo") + .setNullableProperty(Arrays.asList("hello", "world")); + client.patchNonNull(property); + } + + @Test + public void patchNull() { + client.patchNull(new CollectionsStringProperty().setRequiredProperty("foo").setNullableProperty(null)); + } + + @Test + public void getNonNull() { + CollectionsStringProperty response = client.getNonNull(); + assertNotNull(response.getRequiredProperty()); + assertNotNull(response.getNullableProperty()); + assertEquals("foo", response.getRequiredProperty()); + assertIterableEquals(Arrays.asList("hello", "world"), response.getNullableProperty()); + } + + @Test + public void getNull() { + CollectionsStringProperty response = client.getNull(); + assertNotNull(response.getRequiredProperty()); + assertEquals("foo", response.getRequiredProperty()); + assertNull(response.getNullableProperty()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/DatetimeOperationClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/DatetimeOperationClientTest.java new file mode 100644 index 0000000000..534c1945f6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/DatetimeOperationClientTest.java @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.nullable; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; + +class DatetimeOperationClientTest { + + DatetimeOperationClient client = new NullableClientBuilder().buildDatetimeOperationClient(); + + @Test + void patchNonNullWithResponse() { + OffsetDateTime offsetDateTime = OffsetDateTime.parse("2022-08-26T18:38:00Z"); + DatetimeProperty datetimeProperty + = new DatetimeProperty().setRequiredProperty("foo").setNullableProperty(offsetDateTime); + client.patchNonNull(datetimeProperty); + } + + @Test + void patchNullWithResponse() { + client.patchNull(new DatetimeProperty().setRequiredProperty("foo").setNullableProperty(null)); + } + + @Test + void getNonNull() { + DatetimeProperty response = client.getNonNull(); + assertNotNull(response.getNullableProperty()); + } + + @Test + void getNull() { + DatetimeProperty response = client.getNull(); + assertNull(response.getNullableProperty()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/DurationOperationClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/DurationOperationClientTest.java new file mode 100644 index 0000000000..dbc8899b93 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/DurationOperationClientTest.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.nullable; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.time.Duration; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +class DurationOperationClientTest { + + DurationOperationClient client = new NullableClientBuilder().buildDurationOperationClient(); + + @Test + @Disabled("Body provided doesn't match expected body, \"expected\":{\"requiredProperty\":\"foo\",\"nullableProperty\":\"P123DT22H14M12.011S\"},\"actual\":{\"requiredProperty\":\"foo\",\"nullableProperty\":\"PT2974H14M12.011S\"}") + void patchNonNullWithResponse() { + DurationProperty property = new DurationProperty().setRequiredProperty("foo") + .setNullableProperty(Duration.parse("PT2974H14M12.011S")); + client.patchNonNull(property); + } + + @Test + void patchNullWithResponse() { + client.patchNull(new DurationProperty().setRequiredProperty("foo").setNullableProperty(null)); + } + + @Test + void getNonNull() { + DurationProperty response = client.getNonNull(); + assertNotNull(response.getNullableProperty()); + } + + @Test + void getNull() { + DurationProperty response = client.getNull(); + assertNull(response.getNullableProperty()); + + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/StringClientTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/StringClientTests.java new file mode 100644 index 0000000000..04782bca71 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/nullable/StringClientTests.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.nullable; + +import java.io.IOException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class StringClientTests { + + private final StringOperationClient stringClient = new NullableClientBuilder().buildStringOperationClient(); + + @Test + public void testStringNullable() throws IOException { + + Assertions.assertEquals("hello", stringClient.getNonNull().getNullableProperty()); + + Assertions.assertNull(stringClient.getNull().getNullableProperty()); + + stringClient.patchNonNull(new StringProperty().setRequiredProperty("foo").setNullableProperty("hello")); + + stringClient.patchNull(new StringProperty().setRequiredProperty("foo").setNullableProperty(null)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/BooleanLiteralClientTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/BooleanLiteralClientTests.java new file mode 100644 index 0000000000..065fcc46c6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/BooleanLiteralClientTests.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.optional; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class BooleanLiteralClientTests { + private final BooleanLiteralClient client = new OptionalClientBuilder().buildBooleanLiteralClient(); + + @Test + public void getAll() { + BooleanLiteralProperty booleanLiteralProperty = client.getAll(); + Assertions.assertEquals(BooleanLiteralPropertyProperty.TRUE, booleanLiteralProperty.getProperty()); + } + + @Test + public void getDefault() { + BooleanLiteralProperty booleanLiteralProperty = client.getDefault(); + Assertions.assertNull(booleanLiteralProperty.getProperty()); + } + + @Test + public void putAll() { + BooleanLiteralProperty booleanLiteralProperty = new BooleanLiteralProperty(); + booleanLiteralProperty.setProperty(BooleanLiteralPropertyProperty.TRUE); + client.putAll(booleanLiteralProperty); + } + + @Test + public void putDefault() { + BooleanLiteralProperty booleanLiteralProperty = new BooleanLiteralProperty(); + client.putDefault(booleanLiteralProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/BytesClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/BytesClientTest.java new file mode 100644 index 0000000000..9c884287c7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/BytesClientTest.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.optional; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class BytesClientTest { + + BytesClient bytesClient = new OptionalClientBuilder().buildBytesClient(); + + @Test + void getAll() { + BytesProperty bytesProperty = bytesClient.getAll(); + Assertions.assertNotNull(bytesProperty.getProperty()); + } + + @Test + void putAll() { + BytesProperty bytesProperty = new BytesProperty(); + bytesProperty.setProperty(new byte[] { 104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33 }); + bytesClient.putAll(bytesProperty); + } + + @Test + void getDefault() { + BytesProperty bytesProperty = bytesClient.getDefault(); + Assertions.assertNull(bytesProperty.getProperty()); + } + + @Test + void putDefault() { + BytesProperty bytesProperty = new BytesProperty(); + bytesClient.putDefault(bytesProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/CollectionsByteClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/CollectionsByteClientTest.java new file mode 100644 index 0000000000..6f6a483023 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/CollectionsByteClientTest.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.optional; + +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class CollectionsByteClientTest { + + CollectionsByteClient client = new OptionalClientBuilder().buildCollectionsByteClient(); + + @Test + void getAll() { + CollectionsByteProperty collectionsByteProperty = client.getAll(); + for (byte[] p : collectionsByteProperty.getProperty()) { + Assertions.assertNotNull(p); + } + } + + @Test + void getDefault() { + CollectionsByteProperty collectionsByteProperty = client.getDefault(); + Assertions.assertNull(collectionsByteProperty.getProperty()); + } + + @Test + void putAll() { + CollectionsByteProperty collectionsByteProperty = new CollectionsByteProperty(); + byte[] byteProperty = new byte[] { 104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33 }; + collectionsByteProperty.setProperty(Arrays.asList(byteProperty, byteProperty)); + client.putAll(collectionsByteProperty); + } + + @Test + void putDefault() { + CollectionsByteProperty collectionsByteProperty = new CollectionsByteProperty(); + client.putDefault(collectionsByteProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/CollectionsModelClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/CollectionsModelClientTest.java new file mode 100644 index 0000000000..7d45f04940 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/CollectionsModelClientTest.java @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.optional; + +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class CollectionsModelClientTest { + + CollectionsModelClient client = new OptionalClientBuilder().buildCollectionsModelClient(); + + @Test + void getAll() { + CollectionsModelProperty collectionsModelProperty = client.getAll(); + List properties = collectionsModelProperty.getProperty(); + Assertions.assertEquals("hello", properties.get(0).getProperty()); + Assertions.assertEquals("world", properties.get(1).getProperty()); + } + + @Test + void getDefault() { + CollectionsModelProperty collectionsModelProperty = client.getDefault(); + Assertions.assertNull(collectionsModelProperty.getProperty()); + } + + @Test + void putAll() { + CollectionsModelProperty collectionsModelProperty = new CollectionsModelProperty(); + StringProperty stringProperty1 = new StringProperty(); + StringProperty stringProperty2 = new StringProperty(); + stringProperty1.setProperty("hello"); + stringProperty2.setProperty("world"); + collectionsModelProperty.setProperty(Arrays.asList(stringProperty1, stringProperty2)); + client.putAll(collectionsModelProperty); + } + + @Test + void putDefault() { + CollectionsModelProperty collectionsModelProperty = new CollectionsModelProperty(); + client.putDefault(collectionsModelProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/DatetimeOperationClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/DatetimeOperationClientTest.java new file mode 100644 index 0000000000..bbf1758954 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/DatetimeOperationClientTest.java @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.optional; + +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class DatetimeOperationClientTest { + + DatetimeOperationClient client = new OptionalClientBuilder().buildDatetimeOperationClient(); + + @Test + void getAll() { + DatetimeProperty datetimeProperty = client.getAll(); + Assertions.assertEquals("2022-08-26T18:38Z", datetimeProperty.getProperty().toString()); + } + + @Test + void getDefault() { + DatetimeProperty datetimeProperty = client.getDefault(); + Assertions.assertNull(datetimeProperty.getProperty()); + } + + @Test + void putAll() { + OffsetDateTime offsetDateTime = OffsetDateTime.parse("2022-08-26T18:38Z"); + DatetimeProperty datetimeProperty = new DatetimeProperty(); + datetimeProperty.setProperty(offsetDateTime); + client.putAll(datetimeProperty); + } + + @Test + void putDefault() { + DatetimeProperty datetimeProperty = new DatetimeProperty(); + client.putDefault(datetimeProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/DurationOperationClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/DurationOperationClientTest.java new file mode 100644 index 0000000000..aca336f961 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/DurationOperationClientTest.java @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.optional; + +import java.time.Duration; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +class DurationOperationClientTest { + + DurationOperationClient client = new OptionalClientBuilder().buildDurationOperationClient(); + + @Test + void getAll() { + DurationProperty durationProperty = client.getAll(); + Assertions.assertEquals("PT2974H14M12.011S", durationProperty.getProperty().toString()); + } + + @Test + void getDefault() { + DurationProperty durationProperty = client.getDefault(); + Assertions.assertNull(durationProperty.getProperty()); + } + + @Test + @Disabled("Body provided doesn't match expected body, \"expected\":{\"property\":\"P123DT22H14M12.011S\"},\"actual\":{\"property\":\"PT2974H14M12.011S\"}") + void putAll() { + Duration duration = Duration.parse("PT2974H14M12.011S"); + DurationProperty property = new DurationProperty(); + property.setProperty(duration); + client.putAll(property); + } + + @Test + void putDefault() { + DurationProperty property = new DurationProperty(); + client.putDefault(property); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/FloatLiteralClientTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/FloatLiteralClientTests.java new file mode 100644 index 0000000000..6c0f57db62 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/FloatLiteralClientTests.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.optional; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class FloatLiteralClientTests { + private final FloatLiteralClient client = new OptionalClientBuilder().buildFloatLiteralClient(); + + @Test + public void getAll() { + FloatLiteralProperty floatLiteralProperty = client.getAll(); + Assertions.assertEquals(FloatLiteralPropertyProperty.ONE_TWO_FIVE, floatLiteralProperty.getProperty()); + } + + @Test + public void getDefault() { + FloatLiteralProperty floatLiteralProperty = client.getDefault(); + Assertions.assertNull(floatLiteralProperty.getProperty()); + } + + @Test + public void putAll() { + FloatLiteralProperty floatLiteralProperty = new FloatLiteralProperty(); + floatLiteralProperty.setProperty(FloatLiteralPropertyProperty.ONE_TWO_FIVE); + client.putAll(floatLiteralProperty); + } + + @Test + public void putDefault() { + FloatLiteralProperty floatLiteralProperty = new FloatLiteralProperty(); + client.putDefault(floatLiteralProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/IntLiteralClientTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/IntLiteralClientTests.java new file mode 100644 index 0000000000..94f8f6f4bf --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/IntLiteralClientTests.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.optional; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class IntLiteralClientTests { + private final IntLiteralClient client = new OptionalClientBuilder().buildIntLiteralClient(); + + @Test + public void getAll() { + IntLiteralProperty intLiteralProperty = client.getAll(); + Assertions.assertEquals(IntLiteralPropertyProperty.ONE, intLiteralProperty.getProperty()); + } + + @Test + public void getDefault() { + IntLiteralProperty intLiteralProperty = client.getDefault(); + Assertions.assertNull(intLiteralProperty.getProperty()); + } + + @Test + public void putAll() { + IntLiteralProperty intLiteralProperty = new IntLiteralProperty(); + intLiteralProperty.setProperty(IntLiteralPropertyProperty.ONE); + client.putAll(intLiteralProperty); + } + + @Test + public void putDefault() { + IntLiteralProperty intLiteralProperty = new IntLiteralProperty(); + client.putDefault(intLiteralProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/PlainDateClientTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/PlainDateClientTests.java new file mode 100644 index 0000000000..419280238d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/PlainDateClientTests.java @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.optional; + +import java.time.LocalDate; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class PlainDateClientTests { + private final PlainDateClient client = new OptionalClientBuilder().buildPlainDateClient(); + + @Test + public void getAll() { + PlainDateProperty PlainDateProperty = client.getAll(); + Assertions.assertEquals(LocalDate.parse("2022-12-12"), PlainDateProperty.getProperty()); + } + + @Test + public void getDefault() { + PlainDateProperty PlainDateProperty = client.getDefault(); + Assertions.assertNull(PlainDateProperty.getProperty()); + } + + @Test + public void putAll() { + client.putAll(new PlainDateProperty().setProperty(LocalDate.parse("2022-12-12"))); + } + + @Test + public void putDefault() { + client.putDefault(new PlainDateProperty()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/PlainTimeClientTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/PlainTimeClientTests.java new file mode 100644 index 0000000000..7d61da196a --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/PlainTimeClientTests.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.optional; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class PlainTimeClientTests { + private final PlainTimeClient client = new OptionalClientBuilder().buildPlainTimeClient(); + + @Test + public void getAll() { + Assertions.assertEquals("13:06:12", client.getAll().getProperty()); + } + + @Test + public void getDefault() { + Assertions.assertNull(client.getDefault().getProperty()); + } + + @Test + public void putAll() { + client.putAll(new PlainTimeProperty().setProperty("13:06:12")); + } + + @Test + public void putDefault() { + client.putDefault(new PlainTimeProperty()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/RequiredAndOptionalClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/RequiredAndOptionalClientTest.java new file mode 100644 index 0000000000..af19f414f4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/RequiredAndOptionalClientTest.java @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.optional; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class RequiredAndOptionalClientTest { + RequiredAndOptionalClient client = new OptionalClientBuilder().buildRequiredAndOptionalClient(); + + @Test + void getAll() { + RequiredAndOptionalProperty requiredAndOptionalProperty = client.getAll(); + Assertions.assertEquals("hello", requiredAndOptionalProperty.getOptionalProperty()); + Assertions.assertEquals(42, requiredAndOptionalProperty.getRequiredProperty()); + } + + @Test + void getRequiredOnly() { + RequiredAndOptionalProperty requiredAndOptionalProperty = client.getRequiredOnly(); + Assertions.assertEquals(42, requiredAndOptionalProperty.getRequiredProperty()); + Assertions.assertNull(requiredAndOptionalProperty.getOptionalProperty()); + } + + @Test + void putAll() { + RequiredAndOptionalProperty requiredAndOptionalProperty = new RequiredAndOptionalProperty(42); + requiredAndOptionalProperty.setOptionalProperty("hello"); + client.putAll(requiredAndOptionalProperty); + } + + @Test + void putRequiredOnly() { + RequiredAndOptionalProperty requiredAndOptionalProperty = new RequiredAndOptionalProperty(42); + client.putRequiredOnly(requiredAndOptionalProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/StringLiteralClientTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/StringLiteralClientTests.java new file mode 100644 index 0000000000..2f7d893c55 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/StringLiteralClientTests.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.optional; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class StringLiteralClientTests { + private final StringLiteralClient client = new OptionalClientBuilder().buildStringLiteralClient(); + + @Test + public void getAll() { + StringLiteralProperty stringLiteralProperty = client.getAll(); + Assertions.assertEquals(StringLiteralPropertyProperty.HELLO, stringLiteralProperty.getProperty()); + } + + @Test + public void getDefault() { + StringLiteralProperty stringLiteralProperty = client.getDefault(); + Assertions.assertNull(stringLiteralProperty.getProperty()); + } + + @Test + public void putAll() { + StringLiteralProperty stringLiteralProperty = new StringLiteralProperty(); + stringLiteralProperty.setProperty(StringLiteralPropertyProperty.HELLO); + client.putAll(stringLiteralProperty); + } + + @Test + public void putDefault() { + StringLiteralProperty stringLiteralProperty = new StringLiteralProperty(); + client.putDefault(stringLiteralProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/StringOperationClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/StringOperationClientTest.java new file mode 100644 index 0000000000..e9e7e1ac83 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/StringOperationClientTest.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.optional; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class StringOperationClientTest { + + StringOperationClient client = new OptionalClientBuilder().buildStringOperationClient(); + + @Test + void getAll() { + StringProperty stringProperty = client.getAll(); + Assertions.assertEquals("hello", stringProperty.getProperty()); + } + + @Test + void getDefault() { + StringProperty stringProperty = client.getDefault(); + Assertions.assertNull(stringProperty.getProperty()); + } + + @Test + void putAll() { + StringProperty stringProperty = new StringProperty(); + stringProperty.setProperty("hello"); + client.putAll(stringProperty); + } + + @Test + void putDefault() { + StringProperty stringProperty = new StringProperty(); + client.putDefault(stringProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/UnionFloatLiteralClientTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/UnionFloatLiteralClientTests.java new file mode 100644 index 0000000000..65663b49d6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/UnionFloatLiteralClientTests.java @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.optional; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class UnionFloatLiteralClientTests { + private final UnionFloatLiteralClient client = new OptionalClientBuilder().buildUnionFloatLiteralClient(); + + @Test + public void getAll() { + UnionFloatLiteralProperty unionFloatLiteralProperty = client.getAll(); + Assertions.assertEquals(UnionFloatLiteralPropertyProperty.TWO_THREE_SEVEN_FIVE, + unionFloatLiteralProperty.getProperty()); + } + + @Test + public void getDefault() { + UnionFloatLiteralProperty unionFloatLiteralProperty = client.getDefault(); + Assertions.assertNull(unionFloatLiteralProperty.getProperty()); + } + + @Test + public void putAll() { + UnionFloatLiteralProperty unionFloatLiteralProperty = new UnionFloatLiteralProperty(); + unionFloatLiteralProperty.setProperty(UnionFloatLiteralPropertyProperty.TWO_THREE_SEVEN_FIVE); + client.putAll(unionFloatLiteralProperty); + } + + @Test + public void putDefault() { + UnionFloatLiteralProperty unionFloatLiteralProperty = new UnionFloatLiteralProperty(); + client.putDefault(unionFloatLiteralProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/UnionIntLiteralClientTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/UnionIntLiteralClientTests.java new file mode 100644 index 0000000000..3d79f8c3bd --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/UnionIntLiteralClientTests.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.optional; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class UnionIntLiteralClientTests { + private final UnionIntLiteralClient client = new OptionalClientBuilder().buildUnionIntLiteralClient(); + + @Test + public void getAll() { + UnionIntLiteralProperty unionIntLiteralProperty = client.getAll(); + Assertions.assertEquals(UnionIntLiteralPropertyProperty.TWO, unionIntLiteralProperty.getProperty()); + } + + @Test + public void getDefault() { + UnionIntLiteralProperty unionIntLiteralProperty = client.getDefault(); + Assertions.assertNull(unionIntLiteralProperty.getProperty()); + } + + @Test + public void putAll() { + UnionIntLiteralProperty unionIntLiteralProperty = new UnionIntLiteralProperty(); + unionIntLiteralProperty.setProperty(UnionIntLiteralPropertyProperty.TWO); + client.putAll(unionIntLiteralProperty); + } + + @Test + public void putDefault() { + UnionIntLiteralProperty unionIntLiteralProperty = new UnionIntLiteralProperty(); + client.putDefault(unionIntLiteralProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/UnionStringLiteralClientTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/UnionStringLiteralClientTests.java new file mode 100644 index 0000000000..64503589c3 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/optional/UnionStringLiteralClientTests.java @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.optional; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class UnionStringLiteralClientTests { + private final UnionStringLiteralClient client = new OptionalClientBuilder().buildUnionStringLiteralClient(); + + @Test + public void getAll() { + UnionStringLiteralProperty unionStringLiteralProperty = client.getAll(); + Assertions.assertEquals(UnionStringLiteralPropertyProperty.WORLD, unionStringLiteralProperty.getProperty()); + } + + @Test + public void getDefault() { + UnionStringLiteralProperty unionStringLiteralProperty = client.getDefault(); + Assertions.assertNull(unionStringLiteralProperty.getProperty()); + } + + @Test + public void putAll() { + UnionStringLiteralProperty unionStringLiteralProperty = new UnionStringLiteralProperty(); + unionStringLiteralProperty.setProperty(UnionStringLiteralPropertyProperty.WORLD); + client.putAll(unionStringLiteralProperty); + } + + @Test + public void putDefault() { + UnionStringLiteralProperty unionStringLiteralProperty = new UnionStringLiteralProperty(); + client.putDefault(unionStringLiteralProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/BooleanOperationClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/BooleanOperationClientTest.java new file mode 100644 index 0000000000..5c3537607d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/BooleanOperationClientTest.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class BooleanOperationClientTest { + + BooleanOperationClient client = new ValueTypesClientBuilder().buildBooleanOperationClient(); + + @Test + void get() { + BooleanProperty response = client.get(); + Assertions.assertTrue(response.isProperty()); + } + + @Test + void put() { + BooleanProperty booleanProperty = new BooleanProperty(true); + client.put(booleanProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/BytesClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/BytesClientTest.java new file mode 100644 index 0000000000..280325ce1b --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/BytesClientTest.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class BytesClientTest { + + BytesClient client = new ValueTypesClientBuilder().buildBytesClient(); + + @Test + void get() { + BytesProperty bytesProperty = client.get(); + Assertions.assertNotNull(bytesProperty.getProperty()); + } + + @Test + void put() { + byte[] input = new byte[] { 104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33 }; + BytesProperty bytesProperty = new BytesProperty(input); + client.put(bytesProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/CollectionsIntClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/CollectionsIntClientTest.java new file mode 100644 index 0000000000..b2081c0c60 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/CollectionsIntClientTest.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class CollectionsIntClientTest { + + CollectionsIntClient client = new ValueTypesClientBuilder().buildCollectionsIntClient(); + + @Test + void get() { + CollectionsIntProperty collectionsIntProperty = client.get(); + List properties = collectionsIntProperty.getProperty(); + Assertions.assertEquals(1, properties.get(0)); + Assertions.assertEquals(2, properties.get(1)); + } + + @Test + void put() { + CollectionsIntProperty collectionsIntProperty = new CollectionsIntProperty(Arrays.asList(1, 2)); + client.put(collectionsIntProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/CollectionsModelClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/CollectionsModelClientTest.java new file mode 100644 index 0000000000..d6d1adb90f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/CollectionsModelClientTest.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class CollectionsModelClientTest { + + CollectionsModelClient client = new ValueTypesClientBuilder().buildCollectionsModelClient(); + + @Test + void get() { + CollectionsModelProperty collectionsModelProperty = client.get(); + List properties = collectionsModelProperty.getProperty(); + Assertions.assertEquals("hello", properties.get(0).getProperty()); + Assertions.assertEquals("world", properties.get(1).getProperty()); + } + + @Test + void put() { + InnerModel innerModel1 = new InnerModel("hello"); + InnerModel innerModel2 = new InnerModel("world"); + List properties = Arrays.asList(innerModel1, innerModel2); + CollectionsModelProperty collectionsModelProperty = new CollectionsModelProperty(properties); + client.put(collectionsModelProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/CollectionsStringClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/CollectionsStringClientTest.java new file mode 100644 index 0000000000..9295ae92ad --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/CollectionsStringClientTest.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import java.util.Arrays; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class CollectionsStringClientTest { + + CollectionsStringClient client = new ValueTypesClientBuilder().buildCollectionsStringClient(); + + @Test + void get() { + CollectionsStringProperty collectionsStringProperty = client.get(); + Assertions.assertEquals("hello", collectionsStringProperty.getProperty().get(0)); + Assertions.assertEquals("world", collectionsStringProperty.getProperty().get(1)); + } + + @Test + void put() { + CollectionsStringProperty collectionsStringProperty + = new CollectionsStringProperty(Arrays.asList("hello", "world")); + client.put(collectionsStringProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/DatetimeOperationClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/DatetimeOperationClientTest.java new file mode 100644 index 0000000000..b25ca68ad8 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/DatetimeOperationClientTest.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class DatetimeOperationClientTest { + + DatetimeOperationClient client = new ValueTypesClientBuilder().buildDatetimeOperationClient(); + + @Test + void get() { + DatetimeProperty datetimeProperty = client.get(); + Assertions.assertEquals("2022-08-26T18:38Z", datetimeProperty.getProperty().toString()); + } + + @Test + void put() { + OffsetDateTime offsetDateTime = OffsetDateTime.parse("2022-08-26T18:38Z"); + DatetimeProperty datetimeProperty = new DatetimeProperty(offsetDateTime); + client.put(datetimeProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/DecimalTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/DecimalTests.java new file mode 100644 index 0000000000..27a051bcd7 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/DecimalTests.java @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import org.junit.jupiter.api.Test; + +public class DecimalTests { + + private final DecimalClient client1 = new ValueTypesClientBuilder().buildDecimalClient(); + private final Decimal128Client client2 = new ValueTypesClientBuilder().buildDecimal128Client(); + + @Test + public void test() { + client1.put(client1.get()); + + client2.put(client2.get()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/DictionaryStringClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/DictionaryStringClientTest.java new file mode 100644 index 0000000000..323e8053a5 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/DictionaryStringClientTest.java @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import java.util.HashMap; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class DictionaryStringClientTest { + + DictionaryStringClient client = new ValueTypesClientBuilder().buildDictionaryStringClient(); + + @Test + void get() { + DictionaryStringProperty dictionaryStringProperty = client.get(); + Map property = dictionaryStringProperty.getProperty(); + Assertions.assertEquals("hello", property.get("k1")); + Assertions.assertEquals("world", property.get("k2")); + } + + @Test + void put() { + Map property = new HashMap<>(); + property.put("k1", "hello"); + property.put("k2", "world"); + DictionaryStringProperty dictionaryStringProperty = new DictionaryStringProperty(property); + client.put(dictionaryStringProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/DurationOperationClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/DurationOperationClientTest.java new file mode 100644 index 0000000000..bc459264cb --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/DurationOperationClientTest.java @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import java.time.Duration; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +class DurationOperationClientTest { + + DurationOperationClient client = new ValueTypesClientBuilder().buildDurationOperationClient(); + + @Test + void get() { + DurationProperty durationProperty = client.get(); + Assertions.assertEquals("PT2974H14M12.011S", durationProperty.getProperty().toString()); + } + + @Test + @Disabled("Body provided doesn't match expected body,\"expected\":{\"property\":\"P123DT22H14M12.011S\"},\"actual\":{\"property\":\"PT2974H14M12.011S\"}") + void put() { + Duration duration = Duration.parse("PT2974H14M12.011S"); + DurationProperty property = new DurationProperty(duration); + client.put(property); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/EnumClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/EnumClientTest.java new file mode 100644 index 0000000000..f12422d8bc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/EnumClientTest.java @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class EnumClientTest { + + EnumClient client = new ValueTypesClientBuilder().buildEnumClient(); + + @Test + void get() { + EnumProperty enumProperty = client.get(); + FixedInnerEnum innerEnum = enumProperty.getProperty(); + Assertions.assertEquals("ValueOne", innerEnum.toString()); + } + + @Test + void put() { + FixedInnerEnum innerEnum = FixedInnerEnum.VALUE_ONE; + EnumProperty enumProperty = new EnumProperty(innerEnum); + client.put(enumProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/EnumValueTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/EnumValueTests.java new file mode 100644 index 0000000000..d1ad6ed9fc --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/EnumValueTests.java @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import org.junit.jupiter.api.Test; + +public class EnumValueTests { + + private final UnionEnumValueClient client = new ValueTypesClientBuilder().buildUnionEnumValueClient(); + + @Test + public void test() { + client.put(client.get()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/ExtensibleEnumClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/ExtensibleEnumClientTest.java new file mode 100644 index 0000000000..8f0b3b663e --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/ExtensibleEnumClientTest.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class ExtensibleEnumClientTest { + + ExtensibleEnumClient client = new ValueTypesClientBuilder().buildExtensibleEnumClient(); + + @Test + void get() { + ExtensibleEnumProperty extensibleEnumProperty = client.get(); + InnerEnum innerExtensibleEnum = extensibleEnumProperty.getProperty(); + Assertions.assertEquals("UnknownValue", innerExtensibleEnum.toString()); + } + + @Test + void put() { + ExtensibleEnumProperty extensibleEnumProperty = new ExtensibleEnumProperty(InnerEnum.fromValue("UnknownValue")); + client.put(extensibleEnumProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/FloatOperationClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/FloatOperationClientTest.java new file mode 100644 index 0000000000..a55060e345 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/FloatOperationClientTest.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class FloatOperationClientTest { + + FloatOperationClient client = new ValueTypesClientBuilder().buildFloatOperationClient(); + + @Test + void get() { + FloatProperty floatProperty = client.get(); + Assertions.assertEquals(43.125, floatProperty.getProperty()); + } + + @Test + void put() { + FloatProperty floatProperty = new FloatProperty(43.125); + client.put(floatProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/IntClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/IntClientTest.java new file mode 100644 index 0000000000..6f2d8df9b4 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/IntClientTest.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class IntClientTest { + + IntClient client = new ValueTypesClientBuilder().buildIntClient(); + + @Test + void get() { + IntProperty intProperty = client.get(); + Assertions.assertEquals(42, intProperty.getProperty()); + } + + @Test + void put() { + IntProperty intProperty = new IntProperty(42); + client.put(intProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/LiteralTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/LiteralTests.java new file mode 100644 index 0000000000..cccba85009 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/LiteralTests.java @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License + +package type.property.valuetypes; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class LiteralTests { + private final BooleanLiteralClient booleanLiteralClient = new ValueTypesClientBuilder().buildBooleanLiteralClient(); + private final FloatLiteralClient floatLiteralClient = new ValueTypesClientBuilder().buildFloatLiteralClient(); + private final IntLiteralClient intLiteralClient = new ValueTypesClientBuilder().buildIntLiteralClient(); + private final StringLiteralClient stringLiteralClient = new ValueTypesClientBuilder().buildStringLiteralClient(); + + @Test + public void testBooleanLiteral() { + BooleanLiteralProperty body = new BooleanLiteralProperty(); + booleanLiteralClient.put(body); + + Assertions.assertNotNull(booleanLiteralClient.get()); + Assertions.assertTrue(booleanLiteralClient.get().isProperty()); + } + + @Test + public void testFloatLiteral() { + FloatLiteralProperty body = new FloatLiteralProperty(); + floatLiteralClient.put(body); + + Assertions.assertNotNull(floatLiteralClient.get()); + Assertions.assertEquals(43.125, floatLiteralClient.get().getProperty()); + } + + @Test + public void testIntLiteralClient() { + IntLiteralProperty body = new IntLiteralProperty(); + intLiteralClient.put(body); + + Assertions.assertNotNull(intLiteralClient.get()); + Assertions.assertEquals(42, intLiteralClient.get().getProperty()); + } + + @Test + public void testStringLiteral() { + StringLiteralProperty body = new StringLiteralProperty(); + stringLiteralClient.put(body); + + Assertions.assertNotNull(stringLiteralClient.get()); + Assertions.assertEquals("hello", stringLiteralClient.get().getProperty()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/ModelClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/ModelClientTest.java new file mode 100644 index 0000000000..8b4f25f192 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/ModelClientTest.java @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class ModelClientTest { + + ModelClient client = new ValueTypesClientBuilder().buildModelClient(); + + @Test + void get() { + ModelProperty modelProperty = client.get(); + Assertions.assertEquals("hello", modelProperty.getProperty().getProperty()); + } + + @Test + void put() { + InnerModel innerModel = new InnerModel("hello"); + ModelProperty modelProperty = new ModelProperty(innerModel); + client.put(modelProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/NeverClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/NeverClientTest.java new file mode 100644 index 0000000000..d9a4dcca7d --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/NeverClientTest.java @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class NeverClientTest { + + NeverClient client = new ValueTypesClientBuilder().buildNeverClient(); + + @Test + void get() { + NeverProperty response = client.get(); + Assertions.assertNotNull(response); + } + + @Test + void put() { + client.put(new NeverProperty()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/StringOperationClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/StringOperationClientTest.java new file mode 100644 index 0000000000..dc4126d74c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/StringOperationClientTest.java @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class StringOperationClientTest { + + StringOperationClient client = new ValueTypesClientBuilder().buildStringOperationClient(); + + @Test + void get() { + StringProperty stringProperty = client.get(); + Assertions.assertEquals("hello", stringProperty.getProperty()); + } + + @Test + void put() { + StringProperty stringProperty = new StringProperty("hello"); + client.put(stringProperty); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/UnionTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/UnionTests.java new file mode 100644 index 0000000000..b41c1f3cc6 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/UnionTests.java @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class UnionTests { + private final UnionStringLiteralClient unionStringClient + = new ValueTypesClientBuilder().buildUnionStringLiteralClient(); + private final UnionFloatLiteralClient unionFloatClient + = new ValueTypesClientBuilder().buildUnionFloatLiteralClient(); + private final UnionIntLiteralClient unionIntClient = new ValueTypesClientBuilder().buildUnionIntLiteralClient(); + + @Test + public void testUnionStringLiteral() { + UnionStringLiteralProperty body = new UnionStringLiteralProperty(UnionStringLiteralPropertyProperty.WORLD); + unionStringClient.put(body); + + Assertions.assertNotNull(unionStringClient.get()); + Assertions.assertEquals(UnionStringLiteralPropertyProperty.WORLD, unionStringClient.get().getProperty()); + } + + @Test + public void testUnionFloatLiteral() { + UnionFloatLiteralProperty body + = new UnionFloatLiteralProperty(UnionFloatLiteralPropertyProperty.FOUR_SIX_EIGHT_SEVEN_FIVE); + unionFloatClient.put(body); + + Assertions.assertNotNull(unionFloatClient.get()); + Assertions.assertEquals(UnionFloatLiteralPropertyProperty.FOUR_SIX_EIGHT_SEVEN_FIVE, + unionFloatClient.get().getProperty()); + } + + @Test + public void testUnionIntLiteral() { + UnionIntLiteralProperty body = new UnionIntLiteralProperty(UnionIntLiteralPropertyProperty.FOUR_TWO); + unionIntClient.put(body); + + Assertions.assertNotNull(unionIntClient.get()); + Assertions.assertEquals(UnionIntLiteralPropertyProperty.FOUR_TWO, unionIntClient.get().getProperty()); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/UnknownTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/UnknownTests.java new file mode 100644 index 0000000000..9c5736f12c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/property/valuetypes/UnknownTests.java @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.property.valuetypes; + +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class UnknownTests { + + private final UnknownArrayClient arrayClient = new ValueTypesClientBuilder().buildUnknownArrayClient(); + private final UnknownDictClient dictClient = new ValueTypesClientBuilder().buildUnknownDictClient(); + private final UnknownIntClient intClient = new ValueTypesClientBuilder().buildUnknownIntClient(); + private final UnknownStringClient stringClient = new ValueTypesClientBuilder().buildUnknownStringClient(); + + @Test + public void testUnknownArray() throws IOException { + List array = Arrays.asList("hello", "world"); + + arrayClient.put(new UnknownArrayProperty(BinaryData.fromObject(array))); + + Assertions.assertEquals(array, arrayClient.get().getProperty().toObject(List.class)); + } + + @Test + public void testUnknownDict() throws IOException { + Map dict = new HashMap<>(); + dict.put("k1", "hello"); + dict.put("k2", 42); + + dictClient.put(new UnknownDictProperty(BinaryData.fromObject(dict))); + + Assertions.assertEquals(dict, dictClient.get().getProperty().toObject(Map.class)); + } + + @Test + public void testUnknownInt() throws IOException { + int integer = 42; + + intClient.put(new UnknownIntProperty(BinaryData.fromObject(integer))); + + Assertions.assertEquals(integer, (Integer) intClient.get().getProperty().toObject(Integer.class)); + } + + @Test + public void testUnknownString() throws IOException { + String str = "hello"; + + stringClient.put(new UnknownStringProperty(BinaryData.fromObject(str))); + + Assertions.assertEquals(str, stringClient.get().getProperty().toObject(String.class)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/scalar/DecimalTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/scalar/DecimalTests.java new file mode 100644 index 0000000000..02e8c2880f --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/scalar/DecimalTests.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.scalar; + +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.math.BigDecimal; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; +import type.property.valuetypes.DecimalProperty; + +public class DecimalTests { + + @ParameterizedTest + @ValueSource(classes = { DecimalProperty.class }) + public void testBigDecimal(Class clazz) throws IOException { + // precision larger than double + BigDecimal value = new BigDecimal("12345678901234567890.1234567890"); + String json = BinaryData.fromObject(newInstance(clazz, value)).toString(); + T test = BinaryData.fromString(json).toObject(clazz); + Assertions.assertEquals(value, getProperty(clazz, test)); + + // make sure precision difference would cause NotEquals + Assertions.assertNotEquals(value, new BigDecimal("12345678901234567890.123456789")); + + // scientific + value = new BigDecimal("1.2345678901234567890E23"); + json = BinaryData.fromObject(newInstance(clazz, value)).toString(); + test = BinaryData.fromString(json).toObject(clazz); + Assertions.assertEquals(value, getProperty(clazz, test)); + + value = new BigDecimal("-1.2345678901234567890e-105"); + json = BinaryData.fromObject(newInstance(clazz, value)).toString(); + test = BinaryData.fromString(json).toObject(clazz); + Assertions.assertEquals(value, getProperty(clazz, test)); + } + + private static T newInstance(Class clazz, BigDecimal value) { + try { + return clazz.getDeclaredConstructor(BigDecimal.class).newInstance(value); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + private static BigDecimal getProperty(Class clazz, T obj) { + try { + return (BigDecimal) clazz.getDeclaredMethod("getProperty").invoke(obj); + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/scalar/ScalarTests.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/scalar/ScalarTests.java new file mode 100644 index 0000000000..6b1275a8ca --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/scalar/ScalarTests.java @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.scalar; + +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.math.BigDecimal; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +public class ScalarTests { + + private final StringOperationClient stringClient = new ScalarClientBuilder().buildStringOperationClient(); + private final BooleanOperationClient booleanClient = new ScalarClientBuilder().buildBooleanOperationClient(); + private final UnknownClient unknownClient = new ScalarClientBuilder().buildUnknownClient(); + + private final DecimalTypeClient decimalClient1 = new ScalarClientBuilder().buildDecimalTypeClient(); + private final Decimal128TypeClient decimalClient2 = new ScalarClientBuilder().buildDecimal128TypeClient(); + private final DecimalVerifyClient decimalClient3 = new ScalarClientBuilder().buildDecimalVerifyClient(); + private final Decimal128VerifyClient decimalClient4 = new ScalarClientBuilder().buildDecimal128VerifyClient(); + + @Test + public void test() throws IOException { + Assertions.assertEquals("test", stringClient.get()); + stringClient.put("test"); + + Assertions.assertTrue(booleanClient.get()); + booleanClient.put(true); + + Assertions.assertEquals("test", unknownClient.get().toObject(String.class)); + unknownClient.put(BinaryData.fromObject("test")); + } + + @Test + @Disabled("Body provided doesn't match expected body\",\"expected\":0.33333,\"actual\":\"0.33333\"") + public void testDecimal() { + BigDecimal decimal = new BigDecimal("0.33333"); + + decimalClient1.requestBody(decimal); + decimalClient1.requestParameter(decimal); + Assertions.assertEquals(decimal, decimalClient1.responseBody()); + + decimalClient2.requestBody(decimal); + decimalClient2.requestParameter(decimal); + Assertions.assertEquals(decimal, decimalClient2.responseBody()); + + decimalClient3.verify(decimalClient3.prepareVerify().stream().reduce(BigDecimal.valueOf(0), BigDecimal::add)); + + decimalClient4.verify(decimalClient4.prepareVerify().stream().reduce(BigDecimal.valueOf(0), BigDecimal::add)); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/union/UnionsClientTest.java b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/union/UnionsClientTest.java new file mode 100644 index 0000000000..ebb5a43551 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/union/UnionsClientTest.java @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package type.union; + +import io.clientcore.core.util.binarydata.BinaryData; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class UnionsClientTest { + + private final StringsOnlyClient client1 = new UnionClientBuilder().buildStringsOnlyClient(); + private final StringExtensibleClient client2 = new UnionClientBuilder().buildStringExtensibleClient(); + private final StringExtensibleNamedClient client3 = new UnionClientBuilder().buildStringExtensibleNamedClient(); + private final IntsOnlyClient client4 = new UnionClientBuilder().buildIntsOnlyClient(); + private final FloatsOnlyClient client5 = new UnionClientBuilder().buildFloatsOnlyClient(); + private final ModelsOnlyClient client6 = new UnionClientBuilder().buildModelsOnlyClient(); + private final EnumsOnlyClient client7 = new UnionClientBuilder().buildEnumsOnlyClient(); + private final StringAndArrayClient client8 = new UnionClientBuilder().buildStringAndArrayClient(); + private final MixedLiteralsClient client9 = new UnionClientBuilder().buildMixedLiteralsClient(); + private final MixedTypesClient client10 = new UnionClientBuilder().buildMixedTypesClient(); + + @Test + public void testStringsOnlyClient() { + GetResponseProp4 prop = client1.get().getProp(); + Assertions.assertEquals(GetResponseProp4.B, prop); + client1.send(prop); + } + + @Test + public void testStringExtensibleClient() { + GetResponseProp3 prop = client2.get().getProp(); + Assertions.assertEquals("custom", prop.toString()); + client2.send(prop); + } + + @Test + public void testStringExtensibleNamedClient() { + StringExtensibleNamedUnion prop = client3.get().getProp(); + Assertions.assertEquals("custom", prop.toString()); + client3.send(prop); + } + + @Test + public void testIntsOnlyClient() { + GetResponseProp2 prop = client4.get().getProp(); + Assertions.assertEquals(2L, prop.toInt()); + client4.send(prop); + } + + @Test + public void testFloatsOnlyClient() { + GetResponseProp1 prop = client5.get().getProp(); + Assertions.assertEquals(2.2, prop.toDouble()); + client5.send(prop); + } + + @Test + public void testModelsOnlyClient() throws IOException { + BinaryData prop = client6.get().getProp(); + Assertions.assertEquals("test", ((Cat) prop.toObject(Cat.class)).getName()); + client6.send(BinaryData.fromObject(new Cat("test"))); + } + + @Test + public void testEnumsOnlyClient() { + EnumsOnlyCases prop = client7.get().getProp(); + Assertions.assertEquals(EnumsOnlyCasesLr.RIGHT, prop.getLr()); + Assertions.assertEquals(EnumsOnlyCasesUd.UP, prop.getUd()); + client7.send(prop); + } + + @Test + public void testStringAndArrayClient() throws IOException { + StringAndArrayCases prop = client8.get().getProp(); + Assertions.assertEquals("test", prop.getString().toObject(String.class)); + Assertions.assertEquals(Arrays.asList("test1", "test2"), prop.getArray().toObject(List.class)); + client8.send(prop); + } + + @Test + public void testMixedLiteralsClient() throws IOException { + MixedLiteralsCases prop = client9.get().getProp(); + Assertions.assertEquals("a", prop.getStringLiteral().toObject(String.class)); + Assertions.assertEquals(2L, Long.valueOf(prop.getIntLiteral().toString())); + Assertions.assertEquals(3.3, prop.getFloatLiteral().toObject(Double.class)); + Assertions.assertEquals(true, prop.getBooleanLiteral().toObject(Boolean.class)); + client9.send(prop); + } + + @Test + public void testMixedTypesClient() throws IOException { + MixedTypesCases prop = client10.get().getProp(); + Assertions.assertEquals("test", ((Cat) prop.getModel().toObject(Cat.class)).getName()); + Assertions.assertEquals("a", prop.getLiteral().toObject(String.class)); + Assertions.assertEquals(2L, Long.valueOf(prop.getIntProperty().toString())); + Assertions.assertEquals(true, prop.getBooleanProperty().toObject(Boolean.class)); + List array = prop.getArray(); + Assertions.assertEquals("test", ((Cat) array.get(0).toObject(Cat.class)).getName()); + Assertions.assertEquals("a", array.get(1).toObject(String.class)); + Assertions.assertEquals(2L, Long.valueOf(array.get(2).toString())); + Assertions.assertEquals(true, array.get(3).toObject(Boolean.class)); + + client10.send(prop); + } +} diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker new file mode 100644 index 0000000000..1f0955d450 --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker @@ -0,0 +1 @@ +mock-maker-inline diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/tspconfig.yaml b/packages/http-client-java/generator/http-client-generator-clientcore-test/tspconfig.yaml new file mode 100644 index 0000000000..9382aacb8c --- /dev/null +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/tspconfig.yaml @@ -0,0 +1,9 @@ +emit: + - "@typespec/http-client-java" +options: + "@typespec/http-client-java": + emitter-output-dir: "{project-root}/tsp-output" + dev-options: + generate-code-model: true + loglevel: info + debug: false diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClassType.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClassType.java index a555b1688d..051da44136 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClassType.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClassType.java @@ -156,6 +156,8 @@ public String getGenericClass() { put(TypeReference.class, new ClassDetails(TypeReference.class, "io.clientcore.core.models.TypeReference")); put(ClientLogger.class, new ClassDetails(ClientLogger.class, "io.clientcore.core.util.ClientLogger")); put(LogLevel.class, new ClassDetails(LogLevel.class, "io.clientcore.core.util.ClientLogger.LogLevel")); + put(com.azure.core.util.ServiceVersion.class, new ClassDetails(com.azure.core.util.ServiceVersion.class, + "io.clientcore.core.http.models.ServiceVersion")); } }; @@ -483,7 +485,7 @@ private static ClassType.Builder getClassTypeBuilder(Class classKey) { public static final ClassType CONFIGURATION = getClassTypeBuilder(Configuration.class).build(); public static final ClassType SERVICE_VERSION - = new ClassType.Builder(false).knownClass(ServiceVersion.class).build(); + = getClassTypeBuilder(com.azure.core.util.ServiceVersion.class).build(); public static final ClassType AZURE_KEY_CREDENTIAL = new ClassType.Builder(false).knownClass(AzureKeyCredential.class).build(); diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ServiceVersionTemplate.java b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ServiceVersionTemplate.java index 316158a012..c9d3f0359e 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ServiceVersionTemplate.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/java/com/microsoft/typespec/http/client/generator/core/template/ServiceVersionTemplate.java @@ -3,6 +3,7 @@ package com.microsoft.typespec.http.client.generator.core.template; +import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ClassType; import com.microsoft.typespec.http.client.generator.core.model.clientmodel.ServiceVersion; import com.microsoft.typespec.http.client.generator.core.model.javamodel.JavaFile; import com.microsoft.typespec.http.client.generator.core.model.javamodel.JavaJavadocComment; @@ -23,7 +24,7 @@ public static ServiceVersionTemplate getInstance() { public void write(ServiceVersion serviceVersion, JavaFile javaFile) { // imports Set imports = new HashSet<>(); - imports.add("com.azure.core.util.ServiceVersion"); + ClassType.SERVICE_VERSION.addImportsTo(imports, false); javaFile.declareImport(imports); javaFile.javadocComment(comment -> { diff --git a/packages/http-client-java/generator/http-client-generator-core/src/main/resources/GenericMultipartFormDataHelper.java b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/GenericMultipartFormDataHelper.java index 9ec8e8d496..7930fa0cb0 100644 --- a/packages/http-client-java/generator/http-client-generator-core/src/main/resources/GenericMultipartFormDataHelper.java +++ b/packages/http-client-java/generator/http-client-generator-core/src/main/resources/GenericMultipartFormDataHelper.java @@ -127,7 +127,7 @@ public MultipartFormDataHelper serializeFileField( String contentType, String filename) { if (file != null) { - if (contentType != null && !contentType.isEmpty()) { + if (contentType == null || contentType.isEmpty()) { contentType = APPLICATION_OCTET_STREAM; } writeFileField(fieldName, file, contentType, filename); @@ -153,7 +153,7 @@ public MultipartFormDataHelper serializeFileFields( for (int i = 0; i < files.size(); ++i) { BinaryData file = files.get(i); String contentType = contentTypes.get(i); - if (contentType != null && !contentType.isEmpty()) { + if (contentType == null || contentType.isEmpty()) { contentType = APPLICATION_OCTET_STREAM; } String filename = filenames.get(i); diff --git a/packages/http-client-java/generator/http-client-generator-test/package.json b/packages/http-client-java/generator/http-client-generator-test/package.json index 22eca56169..11c2ef6b86 100644 --- a/packages/http-client-java/generator/http-client-generator-test/package.json +++ b/packages/http-client-java/generator/http-client-generator-test/package.json @@ -7,8 +7,8 @@ "format": "npm run -s prettier -- --write", "check-format": "npm run prettier -- --check", "prettier": "prettier --config ./.prettierrc.yaml **/*.tsp", - "spector-serve": "tsp-spector serve ./node_modules/@typespec/http-specs/specs ./node_modules/@azure-tools/azure-http-specs/specs --coverageFile ./tsp-spector-coverage-java-standard.json", - "spector-start": "tsp-spector server start ./node_modules/@typespec/http-specs/specs ./node_modules/@azure-tools/azure-http-specs/specs --coverageFile ./tsp-spector-coverage-java-standard.json", + "spector-serve": "tsp-spector serve ./node_modules/@typespec/http-specs/specs ./node_modules/@azure-tools/azure-http-specs/specs --coverageFile ./tsp-spector-coverage-java-azure.json", + "spector-start": "tsp-spector server start ./node_modules/@typespec/http-specs/specs ./node_modules/@azure-tools/azure-http-specs/specs --coverageFile ./tsp-spector-coverage-java-azure.json", "spector-stop": "tsp-spector server stop" }, "dependencies": { diff --git a/packages/http-client-java/generator/pom.xml b/packages/http-client-java/generator/pom.xml index 22c01a7bf0..7e325d0b8a 100644 --- a/packages/http-client-java/generator/pom.xml +++ b/packages/http-client-java/generator/pom.xml @@ -33,6 +33,7 @@ http-client-generator-test + http-client-generator-clientcore-test diff --git a/packages/http-client-java/package-lock.json b/packages/http-client-java/package-lock.json index 362a01be8f..c36436219d 100644 --- a/packages/http-client-java/package-lock.json +++ b/packages/http-client-java/package-lock.json @@ -29,6 +29,7 @@ "@typespec/http": "0.63.0", "@typespec/openapi": "0.63.0", "@typespec/rest": "0.63.0", + "@typespec/spector": "0.1.0-alpha.5", "@typespec/versioning": "0.63.0", "@vitest/coverage-v8": "^2.1.8", "@vitest/ui": "^2.1.8", @@ -205,6 +206,328 @@ "@typespec/versioning": "~0.63.0" } }, + "node_modules/@azure/abort-controller": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.1.0.tgz", + "integrity": "sha512-TrRLIoSQVzfAJX9H1JeFjzAoDGcoK1IYX1UImfceTZpsyYfWr09Ss1aHW1y5TrrR3iq6RZLBwJ3E24uwPhwahw==", + "dev": true, + "dependencies": { + "tslib": "^2.2.0" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@azure/core-auth": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@azure/core-auth/-/core-auth-1.9.0.tgz", + "integrity": "sha512-FPwHpZywuyasDSLMqJ6fhbOK3TqUdviZNF8OqRGA4W5Ewib2lEEZ+pBsYcBa88B2NGO/SEnYPGhyBqNlE8ilSw==", + "dev": true, + "dependencies": { + "@azure/abort-controller": "^2.0.0", + "@azure/core-util": "^1.11.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-auth/node_modules/@azure/abort-controller": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", + "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", + "dev": true, + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-client": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/@azure/core-client/-/core-client-1.9.2.tgz", + "integrity": "sha512-kRdry/rav3fUKHl/aDLd/pDLcB+4pOFwPPTVEExuMyaI5r+JBbMWqRbCY1pn5BniDaU3lRxO9eaQ1AmSMehl/w==", + "dev": true, + "dependencies": { + "@azure/abort-controller": "^2.0.0", + "@azure/core-auth": "^1.4.0", + "@azure/core-rest-pipeline": "^1.9.1", + "@azure/core-tracing": "^1.0.0", + "@azure/core-util": "^1.6.1", + "@azure/logger": "^1.0.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-client/node_modules/@azure/abort-controller": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", + "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", + "dev": true, + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-http-compat": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@azure/core-http-compat/-/core-http-compat-2.1.2.tgz", + "integrity": "sha512-5MnV1yqzZwgNLLjlizsU3QqOeQChkIXw781Fwh1xdAqJR5AA32IUaq6xv1BICJvfbHoa+JYcaij2HFkhLbNTJQ==", + "dev": true, + "dependencies": { + "@azure/abort-controller": "^2.0.0", + "@azure/core-client": "^1.3.0", + "@azure/core-rest-pipeline": "^1.3.0" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-http-compat/node_modules/@azure/abort-controller": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", + "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", + "dev": true, + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-lro": { + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.7.2.tgz", + "integrity": "sha512-0YIpccoX8m/k00O7mDDMdJpbr6mf1yWo2dfmxt5A8XVZVVMz2SSKaEbMCeJRvgQ0IaSlqhjT47p4hVIRRy90xw==", + "dev": true, + "dependencies": { + "@azure/abort-controller": "^2.0.0", + "@azure/core-util": "^1.2.0", + "@azure/logger": "^1.0.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-lro/node_modules/@azure/abort-controller": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", + "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", + "dev": true, + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-paging": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/@azure/core-paging/-/core-paging-1.6.2.tgz", + "integrity": "sha512-YKWi9YuCU04B55h25cnOYZHxXYtEvQEbKST5vqRga7hWY9ydd3FZHdeQF8pyh+acWZvppw13M/LMGx0LABUVMA==", + "dev": true, + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-rest-pipeline": { + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/@azure/core-rest-pipeline/-/core-rest-pipeline-1.18.1.tgz", + "integrity": "sha512-/wS73UEDrxroUEVywEm7J0p2c+IIiVxyfigCGfsKvCxxCET4V/Hef2aURqltrXMRjNmdmt5IuOgIpl8f6xdO5A==", + "dev": true, + "dependencies": { + "@azure/abort-controller": "^2.0.0", + "@azure/core-auth": "^1.8.0", + "@azure/core-tracing": "^1.0.1", + "@azure/core-util": "^1.11.0", + "@azure/logger": "^1.0.0", + "http-proxy-agent": "^7.0.0", + "https-proxy-agent": "^7.0.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-rest-pipeline/node_modules/@azure/abort-controller": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", + "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", + "dev": true, + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-tracing": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@azure/core-tracing/-/core-tracing-1.2.0.tgz", + "integrity": "sha512-UKTiEJPkWcESPYJz3X5uKRYyOcJD+4nYph+KpfdPRnQJVrZfk0KJgdnaAWKfhsBBtAf/D58Az4AvCJEmWgIBAg==", + "dev": true, + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-util": { + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.11.0.tgz", + "integrity": "sha512-DxOSLua+NdpWoSqULhjDyAZTXFdP/LKkqtYuxxz1SCN289zk3OG8UOpnCQAz/tygyACBtWp/BoO72ptK7msY8g==", + "dev": true, + "dependencies": { + "@azure/abort-controller": "^2.0.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-util/node_modules/@azure/abort-controller": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", + "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", + "dev": true, + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/core-xml": { + "version": "1.4.4", + "resolved": "https://registry.npmjs.org/@azure/core-xml/-/core-xml-1.4.4.tgz", + "integrity": "sha512-J4FYAqakGXcbfeZjwjMzjNcpcH4E+JtEBv+xcV1yL0Ydn/6wbQfeFKTCHh9wttAi0lmajHw7yBbHPRG+YHckZQ==", + "dev": true, + "dependencies": { + "fast-xml-parser": "^4.4.1", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/identity": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/@azure/identity/-/identity-4.4.1.tgz", + "integrity": "sha512-DwnG4cKFEM7S3T+9u05NstXU/HN0dk45kPOinUyNKsn5VWwpXd9sbPKEg6kgJzGbm1lMuhx9o31PVbCtM5sfBA==", + "dev": true, + "dependencies": { + "@azure/abort-controller": "^1.0.0", + "@azure/core-auth": "^1.5.0", + "@azure/core-client": "^1.9.2", + "@azure/core-rest-pipeline": "^1.1.0", + "@azure/core-tracing": "^1.0.0", + "@azure/core-util": "^1.3.0", + "@azure/logger": "^1.0.0", + "@azure/msal-browser": "^3.14.0", + "@azure/msal-node": "^2.9.2", + "events": "^3.0.0", + "jws": "^4.0.0", + "open": "^8.0.0", + "stoppable": "^1.1.0", + "tslib": "^2.2.0" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/logger": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.1.4.tgz", + "integrity": "sha512-4IXXzcCdLdlXuCG+8UKEwLA1T1NHqUfanhXYHiQTn+6sfWCZXduqbtXDGceg3Ce5QxTGo7EqmbV6Bi+aqKuClQ==", + "dev": true, + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/msal-browser": { + "version": "3.28.0", + "resolved": "https://registry.npmjs.org/@azure/msal-browser/-/msal-browser-3.28.0.tgz", + "integrity": "sha512-1c1qUF6vB52mWlyoMem4xR1gdwiQWYEQB2uhDkbAL4wVJr8WmAcXybc1Qs33y19N4BdPI8/DHI7rPE8L5jMtWw==", + "dev": true, + "dependencies": { + "@azure/msal-common": "14.16.0" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@azure/msal-common": { + "version": "14.16.0", + "resolved": "https://registry.npmjs.org/@azure/msal-common/-/msal-common-14.16.0.tgz", + "integrity": "sha512-1KOZj9IpcDSwpNiQNjt0jDYZpQvNZay7QAEi/5DLubay40iGYtLzya/jbjRPLyOTZhEKyL1MzPuw2HqBCjceYA==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@azure/msal-node": { + "version": "2.16.2", + "resolved": "https://registry.npmjs.org/@azure/msal-node/-/msal-node-2.16.2.tgz", + "integrity": "sha512-An7l1hEr0w1HMMh1LU+rtDtqL7/jw74ORlc9Wnh06v7TU/xpG39/Zdr1ZJu3QpjUfKJ+E0/OXMW8DRSWTlh7qQ==", + "dev": true, + "dependencies": { + "@azure/msal-common": "14.16.0", + "jsonwebtoken": "^9.0.0", + "uuid": "^8.3.0" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/@azure/storage-blob": { + "version": "12.25.0", + "resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-12.25.0.tgz", + "integrity": "sha512-oodouhA3nCCIh843tMMbxty3WqfNT+Vgzj3Xo5jqR9UPnzq3d7mzLjlHAYz7lW+b4km3SIgz+NAgztvhm7Z6kQ==", + "dev": true, + "dependencies": { + "@azure/abort-controller": "^2.1.2", + "@azure/core-auth": "^1.4.0", + "@azure/core-client": "^1.6.2", + "@azure/core-http-compat": "^2.0.0", + "@azure/core-lro": "^2.2.0", + "@azure/core-paging": "^1.1.1", + "@azure/core-rest-pipeline": "^1.10.1", + "@azure/core-tracing": "^1.1.2", + "@azure/core-util": "^1.6.1", + "@azure/core-xml": "^1.4.3", + "@azure/logger": "^1.0.0", + "events": "^3.0.0", + "tslib": "^2.2.0" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@azure/storage-blob/node_modules/@azure/abort-controller": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-2.1.2.tgz", + "integrity": "sha512-nBrLsEWm4J2u5LpAPjxADTlq3trDgVZZXHNKabeXZtpq3d3AbN/KGO82R87rdDz5/lYB024rtEf10/q0urNgsA==", + "dev": true, + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/@babel/code-frame": { "version": "7.25.9", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.25.9.tgz", @@ -285,6 +608,26 @@ "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", "dev": true }, + "node_modules/@colors/colors": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz", + "integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==", + "dev": true, + "engines": { + "node": ">=0.1.90" + } + }, + "node_modules/@dabh/diagnostics": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.3.tgz", + "integrity": "sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA==", + "dev": true, + "dependencies": { + "colorspace": "1.1.x", + "enabled": "2.0.x", + "kuler": "^2.0.0" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", @@ -1466,6 +1809,12 @@ "undici-types": "~6.20.0" } }, + "node_modules/@types/triple-beam": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.5.tgz", + "integrity": "sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==", + "dev": true + }, "node_modules/@typespec/compiler": { "version": "0.63.0", "resolved": "https://registry.npmjs.org/@typespec/compiler/-/compiler-0.63.0.tgz", @@ -1561,6 +1910,113 @@ "@typespec/http": "~0.63.0" } }, + "node_modules/@typespec/spec-api": { + "version": "0.1.0-alpha.0", + "resolved": "https://registry.npmjs.org/@typespec/spec-api/-/spec-api-0.1.0-alpha.0.tgz", + "integrity": "sha512-SgWSt5mnl9bbc+C9toMzh4i8RESWcAfMg/Wyq+3oY+0EcKlmDYNWgDhQi/Eh8bA4zyMoymj48hcEzD97E1ERtQ==", + "dev": true, + "dependencies": { + "body-parser": "^1.20.3", + "deep-equal": "^2.2.0", + "express": "^4.21.1", + "express-promise-router": "^4.1.1", + "morgan": "^1.10.0", + "multer": "^1.4.5-lts.1", + "picocolors": "~1.1.0", + "prettier": "~3.3.3", + "winston": "^3.15.0", + "xml2js": "^0.6.2", + "yargs": "~17.7.2" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@typespec/spec-coverage-sdk": { + "version": "0.1.0-alpha.2", + "resolved": "https://registry.npmjs.org/@typespec/spec-coverage-sdk/-/spec-coverage-sdk-0.1.0-alpha.2.tgz", + "integrity": "sha512-bdU5K6jZ12+wEH4b7I7aiytIJu2M+tAigoxxc9Tz7UrucbA5PZqgO+uFoqMKRYcmNjwC4EmvEIVmyzNEKUzUmA==", + "dev": true, + "dependencies": { + "@azure/identity": "~4.4.1", + "@azure/storage-blob": "~12.25.0", + "@types/node": "~22.7.9" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@typespec/spec-coverage-sdk/node_modules/@types/node": { + "version": "22.7.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.9.tgz", + "integrity": "sha512-jrTfRC7FM6nChvU7X2KqcrgquofrWLFDeYC1hKfwNWomVvrn7JIksqf344WN2X/y8xrgqBd2dJATZV4GbatBfg==", + "dev": true, + "dependencies": { + "undici-types": "~6.19.2" + } + }, + "node_modules/@typespec/spec-coverage-sdk/node_modules/undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "dev": true + }, + "node_modules/@typespec/spector": { + "version": "0.1.0-alpha.5", + "resolved": "https://registry.npmjs.org/@typespec/spector/-/spector-0.1.0-alpha.5.tgz", + "integrity": "sha512-HV6fZkQFy/0IrPiySyCzYraESlWsNhp04Azf9Ss6a63Bjkw6ZQoxz4YvzH4fLvlmo1zFPxOYFXul+JZZw81TtQ==", + "dev": true, + "dependencies": { + "@azure/identity": "~4.4.1", + "@types/js-yaml": "^4.0.5", + "@typespec/compiler": "~0.63.0", + "@typespec/http": "~0.63.0", + "@typespec/rest": "~0.63.0", + "@typespec/spec-api": "~0.1.0-alpha.0", + "@typespec/spec-coverage-sdk": "~0.1.0-alpha.2", + "@typespec/versioning": "~0.63.0", + "ajv": "~8.17.1", + "axios": "^1.7.5", + "body-parser": "^1.20.3", + "deep-equal": "^2.2.0", + "express": "^4.21.1", + "express-promise-router": "^4.1.1", + "form-data": "^4.0.1", + "globby": "~14.0.2", + "jackspeak": "4.0.2", + "js-yaml": "^4.1.0", + "morgan": "^1.10.0", + "multer": "^1.4.5-lts.1", + "node-fetch": "^3.3.1", + "picocolors": "~1.1.1", + "source-map-support": "~0.5.21", + "winston": "^3.15.0", + "xml2js": "^0.6.2", + "yargs": "~17.7.2" + }, + "bin": { + "tsp-spector": "cmd/cli.mjs" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@typespec/spector/node_modules/ajv": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", + "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.3", + "fast-uri": "^3.0.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, "node_modules/@typespec/versioning": { "version": "0.63.0", "resolved": "https://registry.npmjs.org/@typespec/versioning/-/versioning-0.63.0.tgz", @@ -1755,6 +2211,28 @@ "url": "https://opencollective.com/vitest" } }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "dev": true, + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/agent-base": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz", + "integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==", + "dev": true, + "engines": { + "node": ">= 14" + } + }, "node_modules/ajv": { "version": "8.12.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.12.0.tgz", @@ -1824,11 +2302,39 @@ "node": ">=4" } }, + "node_modules/append-field": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz", + "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==", + "dev": true + }, "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" }, + "node_modules/array-buffer-byte-length": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.2.tgz", + "integrity": "sha512-LHE+8BuR7RYGDKvnrmcuSq3tDcKv9OFEXQt/HpbZhY7V6h0zlUXutnAD82GiFx9rdieCMjkvtcsPqBwgUl1Iiw==", + "dev": true, + "dependencies": { + "call-bound": "^1.0.3", + "is-array-buffer": "^3.0.5" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", + "dev": true + }, "node_modules/assertion-error": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", @@ -1839,13 +2345,108 @@ "node": ">=12" } }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "node_modules/async": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", + "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", "dev": true }, - "node_modules/brace-expansion": { + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true + }, + "node_modules/available-typed-arrays": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", + "integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==", + "dev": true, + "dependencies": { + "possible-typed-array-names": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/axios": { + "version": "1.7.9", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", + "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", + "dev": true, + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/basic-auth": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", + "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", + "dev": true, + "dependencies": { + "safe-buffer": "5.1.2" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/basic-auth/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "node_modules/body-parser": { + "version": "1.20.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", + "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", + "dev": true, + "dependencies": { + "bytes": "3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.13.0", + "raw-body": "2.5.2", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/body-parser/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/body-parser/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + }, + "node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", @@ -1865,6 +2466,39 @@ "node": ">=8" } }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "dev": true + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, + "node_modules/busboy": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", + "dev": true, + "dependencies": { + "streamsearch": "^1.1.0" + }, + "engines": { + "node": ">=10.16.0" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/c8": { "version": "10.1.3", "resolved": "https://registry.npmjs.org/c8/-/c8-10.1.3.tgz", @@ -1919,6 +2553,53 @@ "node": ">=8" } }, + "node_modules/call-bind": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz", + "integrity": "sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==", + "dev": true, + "dependencies": { + "call-bind-apply-helpers": "^1.0.0", + "es-define-property": "^1.0.0", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.1.tgz", + "integrity": "sha512-BhYE+WDaywFg2TBWYNXAE+8B1ATnThNBqXHP5nQu0jWJdVvY2hvkpyB3qOmtmDePiS5/BDQ8wASEWGMWRG148g==", + "dev": true, + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.3.tgz", + "integrity": "sha512-YTd+6wGlNlPxSuri7Y6X8tY2dmm12UMH66RpKMhiX6rsk5wXXnYgbUcOt8kiS31/AjfoTOvCsE+w8nZQLQnzHA==", + "dev": true, + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/chai": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/chai/-/chai-5.1.2.tgz", @@ -1977,6 +2658,16 @@ "node": ">=12" } }, + "node_modules/color": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/color/-/color-3.2.1.tgz", + "integrity": "sha512-aBl7dZI9ENN6fUGC7mWpMTPNHmWUSNan9tuWN6ahh5ZLNk9baLJOnSMlrQkHcrfFgz2/RigjUVAjdx36VcemKA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.3", + "color-string": "^1.6.0" + } + }, "node_modules/color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", @@ -1990,18 +2681,107 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" }, + "node_modules/color-string": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-string/-/color-string-1.9.1.tgz", + "integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==", + "dev": true, + "dependencies": { + "color-name": "^1.0.0", + "simple-swizzle": "^0.2.2" + } + }, + "node_modules/colorspace": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/colorspace/-/colorspace-1.1.4.tgz", + "integrity": "sha512-BgvKJiuVu1igBUF2kEjRCZXol6wiiGbY5ipL/oVPwm0BL9sIpMIzM8IK7vwuxIIzOXMV3Ey5w+vxhm0rR/TN8w==", + "dev": true, + "dependencies": { + "color": "^3.1.3", + "text-hex": "1.0.x" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, + "node_modules/concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "engines": [ + "node >= 0.8" + ], + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "dev": true, + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/convert-source-map": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", "dev": true }, + "node_modules/cookie": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz", + "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==", + "dev": true + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", @@ -2016,6 +2796,15 @@ "node": ">= 8" } }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "dev": true, + "engines": { + "node": ">= 12" + } + }, "node_modules/debug": { "version": "4.3.7", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", @@ -2043,17 +2832,202 @@ "node": ">=6" } }, + "node_modules/deep-equal": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-2.2.3.tgz", + "integrity": "sha512-ZIwpnevOurS8bpT4192sqAowWM76JDKSHYzMLty3BZGSswgq6pBaH3DhCSW5xVAZICZyKdOBPjwww5wfgT/6PA==", + "dev": true, + "dependencies": { + "array-buffer-byte-length": "^1.0.0", + "call-bind": "^1.0.5", + "es-get-iterator": "^1.1.3", + "get-intrinsic": "^1.2.2", + "is-arguments": "^1.1.1", + "is-array-buffer": "^3.0.2", + "is-date-object": "^1.0.5", + "is-regex": "^1.1.4", + "is-shared-array-buffer": "^1.0.2", + "isarray": "^2.0.5", + "object-is": "^1.1.5", + "object-keys": "^1.1.1", + "object.assign": "^4.1.4", + "regexp.prototype.flags": "^1.5.1", + "side-channel": "^1.0.4", + "which-boxed-primitive": "^1.0.2", + "which-collection": "^1.0.1", + "which-typed-array": "^1.1.13" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dev": true, + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/define-lazy-prop": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", + "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "dev": true, + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "dev": true, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "dev": true, + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", "dev": true }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "dev": true, + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "dev": true + }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, + "node_modules/enabled": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/enabled/-/enabled-2.0.0.tgz", + "integrity": "sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ==", + "dev": true + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-get-iterator": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.3.tgz", + "integrity": "sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.3", + "has-symbols": "^1.0.3", + "is-arguments": "^1.1.1", + "is-map": "^2.0.2", + "is-set": "^2.0.2", + "is-string": "^1.0.7", + "isarray": "^2.0.5", + "stop-iteration-iterator": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/es-module-lexer": { "version": "1.5.4", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.5.4.tgz", @@ -2061,6 +3035,18 @@ "dev": true, "license": "MIT" }, + "node_modules/es-object-atoms": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.0.0.tgz", + "integrity": "sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==", + "dev": true, + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/esbuild": { "version": "0.21.5", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", @@ -2108,6 +3094,12 @@ "node": ">=6" } }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "dev": true + }, "node_modules/escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -2126,16 +3118,118 @@ "@types/estree": "^1.0.0" } }, - "node_modules/expect-type": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.1.0.tgz", - "integrity": "sha512-bFi65yM+xZgk+u/KRIpekdSYkTB5W1pEf0Lt8Q8Msh7b+eQ7LXVtIB1Bkm4fvclDEL1b2CZkMhv2mOeF8tMdkA==", + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", "dev": true, - "license": "Apache-2.0", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "dev": true, + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/expect-type": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.1.0.tgz", + "integrity": "sha512-bFi65yM+xZgk+u/KRIpekdSYkTB5W1pEf0Lt8Q8Msh7b+eQ7LXVtIB1Bkm4fvclDEL1b2CZkMhv2mOeF8tMdkA==", + "dev": true, + "license": "Apache-2.0", "engines": { "node": ">=12.0.0" } }, + "node_modules/express": { + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz", + "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==", + "dev": true, + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.3", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.7.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.3.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.3", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.12", + "proxy-addr": "~2.0.7", + "qs": "6.13.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.19.0", + "serve-static": "1.16.2", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/express-promise-router": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/express-promise-router/-/express-promise-router-4.1.1.tgz", + "integrity": "sha512-Lkvcy/ZGrBhzkl3y7uYBHLMtLI4D6XQ2kiFg9dq7fbktBch5gjqJ0+KovX0cvCAvTJw92raWunRLM/OM+5l4fA==", + "dev": true, + "dependencies": { + "is-promise": "^4.0.0", + "lodash.flattendeep": "^4.0.0", + "methods": "^1.0.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@types/express": "^4.0.0", + "express": "^4.0.0" + }, + "peerDependenciesMeta": { + "@types/express": { + "optional": true + } + } + }, + "node_modules/express/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/express/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -2172,6 +3266,28 @@ "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.1.tgz", "integrity": "sha512-MWipKbbYiYI0UC7cl8m/i/IWTqfC8YXsqjzybjddLsFjStroQzsHXkc73JutMvBiXmOvapk+axIl79ig5t55Bw==" }, + "node_modules/fast-xml-parser": { + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.5.1.tgz", + "integrity": "sha512-y655CeyUQ+jj7KBbYMc4FG01V8ZQqjN+gDYGJ50RtfsUB8iG9AmwmwoAgeKLJdmueKKMrH1RJ7yXHTSoczdv5w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + }, + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + } + ], + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, "node_modules/fastq": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", @@ -2180,6 +3296,35 @@ "reusify": "^1.0.4" } }, + "node_modules/fecha": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.3.tgz", + "integrity": "sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw==", + "dev": true + }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, "node_modules/fflate": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.2.tgz", @@ -2198,6 +3343,39 @@ "node": ">=8" } }, + "node_modules/finalhandler": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", + "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", + "dev": true, + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/finalhandler/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/finalhandler/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + }, "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", @@ -2221,6 +3399,41 @@ "dev": true, "license": "ISC" }, + "node_modules/fn.name": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz", + "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==", + "dev": true + }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/for-each": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", + "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "dev": true, + "dependencies": { + "is-callable": "^1.1.3" + } + }, "node_modules/foreground-child": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.2.1.tgz", @@ -2237,6 +3450,50 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/form-data": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", + "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "dev": true, + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/fs-extra": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", @@ -2276,6 +3533,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -2284,6 +3550,43 @@ "node": "6.* || 8.* || >= 10.*" } }, + "node_modules/get-intrinsic": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.7.tgz", + "integrity": "sha512-VW6Pxhsrk0KAOqs3WEd0klDiF/+V7gQOpAvY1jVU/LHmaD/kQO4523aiJuikX/QAKYiW6x8Jh+RJej1almdtCA==", + "dev": true, + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0", + "function-bind": "^1.1.2", + "get-proto": "^1.0.0", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "dev": true, + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/glob": { "version": "11.0.0", "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.0.tgz", @@ -2301,88 +3604,489 @@ "glob": "dist/esm/bin.mjs" }, "engines": { - "node": "20 || >=22" + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/globby": { + "version": "14.0.2", + "resolved": "https://registry.npmjs.org/globby/-/globby-14.0.2.tgz", + "integrity": "sha512-s3Fq41ZVh7vbbe2PN3nrW7yC7U7MFVc5c98/iTl9c2GawNMKx/J648KQRW6WKkuU8GIbbh2IXfIRQjOZnXcTnw==", + "license": "MIT", + "dependencies": { + "@sindresorhus/merge-streams": "^2.1.0", + "fast-glob": "^3.3.2", + "ignore": "^5.2.4", + "path-type": "^5.0.0", + "slash": "^5.1.0", + "unicorn-magic": "^0.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" + }, + "node_modules/has-bigints": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.1.0.tgz", + "integrity": "sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "engines": { + "node": ">=4" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dev": true, + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "dev": true, + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "node_modules/http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "dev": true, + "dependencies": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/http-proxy-agent": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz", + "integrity": "sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig==", + "dev": true, + "dependencies": { + "agent-base": "^7.1.0", + "debug": "^4.3.4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/https-proxy-agent": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "dev": true, + "dependencies": { + "agent-base": "^7.1.2", + "debug": "4" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "dev": true, + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/ignore": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-lazy": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-4.0.0.tgz", + "integrity": "sha512-rKtvo6a868b5Hu3heneU+L4yEQ4jYKLtjpnPeUdK7h0yzXGmyBTypknlkCvHFBqfX9YlorEiMM6Dnq/5atfHkw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/internal-slot": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.1.0.tgz", + "integrity": "sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw==", + "dev": true, + "dependencies": { + "es-errors": "^1.3.0", + "hasown": "^2.0.2", + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "dev": true, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-arguments": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.2.0.tgz", + "integrity": "sha512-7bVbi0huj/wrIAOzb8U1aszg9kdi3KN/CyU19CTI7tAoZYEZoL9yCDXpbXN+uPsuWnP02cyug1gleqq+TU+YCA==", + "dev": true, + "dependencies": { + "call-bound": "^1.0.2", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-array-buffer": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz", + "integrity": "sha512-DDfANUiiG2wC1qawP66qlTugJeL5HyzMpfr8lLK+jMQirGzNod0B12cFB/9q838Ru27sBwfw78/rdoU7RERz6A==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-arrayish": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.3.2.tgz", + "integrity": "sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==", + "dev": true + }, + "node_modules/is-bigint": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.1.0.tgz", + "integrity": "sha512-n4ZT37wG78iz03xPRKJrHTdZbe3IicyucEtdRsV5yglwc3GyUfbAfpSeD0FJ41NbUNSt5wbhqfp1fS+BgnvDFQ==", + "dev": true, + "dependencies": { + "has-bigints": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-boolean-object": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.2.1.tgz", + "integrity": "sha512-l9qO6eFlUETHtuihLcYOaLKByJ1f+N4kthcU9YjHy3N+B3hWv0y/2Nd0mu/7lTFnRQHTrSdXF50HQ3bl5fEnng==", + "dev": true, + "dependencies": { + "call-bound": "^1.0.2", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-core-module": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.0.tgz", + "integrity": "sha512-Dd+Lb2/zvk9SKy1TGCt1wFJFo/MWBPMX5x7KcvLajWTGuomczdQX61PvY5yK6SVACwpoexWo81IfFyoKY2QnTA==", + "dev": true, + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-date-object": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.1.0.tgz", + "integrity": "sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg==", + "dev": true, + "dependencies": { + "call-bound": "^1.0.2", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-map": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.3.tgz", + "integrity": "sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-number-object": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.1.1.tgz", + "integrity": "sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw==", + "dev": true, + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" }, "funding": { - "url": "https://github.com/sponsors/isaacs" + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/globby": { - "version": "14.0.2", - "resolved": "https://registry.npmjs.org/globby/-/globby-14.0.2.tgz", - "integrity": "sha512-s3Fq41ZVh7vbbe2PN3nrW7yC7U7MFVc5c98/iTl9c2GawNMKx/J648KQRW6WKkuU8GIbbh2IXfIRQjOZnXcTnw==", - "license": "MIT", + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "dev": true + }, + "node_modules/is-regex": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", + "integrity": "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==", + "dev": true, "dependencies": { - "@sindresorhus/merge-streams": "^2.1.0", - "fast-glob": "^3.3.2", - "ignore": "^5.2.4", - "path-type": "^5.0.0", - "slash": "^5.1.0", - "unicorn-magic": "^0.1.0" + "call-bound": "^1.0.2", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" }, "engines": { - "node": ">=18" + "node": ">= 0.4" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/graceful-fs": { - "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" - }, - "node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "node_modules/is-set": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.3.tgz", + "integrity": "sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg==", + "dev": true, "engines": { - "node": ">=4" + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "node_modules/is-shared-array-buffer": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.4.tgz", + "integrity": "sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A==", "dev": true, "dependencies": { - "function-bind": "^1.1.2" + "call-bound": "^1.0.3" }, "engines": { "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/html-escaper": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", - "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", - "dev": true - }, - "node_modules/ignore": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", - "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", - "engines": { - "node": ">= 4" - } - }, - "node_modules/import-lazy": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-4.0.0.tgz", - "integrity": "sha512-rKtvo6a868b5Hu3heneU+L4yEQ4jYKLtjpnPeUdK7h0yzXGmyBTypknlkCvHFBqfX9YlorEiMM6Dnq/5atfHkw==", + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", "dev": true, - "license": "MIT", "engines": { "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/is-core-module": { - "version": "2.15.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.15.0.tgz", - "integrity": "sha512-Dd+Lb2/zvk9SKy1TGCt1wFJFo/MWBPMX5x7KcvLajWTGuomczdQX61PvY5yK6SVACwpoexWo81IfFyoKY2QnTA==", + "node_modules/is-string": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.1.1.tgz", + "integrity": "sha512-BtEeSsoaQjlSPBemMQIrY1MY0uM6vnS1g5fmufYOtnxLGUZM2178PKbhsk7Ffv58IX+ZtcvoGwccYsh0PglkAA==", "dev": true, "dependencies": { - "hasown": "^2.0.2" + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" }, "engines": { "node": ">= 0.4" @@ -2391,41 +4095,69 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "node_modules/is-symbol": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.1.1.tgz", + "integrity": "sha512-9gGx6GTtCQM73BgmHQXfDmLtfjjTUDSyoxTCbp5WtoixAhfgsDirWIcVQ/IHpvI5Vgd5i/J5F7B9cN/WlVbC/w==", + "dev": true, + "dependencies": { + "call-bound": "^1.0.2", + "has-symbols": "^1.1.0", + "safe-regex-test": "^1.1.0" + }, "engines": { - "node": ">=0.10.0" + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "node_modules/is-weakmap": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.2.tgz", + "integrity": "sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==", + "dev": true, "engines": { - "node": ">=8" + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "node_modules/is-weakset": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.4.tgz", + "integrity": "sha512-mfcwb6IzQyOKTs84CQMrOwW4gQcaTOAWJ0zzJCl2WSPDrWk/OzDaImWFH3djXhb24g4eudZfLRozAvPGw4d9hQ==", + "dev": true, "dependencies": { - "is-extglob": "^2.1.1" + "call-bound": "^1.0.3", + "get-intrinsic": "^1.2.6" }, "engines": { - "node": ">=0.10.0" + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "dependencies": { + "is-docker": "^2.0.0" + }, "engines": { - "node": ">=0.12.0" + "node": ">=8" } }, + "node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "dev": true + }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -2504,9 +4236,9 @@ } }, "node_modules/jackspeak": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.1.tgz", - "integrity": "sha512-cub8rahkh0Q/bw1+GxP7aeSe29hHHn2V4m29nnDlvCdlgU+3UGxkZp7Z53jLUdpX3jdTO0nJZUDl3xvbWc2Xog==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.2.tgz", + "integrity": "sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw==", "dev": true, "dependencies": { "@isaacs/cliui": "^8.0.2" @@ -2516,9 +4248,6 @@ }, "funding": { "url": "https://github.com/sponsors/isaacs" - }, - "optionalDependencies": { - "@pkgjs/parseargs": "^0.11.0" } }, "node_modules/jju": { @@ -2559,6 +4288,70 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/jsonwebtoken": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", + "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", + "dev": true, + "dependencies": { + "jws": "^3.2.2", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, + "node_modules/jsonwebtoken/node_modules/jwa": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "dev": true, + "dependencies": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jsonwebtoken/node_modules/jws": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "dev": true, + "dependencies": { + "jwa": "^1.4.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jwa": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.0.tgz", + "integrity": "sha512-jrZ2Qx916EA+fq9cEAeCROWPTfCwi1IVHqT2tapuqLEVVDKFDENFw1oL+MwrTvH6msKxsd1YTDVw6uKEcsrLEA==", + "dev": true, + "dependencies": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.0.tgz", + "integrity": "sha512-KDncfTmOZoOMTFG4mBlG0qUIOlc03fmzH+ru6RgYVZhPkyiy/92Owlt/8UEN+a4TXR1FQetfIpJE8ApdvdVxTg==", + "dev": true, + "dependencies": { + "jwa": "^2.0.0", + "safe-buffer": "^5.0.1" + } + }, "node_modules/kleur": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", @@ -2567,6 +4360,12 @@ "node": ">=6" } }, + "node_modules/kuler": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz", + "integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A==", + "dev": true + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -2587,6 +4386,71 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "node_modules/lodash.flattendeep": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", + "integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==", + "dev": true + }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", + "dev": true + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", + "dev": true + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", + "dev": true + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", + "dev": true + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "dev": true + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "dev": true + }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", + "dev": true + }, + "node_modules/logform": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/logform/-/logform-2.7.0.tgz", + "integrity": "sha512-TFYA4jnP7PVbmlBIfhlSe+WKxs9dklXMTEGcBCIvLhE/Tn3H6Gk1norupVW7m5Cnd4bLcr08AytbyV/xj7f/kQ==", + "dev": true, + "dependencies": { + "@colors/colors": "1.6.0", + "@types/triple-beam": "^1.3.2", + "fecha": "^4.2.0", + "ms": "^2.1.1", + "safe-stable-stringify": "^2.3.1", + "triple-beam": "^1.3.0" + }, + "engines": { + "node": ">= 12.0.0" + } + }, "node_modules/loupe": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.2.tgz", @@ -2640,6 +4504,33 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -2648,6 +4539,15 @@ "node": ">= 8" } }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/micromatch": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", @@ -2660,6 +4560,39 @@ "node": ">=8.6" } }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "dev": true, + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/minimatch": { "version": "10.0.1", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz", @@ -2675,13 +4608,77 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/minimist": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", + "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/minipass": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", "dev": true, "engines": { - "node": ">=16 || 14 >=14.17" + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/mkdirp": { + "version": "0.5.6", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", + "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", + "dev": true, + "dependencies": { + "minimist": "^1.2.6" + }, + "bin": { + "mkdirp": "bin/cmd.js" + } + }, + "node_modules/morgan": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz", + "integrity": "sha512-AbegBVI4sh6El+1gNwvD5YIck7nSA36weD7xvIxG4in80j/UoK8AEGaWnnz8v1GxonMCltmlNs5ZKbGvl9b1XQ==", + "dev": true, + "dependencies": { + "basic-auth": "~2.0.1", + "debug": "2.6.9", + "depd": "~2.0.0", + "on-finished": "~2.3.0", + "on-headers": "~1.0.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/morgan/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/morgan/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + }, + "node_modules/morgan/node_modules/on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==", + "dev": true, + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" } }, "node_modules/mrmime": { @@ -2700,6 +4697,24 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "node_modules/multer": { + "version": "1.4.5-lts.1", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.1.tgz", + "integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==", + "dev": true, + "dependencies": { + "append-field": "^1.0.0", + "busboy": "^1.0.0", + "concat-stream": "^1.5.2", + "mkdirp": "^0.5.4", + "object-assign": "^4.1.1", + "type-is": "^1.6.4", + "xtend": "^4.0.0" + }, + "engines": { + "node": ">= 6.0.0" + } + }, "node_modules/mustache": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", @@ -2727,6 +4742,165 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node-domexception": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", + "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "github", + "url": "https://paypal.me/jimmywarting" + } + ], + "engines": { + "node": ">=10.5.0" + } + }, + "node_modules/node-fetch": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "dev": true, + "dependencies": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.3.tgz", + "integrity": "sha512-kDCGIbxkDSXE3euJZZXzc6to7fCrKHNI/hSRQnRuQ+BWjFNzZwiFF8fj/6o2t2G9/jTj8PSIYTfCLelLZEeRpA==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-is": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.6.tgz", + "integrity": "sha512-F8cZ+KfGlSGi09lJT7/Nd6KJZ9ygtvYC0/UYYLI9nmQKLMnydpB9yvbv9K1uSkEu7FU9vYPmVwLg328tX+ot3Q==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.assign": { + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.7.tgz", + "integrity": "sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0", + "has-symbols": "^1.1.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "dev": true, + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/on-headers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", + "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/one-time": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/one-time/-/one-time-1.0.0.tgz", + "integrity": "sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g==", + "dev": true, + "dependencies": { + "fn.name": "1.x.x" + } + }, + "node_modules/open": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-8.4.2.tgz", + "integrity": "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==", + "dev": true, + "dependencies": { + "define-lazy-prop": "^2.0.0", + "is-docker": "^2.1.1", + "is-wsl": "^2.2.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -2763,6 +4937,15 @@ "integrity": "sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==", "dev": true }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -2803,6 +4986,12 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/path-to-regexp": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", + "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", + "dev": true + }, "node_modules/path-type": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-5.0.0.tgz", @@ -2858,6 +5047,15 @@ "node": ">=4" } }, + "node_modules/possible-typed-array-names": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.0.0.tgz", + "integrity": "sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/postcss": { "version": "8.4.49", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.49.tgz", @@ -2901,6 +5099,12 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true + }, "node_modules/prompts": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", @@ -2925,6 +5129,25 @@ "node": ">=4.0.0" } }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "dev": true, + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "dev": true + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -2935,6 +5158,21 @@ "node": ">=6" } }, + "node_modules/qs": { + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", + "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", + "dev": true, + "dependencies": { + "side-channel": "^1.0.6" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -2954,6 +5192,77 @@ } ] }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", + "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", + "dev": true, + "dependencies": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/readable-stream/node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "dev": true + }, + "node_modules/readable-stream/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "node_modules/regexp.prototype.flags": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz", + "integrity": "sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-errors": "^1.3.0", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "set-function-name": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -3062,39 +5371,198 @@ "fsevents": "~2.3.2" } }, - "node_modules/run-parallel": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", - "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safe-regex-test": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.1.0.tgz", + "integrity": "sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==", + "dev": true, + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "is-regex": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/safe-stable-stringify": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", + "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "node_modules/sax": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.4.1.tgz", + "integrity": "sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==", + "dev": true + }, + "node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/send": { + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", + "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", + "dev": true, + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "2.4.1", + "range-parser": "~1.2.1", + "statuses": "2.0.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/send/node_modules/debug/node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "dev": true + }, + "node_modules/send/node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/serve-static": { + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", + "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", + "dev": true, + "dependencies": { + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.19.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dev": true, "dependencies": { - "queue-microtask": "^1.2.2" + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" } }, - "node_modules/semver": { - "version": "7.6.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", - "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", - "bin": { - "semver": "bin/semver.js" + "node_modules/set-function-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.2.tgz", + "integrity": "sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==", + "dev": true, + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "functions-have-names": "^1.2.3", + "has-property-descriptors": "^1.0.2" }, "engines": { - "node": ">=10" + "node": ">= 0.4" } }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "dev": true + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -3116,6 +5584,78 @@ "node": ">=8" } }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "dev": true, + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "dev": true, + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "dev": true, + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "dev": true, + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/siginfo": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", @@ -3135,6 +5675,15 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/simple-swizzle": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz", + "integrity": "sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==", + "dev": true, + "dependencies": { + "is-arrayish": "^0.3.1" + } + }, "node_modules/sirv": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.0.tgz", @@ -3186,6 +5735,16 @@ "node": ">=0.10.0" } }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -3193,6 +5752,15 @@ "dev": true, "license": "BSD-3-Clause" }, + "node_modules/stack-trace": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", + "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==", + "dev": true, + "engines": { + "node": "*" + } + }, "node_modules/stackback": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", @@ -3200,6 +5768,15 @@ "dev": true, "license": "MIT" }, + "node_modules/statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/std-env": { "version": "3.8.0", "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.8.0.tgz", @@ -3207,6 +5784,53 @@ "dev": true, "license": "MIT" }, + "node_modules/stop-iteration-iterator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz", + "integrity": "sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==", + "dev": true, + "dependencies": { + "es-errors": "^1.3.0", + "internal-slot": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/stoppable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/stoppable/-/stoppable-1.1.0.tgz", + "integrity": "sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==", + "dev": true, + "engines": { + "node": ">=4", + "npm": ">=6" + } + }, + "node_modules/streamsearch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", + "dev": true, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/string_decoder/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, "node_modules/string-argv": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.2.tgz", @@ -3281,6 +5905,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/strnum": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz", + "integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==", + "dev": true + }, "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -3403,6 +6033,12 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/text-hex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", + "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==", + "dev": true + }, "node_modules/tinybench": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", @@ -3500,6 +6136,15 @@ "node": ">=8.0" } }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "dev": true, + "engines": { + "node": ">=0.6" + } + }, "node_modules/totalist": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", @@ -3510,6 +6155,40 @@ "node": ">=6" } }, + "node_modules/triple-beam": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.4.1.tgz", + "integrity": "sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg==", + "dev": true, + "engines": { + "node": ">= 14.0.0" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "dev": true, + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", + "dev": true + }, "node_modules/typescript": { "version": "5.7.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", @@ -3552,6 +6231,15 @@ "node": ">= 4.0.0" } }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -3562,6 +6250,30 @@ "punycode": "^2.1.0" } }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "dev": true, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/v8-to-istanbul": { "version": "9.3.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", @@ -3576,6 +6288,15 @@ "node": ">=10.12.0" } }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "dev": true, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/vite": { "version": "5.4.11", "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.11.tgz", @@ -3763,6 +6484,15 @@ "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.5.tgz", "integrity": "sha512-Ld1VelNuX9pdF39h2Hgaeb5hEZM2Z3jUrrMgWQAu82jMtZp7p3vJT3BzToKtZI7NgQssZje5o0zryOrhQvzQAg==" }, + "node_modules/web-streams-polyfill": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", + "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -3778,6 +6508,63 @@ "node": ">= 8" } }, + "node_modules/which-boxed-primitive": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.1.1.tgz", + "integrity": "sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==", + "dev": true, + "dependencies": { + "is-bigint": "^1.1.0", + "is-boolean-object": "^1.2.1", + "is-number-object": "^1.1.1", + "is-string": "^1.1.1", + "is-symbol": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-collection": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.2.tgz", + "integrity": "sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==", + "dev": true, + "dependencies": { + "is-map": "^2.0.3", + "is-set": "^2.0.3", + "is-weakmap": "^2.0.2", + "is-weakset": "^2.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-typed-array": { + "version": "1.1.18", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.18.tgz", + "integrity": "sha512-qEcY+KJYlWyLH9vNbsr6/5j59AXk5ni5aakf8ldzBvGde6Iz4sxZGkJyWSAueTG7QhOvNRYb1lDdFmL5Td0QKA==", + "dev": true, + "dependencies": { + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "for-each": "^0.3.3", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/why-is-node-running": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", @@ -3795,6 +6582,70 @@ "node": ">=8" } }, + "node_modules/winston": { + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/winston/-/winston-3.17.0.tgz", + "integrity": "sha512-DLiFIXYC5fMPxaRg832S6F5mJYvePtmO5G9v9IgUFPhXm9/GkXarH/TUrBAVzhTCzAj9anE/+GjrgXp/54nOgw==", + "dev": true, + "dependencies": { + "@colors/colors": "^1.6.0", + "@dabh/diagnostics": "^2.0.2", + "async": "^3.2.3", + "is-stream": "^2.0.0", + "logform": "^2.7.0", + "one-time": "^1.0.0", + "readable-stream": "^3.4.0", + "safe-stable-stringify": "^2.3.1", + "stack-trace": "0.0.x", + "triple-beam": "^1.3.0", + "winston-transport": "^4.9.0" + }, + "engines": { + "node": ">= 12.0.0" + } + }, + "node_modules/winston-transport": { + "version": "4.9.0", + "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.9.0.tgz", + "integrity": "sha512-8drMJ4rkgaPo1Me4zD/3WLfI/zPdA9o2IipKODunnGDcuqbHwjsbB79ylv04LCGGzU0xQ6vTznOMpQGaLhhm6A==", + "dev": true, + "dependencies": { + "logform": "^2.7.0", + "readable-stream": "^3.6.2", + "triple-beam": "^1.3.0" + }, + "engines": { + "node": ">= 12.0.0" + } + }, + "node_modules/winston-transport/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/winston/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -3892,6 +6743,37 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "node_modules/xml2js": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.6.2.tgz", + "integrity": "sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==", + "dev": true, + "dependencies": { + "sax": ">=0.6.0", + "xmlbuilder": "~11.0.0" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/xmlbuilder": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "dev": true, + "engines": { + "node": ">=0.4" + } + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/packages/http-client-java/package.json b/packages/http-client-java/package.json index 65bee48722..09e9839304 100644 --- a/packages/http-client-java/package.json +++ b/packages/http-client-java/package.json @@ -64,6 +64,7 @@ "@azure-tools/typespec-azure-resource-manager": "0.49.0", "@azure-tools/typespec-azure-rulesets": "0.49.0", "@azure-tools/typespec-client-generator-core": "0.49.1", + "@typespec/spector": "0.1.0-alpha.5", "@microsoft/api-extractor": "^7.48.0", "@microsoft/api-extractor-model": "^7.30.0", "@types/js-yaml": "~4.0.9", From 74ec773d66f41877c3b14bd7ea065e731138cc58 Mon Sep 17 00:00:00 2001 From: Dapeng Zhang Date: Tue, 14 Jan 2025 11:31:21 +0800 Subject: [PATCH 03/16] report diagnostics on unsupported auth (#5496) Fixes https://github.com/microsoft/typespec/issues/5302 it works like this: ![image](https://github.com/user-attachments/assets/18641e23-cca3-49f1-b2e9-96d95eabc852) --- .../emitter/src/lib/client-model-builder.ts | 2 +- .../http-client-csharp/emitter/src/lib/lib.ts | 6 ++ .../emitter/src/lib/service-authentication.ts | 86 ++++++++++++------- .../emitter/src/type/input-api-key-auth.ts | 3 + .../emitter/test/Unit/auth.test.ts | 70 +++++++++++++++ .../emitter/test/Unit/utils/test-util.ts | 5 +- .../authentication/api-key/tspCodeModel.json | 3 +- .../http/custom/tspCodeModel.json | 1 + .../authentication/union/tspCodeModel.json | 3 +- .../Unbranded-TypeSpec/tspCodeModel.json | 3 +- 10 files changed, 146 insertions(+), 36 deletions(-) create mode 100644 packages/http-client-csharp/emitter/test/Unit/auth.test.ts diff --git a/packages/http-client-csharp/emitter/src/lib/client-model-builder.ts b/packages/http-client-csharp/emitter/src/lib/client-model-builder.ts index f010c39312..fdc05bb349 100644 --- a/packages/http-client-csharp/emitter/src/lib/client-model-builder.ts +++ b/packages/http-client-csharp/emitter/src/lib/client-model-builder.ts @@ -60,7 +60,7 @@ export function createModel(sdkContext: SdkContext): CodeMode Enums: Array.from(sdkTypeMap.enums.values()), Models: Array.from(sdkTypeMap.models.values()), Clients: inputClients, - Auth: processServiceAuthentication(sdkPackage), + Auth: processServiceAuthentication(sdkContext, sdkPackage), }; return clientModel; diff --git a/packages/http-client-csharp/emitter/src/lib/lib.ts b/packages/http-client-csharp/emitter/src/lib/lib.ts index 4d5986f994..a4c8690cac 100644 --- a/packages/http-client-csharp/emitter/src/lib/lib.ts +++ b/packages/http-client-csharp/emitter/src/lib/lib.ts @@ -44,6 +44,12 @@ const $lib = createTypeSpecLibrary({ "Cannot generate CSharp SDK since no public root client is defined in typespec file.", }, }, + "unsupported-auth": { + severity: "warning", + messages: { + default: paramMessage`${"message"}`, + }, + }, }, emitter: { options: NetEmitterOptionsSchema, diff --git a/packages/http-client-csharp/emitter/src/lib/service-authentication.ts b/packages/http-client-csharp/emitter/src/lib/service-authentication.ts index 7150e804ba..1987d451d6 100644 --- a/packages/http-client-csharp/emitter/src/lib/service-authentication.ts +++ b/packages/http-client-csharp/emitter/src/lib/service-authentication.ts @@ -2,16 +2,20 @@ // Licensed under the MIT License. See License.txt in the project root for license information. import { + SdkContext, SdkCredentialParameter, SdkCredentialType, SdkHttpOperation, SdkPackage, } from "@azure-tools/typespec-client-generator-core"; +import { NoTarget } from "@typespec/compiler"; import { Oauth2Auth, OAuth2Flow } from "@typespec/http"; +import { NetEmitterOptions } from "../options.js"; import { InputAuth } from "../type/input-auth.js"; -import { Logger } from "./logger.js"; +import { reportDiagnostic } from "./lib.js"; export function processServiceAuthentication( + sdkContext: SdkContext, sdkPackage: SdkPackage, ): InputAuth | undefined { let authClientParameter: SdkCredentialParameter | undefined = undefined; @@ -28,11 +32,11 @@ export function processServiceAuthentication( return undefined; } if (authClientParameter.type.kind === "credential") { - return processAuthType(authClientParameter.type); + return processAuthType(sdkContext, authClientParameter.type); } const inputAuth: InputAuth = {}; for (const authType of authClientParameter.type.variantTypes) { - const auth = processAuthType(authType); + const auth = processAuthType(sdkContext, authType); if (auth?.ApiKey) { inputAuth.ApiKey = auth.ApiKey; } @@ -43,41 +47,61 @@ export function processServiceAuthentication( return inputAuth; } -function processAuthType(credentialType: SdkCredentialType): InputAuth | undefined { +function processAuthType( + sdkContext: SdkContext, + credentialType: SdkCredentialType, +): InputAuth | undefined { const scheme = credentialType.scheme; switch (scheme.type) { case "apiKey": - return { ApiKey: { Name: scheme.name } } as InputAuth; + if (scheme.in !== "header") { + reportDiagnostic(sdkContext.program, { + code: "unsupported-auth", + format: { + message: `Only header is supported for ApiKey authentication. ${scheme.in} is not supported.`, + }, + target: credentialType.__raw ?? NoTarget, + }); + return undefined; + } + return { ApiKey: { Name: scheme.name, In: scheme.in } } as InputAuth; case "oauth2": return processOAuth2(scheme); - case "http": - { - const schemeOrApiKeyPrefix = scheme.scheme; - switch (schemeOrApiKeyPrefix) { - case "basic": - Logger.getInstance().warn( - `${schemeOrApiKeyPrefix} auth method is currently not supported.`, - ); - return undefined; - case "bearer": - return { - ApiKey: { - Name: "Authorization", - Prefix: "Bearer", - }, - } as InputAuth; - default: - return { - ApiKey: { - Name: "Authorization", - Prefix: schemeOrApiKeyPrefix, - }, - } as InputAuth; - } + case "http": { + const schemeOrApiKeyPrefix = scheme.scheme; + switch (schemeOrApiKeyPrefix) { + case "basic": + reportDiagnostic(sdkContext.program, { + code: "unsupported-auth", + format: { message: `${schemeOrApiKeyPrefix} auth method is currently not supported.` }, + target: credentialType.__raw ?? NoTarget, + }); + return undefined; + case "bearer": + return { + ApiKey: { + Name: "Authorization", + In: "header", + Prefix: "Bearer", + }, + }; + default: + return { + ApiKey: { + Name: "Authorization", + In: "header", + Prefix: schemeOrApiKeyPrefix, + }, + }; } - break; + } default: - throw new Error(`un-supported authentication scheme ${scheme.type}`); + reportDiagnostic(sdkContext.program, { + code: "unsupported-auth", + format: { message: `un-supported authentication scheme ${scheme.type}` }, + target: credentialType.__raw ?? NoTarget, + }); + return undefined; } } diff --git a/packages/http-client-csharp/emitter/src/type/input-api-key-auth.ts b/packages/http-client-csharp/emitter/src/type/input-api-key-auth.ts index 54e87316f8..07c54ab26e 100644 --- a/packages/http-client-csharp/emitter/src/type/input-api-key-auth.ts +++ b/packages/http-client-csharp/emitter/src/type/input-api-key-auth.ts @@ -3,5 +3,8 @@ export interface InputApiKeyAuth { Name: string; + In: ApiKeyLocation; Prefix?: string; } + +export type ApiKeyLocation = "header"; // | "query" | "cookie"; // we do not support query or cookie yet diff --git a/packages/http-client-csharp/emitter/test/Unit/auth.test.ts b/packages/http-client-csharp/emitter/test/Unit/auth.test.ts new file mode 100644 index 0000000000..60108b5250 --- /dev/null +++ b/packages/http-client-csharp/emitter/test/Unit/auth.test.ts @@ -0,0 +1,70 @@ +import { TestHost } from "@typespec/compiler/testing"; +import { ok, strictEqual } from "assert"; +import { beforeEach, describe, it } from "vitest"; +import { createModel } from "../../src/lib/client-model-builder.js"; +import { + createEmitterContext, + createEmitterTestHost, + createNetSdkContext, + typeSpecCompile, +} from "./utils/test-util.js"; + +describe("Test auth", () => { + let runner: TestHost; + + beforeEach(async () => { + runner = await createEmitterTestHost(); + }); + + it("cookie header is not supported", async () => { + const program = await typeSpecCompile( + ` + op test(): NoContentResponse; + `, + runner, + { + AuthDecorator: `@useAuth(ApiKeyAuth)`, + }, + ); + const context = createEmitterContext(program); + const sdkContext = await createNetSdkContext(context); + const root = createModel(sdkContext); + const diagnostics = context.program.diagnostics; + + const noAuthDiagnostic = diagnostics.find( + (d) => d.code === "@typespec/http-client-csharp/unsupported-auth", + ); + ok(noAuthDiagnostic); + strictEqual( + noAuthDiagnostic.message, + "Only header is supported for ApiKey authentication. cookie is not supported.", + ); + strictEqual(root.Auth, undefined); // we do not support it therefore it falls back to undefined + }); + + it("query header is not supported", async () => { + const program = await typeSpecCompile( + ` + op test(): NoContentResponse; + `, + runner, + { + AuthDecorator: `@useAuth(ApiKeyAuth)`, + }, + ); + const context = createEmitterContext(program); + const sdkContext = await createNetSdkContext(context); + const root = createModel(sdkContext); + const diagnostics = context.program.diagnostics; + + const noAuthDiagnostic = diagnostics.find( + (d) => d.code === "@typespec/http-client-csharp/unsupported-auth", + ); + ok(noAuthDiagnostic); + strictEqual( + noAuthDiagnostic.message, + "Only header is supported for ApiKey authentication. query is not supported.", + ); + strictEqual(root.Auth, undefined); // we do not support it therefore it falls back to undefined + }); +}); diff --git a/packages/http-client-csharp/emitter/test/Unit/utils/test-util.ts b/packages/http-client-csharp/emitter/test/Unit/utils/test-util.ts index 1e3b657c49..5a6adb2958 100644 --- a/packages/http-client-csharp/emitter/test/Unit/utils/test-util.ts +++ b/packages/http-client-csharp/emitter/test/Unit/utils/test-util.ts @@ -43,6 +43,7 @@ export interface TypeSpecCompileOptions { IsAzureCoreNeeded?: boolean; IsTCGCNeeded?: boolean; IsXmlNeeded?: boolean; + AuthDecorator?: string; } export async function typeSpecCompile( @@ -54,9 +55,11 @@ export async function typeSpecCompile( const needAzureCore = options?.IsAzureCoreNeeded ?? false; const needTCGC = options?.IsTCGCNeeded ?? false; const needXml = options?.IsXmlNeeded ?? false; + const authDecorator = + options?.AuthDecorator ?? `@useAuth(ApiKeyAuth)`; const namespace = ` @versioned(Versions) - @useAuth(ApiKeyAuth) + ${authDecorator} @service({ title: "Azure Csharp emitter Testing", }) diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/api-key/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/api-key/tspCodeModel.json index ef0de4c6a0..31fab45bc2 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/api-key/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/api-key/tspCodeModel.json @@ -168,7 +168,8 @@ "$id": "18", "ApiKey": { "$id": "19", - "Name": "x-ms-api-key" + "Name": "x-ms-api-key", + "In": "header" } } } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/http/custom/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/http/custom/tspCodeModel.json index 66a0b73463..25a039a6a6 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/http/custom/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/http/custom/tspCodeModel.json @@ -169,6 +169,7 @@ "ApiKey": { "$id": "19", "Name": "Authorization", + "In": "header", "Prefix": "SharedAccessKey" } } diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/union/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/union/tspCodeModel.json index a45094e11e..354f11d3bf 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/union/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/authentication/union/tspCodeModel.json @@ -110,7 +110,8 @@ "$id": "12", "ApiKey": { "$id": "13", - "Name": "x-ms-api-key" + "Name": "x-ms-api-key", + "In": "header" }, "OAuth2": { "$id": "14", diff --git a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json index 4633b09745..343ac81988 100644 --- a/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json +++ b/packages/http-client-csharp/generator/TestProjects/Local/Unbranded-TypeSpec/tspCodeModel.json @@ -3684,7 +3684,8 @@ "$id": "348", "ApiKey": { "$id": "349", - "Name": "my-api-key" + "Name": "my-api-key", + "In": "header" } } } From 84ebce0472b6987c17c5e18f43dd3db7313116cb Mon Sep 17 00:00:00 2001 From: Weidong Xu Date: Tue, 14 Jan 2025 13:36:52 +0800 Subject: [PATCH 04/16] http-client-java, prepare release 0.1.6 (#5592) Use code="invalid-runtime-dependency" if cannot find JDK or Maven, as this is what .NET plan to use (it could change). ![image](https://github.com/user-attachments/assets/fb29e758-310d-4de5-89ce-f15e4321b164) --- .../http-client-java/emitter/src/emitter.ts | 8 +- .../http-client-java/emitter/src/utils.ts | 8 +- .../http-client-java/emitter/src/validate.ts | 7 +- .../package.json | 2 +- .../http-client-generator-test/package.json | 2 +- packages/http-client-java/package-lock.json | 93 ++++++++++--------- packages/http-client-java/package.json | 14 +-- 7 files changed, 70 insertions(+), 64 deletions(-) diff --git a/packages/http-client-java/emitter/src/emitter.ts b/packages/http-client-java/emitter/src/emitter.ts index 7e4c865637..2b8313b53a 100644 --- a/packages/http-client-java/emitter/src/emitter.ts +++ b/packages/http-client-java/emitter/src/emitter.ts @@ -12,7 +12,11 @@ import { fileURLToPath } from "url"; import { CodeModelBuilder } from "./code-model-builder.js"; import { CodeModel } from "./common/code-model.js"; import { logError, spawnAsync, SpawnError } from "./utils.js"; -import { JDK_NOT_FOUND_MESSAGE, validateDependencies } from "./validate.js"; +import { + CODE_RUNTIME_DEPENDENCY, + JDK_NOT_FOUND_MESSAGE, + validateDependencies, +} from "./validate.js"; export interface EmitterOptions { namespace?: string; @@ -193,7 +197,7 @@ export async function $onEmit(context: EmitContext) { program.trace("http-client-java", `Code generation log: ${result.stdout}`); } catch (error: any) { if (error && "code" in error && error["code"] === "ENOENT") { - logError(program, JDK_NOT_FOUND_MESSAGE); + logError(program, JDK_NOT_FOUND_MESSAGE, CODE_RUNTIME_DEPENDENCY); } else { logError( program, diff --git a/packages/http-client-java/emitter/src/utils.ts b/packages/http-client-java/emitter/src/utils.ts index dd23facae8..b70ace8bc7 100644 --- a/packages/http-client-java/emitter/src/utils.ts +++ b/packages/http-client-java/emitter/src/utils.ts @@ -1,18 +1,18 @@ import { NoTarget, Program, Type } from "@typespec/compiler"; import { spawn, SpawnOptions } from "child_process"; -export function logError(program: Program, msg: string) { +export function logError(program: Program, msg: string, code: string = "http-client-java") { program.reportDiagnostic({ - code: "http-client-java", + code: code, severity: "error", message: msg, target: NoTarget, }); } -export function logWarning(program: Program, msg: string) { +export function logWarning(program: Program, msg: string, code: string = "http-client-java") { program.reportDiagnostic({ - code: "http-client-java", + code: code, severity: "warning", message: msg, target: NoTarget, diff --git a/packages/http-client-java/emitter/src/validate.ts b/packages/http-client-java/emitter/src/validate.ts index 99cd183faa..2598cfb992 100644 --- a/packages/http-client-java/emitter/src/validate.ts +++ b/packages/http-client-java/emitter/src/validate.ts @@ -3,6 +3,7 @@ import { logError, spawnAsync, trace } from "./utils.js"; export const JDK_NOT_FOUND_MESSAGE = "Java Development Kit (JDK) is not found in PATH. Please install JDK 17 or above. Microsoft Build of OpenJDK can be downloaded from https://learn.microsoft.com/java/openjdk/download"; +export const CODE_RUNTIME_DEPENDENCY = "invalid-runtime-dependency"; export async function validateDependencies( program: Program | undefined, @@ -24,7 +25,7 @@ export async function validateDependencies( // // eslint-disable-next-line no-console // console.log("[ERROR] " + message); if (program && logDiagnostic) { - logError(program, message); + logError(program, message, CODE_RUNTIME_DEPENDENCY); } } } @@ -36,7 +37,7 @@ export async function validateDependencies( // // eslint-disable-next-line no-console // console.log("[ERROR] " + message); if (program && logDiagnostic) { - logError(program, message); + logError(program, message, CODE_RUNTIME_DEPENDENCY); } } @@ -60,7 +61,7 @@ export async function validateDependencies( // // eslint-disable-next-line no-console // console.log("[ERROR] " + message); if (program && logDiagnostic) { - logError(program, message); + logError(program, message, CODE_RUNTIME_DEPENDENCY); } } } diff --git a/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json b/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json index af076455a1..30d5c49704 100644 --- a/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json +++ b/packages/http-client-java/generator/http-client-generator-clientcore-test/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@typespec/http-specs": "0.1.0-alpha.5", - "@typespec/http-client-java": "file:../../typespec-http-client-java-0.1.5.tgz", + "@typespec/http-client-java": "file:../../typespec-http-client-java-0.1.6.tgz", "@typespec/http-client-java-tests": "file:" }, "overrides": { diff --git a/packages/http-client-java/generator/http-client-generator-test/package.json b/packages/http-client-java/generator/http-client-generator-test/package.json index 11c2ef6b86..992c7336d2 100644 --- a/packages/http-client-java/generator/http-client-generator-test/package.json +++ b/packages/http-client-java/generator/http-client-generator-test/package.json @@ -14,7 +14,7 @@ "dependencies": { "@typespec/http-specs": "0.1.0-alpha.5", "@azure-tools/azure-http-specs": "0.1.0-alpha.4", - "@typespec/http-client-java": "file:../../typespec-http-client-java-0.1.5.tgz", + "@typespec/http-client-java": "file:../../typespec-http-client-java-0.1.6.tgz", "@typespec/http-client-java-tests": "file:" }, "overrides": { diff --git a/packages/http-client-java/package-lock.json b/packages/http-client-java/package-lock.json index c36436219d..e00081adbe 100644 --- a/packages/http-client-java/package-lock.json +++ b/packages/http-client-java/package-lock.json @@ -1,12 +1,12 @@ { "name": "@typespec/http-client-java", - "version": "0.1.5", + "version": "0.1.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@typespec/http-client-java", - "version": "0.1.5", + "version": "0.1.6", "license": "MIT", "dependencies": { "@autorest/codemodel": "~4.20.0", @@ -20,22 +20,22 @@ "@azure-tools/typespec-azure-resource-manager": "0.49.0", "@azure-tools/typespec-azure-rulesets": "0.49.0", "@azure-tools/typespec-client-generator-core": "0.49.1", - "@microsoft/api-extractor": "^7.48.0", - "@microsoft/api-extractor-model": "^7.30.0", + "@microsoft/api-extractor": "^7.49.1", + "@microsoft/api-extractor-model": "^7.30.2", "@types/js-yaml": "~4.0.9", - "@types/lodash": "~4.17.13", - "@types/node": "~22.10.1", + "@types/lodash": "~4.17.14", + "@types/node": "~22.10.6", "@typespec/compiler": "0.63.0", "@typespec/http": "0.63.0", "@typespec/openapi": "0.63.0", - "@typespec/rest": "0.63.0", + "@typespec/rest": "0.63.1", "@typespec/spector": "0.1.0-alpha.5", "@typespec/versioning": "0.63.0", "@vitest/coverage-v8": "^2.1.8", "@vitest/ui": "^2.1.8", "c8": "~10.1.3", "rimraf": "~6.0.1", - "typescript": "~5.7.2", + "typescript": "~5.7.3", "vitest": "^2.1.8" }, "engines": { @@ -1173,40 +1173,40 @@ } }, "node_modules/@microsoft/api-extractor": { - "version": "7.48.0", - "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.48.0.tgz", - "integrity": "sha512-FMFgPjoilMUWeZXqYRlJ3gCVRhB7WU/HN88n8OLqEsmsG4zBdX/KQdtJfhq95LQTQ++zfu0Em1LLb73NqRCLYQ==", + "version": "7.49.1", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.49.1.tgz", + "integrity": "sha512-jRTR/XbQF2kb+dYn8hfYSicOGA99+Fo00GrsdMwdfE3eIgLtKdH6Qa2M3wZV9S2XmbgCaGX1OdPtYctbfu5jQg==", "dev": true, "license": "MIT", "dependencies": { - "@microsoft/api-extractor-model": "7.30.0", + "@microsoft/api-extractor-model": "7.30.2", "@microsoft/tsdoc": "~0.15.1", "@microsoft/tsdoc-config": "~0.17.1", - "@rushstack/node-core-library": "5.10.0", + "@rushstack/node-core-library": "5.10.2", "@rushstack/rig-package": "0.5.3", - "@rushstack/terminal": "0.14.3", - "@rushstack/ts-command-line": "4.23.1", + "@rushstack/terminal": "0.14.5", + "@rushstack/ts-command-line": "4.23.3", "lodash": "~4.17.15", "minimatch": "~3.0.3", "resolve": "~1.22.1", "semver": "~7.5.4", "source-map": "~0.6.1", - "typescript": "5.4.2" + "typescript": "5.7.2" }, "bin": { "api-extractor": "bin/api-extractor" } }, "node_modules/@microsoft/api-extractor-model": { - "version": "7.30.0", - "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.30.0.tgz", - "integrity": "sha512-26/LJZBrsWDKAkOWRiQbdVgcfd1F3nyJnAiJzsAgpouPk7LtOIj7PK9aJtBaw/pUXrkotEg27RrT+Jm/q0bbug==", + "version": "7.30.2", + "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.30.2.tgz", + "integrity": "sha512-3/t2F+WhkJgBzSNwlkTIL0tBgUoBqDqL66pT+nh2mPbM0NIDGVGtpqbGWPgHIzn/mn7kGS/Ep8D8po58e8UUIw==", "dev": true, "license": "MIT", "dependencies": { "@microsoft/tsdoc": "~0.15.1", "@microsoft/tsdoc-config": "~0.17.1", - "@rushstack/node-core-library": "5.10.0" + "@rushstack/node-core-library": "5.10.2" } }, "node_modules/@microsoft/api-extractor/node_modules/brace-expansion": { @@ -1259,10 +1259,11 @@ } }, "node_modules/@microsoft/api-extractor/node_modules/typescript": { - "version": "5.4.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.2.tgz", - "integrity": "sha512-+2/g0Fds1ERlP6JsakQQDXjZdZMM+rqpamFZJEKh4kwTIn3iDkgKtby0CeNd5ATNZ4Ry1ax15TMx0W2V+miizQ==", + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", + "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -1607,9 +1608,9 @@ ] }, "node_modules/@rushstack/node-core-library": { - "version": "5.10.0", - "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-5.10.0.tgz", - "integrity": "sha512-2pPLCuS/3x7DCd7liZkqOewGM0OzLyCacdvOe8j6Yrx9LkETGnxul1t7603bIaB8nUAooORcct9fFDOQMbWAgw==", + "version": "5.10.2", + "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-5.10.2.tgz", + "integrity": "sha512-xOF/2gVJZTfjTxbo4BDj9RtQq/HFnrrKdtem4JkyRLnwsRz2UDTg8gA1/et10fBx5RxmZD9bYVGST69W8ME5OQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1688,13 +1689,13 @@ } }, "node_modules/@rushstack/terminal": { - "version": "0.14.3", - "resolved": "https://registry.npmjs.org/@rushstack/terminal/-/terminal-0.14.3.tgz", - "integrity": "sha512-csXbZsAdab/v8DbU1sz7WC2aNaKArcdS/FPmXMOXEj/JBBZMvDK0+1b4Qao0kkG0ciB1Qe86/Mb68GjH6/TnMw==", + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/@rushstack/terminal/-/terminal-0.14.5.tgz", + "integrity": "sha512-TEOpNwwmsZVrkp0omnuTUTGZRJKTr6n6m4OITiNjkqzLAkcazVpwR1SOtBg6uzpkIBLgrcNHETqI8rbw3uiUfw==", "dev": true, "license": "MIT", "dependencies": { - "@rushstack/node-core-library": "5.10.0", + "@rushstack/node-core-library": "5.10.2", "supports-color": "~8.1.1" }, "peerDependencies": { @@ -1733,13 +1734,13 @@ } }, "node_modules/@rushstack/ts-command-line": { - "version": "4.23.1", - "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.23.1.tgz", - "integrity": "sha512-40jTmYoiu/xlIpkkRsVfENtBq4CW3R4azbL0Vmda+fMwHWqss6wwf/Cy/UJmMqIzpfYc2OTnjYP1ZLD3CmyeCA==", + "version": "4.23.3", + "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.23.3.tgz", + "integrity": "sha512-HazKL8fv4HMQMzrKJCrOrhyBPPdzk7iajUXgsASwjQ8ROo1cmgyqxt/k9+SdmrNLGE1zATgRqMUH3s/6smbRMA==", "dev": true, "license": "MIT", "dependencies": { - "@rushstack/terminal": "0.14.3", + "@rushstack/terminal": "0.14.5", "@types/argparse": "1.0.38", "argparse": "~1.0.9", "string-argv": "~0.3.1" @@ -1793,16 +1794,16 @@ "dev": true }, "node_modules/@types/lodash": { - "version": "4.17.13", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.13.tgz", - "integrity": "sha512-lfx+dftrEZcdBPczf9d0Qv0x+j/rfNCMuC6OcfXmO8gkfeNAY88PgKUbvG56whcN23gc27yenwF6oJZXGFpYxg==", + "version": "4.17.14", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.14.tgz", + "integrity": "sha512-jsxagdikDiDBeIRaPYtArcT8my4tN1og7MtMRquFT3XNA6axxyHDRUemqDz/taRDdOUn0GnGHRCuff4q48sW9A==", "dev": true, "license": "MIT" }, "node_modules/@types/node": { - "version": "22.10.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.1.tgz", - "integrity": "sha512-qKgsUwfHZV2WCWLAnVP1JqnpE6Im6h3Y0+fYgMTasNQ7V++CBX5OT1as0g0f+OyubbFqhf6XVNIsmN4IIhEgGQ==", + "version": "22.10.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.6.tgz", + "integrity": "sha512-qNiuwC4ZDAUNcY47xgaSuS92cjf8JbSUoaKS77bmLG1rU7MlATVSiw/IlrjtIyyskXBZ8KkNfjK/P5na7rgXbQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1897,9 +1898,9 @@ } }, "node_modules/@typespec/rest": { - "version": "0.63.0", - "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.63.0.tgz", - "integrity": "sha512-HftzMjSDHAYX+ILE9C6pFS4oAq7oBHMCtpA8QgSFPDF4V5a8l1k2K8c4x1B+7yl+GkREmIdtpc6S0xZm2G7hXg==", + "version": "0.63.1", + "resolved": "https://registry.npmjs.org/@typespec/rest/-/rest-0.63.1.tgz", + "integrity": "sha512-RQbTM+HGjCaNIWC0v72m5ulnuvLjuRigb7pH4QeRCvFtGPHos+WBv5SImkGrbYx3353OGR8dIi7lWe7aNwiDcQ==", "dev": true, "license": "MIT", "engines": { @@ -6190,9 +6191,9 @@ "dev": true }, "node_modules/typescript": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", - "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz", + "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/packages/http-client-java/package.json b/packages/http-client-java/package.json index 09e9839304..6f3cfd6e5c 100644 --- a/packages/http-client-java/package.json +++ b/packages/http-client-java/package.json @@ -1,6 +1,6 @@ { "name": "@typespec/http-client-java", - "version": "0.1.5", + "version": "0.1.6", "description": "TypeSpec library for emitting Java client from the TypeSpec REST protocol binding", "keywords": [ "TypeSpec" @@ -65,21 +65,21 @@ "@azure-tools/typespec-azure-rulesets": "0.49.0", "@azure-tools/typespec-client-generator-core": "0.49.1", "@typespec/spector": "0.1.0-alpha.5", - "@microsoft/api-extractor": "^7.48.0", - "@microsoft/api-extractor-model": "^7.30.0", + "@microsoft/api-extractor": "^7.49.1", + "@microsoft/api-extractor-model": "^7.30.2", "@types/js-yaml": "~4.0.9", - "@types/lodash": "~4.17.13", - "@types/node": "~22.10.1", + "@types/lodash": "~4.17.14", + "@types/node": "~22.10.6", "@typespec/compiler": "0.63.0", "@typespec/http": "0.63.0", "@typespec/openapi": "0.63.0", - "@typespec/rest": "0.63.0", + "@typespec/rest": "0.63.1", "@typespec/versioning": "0.63.0", "@vitest/coverage-v8": "^2.1.8", "@vitest/ui": "^2.1.8", "c8": "~10.1.3", "rimraf": "~6.0.1", - "typescript": "~5.7.2", + "typescript": "~5.7.3", "vitest": "^2.1.8" } } From c0a9a53365085f6ac2f627de0539ac4108bde085 Mon Sep 17 00:00:00 2001 From: Wanpeng Li Date: Tue, 14 Jan 2025 15:26:52 +0800 Subject: [PATCH 05/16] Fix OpenAPI YAML converts strings to boolean (#5456) Problem: yaml 1.1 treats some string as other types of value. Check out: https://perlpunk.github.io/yaml-test-schema/schemas.html Fix: https://github.com/microsoft/typespec/issues/5377 Solution: make serialization compatible with YAML 1.1 Todo: test other types (in next PR). --- ...wanl-fix-noway-yaml-2024-11-27-14-31-43.md | 7 ++ packages/openapi3/src/openapi.ts | 1 + packages/openapi3/test/emit-openapi.test.ts | 79 +++++++++++++++++++ packages/openapi3/test/test-host.ts | 10 ++- 4 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 .chronus/changes/wanl-fix-noway-yaml-2024-11-27-14-31-43.md create mode 100644 packages/openapi3/test/emit-openapi.test.ts diff --git a/.chronus/changes/wanl-fix-noway-yaml-2024-11-27-14-31-43.md b/.chronus/changes/wanl-fix-noway-yaml-2024-11-27-14-31-43.md new file mode 100644 index 0000000000..b71ee9dcbe --- /dev/null +++ b/.chronus/changes/wanl-fix-noway-yaml-2024-11-27-14-31-43.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/openapi3" +--- + +Fix: OpenAPI YAML converts strings to boolean diff --git a/packages/openapi3/src/openapi.ts b/packages/openapi3/src/openapi.ts index e32d95eb41..e4ad848b7d 100644 --- a/packages/openapi3/src/openapi.ts +++ b/packages/openapi3/src/openapi.ts @@ -1844,6 +1844,7 @@ function serializeDocument(root: OpenAPI3Document, fileType: FileType): string { singleQuote: true, aliasDuplicateObjects: false, lineWidth: 0, + compat: "yaml-1.1", }); } } diff --git a/packages/openapi3/test/emit-openapi.test.ts b/packages/openapi3/test/emit-openapi.test.ts new file mode 100644 index 0000000000..6567704d7f --- /dev/null +++ b/packages/openapi3/test/emit-openapi.test.ts @@ -0,0 +1,79 @@ +import { describe, expect, it } from "vitest"; +import { emitOpenApiWithDiagnostics } from "./test-host.js"; + +describe("Scalar formats of serialized document in YAML", () => { + it("should add single quote for y|Y|yes|Yes|YES|n|N|no|No|NO|true|True|TRUE|false|False|FALSE|on|On|ON|off|Off|OFF", async () => { + const [_, __, content] = await emitOpenApiWithDiagnostics(` + enum TestEnum { + y: "y", + Y: "Y", + yes: "yes", + Yes: "Yes", + YES: "YES", + yEs: "yEs", + n: "n", + N: "N", + no: "no", + No: "No", + NO: "NO", + nO: "nO", + "true": "true", + True: "True", + TRUE: "TRUE", + tRUE: "tRUE", + "false": "false", + False: "False", + FALSE: "FALSE", + fALSE: "fALSE", + on: "on", + On: "On", + ON: "ON", + oN: "oN", + off: "off", + Off: "Off", + OFF: "OFF", + oFF: "oFF" + } + `); + expect(content).toBe(`openapi: 3.0.0 +info: + title: (title) + version: 0.0.0 +tags: [] +paths: {} +components: + schemas: + TestEnum: + type: string + enum: + - 'y' + - 'Y' + - 'yes' + - 'Yes' + - 'YES' + - yEs + - 'n' + - 'N' + - 'no' + - 'No' + - 'NO' + - nO + - 'true' + - 'True' + - 'TRUE' + - tRUE + - 'false' + - 'False' + - 'FALSE' + - fALSE + - 'on' + - 'On' + - 'ON' + - oN + - 'off' + - 'Off' + - 'OFF' + - oFF +`); + }); +}); diff --git a/packages/openapi3/test/test-host.ts b/packages/openapi3/test/test-host.ts index 2be1f42e0f..2aa902decb 100644 --- a/packages/openapi3/test/test-host.ts +++ b/packages/openapi3/test/test-host.ts @@ -11,6 +11,7 @@ import { RestTestLibrary } from "@typespec/rest/testing"; import { VersioningTestLibrary } from "@typespec/versioning/testing"; import { XmlTestLibrary } from "@typespec/xml/testing"; import { ok } from "assert"; +import { parse } from "yaml"; import { OpenAPI3EmitterOptions } from "../src/lib.js"; import { OpenAPI3TestLibrary } from "../src/testing/index.js"; import { OpenAPI3Document } from "../src/types.js"; @@ -56,9 +57,10 @@ export async function createOpenAPITestRunner({ export async function emitOpenApiWithDiagnostics( code: string, options: OpenAPI3EmitterOptions = {}, -): Promise<[OpenAPI3Document, readonly Diagnostic[]]> { +): Promise<[OpenAPI3Document, readonly Diagnostic[], string]> { const runner = await createOpenAPITestRunner(); - const outputFile = resolveVirtualPath("openapi.json"); + const fileType = options["file-type"] || "yaml"; + const outputFile = resolveVirtualPath("openapi" + fileType === "json" ? ".json" : ".yaml"); const diagnostics = await runner.diagnose(code, { noEmit: false, emit: ["@typespec/openapi3"], @@ -68,8 +70,8 @@ export async function emitOpenApiWithDiagnostics( }); const content = runner.fs.get(outputFile); ok(content, "Expected to have found openapi output"); - const doc = JSON.parse(content); - return [doc, diagnostics]; + const doc = fileType === "json" ? JSON.parse(content) : parse(content); + return [doc, diagnostics, content]; } export async function diagnoseOpenApiFor(code: string, options: OpenAPI3EmitterOptions = {}) { From 2bdac729d3c9e7b73baedd5196a1a679e0748473 Mon Sep 17 00:00:00 2001 From: iscai-msft <43154838+iscai-msft@users.noreply.github.com> Date: Tue, 14 Jan 2025 13:59:08 -0500 Subject: [PATCH 06/16] [python] remove python2 code for datetime from serialization.py (#5599) fixes https://github.com/Azure/autorest.python/issues/2000 --------- Co-authored-by: iscai-msft --- packages/http-client-python/CHANGELOG.md | 6 ++ .../codegen/templates/serialization.py.jinja2 | 70 +------------------ packages/http-client-python/package.json | 2 +- 3 files changed, 9 insertions(+), 69 deletions(-) diff --git a/packages/http-client-python/CHANGELOG.md b/packages/http-client-python/CHANGELOG.md index 500dfb649b..a13f39518b 100644 --- a/packages/http-client-python/CHANGELOG.md +++ b/packages/http-client-python/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log - @typespec/http-client-python +## 0.6.3 + +### Other Changes + +- Remove Python2 specific datetime logic from internal serialization. + ## 0.6.2 ### Bug Fixes diff --git a/packages/http-client-python/generator/pygen/codegen/templates/serialization.py.jinja2 b/packages/http-client-python/generator/pygen/codegen/templates/serialization.py.jinja2 index 37b45fffdc..43b0e60403 100644 --- a/packages/http-client-python/generator/pygen/codegen/templates/serialization.py.jinja2 +++ b/packages/http-client-python/generator/pygen/codegen/templates/serialization.py.jinja2 @@ -184,73 +184,7 @@ try: except NameError: _long_type = int - -class UTC(datetime.tzinfo): - """Time Zone info for handling UTC""" - - def utcoffset(self, dt): - """UTF offset for UTC is 0. - - :param datetime.datetime dt: The datetime - :returns: The offset - :rtype: datetime.timedelta - """ - return datetime.timedelta(0) - - def tzname(self, dt): - """Timestamp representation. - - :param datetime.datetime dt: The datetime - :returns: The timestamp representation - :rtype: str - """ - return "Z" - - def dst(self, dt): - """No daylight saving for UTC. - - :param datetime.datetime dt: The datetime - :returns: The daylight saving time - :rtype: datetime.timedelta - """ - return datetime.timedelta(hours=1) - - -try: - from datetime import timezone as _FixedOffset # type: ignore -except ImportError: # Python 2.7 - - class _FixedOffset(datetime.tzinfo): # type: ignore - """Fixed offset in minutes east from UTC. - Copy/pasted from Python doc - :param datetime.timedelta offset: offset in timedelta format - """ - - def __init__(self, offset) -> None: - self.__offset = offset - - def utcoffset(self, dt): - return self.__offset - - def tzname(self, dt): - return str(self.__offset.total_seconds() / 3600) - - def __repr__(self): - return "".format(self.tzname(None)) - - def dst(self, dt): - return datetime.timedelta(0) - - def __getinitargs__(self): - return (self.__offset,) - - -try: - from datetime import timezone - - TZ_UTC = timezone.utc -except ImportError: - TZ_UTC = UTC() # type: ignore +TZ_UTC = datetime.timezone.utc _FLATTEN = re.compile(r"(? Date: Tue, 14 Jan 2025 10:59:09 -0800 Subject: [PATCH 07/16] add openapi 3.1 support (#5372) This PR adds support for Open API 3.1 in the `@typespec/openapi3` package. The changes in this PR includes: #4946 - adds `output-spec-versions` emitter option #5035 - adds initial open api 3.1 schema emitter #5245 - add support for tuples #5246 - add support for enums backed by multiple types #5310 - playground support for array of constants emitter options #5407 - add support for json-schema decorators #5549 - add support for binary types in Open API 3.1 --------- Co-authored-by: Christopher Radek --- ...api3-json-decorators-2024-11-18-14-22-8.md | 7 + ...output-spec-versions-2024-10-1-11-53-51.md | 8 + .../openapi31-playground-2025-0-9-12-38-34.md | 7 + packages/openapi3/README.md | 4 + packages/openapi3/package.json | 5 + packages/openapi3/src/attach-extensions.ts | 12 + packages/openapi3/src/encoding.ts | 12 +- packages/openapi3/src/json-schema.ts | 9 + packages/openapi3/src/lib.ts | 23 + packages/openapi3/src/openapi-helpers-3-0.ts | 25 + packages/openapi3/src/openapi-helpers-3-1.ts | 36 + .../openapi3/src/openapi-spec-mappings.ts | 109 ++ packages/openapi3/src/openapi.ts | 120 +- packages/openapi3/src/schema-emitter-3-0.ts | 281 +++ packages/openapi3/src/schema-emitter-3-1.ts | 319 +++ packages/openapi3/src/schema-emitter.ts | 484 ++--- packages/openapi3/src/std-scalar-schemas.ts | 4 +- packages/openapi3/src/types.ts | 423 +++- packages/openapi3/src/util.ts | 73 +- packages/openapi3/src/xml-module.ts | 8 +- .../test/additional-properties.test.ts | 4 +- packages/openapi3/test/array.test.ts | 156 +- .../openapi3/test/circular-references.test.ts | 6 +- packages/openapi3/test/discriminator.test.ts | 6 +- packages/openapi3/test/documentation.test.ts | 6 +- packages/openapi3/test/enums.test.ts | 39 +- packages/openapi3/test/examples.test.ts | 3 +- packages/openapi3/test/info.test.ts | 6 +- packages/openapi3/test/metadata.test.ts | 112 +- packages/openapi3/test/models.test.ts | 226 ++- packages/openapi3/test/multipart.test.ts | 907 ++++++--- .../openapi3/test/no-service-found.test.ts | 6 +- .../openapi3/test/nullable-properties.test.ts | 73 +- packages/openapi3/test/openapi-output.test.ts | 402 ++-- .../test/output-spec-versions.test.ts | 61 + packages/openapi3/test/overloads.test.ts | 4 +- packages/openapi3/test/parameters.test.ts | 878 ++++----- .../openapi3/test/primitive-types.test.ts | 89 +- packages/openapi3/test/record.test.ts | 6 +- .../test/response-descriptions.test.ts | 6 +- packages/openapi3/test/return-types.test.ts | 163 +- .../openapi3/test/scalar-constraints.test.ts | 167 +- packages/openapi3/test/security.test.ts | 6 +- packages/openapi3/test/servers.test.ts | 6 +- packages/openapi3/test/shared-routes.test.ts | 6 +- packages/openapi3/test/status-codes.test.ts | 6 +- .../openapi3/test/string-template.test.ts | 4 +- packages/openapi3/test/tagmetadata.test.ts | 7 +- packages/openapi3/test/test-host.ts | 55 +- packages/openapi3/test/union-schema.test.ts | 314 ++- packages/openapi3/test/versioning.test.ts | 27 +- packages/openapi3/test/works-for.ts | 53 + packages/openapi3/test/xml-models.test.ts | 1713 ++++++++--------- .../react/settings/emitter-options-form.tsx | 98 +- pnpm-lock.yaml | 3 + .../emitters/openapi3/reference/emitter.md | 4 + 56 files changed, 4940 insertions(+), 2657 deletions(-) create mode 100644 .chronus/changes/openapi3-json-decorators-2024-11-18-14-22-8.md create mode 100644 .chronus/changes/openapi3-output-spec-versions-2024-10-1-11-53-51.md create mode 100644 .chronus/changes/openapi31-playground-2025-0-9-12-38-34.md create mode 100644 packages/openapi3/src/attach-extensions.ts create mode 100644 packages/openapi3/src/json-schema.ts create mode 100644 packages/openapi3/src/openapi-helpers-3-0.ts create mode 100644 packages/openapi3/src/openapi-helpers-3-1.ts create mode 100644 packages/openapi3/src/openapi-spec-mappings.ts create mode 100644 packages/openapi3/src/schema-emitter-3-0.ts create mode 100644 packages/openapi3/src/schema-emitter-3-1.ts create mode 100644 packages/openapi3/test/output-spec-versions.test.ts create mode 100644 packages/openapi3/test/works-for.ts diff --git a/.chronus/changes/openapi3-json-decorators-2024-11-18-14-22-8.md b/.chronus/changes/openapi3-json-decorators-2024-11-18-14-22-8.md new file mode 100644 index 0000000000..f2d5ebfc7b --- /dev/null +++ b/.chronus/changes/openapi3-json-decorators-2024-11-18-14-22-8.md @@ -0,0 +1,7 @@ +--- +changeKind: feature +packages: + - "@typespec/openapi3" +--- + +Adds support for @typespec/json-schema decorators with Open API 3.0 and 3.1 emitters. \ No newline at end of file diff --git a/.chronus/changes/openapi3-output-spec-versions-2024-10-1-11-53-51.md b/.chronus/changes/openapi3-output-spec-versions-2024-10-1-11-53-51.md new file mode 100644 index 0000000000..ab8f8d743a --- /dev/null +++ b/.chronus/changes/openapi3-output-spec-versions-2024-10-1-11-53-51.md @@ -0,0 +1,8 @@ +--- +changeKind: feature +packages: + - "@typespec/openapi3" +--- + +Adds support for emitting Open API 3.1 models using the `openapi-versions` emitter configuration option. +Open API 3.0 is emitted by default. diff --git a/.chronus/changes/openapi31-playground-2025-0-9-12-38-34.md b/.chronus/changes/openapi31-playground-2025-0-9-12-38-34.md new file mode 100644 index 0000000000..237063111f --- /dev/null +++ b/.chronus/changes/openapi31-playground-2025-0-9-12-38-34.md @@ -0,0 +1,7 @@ +--- +changeKind: feature +packages: + - "@typespec/playground" +--- + +Add support for displaying array-based emitter options \ No newline at end of file diff --git a/packages/openapi3/README.md b/packages/openapi3/README.md index cd139f049b..795af3c4e7 100644 --- a/packages/openapi3/README.md +++ b/packages/openapi3/README.md @@ -74,6 +74,10 @@ Example Multiple service with versioning - `openapi.Org1.Service2.v1.0.yaml` - `openapi.Org1.Service2.v1.1.yaml` +### `openapi-versions` + +**Type:** `array` + ### `new-line` **Type:** `"crlf" | "lf"` diff --git a/packages/openapi3/package.json b/packages/openapi3/package.json index b66afceb1b..12e12e165a 100644 --- a/packages/openapi3/package.json +++ b/packages/openapi3/package.json @@ -65,10 +65,14 @@ "peerDependencies": { "@typespec/compiler": "workspace:~", "@typespec/http": "workspace:~", + "@typespec/json-schema": "workspace:~", "@typespec/openapi": "workspace:~", "@typespec/versioning": "workspace:~" }, "peerDependenciesMeta": { + "@typespec/json-schema": { + "optional": true + }, "@typespec/xml": { "optional": true } @@ -78,6 +82,7 @@ "@types/yargs": "~17.0.33", "@typespec/compiler": "workspace:~", "@typespec/http": "workspace:~", + "@typespec/json-schema": "workspace:~", "@typespec/library-linter": "workspace:~", "@typespec/openapi": "workspace:~", "@typespec/rest": "workspace:~", diff --git a/packages/openapi3/src/attach-extensions.ts b/packages/openapi3/src/attach-extensions.ts new file mode 100644 index 0000000000..f86ae817f9 --- /dev/null +++ b/packages/openapi3/src/attach-extensions.ts @@ -0,0 +1,12 @@ +import { Program, Type } from "@typespec/compiler"; +import { getExtensions } from "@typespec/openapi"; + +export function attachExtensions(program: Program, type: Type, emitObject: any) { + // Attach any OpenAPI extensions + const extensions = getExtensions(program, type); + if (extensions) { + for (const key of extensions.keys()) { + emitObject[key] = extensions.get(key); + } + } +} diff --git a/packages/openapi3/src/encoding.ts b/packages/openapi3/src/encoding.ts index 6cf027c42d..9ec4f3efe1 100644 --- a/packages/openapi3/src/encoding.ts +++ b/packages/openapi3/src/encoding.ts @@ -2,22 +2,24 @@ import { type ModelProperty, Program, type Scalar, getEncode } from "@typespec/c import { ObjectBuilder } from "@typespec/compiler/emitter-framework"; import type { ResolvedOpenAPI3EmitterOptions } from "./openapi.js"; import { getSchemaForStdScalars } from "./std-scalar-schemas.js"; -import type { OpenAPI3Schema } from "./types.js"; +import type { OpenAPI3Schema, OpenAPISchema3_1 } from "./types.js"; export function applyEncoding( program: Program, typespecType: Scalar | ModelProperty, - target: OpenAPI3Schema, + target: OpenAPI3Schema | OpenAPISchema3_1, + getEncodedFieldName: (typespecType: Scalar | ModelProperty) => string, options: ResolvedOpenAPI3EmitterOptions, -): OpenAPI3Schema { +): OpenAPI3Schema & OpenAPISchema3_1 { const encodeData = getEncode(program, typespecType); if (encodeData) { const newTarget = new ObjectBuilder(target); const newType = getSchemaForStdScalars(encodeData.type as any, options); newTarget.type = newType.type; // If the target already has a format it takes priority. (e.g. int32) - newTarget.format = mergeFormatAndEncoding( - newTarget.format, + const encodedFieldName = getEncodedFieldName(typespecType); + newTarget[encodedFieldName] = mergeFormatAndEncoding( + newTarget[encodedFieldName], encodeData.encoding, newType.format, ); diff --git a/packages/openapi3/src/json-schema.ts b/packages/openapi3/src/json-schema.ts new file mode 100644 index 0000000000..f9b3ed363a --- /dev/null +++ b/packages/openapi3/src/json-schema.ts @@ -0,0 +1,9 @@ +export type JsonSchemaModule = typeof import("@typespec/json-schema"); + +export async function resolveJsonSchemaModule(): Promise { + try { + return await import("@typespec/json-schema"); + } catch { + return undefined; + } +} diff --git a/packages/openapi3/src/lib.ts b/packages/openapi3/src/lib.ts index bd994c9a85..7ea2e95cf9 100644 --- a/packages/openapi3/src/lib.ts +++ b/packages/openapi3/src/lib.ts @@ -1,6 +1,7 @@ import { createTypeSpecLibrary, JSONSchemaType, paramMessage } from "@typespec/compiler"; export type FileType = "yaml" | "json"; +export type OpenAPIVersion = "3.0.0" | "3.1.0"; export interface OpenAPI3EmitterOptions { /** * If the content should be serialized as YAML or JSON. @@ -36,6 +37,16 @@ export interface OpenAPI3EmitterOptions { */ "output-file"?: string; + /** + * The Open API specification versions to emit. + * If more than one version is specified, then the output file + * will be created inside a directory matching each specification version. + * + * @default ["v3.0"] + * @internal + */ + "openapi-versions"?: OpenAPIVersion[]; + /** * Set the newline character for emitting files. * @default lf @@ -104,6 +115,18 @@ const EmitterOptionsSchema: JSONSchemaType = { " - `openapi.Org1.Service2.v1.1.yaml` ", ].join("\n"), }, + "openapi-versions": { + type: "array", + items: { + type: "string", + enum: ["3.0.0", "3.1.0"], + nullable: true, + description: "The versions of OpenAPI to emit. Defaults to `[3.0.0]`", + }, + nullable: true, + uniqueItems: true, + minItems: 1, + }, "new-line": { type: "string", enum: ["crlf", "lf"], diff --git a/packages/openapi3/src/openapi-helpers-3-0.ts b/packages/openapi3/src/openapi-helpers-3-0.ts new file mode 100644 index 0000000000..d97cf691c8 --- /dev/null +++ b/packages/openapi3/src/openapi-helpers-3-0.ts @@ -0,0 +1,25 @@ +import { applyEncoding as baseApplyEncoding } from "./encoding.js"; +import { OpenApiSpecSpecificProps } from "./openapi-spec-mappings.js"; +import { OpenAPI3Schema } from "./types.js"; + +function getEncodingFieldName() { + // In Open API 3.0, format is always used for encoding. + return "format"; +} + +export const applyEncoding: OpenApiSpecSpecificProps["applyEncoding"] = ( + program, + typespecType, + target, + options, +) => { + return baseApplyEncoding(program, typespecType, target, getEncodingFieldName, options); +}; + +export const getRawBinarySchema = (): OpenAPI3Schema => { + return { type: "string", format: "binary" }; +}; + +export const isRawBinarySchema = (schema: OpenAPI3Schema): boolean => { + return schema.type === "string" && schema.format === "binary"; +}; diff --git a/packages/openapi3/src/openapi-helpers-3-1.ts b/packages/openapi3/src/openapi-helpers-3-1.ts new file mode 100644 index 0000000000..18f2f58f00 --- /dev/null +++ b/packages/openapi3/src/openapi-helpers-3-1.ts @@ -0,0 +1,36 @@ +import { ModelProperty, Scalar } from "@typespec/compiler"; +import { applyEncoding as baseApplyEncoding } from "./encoding.js"; +import { OpenApiSpecSpecificProps } from "./openapi-spec-mappings.js"; +import { OpenAPISchema3_1 } from "./types.js"; +import { isScalarExtendsBytes } from "./util.js"; + +function getEncodingFieldName(typespecType: Scalar | ModelProperty) { + // In Open API 3.1, `contentEncoding` is used for encoded binary data instead of `format`. + const typeIsBytes = isScalarExtendsBytes( + typespecType.kind === "ModelProperty" ? typespecType.type : typespecType, + ); + if (typeIsBytes) { + return "contentEncoding"; + } + return "format"; +} + +export const applyEncoding: OpenApiSpecSpecificProps["applyEncoding"] = ( + program, + typespecType, + target, + options, +) => { + return baseApplyEncoding(program, typespecType, target, getEncodingFieldName, options); +}; + +export const getRawBinarySchema = (contentType?: string): OpenAPISchema3_1 => { + if (contentType) { + return { contentMediaType: contentType }; + } + return {}; +}; + +export const isRawBinarySchema = (schema: OpenAPISchema3_1): boolean => { + return schema.type === undefined; +}; diff --git a/packages/openapi3/src/openapi-spec-mappings.ts b/packages/openapi3/src/openapi-spec-mappings.ts new file mode 100644 index 0000000000..7a16b1a176 --- /dev/null +++ b/packages/openapi3/src/openapi-spec-mappings.ts @@ -0,0 +1,109 @@ +import { EmitContext, ModelProperty, Namespace, Program, Scalar } from "@typespec/compiler"; +import { AssetEmitter } from "@typespec/compiler/emitter-framework"; +import { MetadataInfo } from "@typespec/http"; +import { getExternalDocs, resolveInfo } from "@typespec/openapi"; +import { JsonSchemaModule } from "./json-schema.js"; +import { OpenAPI3EmitterOptions, OpenAPIVersion } from "./lib.js"; +import { + applyEncoding as applyEncoding3_0, + getRawBinarySchema as getRawBinarySchema3_0, + isRawBinarySchema as isRawBinarySchema3_0, +} from "./openapi-helpers-3-0.js"; +import { + applyEncoding as applyEncoding3_1, + getRawBinarySchema as getRawBinarySchema3_1, + isRawBinarySchema as isRawBinarySchema3_1, +} from "./openapi-helpers-3-1.js"; +import { ResolvedOpenAPI3EmitterOptions } from "./openapi.js"; +import { createSchemaEmitter3_0 } from "./schema-emitter-3-0.js"; +import { createSchemaEmitter3_1 } from "./schema-emitter-3-1.js"; +import { OpenAPI3Schema, OpenAPISchema3_1, SupportedOpenAPIDocuments } from "./types.js"; +import { VisibilityUsageTracker } from "./visibility-usage.js"; +import { XmlModule } from "./xml-module.js"; + +export type CreateSchemaEmitter = (props: { + program: Program; + context: EmitContext; + metadataInfo: MetadataInfo; + visibilityUsage: VisibilityUsageTracker; + options: ResolvedOpenAPI3EmitterOptions; + optionalDependencies: { jsonSchemaModule?: JsonSchemaModule; xmlModule?: XmlModule }; +}) => AssetEmitter; + +export interface OpenApiSpecSpecificProps { + applyEncoding( + program: Program, + typespecType: Scalar | ModelProperty, + target: OpenAPI3Schema, + options: ResolvedOpenAPI3EmitterOptions, + ): OpenAPI3Schema & OpenAPISchema3_1; + createRootDoc: ( + program: Program, + serviceType: Namespace, + serviceVersion?: string, + ) => SupportedOpenAPIDocuments; + + createSchemaEmitter: CreateSchemaEmitter; + /** + * Returns the binary description for an unencoded binary type + * @see https://spec.openapis.org/oas/v3.1.1.html#migrating-binary-descriptions-from-oas-3-0 + */ + getRawBinarySchema(contentType?: string): OpenAPI3Schema | OpenAPISchema3_1; + + isRawBinarySchema(schema: OpenAPI3Schema | OpenAPISchema3_1): boolean; +} + +export function getOpenApiSpecProps(specVersion: OpenAPIVersion): OpenApiSpecSpecificProps { + switch (specVersion) { + case "3.0.0": + return { + applyEncoding: applyEncoding3_0, + createRootDoc(program, serviceType, serviceVersion) { + return createRoot(program, serviceType, specVersion, serviceVersion); + }, + createSchemaEmitter: createSchemaEmitter3_0, + getRawBinarySchema: getRawBinarySchema3_0, + isRawBinarySchema: isRawBinarySchema3_0, + }; + case "3.1.0": + return { + applyEncoding: applyEncoding3_1, + createRootDoc(program, serviceType, serviceVersion) { + return createRoot(program, serviceType, specVersion, serviceVersion); + }, + createSchemaEmitter: createSchemaEmitter3_1, + getRawBinarySchema: getRawBinarySchema3_1, + isRawBinarySchema: isRawBinarySchema3_1, + }; + } +} + +function createRoot( + program: Program, + serviceType: Namespace, + specVersion: OpenAPIVersion, + serviceVersion?: string, +): SupportedOpenAPIDocuments { + const info = resolveInfo(program, serviceType); + + return { + openapi: specVersion, + info: { + title: "(title)", + ...info, + version: serviceVersion ?? info?.version ?? "0.0.0", + }, + externalDocs: getExternalDocs(program, serviceType), + tags: [], + paths: {}, + security: undefined, + components: { + parameters: {}, + requestBodies: {}, + responses: {}, + schemas: {}, + examples: {}, + securitySchemes: {}, + }, + }; +} diff --git a/packages/openapi3/src/openapi.ts b/packages/openapi3/src/openapi.ts index e4ad848b7d..663d62c549 100644 --- a/packages/openapi3/src/openapi.ts +++ b/packages/openapi3/src/openapi.ts @@ -80,20 +80,18 @@ import { getParameterKey, getTagsMetadata, isReadonlyProperty, - resolveInfo, resolveOperationId, shouldInline, } from "@typespec/openapi"; import { buildVersionProjections, VersionProjections } from "@typespec/versioning"; import { stringify } from "yaml"; import { getRef } from "./decorators.js"; -import { applyEncoding } from "./encoding.js"; import { getExampleOrExamples, OperationExamples, resolveOperationExamples } from "./examples.js"; -import { createDiagnostic, FileType, OpenAPI3EmitterOptions } from "./lib.js"; -import { getDefaultValue, isBytesKeptRaw, OpenAPI3SchemaEmitter } from "./schema-emitter.js"; +import { JsonSchemaModule, resolveJsonSchemaModule } from "./json-schema.js"; +import { createDiagnostic, FileType, OpenAPI3EmitterOptions, OpenAPIVersion } from "./lib.js"; +import { getOpenApiSpecProps } from "./openapi-spec-mappings.js"; import { getOpenAPI3StatusCodes } from "./status-codes.js"; import { - OpenAPI3Document, OpenAPI3Encoding, OpenAPI3Header, OpenAPI3MediaType, @@ -111,9 +109,17 @@ import { OpenAPI3StatusCode, OpenAPI3Tag, OpenAPI3VersionedServiceRecord, + OpenAPISchema3_1, Refable, + SupportedOpenAPIDocuments, } from "./types.js"; -import { deepEquals, isSharedHttpOperation, SharedHttpOperation } from "./util.js"; +import { + deepEquals, + getDefaultValue, + isBytesKeptRaw, + isSharedHttpOperation, + SharedHttpOperation, +} from "./util.js"; import { resolveVisibilityUsage, VisibilityUsageTracker } from "./visibility-usage.js"; import { resolveXmlModule, XmlModule } from "./xml-module.js"; @@ -127,8 +133,10 @@ const defaultOptions = { export async function $onEmit(context: EmitContext) { const options = resolveOptions(context); - const emitter = createOAPIEmitter(context, options); - await emitter.emitOpenAPI(); + for (const specVersion of options.openapiVersions) { + const emitter = createOAPIEmitter(context, options, specVersion); + await emitter.emitOpenAPI(); + } } type IrrelevantOpenAPI3EmitterOptionsForObject = "file-type" | "output-file" | "new-line"; @@ -158,8 +166,12 @@ export async function getOpenAPI3( }; const resolvedOptions = resolveOptions(context); - const emitter = createOAPIEmitter(context, resolvedOptions); - return emitter.getOpenAPI(); + const serviceRecords: OpenAPI3ServiceRecord[] = []; + for (const specVersion of resolvedOptions.openapiVersions) { + const emitter = createOAPIEmitter(context, resolvedOptions, specVersion); + serviceRecords.push(...(await emitter.getOpenAPI())); + } + return serviceRecords; } function findFileTypeFromFilename(filename: string | undefined): FileType { @@ -186,19 +198,26 @@ export function resolveOptions( const outputFile = resolvedOptions["output-file"] ?? `openapi.{service-name}.{version}.${fileType}`; + + const openapiVersions = resolvedOptions["openapi-versions"] ?? ["3.0.0"]; + + const specDir = openapiVersions.length > 1 ? "{openapi-version}" : ""; + return { fileType, newLine: resolvedOptions["new-line"], omitUnreachableTypes: resolvedOptions["omit-unreachable-types"], includeXTypeSpecName: resolvedOptions["include-x-typespec-name"], safeintStrategy: resolvedOptions["safeint-strategy"], - outputFile: resolvePath(context.emitterOutputDir, outputFile), + outputFile: resolvePath(context.emitterOutputDir, specDir, outputFile), + openapiVersions, }; } export interface ResolvedOpenAPI3EmitterOptions { fileType: FileType; outputFile: string; + openapiVersions: OpenAPIVersion[]; newLine: NewLine; omitUnreachableTypes: boolean; includeXTypeSpecName: "inline-only" | "never"; @@ -208,11 +227,19 @@ export interface ResolvedOpenAPI3EmitterOptions { function createOAPIEmitter( context: EmitContext, options: ResolvedOpenAPI3EmitterOptions, + specVersion: OpenAPIVersion = "3.0.0", ) { + const { + applyEncoding, + createRootDoc, + createSchemaEmitter, + getRawBinarySchema, + isRawBinarySchema, + } = getOpenApiSpecProps(specVersion); let program = context.program; - let schemaEmitter: AssetEmitter; + let schemaEmitter: AssetEmitter; - let root: OpenAPI3Document; + let root: SupportedOpenAPIDocuments; let diagnostics: DiagnosticCollector; let currentService: Service; let serviceAuth: HttpServiceAuthentication; @@ -290,7 +317,7 @@ function createOAPIEmitter( service: Service, allHttpAuthentications: HttpAuth[], defaultAuth: AuthenticationReference, - xmlModule: XmlModule | undefined, + optionalDependencies: { jsonSchemaModule?: JsonSchemaModule; xmlModule?: XmlModule }, version?: string, ) { diagnostics = createDiagnosticCollector(); @@ -306,40 +333,23 @@ function createOAPIEmitter( options.omitUnreachableTypes, ); - schemaEmitter = createAssetEmitter( + schemaEmitter = createSchemaEmitter({ program, - class extends OpenAPI3SchemaEmitter { - constructor(emitter: AssetEmitter, OpenAPI3EmitterOptions>) { - super(emitter, metadataInfo, visibilityUsage, options, xmlModule); - } - } as any, context, - ); + metadataInfo, + visibilityUsage, + options, + optionalDependencies, + }); const securitySchemes = getOpenAPISecuritySchemes(allHttpAuthentications); const security = getOpenAPISecurity(defaultAuth); - const info = resolveInfo(program, service.type); - root = { - openapi: "3.0.0", - info: { - title: "(title)", - ...info, - version: version ?? info?.version ?? "0.0.0", - }, - externalDocs: getExternalDocs(program, service.type), - tags: [], - paths: {}, - security: security.length > 0 ? security : undefined, - components: { - parameters: {}, - requestBodies: {}, - responses: {}, - schemas: {}, - examples: {}, - securitySchemes: securitySchemes, - }, - }; + root = createRootDoc(program, service.type, version); + if (security.length > 0) { + root.security = security; + } + root.components!.securitySchemes = securitySchemes; const servers = getServers(program, service.type); if (servers) { @@ -515,6 +525,7 @@ function createOAPIEmitter( function resolveOutputFile(service: Service, multipleService: boolean, version?: string): string { return interpolatePath(options.outputFile, { + "openapi-version": specVersion, "service-name": multipleService ? getNamespaceFullName(service.type) : undefined, version, }); @@ -627,13 +638,20 @@ function createOAPIEmitter( async function getOpenApiFromVersion( service: Service, version?: string, - ): Promise<[OpenAPI3Document, Readonly] | undefined> { + ): Promise<[SupportedOpenAPIDocuments, Readonly] | undefined> { try { const httpService = ignoreDiagnostics(getHttpService(program, service.type)); const auth = (serviceAuth = resolveAuthentication(httpService)); const xmlModule = await resolveXmlModule(); - initializeEmitter(service, auth.schemes, auth.defaultAuth, xmlModule, version); + const jsonSchemaModule = await resolveJsonSchemaModule(); + initializeEmitter( + service, + auth.schemes, + auth.defaultAuth, + { xmlModule, jsonSchemaModule }, + version, + ); reportIfNoRoutes(program, httpService.operations); for (const op of resolveOperations(httpService.operations)) { @@ -1079,7 +1097,7 @@ function createOAPIEmitter( ): OpenAPI3MediaType { const isBinary = isBinaryPayload(body.type, contentType); if (isBinary) { - return { schema: { type: "string", format: "binary" } }; + return { schema: getRawBinarySchema(contentType) } as OpenAPI3MediaType; } const oai3Examples = examples && getExampleOrExamples(program, examples); @@ -1128,7 +1146,7 @@ function createOAPIEmitter( for (const [partIndex, part] of body.parts.entries()) { const partName = part.name ?? `part${partIndex}`; let schema = isBytesKeptRaw(program, part.body.type) - ? { type: "string", format: "binary" } + ? getRawBinarySchema() : getSchemaForSingleBody( part.body.type, visibility, @@ -1218,10 +1236,8 @@ function createOAPIEmitter( return schema.type === "string" || schema.type === "number"; case "application/octet-stream": return ( - (schema.type === "string" && schema.format === "binary") || - (schema.type === "array" && - (schema.items as any)?.type === "string" && - (schema.items as any)?.format === "binary") + isRawBinarySchema(schema) || + (schema.type === "array" && !!schema.items && isRawBinarySchema(schema.items as any)) ); case "application/json": return schema.type === "object"; @@ -1834,7 +1850,7 @@ function createOAPIEmitter( } } -function serializeDocument(root: OpenAPI3Document, fileType: FileType): string { +function serializeDocument(root: SupportedOpenAPIDocuments, fileType: FileType): string { sortOpenAPIDocument(root); switch (fileType) { case "json": @@ -1868,7 +1884,7 @@ function sortObjectByKeys>(obj: T): T { }, {}); } -function sortOpenAPIDocument(doc: OpenAPI3Document): void { +function sortOpenAPIDocument(doc: SupportedOpenAPIDocuments): void { doc.paths = sortObjectByKeys(doc.paths); if (doc.components?.schemas) { doc.components.schemas = sortObjectByKeys(doc.components.schemas); diff --git a/packages/openapi3/src/schema-emitter-3-0.ts b/packages/openapi3/src/schema-emitter-3-0.ts new file mode 100644 index 0000000000..3ddbd77477 --- /dev/null +++ b/packages/openapi3/src/schema-emitter-3-0.ts @@ -0,0 +1,281 @@ +import { + compilerAssert, + Enum, + getExamples, + getMaxValueExclusive, + getMinValueExclusive, + IntrinsicType, + isNullType, + Model, + ModelProperty, + Scalar, + serializeValueAsJson, + Type, + Union, +} from "@typespec/compiler"; +import { + AssetEmitter, + createAssetEmitter, + EmitterOutput, + ObjectBuilder, + Placeholder, + TypeEmitter, +} from "@typespec/compiler/emitter-framework"; +import { MetadataInfo } from "@typespec/http"; +import { shouldInline } from "@typespec/openapi"; +import { getOneOf } from "./decorators.js"; +import { JsonSchemaModule } from "./json-schema.js"; +import { OpenAPI3EmitterOptions, reportDiagnostic } from "./lib.js"; +import { applyEncoding, getRawBinarySchema } from "./openapi-helpers-3-0.js"; +import { CreateSchemaEmitter } from "./openapi-spec-mappings.js"; +import { ResolvedOpenAPI3EmitterOptions } from "./openapi.js"; +import { Builders, OpenAPI3SchemaEmitterBase } from "./schema-emitter.js"; +import { JsonType, OpenAPI3Schema } from "./types.js"; +import { isBytesKeptRaw, isLiteralType, literalType } from "./util.js"; +import { VisibilityUsageTracker } from "./visibility-usage.js"; +import { XmlModule } from "./xml-module.js"; + +function createWrappedSchemaEmitterClass( + metadataInfo: MetadataInfo, + visibilityUsage: VisibilityUsageTracker, + options: ResolvedOpenAPI3EmitterOptions, + optionalDependencies: { jsonSchemaModule?: JsonSchemaModule; xmlModule?: XmlModule }, +): typeof TypeEmitter, OpenAPI3EmitterOptions> { + return class extends OpenAPI3SchemaEmitter { + constructor(emitter: AssetEmitter, OpenAPI3EmitterOptions>) { + super(emitter, metadataInfo, visibilityUsage, options, optionalDependencies); + } + }; +} + +export const createSchemaEmitter3_0: CreateSchemaEmitter = ({ program, context, ...rest }) => { + return createAssetEmitter( + program, + createWrappedSchemaEmitterClass( + rest.metadataInfo, + rest.visibilityUsage, + rest.options, + rest.optionalDependencies, + ), + context, + ); +}; + +/** + * OpenAPI 3.0 schema emitter. Deals with emitting content of `components/schemas` section. + */ +export class OpenAPI3SchemaEmitter extends OpenAPI3SchemaEmitterBase { + #applySchemaExamples( + type: Model | Scalar | Union | Enum | ModelProperty, + target: ObjectBuilder, + ) { + const program = this.emitter.getProgram(); + const examples = getExamples(program, type); + if (examples.length > 0) { + target.set("example", serializeValueAsJson(program, examples[0].value, type)); + } + } + + applyCustomConstraints( + type: Scalar | Model | ModelProperty | Union | Enum, + target: ObjectBuilder, + refSchema?: OpenAPI3Schema, + ) { + const program = this.emitter.getProgram(); + + const minValueExclusive = getMinValueExclusive(program, type); + if (minValueExclusive !== undefined) { + target.minimum = minValueExclusive; + target.exclusiveMinimum = true; + } + + const maxValueExclusive = getMaxValueExclusive(program, type); + if (maxValueExclusive !== undefined) { + target.maximum = maxValueExclusive; + target.exclusiveMaximum = true; + } + + this.#applySchemaExamples(type, target); + } + + applyEncoding( + typespecType: Scalar | ModelProperty, + target: OpenAPI3Schema | Placeholder, + ): OpenAPI3Schema { + return applyEncoding(this.emitter.getProgram(), typespecType, target as any, this._options); + } + + getRawBinarySchema(): OpenAPI3Schema { + return getRawBinarySchema(); + } + + enumSchema(en: Enum): OpenAPI3Schema { + const program = this.emitter.getProgram(); + if (en.members.size === 0) { + reportDiagnostic(program, { code: "empty-enum", target: en }); + return {}; + } + + const enumTypes = new Set(); + const enumValues = new Set(); + for (const member of en.members.values()) { + enumTypes.add(typeof member.value === "number" ? "number" : "string"); + enumValues.add(member.value ?? member.name); + } + + if (enumTypes.size > 1) { + reportDiagnostic(program, { code: "enum-unique-type", target: en }); + } + + const schema: OpenAPI3Schema = { + type: enumTypes.values().next().value!, + enum: [...enumValues], + }; + + return this.applyConstraints(en, schema); + } + + unionSchema(union: Union): ObjectBuilder { + const program = this.emitter.getProgram(); + if (union.variants.size === 0) { + reportDiagnostic(program, { code: "empty-union", target: union }); + return new ObjectBuilder({}); + } + const variants = Array.from(union.variants.values()); + const literalVariantEnumByType: Record = {}; + const ofType = getOneOf(program, union) ? "oneOf" : "anyOf"; + const schemaMembers: { schema: any; type: Type | null }[] = []; + let nullable = false; + const isMultipart = this.getContentType().startsWith("multipart/"); + + for (const variant of variants) { + if (isNullType(variant.type)) { + nullable = true; + continue; + } + + if (isMultipart && isBytesKeptRaw(program, variant.type)) { + schemaMembers.push({ schema: this.getRawBinarySchema(), type: variant.type }); + continue; + } + + if (isLiteralType(variant.type)) { + if (!literalVariantEnumByType[variant.type.kind]) { + const enumValue: any[] = [variant.type.value]; + literalVariantEnumByType[variant.type.kind] = enumValue; + schemaMembers.push({ + schema: { type: literalType(variant.type), enum: enumValue }, + type: null, + }); + } else { + literalVariantEnumByType[variant.type.kind].push(variant.type.value); + } + } else { + const enumSchema = this.emitter.emitTypeReference(variant.type, { + referenceContext: isMultipart ? { contentType: "application/json" } : {}, + }); + compilerAssert(enumSchema.kind === "code", "Unexpected enum schema. Should be kind: code"); + schemaMembers.push({ schema: enumSchema.value, type: variant.type }); + } + } + + const wrapWithObjectBuilder = ( + schemaMember: { schema: any; type: Type | null }, + { mergeUnionWideConstraints }: { mergeUnionWideConstraints: boolean }, + ): ObjectBuilder => { + // we can just return the single schema member after applying nullable + const schema = schemaMember.schema; + const type = schemaMember.type; + const additionalProps: Partial = mergeUnionWideConstraints + ? this.applyConstraints(union, {}) + : {}; + + if (mergeUnionWideConstraints && nullable) { + additionalProps.nullable = true; + } + + if (Object.keys(additionalProps).length === 0) { + return new ObjectBuilder(schema); + } else { + if ( + (schema instanceof Placeholder || "$ref" in schema) && + !(type && shouldInline(program, type)) + ) { + if (type && (type.kind === "Model" || type.kind === "Scalar")) { + return new ObjectBuilder({ + type: "object", + allOf: Builders.array([schema]), + ...additionalProps, + }); + } else { + return new ObjectBuilder({ allOf: Builders.array([schema]), ...additionalProps }); + } + } else { + const merged = new ObjectBuilder(schema); + for (const [key, value] of Object.entries(additionalProps)) { + merged.set(key, value); + } + return merged; + } + } + }; + + const checkMerge = (schemaMembers: { schema: any; type: Type | null }[]): boolean => { + if (nullable) { + for (const m of schemaMembers) { + if (m.schema instanceof Placeholder || "$ref" in m.schema) { + return true; + } + } + } + return false; + }; + + if (schemaMembers.length === 0) { + if (nullable) { + // This union is equivalent to just `null` but OA3 has no way to specify + // null as a value, so we throw an error. + reportDiagnostic(program, { code: "union-null", target: union }); + return new ObjectBuilder({}); + } else { + // completely empty union can maybe only happen with bugs? + compilerAssert(false, "Attempting to emit an empty union"); + } + } + + if (schemaMembers.length === 1) { + return wrapWithObjectBuilder(schemaMembers[0], { mergeUnionWideConstraints: true }); + } + + const isMerge = checkMerge(schemaMembers); + const schema: OpenAPI3Schema = { + [ofType]: schemaMembers.map((m) => + wrapWithObjectBuilder(m, { mergeUnionWideConstraints: isMerge }), + ), + }; + + if (!isMerge && nullable) { + schema.nullable = true; + } + + this.applyDiscriminator(union, schema); + + return this.applyConstraints(union, schema); + } + + intrinsic(intrinsic: IntrinsicType, name: string): EmitterOutput { + switch (name) { + case "unknown": + return {}; + case "null": + return { nullable: true }; + } + + reportDiagnostic(this.emitter.getProgram(), { + code: "invalid-schema", + format: { type: name }, + target: intrinsic, + }); + return {}; + } +} diff --git a/packages/openapi3/src/schema-emitter-3-1.ts b/packages/openapi3/src/schema-emitter-3-1.ts new file mode 100644 index 0000000000..6f1152377f --- /dev/null +++ b/packages/openapi3/src/schema-emitter-3-1.ts @@ -0,0 +1,319 @@ +import { + compilerAssert, + Enum, + getExamples, + getMaxValueExclusive, + getMinValueExclusive, + IntrinsicScalarName, + IntrinsicType, + Model, + ModelProperty, + Program, + Scalar, + serializeValueAsJson, + Tuple, + Type, + Union, +} from "@typespec/compiler"; +import { + ArrayBuilder, + AssetEmitter, + createAssetEmitter, + EmitterOutput, + ObjectBuilder, + Placeholder, + TypeEmitter, +} from "@typespec/compiler/emitter-framework"; +import { MetadataInfo } from "@typespec/http"; +import { shouldInline } from "@typespec/openapi"; +import { getOneOf } from "./decorators.js"; +import { JsonSchemaModule } from "./json-schema.js"; +import { OpenAPI3EmitterOptions, reportDiagnostic } from "./lib.js"; +import { applyEncoding, getRawBinarySchema } from "./openapi-helpers-3-1.js"; +import { CreateSchemaEmitter } from "./openapi-spec-mappings.js"; +import { ResolvedOpenAPI3EmitterOptions } from "./openapi.js"; +import { Builders, OpenAPI3SchemaEmitterBase } from "./schema-emitter.js"; +import { JsonType, OpenAPISchema3_1 } from "./types.js"; +import { isBytesKeptRaw, isLiteralType, literalType } from "./util.js"; +import { VisibilityUsageTracker } from "./visibility-usage.js"; +import { XmlModule } from "./xml-module.js"; + +function createWrappedSchemaEmitterClass( + metadataInfo: MetadataInfo, + visibilityUsage: VisibilityUsageTracker, + options: ResolvedOpenAPI3EmitterOptions, + optionalDependencies: { jsonSchemaModule?: JsonSchemaModule; xmlModule?: XmlModule }, +): typeof TypeEmitter, OpenAPI3EmitterOptions> { + return class extends OpenAPI31SchemaEmitter { + constructor(emitter: AssetEmitter, OpenAPI3EmitterOptions>) { + super(emitter, metadataInfo, visibilityUsage, options, optionalDependencies); + } + }; +} + +export const createSchemaEmitter3_1: CreateSchemaEmitter = ({ program, context, ...rest }) => { + return createAssetEmitter( + program, + createWrappedSchemaEmitterClass( + rest.metadataInfo, + rest.visibilityUsage, + rest.options, + rest.optionalDependencies, + ), + context, + ); +}; + +/** + * OpenAPI 3.1 schema emitter. Deals with emitting content of `components/schemas` section. + */ +export class OpenAPI31SchemaEmitter extends OpenAPI3SchemaEmitterBase { + #applySchemaExamples( + program: Program, + type: Model | Scalar | Union | Enum | ModelProperty, + target: ObjectBuilder, + ) { + const examples = getExamples(program, type); + if (examples.length > 0) { + target.set( + "examples", + examples.map((example) => serializeValueAsJson(program, example.value, type)), + ); + } + } + + applyCustomConstraints( + type: Scalar | Model | ModelProperty | Union | Enum, + target: ObjectBuilder, + refSchema?: OpenAPISchema3_1, + ) { + const applyConstraint = (fn: (p: Program, t: Type) => any, key: keyof OpenAPISchema3_1) => { + const value = fn(program, type); + if (value !== undefined) { + target[key] = value; + } + }; + + const applyTypeConstraint = (fn: (p: Program, t: Type) => Type | undefined, key: string) => { + const constraintType = fn(this.emitter.getProgram(), type); + if (constraintType) { + const ref = this.emitter.emitTypeReference(constraintType); + compilerAssert(ref.kind === "code", "Unexpected non-code result from emit reference"); + target.set(key, ref.value); + } + }; + + const program = this.emitter.getProgram(); + + const minValueExclusive = getMinValueExclusive(program, type); + if (minValueExclusive !== undefined) { + target.minimum = undefined; + target.exclusiveMinimum = minValueExclusive; + } + + const maxValueExclusive = getMaxValueExclusive(program, type); + if (maxValueExclusive !== undefined) { + target.maximum = undefined; + target.exclusiveMaximum = maxValueExclusive; + } + + // apply json schema decorators + const jsonSchemaModule = this._jsonSchemaModule; + if (jsonSchemaModule) { + applyTypeConstraint(jsonSchemaModule.getContains, "contains"); + applyConstraint(jsonSchemaModule.getMinContains, "minContains"); + applyConstraint(jsonSchemaModule.getMaxContains, "maxContains"); + applyConstraint(jsonSchemaModule.getContentEncoding, "contentEncoding"); + applyConstraint(jsonSchemaModule.getContentMediaType, "contentMediaType"); + applyTypeConstraint(jsonSchemaModule.getContentSchema, "contentSchema"); + + const prefixItems = jsonSchemaModule.getPrefixItems(program, type); + if (prefixItems) { + const prefixItemsSchema = new ArrayBuilder>(); + for (const item of prefixItems.values) { + prefixItemsSchema.push(this.emitter.emitTypeReference(item)); + } + target.set("prefixItems", prefixItemsSchema as any); + } + } + + this.#applySchemaExamples(program, type, target); + } + + applyEncoding( + typespecType: Scalar | ModelProperty, + target: OpenAPISchema3_1 | Placeholder, + ): OpenAPISchema3_1 { + return applyEncoding(this.emitter.getProgram(), typespecType, target as any, this._options); + } + + getRawBinarySchema(): OpenAPISchema3_1 { + return getRawBinarySchema(); + } + + getSchemaForStdScalars(scalar: Scalar & { name: IntrinsicScalarName }): OpenAPISchema3_1 { + // Raw binary data is handled separately when resolving a request/response body. + // Open API 3.1 treats encoded binaries differently from Open API 3.0, so we need to handle + // the Scalar 'bytes' special here. + // @see https://spec.openapis.org/oas/v3.1.1.html#working-with-binary-data + if (scalar.name === "bytes") { + const contentType = this.emitter.getContext().contentType; + return { type: "string", contentMediaType: contentType, contentEncoding: "base64" }; + } + return super.getSchemaForStdScalars(scalar); + } + + enumSchema(en: Enum): OpenAPISchema3_1 { + const program = this.emitter.getProgram(); + if (en.members.size === 0) { + reportDiagnostic(program, { code: "empty-enum", target: en }); + return {}; + } + + const enumTypes = new Set(); + const enumValues = new Set(); + for (const member of en.members.values()) { + enumTypes.add(typeof member.value === "number" ? "number" : "string"); + enumValues.add(member.value ?? member.name); + } + + const enumTypesArray = [...enumTypes]; + + const schema: OpenAPISchema3_1 = { + type: enumTypesArray.length === 1 ? enumTypesArray[0] : enumTypesArray, + enum: [...enumValues], + }; + + return this.applyConstraints(en, schema); + } + + unionSchema(union: Union): ObjectBuilder { + const program = this.emitter.getProgram(); + if (union.variants.size === 0) { + reportDiagnostic(program, { code: "empty-union", target: union }); + return new ObjectBuilder({}); + } + const variants = Array.from(union.variants.values()); + const literalVariantEnumByType: Record = {}; + const ofType = getOneOf(program, union) ? "oneOf" : "anyOf"; + const schemaMembers: { schema: any; type: Type | null }[] = []; + const isMultipart = this.getContentType().startsWith("multipart/"); + + // 1. Iterate over all the union variants to generate a schema for each one. + for (const variant of variants) { + // 2. Special handling for multipart - want to treat as binary + if (isMultipart && isBytesKeptRaw(program, variant.type)) { + schemaMembers.push({ schema: this.getRawBinarySchema(), type: variant.type }); + continue; + } + + // 3.a. Literal types are actual values (though not Value types) + if (isLiteralType(variant.type)) { + // Create schemas grouped by kind (boolean, string, numeric) + // and add the literals seen to each respective `enum` array + if (!literalVariantEnumByType[variant.type.kind]) { + const enumValue: any[] = [variant.type.value]; + literalVariantEnumByType[variant.type.kind] = enumValue; + schemaMembers.push({ + schema: { type: literalType(variant.type), enum: enumValue }, + type: null, + }); + } else { + literalVariantEnumByType[variant.type.kind].push(variant.type.value); + } + } else { + // 3.b. Anything else, we get the schema for that type. + const enumSchema = this.emitter.emitTypeReference(variant.type, { + referenceContext: isMultipart ? { contentType: "application/json" } : {}, + }); + compilerAssert(enumSchema.kind === "code", "Unexpected enum schema. Should be kind: code"); + schemaMembers.push({ schema: enumSchema.value, type: variant.type }); + } + } + + const wrapWithObjectBuilder = ( + schemaMember: { schema: any; type: Type | null }, + { mergeUnionWideConstraints }: { mergeUnionWideConstraints: boolean }, + ): ObjectBuilder => { + const schema = schemaMember.schema; + const type = schemaMember.type; + const additionalProps: Partial = mergeUnionWideConstraints + ? this.applyConstraints(union, {}) + : {}; + + if (Object.keys(additionalProps).length === 0) { + return new ObjectBuilder(schema); + } else { + if ( + (schema instanceof Placeholder || "$ref" in schema) && + !(type && shouldInline(program, type)) + ) { + if (type && (type.kind === "Model" || type.kind === "Scalar")) { + return new ObjectBuilder({ + type: "object", + allOf: Builders.array([schema]), + ...additionalProps, + }); + } else { + return new ObjectBuilder({ allOf: Builders.array([schema]), ...additionalProps }); + } + } else { + const merged = new ObjectBuilder(schema); + for (const [key, value] of Object.entries(additionalProps)) { + merged.set(key, value); + } + return merged; + } + } + }; + + if (schemaMembers.length === 0) { + compilerAssert(false, "Attempting to emit an empty union"); + } + + if (schemaMembers.length === 1) { + return wrapWithObjectBuilder(schemaMembers[0], { mergeUnionWideConstraints: true }); + } + + const schema: OpenAPISchema3_1 = { + [ofType]: schemaMembers.map((m) => + wrapWithObjectBuilder(m, { mergeUnionWideConstraints: false }), + ), + }; + + this.applyDiscriminator(union, schema); + + return this.applyConstraints(union, schema); + } + + intrinsic(intrinsic: IntrinsicType, name: string): EmitterOutput { + switch (name) { + case "unknown": + return {}; + case "null": + return { type: "null" }; + } + + reportDiagnostic(this.emitter.getProgram(), { + code: "invalid-schema", + format: { type: name }, + target: intrinsic, + }); + return {}; + } + + tupleLiteral(tuple: Tuple): EmitterOutput> { + return new ObjectBuilder({ + type: "array", + prefixItems: this.emitter.emitTupleLiteralValues(tuple), + }); + } + + tupleLiteralValues(tuple: Tuple): EmitterOutput> { + const values = new ArrayBuilder(); + for (const value of tuple.values.values()) { + values.push(this.emitter.emitType(value)); + } + return values; + } +} diff --git a/packages/openapi3/src/schema-emitter.ts b/packages/openapi3/src/schema-emitter.ts index 4ecf08b542..ace487d424 100644 --- a/packages/openapi3/src/schema-emitter.ts +++ b/packages/openapi3/src/schema-emitter.ts @@ -4,7 +4,6 @@ import { Enum, EnumMember, IntrinsicScalarName, - IntrinsicType, Model, ModelProperty, NumericLiteral, @@ -17,7 +16,6 @@ import { TypeNameOptions, Union, UnionVariant, - Value, compilerAssert, explainStringTemplateNotSerializable, getDeprecated, @@ -25,17 +23,14 @@ import { getDiscriminator, getDoc, getEncode, - getExamples, getFormat, getKnownValues, getMaxItems, getMaxLength, getMaxValue, - getMaxValueExclusive, getMinItems, getMinLength, getMinValue, - getMinValueExclusive, getNamespaceFullName, getPattern, getSummary, @@ -43,11 +38,8 @@ import { ignoreDiagnostics, isArrayModelType, isNeverType, - isNullType, isSecret, - isTemplateDeclaration, resolveEncodedName, - serializeValueAsJson, } from "@typespec/compiler"; import { ArrayBuilder, @@ -66,49 +58,52 @@ import { import { MetadataInfo, Visibility, getVisibilitySuffix } from "@typespec/http"; import { checkDuplicateTypeName, - getExtensions, getExternalDocs, getOpenAPITypeName, isReadonlyProperty, shouldInline, } from "@typespec/openapi"; +import { attachExtensions } from "./attach-extensions.js"; import { getOneOf, getRef } from "./decorators.js"; -import { applyEncoding } from "./encoding.js"; +import { JsonSchemaModule } from "./json-schema.js"; import { OpenAPI3EmitterOptions, reportDiagnostic } from "./lib.js"; import { ResolvedOpenAPI3EmitterOptions } from "./openapi.js"; import { getSchemaForStdScalars } from "./std-scalar-schemas.js"; import { - JsonType, - OpenAPI3Discriminator, + CommonOpenAPI3Schema, OpenAPI3Schema, OpenAPI3SchemaProperty, + OpenAPISchema3_1, } from "./types.js"; +import { getDefaultValue, includeDerivedModel, isBytesKeptRaw, isStdType } from "./util.js"; import { VisibilityUsageTracker } from "./visibility-usage.js"; import { XmlModule } from "./xml-module.js"; /** - * OpenAPI3 schema emitter. Deals with emitting content of `components/schemas` section. + * Base OpenAPI3 schema emitter. Deals with emitting content of `components/schemas` section. */ -export class OpenAPI3SchemaEmitter extends TypeEmitter< - Record, - OpenAPI3EmitterOptions -> { - #metadataInfo: MetadataInfo; - #visibilityUsage: VisibilityUsageTracker; - #options: ResolvedOpenAPI3EmitterOptions; - #xmlModule: XmlModule | undefined; +export class OpenAPI3SchemaEmitterBase< + Schema extends OpenAPI3Schema | OpenAPISchema3_1, +> extends TypeEmitter, OpenAPI3EmitterOptions> { + protected _metadataInfo: MetadataInfo; + protected _visibilityUsage: VisibilityUsageTracker; + protected _options: ResolvedOpenAPI3EmitterOptions; + protected _jsonSchemaModule: JsonSchemaModule | undefined; + protected _xmlModule: XmlModule | undefined; + constructor( emitter: AssetEmitter, OpenAPI3EmitterOptions>, metadataInfo: MetadataInfo, visibilityUsage: VisibilityUsageTracker, options: ResolvedOpenAPI3EmitterOptions, - xmlModule: XmlModule | undefined, + optionalDependencies: { jsonSchemaModule?: JsonSchemaModule; xmlModule?: XmlModule }, ) { super(emitter); - this.#metadataInfo = metadataInfo; - this.#visibilityUsage = visibilityUsage; - this.#options = options; - this.#xmlModule = xmlModule; + this._metadataInfo = metadataInfo; + this._visibilityUsage = visibilityUsage; + this._options = options; + this._jsonSchemaModule = optionalDependencies.jsonSchemaModule; + this._xmlModule = optionalDependencies.xmlModule; } modelDeclarationReferenceContext(model: Model, name: string): Context { @@ -134,10 +129,10 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< reduceContext(type: Type): Context { const visibility = this.#getVisibilityContext(); const patch: Record = {}; - if (visibility !== Visibility.Read && !this.#metadataInfo.isTransformed(type, visibility)) { + if (visibility !== Visibility.Read && !this._metadataInfo.isTransformed(type, visibility)) { patch.visibility = Visibility.Read; } - const contentType = this.#getContentType(); + const contentType = this.getContentType(); if (contentType === "application/json") { patch.contentType = undefined; @@ -146,6 +141,20 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< return patch; } + applyDiscriminator(type: Model | Union, schema: Schema): void { + const program = this.emitter.getProgram(); + const discriminator = getDiscriminator(program, type); + if (discriminator) { + // the decorator validates that all the variants will be a model type + // with the discriminator field present. + schema.discriminator = { ...discriminator }; + const discriminatedUnion = ignoreDiagnostics(getDiscriminatedUnion(type, discriminator)); + if (discriminatedUnion.variants.size > 0) { + schema.discriminator.mapping = this.getDiscriminatorMapping(discriminatedUnion); + } + } + } + modelDeclaration(model: Model, _: string): EmitterOutput { const program = this.emitter.getProgram(); const visibility = this.#getVisibilityContext(); @@ -165,28 +174,17 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< this.emitter.emitTypeReference(child); } - const discriminator = getDiscriminator(program, model); - if (discriminator) { - const [union] = getDiscriminatedUnion(model, discriminator); - - const openApiDiscriminator: OpenAPI3Discriminator = { ...discriminator }; - if (union.variants.size > 0) { - openApiDiscriminator.mapping = this.#getDiscriminatorMapping(union); - } - - schema.discriminator = openApiDiscriminator; - } - + this.applyDiscriminator(model, schema as any); this.#applyExternalDocs(model, schema); if (model.baseModel) { - schema.set("allOf", B.array([this.emitter.emitTypeReference(model.baseModel)])); + schema.set("allOf", Builders.array([this.emitter.emitTypeReference(model.baseModel)])); } const baseName = getOpenAPITypeName(program, model, this.#typeNameOptions()); - const isMultipart = this.#getContentType().startsWith("multipart/"); + const isMultipart = this.getContentType().startsWith("multipart/"); const name = isMultipart ? baseName + "MultiPart" : baseName; - return this.#createDeclaration(model, name, this.#applyConstraints(model, schema)); + return this.#createDeclaration(model, name, this.applyConstraints(model, schema as any)); } #applyExternalDocs(typespecType: Type, target: Record) { @@ -215,7 +213,7 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< return this.emitter.getContext().ignoreMetadataAnnotations; } - #getContentType(): string { + getContentType(): string { return this.emitter.getContext().contentType ?? "application/json"; } @@ -248,7 +246,7 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< items: this.emitter.emitTypeReference(elementType), }); - return this.#createDeclaration(array, name, this.#applyConstraints(array, schema)); + return this.#createDeclaration(array, name, this.applyConstraints(array, schema as any)); } arrayDeclarationReferenceContext(array: Model, name: string, elementType: Type): Context { @@ -283,16 +281,16 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< } if ( - !this.#metadataInfo.isPayloadProperty(prop, visibility, this.#ignoreMetadataAnnotations()) + !this._metadataInfo.isPayloadProperty(prop, visibility, this.#ignoreMetadataAnnotations()) ) { continue; } - if (!this.#metadataInfo.isOptional(prop, visibility)) { + if (!this._metadataInfo.isOptional(prop, visibility)) { const encodedName = resolveEncodedName( this.emitter.getProgram(), prop, - this.#getContentType(), + this.getContentType(), ); requiredProps.push(encodedName); @@ -313,7 +311,7 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< const program = this.emitter.getProgram(); const props = new ObjectBuilder(); const visibility = this.emitter.getContext().visibility; - const contentType = this.#getContentType(); + const contentType = this.getContentType(); for (const prop of model.properties.values()) { if (isNeverType(prop.type)) { @@ -321,7 +319,7 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< continue; } if ( - !this.#metadataInfo.isPayloadProperty(prop, visibility, this.#ignoreMetadataAnnotations()) + !this._metadataInfo.isPayloadProperty(prop, visibility, this.#ignoreMetadataAnnotations()) ) { continue; } @@ -345,19 +343,23 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< return props; } + getRawBinarySchema(): Schema { + throw new Error("Method not implemented."); + } + modelPropertyLiteral(prop: ModelProperty): EmitterOutput { const program = this.emitter.getProgram(); - const isMultipart = this.#getContentType().startsWith("multipart/"); + const isMultipart = this.getContentType().startsWith("multipart/"); if (isMultipart) { if (isBytesKeptRaw(program, prop.type) && getEncode(program, prop) === undefined) { - return { type: "string", format: "binary" }; + return this.getRawBinarySchema(); } if ( prop.type.kind === "Model" && isArrayModelType(program, prop.type) && isBytesKeptRaw(program, prop.type.indexer.value) ) { - return { type: "array", items: { type: "string", format: "binary" } }; + return { type: "array", items: this.getRawBinarySchema() }; } } @@ -383,10 +385,14 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< const isRef = refSchema.value instanceof Placeholder || "$ref" in refSchema.value; - const schema = this.#applyEncoding(prop, refSchema.value as any); + const schema = this.applyEncoding(prop, refSchema.value as any); // Apply decorators on the property to the type's schema - const additionalProps: Partial = this.#applyConstraints(prop, {}, schema); + const additionalProps: Partial = this.applyConstraints( + prop, + {} as Schema, + schema, + ) as any; if (prop.defaultValue) { additionalProps.default = getDefaultValue(program, prop.defaultValue, prop); } @@ -396,7 +402,7 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< } // Attach any additional OpenAPI extensions - this.#attachExtensions(program, prop, additionalProps); + attachExtensions(program, prop, additionalProps); if (schema && isRef && !(prop.type.kind === "Model" && isArrayModelType(program, prop.type))) { if (Object.keys(additionalProps).length === 0) { @@ -451,33 +457,12 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< enumDeclaration(en: Enum, name: string): EmitterOutput { const baseName = getOpenAPITypeName(this.emitter.getProgram(), en, this.#typeNameOptions()); - return this.#createDeclaration(en, baseName, new ObjectBuilder(this.#enumSchema(en))); + return this.#createDeclaration(en, baseName, new ObjectBuilder(this.enumSchema(en))); } - #enumSchema(en: Enum): OpenAPI3Schema { - const program = this.emitter.getProgram(); - if (en.members.size === 0) { - reportDiagnostic(program, { code: "empty-enum", target: en }); - return {}; - } - - const enumTypes = new Set(); - const enumValues = new Set(); - for (const member of en.members.values()) { - enumTypes.add(typeof member.value === "number" ? "number" : "string"); - enumValues.add(member.value ?? member.name); - } - - if (enumTypes.size > 1) { - reportDiagnostic(program, { code: "enum-unique-type", target: en }); - } - - const schema: OpenAPI3Schema = { - type: enumTypes.values().next().value!, - enum: [...enumValues], - }; - - return this.#applyConstraints(en, schema); + enumSchema(en: Enum): Schema { + // Enums are handled differently between 3.x versions due to the differences in `type` + throw new Error("Method not implemented."); } enumMember(member: EnumMember): EmitterOutput> { @@ -497,150 +482,18 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< } unionDeclaration(union: Union, name: string): EmitterOutput { - const schema = this.#unionSchema(union); + const schema = this.unionSchema(union); const baseName = getOpenAPITypeName(this.emitter.getProgram(), union, this.#typeNameOptions()); return this.#createDeclaration(union, baseName, schema); } - #unionSchema(union: Union): ObjectBuilder { - const program = this.emitter.getProgram(); - if (union.variants.size === 0) { - reportDiagnostic(program, { code: "empty-union", target: union }); - return new ObjectBuilder({}); - } - const variants = Array.from(union.variants.values()); - const literalVariantEnumByType: Record = {}; - const ofType = getOneOf(program, union) ? "oneOf" : "anyOf"; - const schemaMembers: { schema: any; type: Type | null }[] = []; - let nullable = false; - const discriminator = getDiscriminator(program, union); - const isMultipart = this.#getContentType().startsWith("multipart/"); - - for (const variant of variants) { - if (isNullType(variant.type)) { - nullable = true; - continue; - } - - if (isMultipart && isBytesKeptRaw(program, variant.type)) { - schemaMembers.push({ schema: { type: "string", format: "binary" }, type: variant.type }); - continue; - } - - if (isLiteralType(variant.type)) { - if (!literalVariantEnumByType[variant.type.kind]) { - const enumValue: any[] = [variant.type.value]; - literalVariantEnumByType[variant.type.kind] = enumValue; - schemaMembers.push({ - schema: { type: literalType(variant.type), enum: enumValue }, - type: null, - }); - } else { - literalVariantEnumByType[variant.type.kind].push(variant.type.value); - } - } else { - const enumSchema = this.emitter.emitTypeReference(variant.type, { - referenceContext: isMultipart ? { contentType: "application/json" } : {}, - }); - compilerAssert(enumSchema.kind === "code", "Unexpected enum schema. Should be kind: code"); - schemaMembers.push({ schema: enumSchema.value, type: variant.type }); - } - } - - const wrapWithObjectBuilder = ( - schemaMember: { schema: any; type: Type | null }, - { mergeUnionWideConstraints }: { mergeUnionWideConstraints: boolean }, - ): ObjectBuilder => { - // we can just return the single schema member after applying nullable - const schema = schemaMember.schema; - const type = schemaMember.type; - const additionalProps: Partial = mergeUnionWideConstraints - ? this.#applyConstraints(union, {}) - : {}; - - if (mergeUnionWideConstraints && nullable) { - additionalProps.nullable = true; - } - - if (Object.keys(additionalProps).length === 0) { - return new ObjectBuilder(schema); - } else { - if ( - (schema instanceof Placeholder || "$ref" in schema) && - !(type && shouldInline(program, type)) - ) { - if (type && (type.kind === "Model" || type.kind === "Scalar")) { - return new ObjectBuilder({ - type: "object", - allOf: B.array([schema]), - ...additionalProps, - }); - } else { - return new ObjectBuilder({ allOf: B.array([schema]), ...additionalProps }); - } - } else { - const merged = new ObjectBuilder(schema); - for (const [key, value] of Object.entries(additionalProps)) { - merged.set(key, value); - } - return merged; - } - } - }; - - const checkMerge = (schemaMembers: { schema: any; type: Type | null }[]): boolean => { - if (nullable) { - for (const m of schemaMembers) { - if (m.schema instanceof Placeholder || "$ref" in m.schema) { - return true; - } - } - } - return false; - }; - - if (schemaMembers.length === 0) { - if (nullable) { - // This union is equivalent to just `null` but OA3 has no way to specify - // null as a value, so we throw an error. - reportDiagnostic(program, { code: "union-null", target: union }); - return new ObjectBuilder({}); - } else { - // completely empty union can maybe only happen with bugs? - compilerAssert(false, "Attempting to emit an empty union"); - } - } - - if (schemaMembers.length === 1) { - return wrapWithObjectBuilder(schemaMembers[0], { mergeUnionWideConstraints: true }); - } - - const isMerge = checkMerge(schemaMembers); - const schema: OpenAPI3Schema = { - [ofType]: schemaMembers.map((m) => - wrapWithObjectBuilder(m, { mergeUnionWideConstraints: isMerge }), - ), - }; - - if (!isMerge && nullable) { - schema.nullable = true; - } - - if (discriminator) { - // the decorator validates that all the variants will be a model type - // with the discriminator field present. - schema.discriminator = { ...discriminator }; - // Diagnostic already reported in compiler for unions - const discriminatedUnion = ignoreDiagnostics(getDiscriminatedUnion(union, discriminator)); - if (discriminatedUnion.variants.size > 0) { - schema.discriminator.mapping = this.#getDiscriminatorMapping(discriminatedUnion); - } - } - - return this.#applyConstraints(union, schema); + unionSchema(union: Union): ObjectBuilder { + // Unions are handled differently between 3.x versions + // mostly due to how nullable properties are handled. + throw new Error("Method not implemented."); } - #getDiscriminatorMapping(union: DiscriminatedUnion) { + getDiscriminatorMapping(union: DiscriminatedUnion) { const mapping: Record | undefined = {}; for (const [key, model] of union.variants.entries()) { const ref = this.emitter.emitTypeReference(model); @@ -651,7 +504,7 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< } unionLiteral(union: Union): EmitterOutput { - return this.#unionSchema(union); + return this.unionSchema(union); } unionVariants(union: Union): EmitterOutput { @@ -670,16 +523,6 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< return this.modelPropertyLiteral(prop); } - #attachExtensions(program: Program, type: Type, emitObject: OpenAPI3Schema) { - // Attach any OpenAPI extensions - const extensions = getExtensions(program, type); - if (extensions) { - for (const key of extensions.keys()) { - emitObject[key] = extensions.get(key); - } - } - } - reference( targetDeclaration: Declaration>, pathUp: Scope>[], @@ -720,13 +563,15 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< return super.circularReference(target, scope, cycle); } - scalarDeclaration(scalar: Scalar, name: string): EmitterOutput { - const isStd = this.#isStdType(scalar); + scalarDeclaration(scalar: Scalar, name: string): EmitterOutput { + const isStd = isStdType(this.emitter.getProgram(), scalar); const schema = this.#getSchemaForScalar(scalar); const baseName = getOpenAPITypeName(this.emitter.getProgram(), scalar, this.#typeNameOptions()); // Don't create a declaration for std types - return isStd ? schema : this.#createDeclaration(scalar, baseName, new ObjectBuilder(schema)); + return isStd + ? schema + : (this.#createDeclaration(scalar, baseName, new ObjectBuilder(schema)) as any); } scalarInstantiation( @@ -739,15 +584,15 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< tupleLiteral(tuple: Tuple): EmitterOutput> { return { type: "array", items: {} }; } - #getSchemaForScalar(scalar: Scalar): OpenAPI3Schema { - let result: OpenAPI3Schema = {}; - const isStd = this.#isStdType(scalar); + #getSchemaForScalar(scalar: Scalar): Schema { + let result: Schema = {} as Schema; + const isStd = isStdType(this.emitter.getProgram(), scalar); if (isStd) { - result = this.#getSchemaForStdScalars(scalar); + result = this.getSchemaForStdScalars(scalar); } else if (scalar.baseScalar) { result = this.#getSchemaForScalar(scalar.baseScalar); } - const withDecorators = this.#applyEncoding(scalar, this.#applyConstraints(scalar, result)); + const withDecorators = this.applyEncoding(scalar, this.applyConstraints(scalar, result) as any); if (isStd) { // Standard types are going to be inlined in the spec and we don't want the description of the scalar to show up delete withDecorators.description; @@ -755,36 +600,31 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< return withDecorators; } - #getSchemaForStdScalars(scalar: Scalar & { name: IntrinsicScalarName }): OpenAPI3Schema { - return getSchemaForStdScalars(scalar, this.#options); + getSchemaForStdScalars(scalar: Scalar & { name: IntrinsicScalarName }): Schema { + return getSchemaForStdScalars(scalar, this._options) as Schema; } - #applySchemaExamples( - type: Model | Scalar | Union | Enum | ModelProperty, - target: ObjectBuilder, - ) { - const program = this.emitter.getProgram(); - const examples = getExamples(program, type); - if (examples.length > 0) { - target.set("example", serializeValueAsJson(program, examples[0].value, type)); - } - } + applyCustomConstraints( + type: Scalar | Model | ModelProperty | Union | Enum, + target: Schema, + refSchema?: Schema, + ) {} - #applyConstraints( + applyConstraints( type: Scalar | Model | ModelProperty | Union | Enum, - original: OpenAPI3Schema, - refSchema?: OpenAPI3Schema, - ): ObjectBuilder { - const schema = new ObjectBuilder(original); + original: Schema, + refSchema?: Schema, + ): ObjectBuilder { + // Apply common constraints + const schema = new ObjectBuilder(original); const program = this.emitter.getProgram(); - const applyConstraint = (fn: (p: Program, t: Type) => any, key: keyof OpenAPI3Schema) => { + const applyConstraint = (fn: (p: Program, t: Type) => any, key: keyof CommonOpenAPI3Schema) => { const value = fn(program, type); if (value !== undefined) { schema[key] = value; } }; - this.#applySchemaExamples(type, schema); applyConstraint(getMinLength, "minLength"); applyConstraint(getMaxLength, "maxLength"); applyConstraint(getMinValue, "minimum"); @@ -793,16 +633,13 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< applyConstraint(getMinItems, "minItems"); applyConstraint(getMaxItems, "maxItems"); - const minValueExclusive = getMinValueExclusive(program, type); - if (minValueExclusive !== undefined) { - schema.minimum = minValueExclusive; - schema.exclusiveMinimum = true; - } - - const maxValueExclusive = getMaxValueExclusive(program, type); - if (maxValueExclusive !== undefined) { - schema.maximum = maxValueExclusive; - schema.exclusiveMaximum = true; + // apply json schema decorators + const jsonSchemaModule = this._jsonSchemaModule; + if (jsonSchemaModule) { + applyConstraint(jsonSchemaModule.getMultipleOf, "multipleOf"); + applyConstraint(jsonSchemaModule.getUniqueItems, "uniqueItems"); + applyConstraint(jsonSchemaModule.getMinProperties, "minProperties"); + applyConstraint(jsonSchemaModule.getMaxProperties, "maxProperties"); } if (isSecret(program, type)) { @@ -811,7 +648,7 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< // the stdlib applies a format of "url" but json schema wants "uri", // so ignore this format if it's the built-in type. - if (!this.#isStdType(type) || type.name !== "url") { + if (!isStdType(program, type) || type.name !== "url") { applyConstraint(getFormat, "format"); } @@ -822,16 +659,38 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< "deprecated", ); - if (this.#xmlModule) { + this.applyCustomConstraints(type, schema as any, refSchema); + + this.applyXml(type, schema as any, refSchema); + attachExtensions(program, type, schema); + + const values = getKnownValues(program, type as any); + if (values) { + return new ObjectBuilder({ + oneOf: [schema, this.enumSchema(values)], + }); + } + + return new ObjectBuilder(schema); + } + + applyXml( + type: Scalar | Model | ModelProperty | Union | Enum, + schema: Schema, + refSchema?: Schema, + ): void { + const program = this.emitter.getProgram(); + + if (this._xmlModule) { switch (type.kind) { case "Scalar": case "Model": - this.#xmlModule.attachXmlObjectForScalarOrModel(program, type, schema); + this._xmlModule.attachXmlObjectForScalarOrModel(program, type, schema); break; case "ModelProperty": - this.#xmlModule.attachXmlObjectForModelProperty( + this._xmlModule.attachXmlObjectForModelProperty( program, - this.#options, + this._options, type, schema, refSchema, @@ -839,21 +698,10 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< break; } } - - this.#attachExtensions(program, type, schema); - - const values = getKnownValues(program, type as any); - if (values) { - return new ObjectBuilder({ - oneOf: [schema, this.#enumSchema(values)], - }); - } - - return new ObjectBuilder(schema); } #inlineType(type: Type, schema: ObjectBuilder) { - if (this.#options.includeXTypeSpecName !== "never") { + if (this._options.includeXTypeSpecName !== "never") { schema.set("x-typespec-name", getTypeName(type, this.#typeNameOptions())); } return schema; @@ -876,7 +724,7 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< schema.set("title", title); } - const usage = this.#visibilityUsage.getUsage(type); + const usage = this._visibilityUsage.getUsage(type); const shouldAddSuffix = usage !== undefined && usage.size > 1; const visibility = this.#getVisibilityContext(); @@ -894,31 +742,11 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< return decl; } - #isStdType(type: Type): type is Scalar & { name: IntrinsicScalarName } { - return this.emitter.getProgram().checker.isStdType(type); - } - - #applyEncoding( + applyEncoding( typespecType: Scalar | ModelProperty, - target: OpenAPI3Schema | Placeholder, - ): OpenAPI3Schema { - return applyEncoding(this.emitter.getProgram(), typespecType, target as any, this.#options); - } - - intrinsic(intrinsic: IntrinsicType, name: string): EmitterOutput { - switch (name) { - case "unknown": - return {}; - case "null": - return { nullable: true }; - } - - reportDiagnostic(this.emitter.getProgram(), { - code: "invalid-schema", - format: { type: name }, - target: intrinsic, - }); - return {}; + target: Schema | Placeholder, + ): Schema { + throw new Error("Method not implemented."); } programContext(program: Program): Context { @@ -927,31 +755,7 @@ export class OpenAPI3SchemaEmitter extends TypeEmitter< } } -function isLiteralType(type: Type): type is StringLiteral | NumericLiteral | BooleanLiteral { - return type.kind === "Boolean" || type.kind === "String" || type.kind === "Number"; -} - -function literalType(type: StringLiteral | NumericLiteral | BooleanLiteral) { - switch (type.kind) { - case "String": - return "string"; - case "Number": - return "number"; - case "Boolean": - return "boolean"; - } -} - -function includeDerivedModel(model: Model): boolean { - return ( - !isTemplateDeclaration(model) && - (model.templateMapper?.args === undefined || - model.templateMapper.args?.length === 0 || - model.derivedModels.length > 0) - ); -} - -const B = { +export const Builders = { array: (items: T[]): ArrayBuilder => { const builder = new ArrayBuilder(); for (const item of items) { @@ -967,15 +771,3 @@ const B = { return builder; }, } as const; - -export function getDefaultValue( - program: Program, - defaultType: Value, - modelProperty: ModelProperty, -): any { - return serializeValueAsJson(program, defaultType, modelProperty); -} - -export function isBytesKeptRaw(program: Program, type: Type) { - return type.kind === "Scalar" && type.name === "bytes" && getEncode(program, type) === undefined; -} diff --git a/packages/openapi3/src/std-scalar-schemas.ts b/packages/openapi3/src/std-scalar-schemas.ts index 0e66bf05bd..611875181f 100644 --- a/packages/openapi3/src/std-scalar-schemas.ts +++ b/packages/openapi3/src/std-scalar-schemas.ts @@ -1,11 +1,11 @@ import type { IntrinsicScalarName, Scalar } from "@typespec/compiler"; import type { ResolvedOpenAPI3EmitterOptions } from "./openapi.js"; -import type { OpenAPI3Schema } from "./types.js"; +import type { OpenAPI3Schema, OpenAPISchema3_1 } from "./types.js"; export function getSchemaForStdScalars( scalar: Scalar & { name: IntrinsicScalarName }, options: ResolvedOpenAPI3EmitterOptions, -): OpenAPI3Schema { +): OpenAPI3Schema & OpenAPISchema3_1 { switch (scalar.name) { case "bytes": return { type: "string", format: "byte" }; diff --git a/packages/openapi3/src/types.ts b/packages/openapi3/src/types.ts index 239fbbd6c5..ca5d3b17d2 100644 --- a/packages/openapi3/src/types.ts +++ b/packages/openapi3/src/types.ts @@ -1,6 +1,10 @@ import { Diagnostic, Service } from "@typespec/compiler"; import { Contact, ExtensionKey, License } from "@typespec/openapi"; +export type CommonOpenAPI3Schema = OpenAPI3Schema & OpenAPISchema3_1; + +export type SupportedOpenAPIDocuments = OpenAPI3Document | OpenAPIDocument3_1; + export type Extensions = { [key in ExtensionKey]?: any; }; @@ -56,7 +60,7 @@ export interface OpenAPI3UnversionedServiceRecord { readonly versioned: false; /** The OpenAPI 3 document */ - readonly document: OpenAPI3Document; + readonly document: SupportedOpenAPIDocuments; /** The diagnostics created for this document */ readonly diagnostics: readonly Diagnostic[]; @@ -79,7 +83,7 @@ export interface OpenAPI3VersionedServiceRecord { export interface OpenAPI3VersionedDocumentRecord { /** The OpenAPI document*/ - readonly document: OpenAPI3Document; + readonly document: SupportedOpenAPIDocuments; /** The service that generated this OpenAPI document. */ readonly service: Service; @@ -695,3 +699,418 @@ export interface Ref { } export type Refable = Ref | T; + +export type JsonSchemaType = + | "array" + | "boolean" + | "integer" + | "null" + | "number" + | "object" + | "string"; + +export type JsonSchema = AdditionalVocabularies & { + /** + * The JSON type for the schema. + * If the value is an array, then an instance validates successfully if its type + * matches any of the types indicated by the string in the array. + * + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-type + */ + type?: JsonSchemaType | JsonSchemaType[]; + + /** + * The extending format for the previously mentioned type. + */ + format?: string; + + /** + * This provides an enumeration of all possible values that are valid + * for the instance property. This MUST be an array, and each item in + * the array represents a possible value for the instance value. If + * this attribute is defined, the instance value MUST be one of the + * values in the array in order for the schema to be valid. + * + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-enum + */ + enum?: (string | number | boolean | null)[]; + + /** + * Functionally equivalent to "enum" with a single value. + * An instance validates successfully if its value is equal to the value of this keyword. + * + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-const + */ + const?: unknown; + + /** + * Must be strictly greater than 0. + * A numeric instance is valid only if division by this keyword's value results in an integer. + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-multipleof + */ + multipleOf?: number; + + /** + * Representing an inclusive upper limit for a numeric instance. + * This keyword validates only if the instance is less than or exactly equal to "maximum". + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-maximum + */ + maximum?: number; + + /** + * Representing an exclusive upper limit for a numeric instance. + * This keyword validates only if the instance is strictly less than (not equal to) to "exclusiveMaximum". + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-exclusivemaximum + */ + exclusiveMaximum?: number; + + /** + * Representing an inclusive lower limit for a numeric instance. + * This keyword validates only if the instance is greater than or exactly equal to "minimum". + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-minimum + */ + minimum?: number; + + /** + * Representing an exclusive lower limit for a numeric instance. + * This keyword validates only if the instance is strictly greater than (not equal to) to "exclusiveMinimum". + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-exclusiveminimum + */ + exclusiveMinimum?: number; + + /** + * Must be a non-negative integer. + * A string instance is valid against this keyword if its length is less than, or equal to, the value of this keyword. + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-maxlength + */ + maxLength?: number; + + /** + * Must be a non-negative integer. + * A string instance is valid against this keyword if its length is greater than, or equal to, the value of this keyword. + * Omitting this keyword has the same behavior as a value of 0. + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-minlength + */ + minLength?: number; + + /** + * Should be a valid regular expression, according to the ECMA 262 regular expression dialect. + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-pattern + */ + pattern?: string; + + /** + * Must be a non-negative integer. + * An array instance is valid against "maxItems" if its size is less than, or equal to, the value of this keyword. + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-maxitems + */ + maxItems?: number; + + /** + * Must be a non-negative integer. + * An array instance is valid against "maxItems" if its size is greater than, or equal to, the value of this keyword. + * Omitting this keyword has the same behavior as a value of 0. + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-minitems + */ + minItems?: number; + + /** + * If this keyword has boolean value false, the instance validates successfully. + * If it has boolean value true, the instance validates successfully if all of its elements are unique. + * Omitting this keyword has the same behavior as a value of false. + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-uniqueitems + */ + uniqueItems?: boolean; + + /** + * Must be a non-negative integer. + * If "contains" is not present within the same schema object, then this has no effect. + * An array instance is valid against "maxContains" if the number of elements that are' + * valid against the schema defined by "contains" is less than, or equal to, the value of this keyword. + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-maxcontains + */ + maxContains?: number; + + /** + * Must be a non-negative integer. + * If "contains" is not present within the same schema object, then this has no effect. + * An array instance is valid against "minContains" if the number of elements that are' + * valid against the schema defined by "contains" is greater than, or equal to, the value of this keyword. + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-maxcontains + */ + minContains?: number; + + /** + * Must be a non-negative integer. + * An object instance is valid against "maxProperties" if its number of properties is less than, or equal to, the value of this keyword. + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-maxproperties + */ + maxProperties?: number; + + /** + * Must be a non-negative integer. + * An object instance is valid against "maxProperties" if its number of properties is greater than, + * or equal to, the value of this keyword. + * Omitting this keyword has the same behavior as a value of 0. + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-minproperties + */ + minProperties?: number; + + /** + * Elements of this array must be unique. + * An object instance is valid against this keyword if every item in the array is the name of a property in the instance. + * Omitting this keyword has the same behavior as an empty array. + * + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-required + */ + required?: Array; + + /** + * Must be a string. + * If the schema instance is a string, this property defines that the string SHOULD be + * interpreted as encoded binary data and decoded using the encoding named by this property. + * + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-contentencoding + */ + contentEncoding?: string; + + /** + * If the schema instance is a string and "contentMediaType" is present, this property + * contains a schema which describes the structure of the string. + * This should be ignored if "contentMediaType" is not present. + * + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-contentschema + */ + contentSchema?: Refable>; + + /** + * Must be a string. + * If the schema instance is a string, this property indicates the media type of the contents of the string. + * If "contentEncoding" is present, this property describes the decoded string. + * + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-contentmediatype + */ + contentMediaType?: string; + + /** + * This attribute is a string that provides a short description of the instance property. + * + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-title-and-description + */ + title?: string; + + /** + * This attribute is a string that provides a full description of the schema + * + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-title-and-description + */ + description?: string; + + /** + * Declares the value of the property that the server will use if none is provided, + * for example a "count" to control the number of results per page might default to 100 if not supplied by the client in the request. + * + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-default + */ + default?: string | boolean | number | null | Record; + + /** + * Specifies that a schema is deprecated and SHOULD be transitioned out of usage. + * Default value is false. + * + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-deprecated + */ + deprecated?: boolean; + + /** + * An array of free-form properties to include examples of an instance for this schema. + * To represent examples that cannot be naturally represented in JSON or YAML, a string value can be used to contain the example with escaping where necessary. + * + * @see https://json-schema.org/draft/2020-12/json-schema-validation#name-examples + */ + examples?: any[]; + + /** + * A collection of schemas that this schema also must conform to. + * + * An instance validates successfully against this keyword if it validates successfully against all schemas defined by this keyword's value. + * + * @see https://json-schema.org/draft/2020-12/json-schema-core#name-allof + */ + allOf?: Refable>[]; + + /** + * A collection of schemas that this schema may conform to one or more of. + * + * An instance validates successfully against this keyword if it validates successfully against at least one schema defined by this keyword's value. + * + * @see https://json-schema.org/draft/2020-12/json-schema-core#name-anyof + */ + anyOf?: Refable>[]; + + /** + * A collection of schemas that this schema may conform to only one of. + * + * An instance validates successfully against this keyword if it validates successfully against exactly one schema defined by this keyword's value. + * + * @see https://json-schema.org/draft/2020-12/json-schema-core#name-oneof + */ + oneOf?: Refable>[]; + + /** + * An instance is valid against this keyword if it fails to validate successfully against the schema defined by this keyword. + * @see https://json-schema.org/draft/2020-12/json-schema-core#name-not + */ + not?: Refable>; + + /** + * Validation succeeds if each element of the instance validates against the schema at the same position, if any. + * This keyword does not constrain the length of the array. + * If the array is longer than this keyword's value, this keyword validates only the prefix of matching length. + * + * @see https://json-schema.org/draft/2020-12/json-schema-core#name-prefixitems + */ + prefixItems?: Refable>[]; + + /** + * This keyword applies its subschema to all instance elements at indexes greater than the lenfth of the "prefixItems" array. + * + * @see https://json-schema.org/draft/2020-12/json-schema-core#name-items + * */ + items?: Refable>; + + /** + * An array instance validates successfully against this keyword if at least one of its elements is valid against the given schema, + * except when `minContains` is present and has a value of 0. + * + * @see https://json-schema.org/draft/2020-12/json-schema-core#name-contains + */ + contains?: Refable>; + + /** + * This attribute is an object with property definitions that define the + * valid values of instance object property values. When the instance + * value is an object, the property values of the instance object MUST + * conform to the property definitions in this object. In this object, + * each property definition's value MUST be a schema, and the property's + * name MUST be the name of the instance property that it defines. The + * instance property value MUST be valid according to the schema from + * the property definition. Properties are considered unordered, the + * order of the instance properties MAY be in any order. + * + * @see https://json-schema.org/draft/2020-12/json-schema-core#name-properties + */ + properties?: Record< + string, + Refable> | JsonSchema + >; + + /** + * indicates that additional unlisted properties can exist in this schema + * + * @see https://json-schema.org/draft/2020-12/json-schema-core#name-additionalproperties + */ + additionalProperties?: boolean | Refable>; + + /** + * Property is readonly. + */ + readOnly?: boolean; + + /** Adds support for polymorphism. The discriminator is an object name that is used to differentiate between other schemas which may satisfy the payload description */ + discriminator?: OpenAPI3Discriminator; + + /** Additional external documentation for this schema. */ + externalDocs?: OpenAPI3ExternalDocs; +}; + +export type OpenAPISchema3_1 = JsonSchema< + { + /** + * Adds support for polymorphism. + * The discriminator is an object name that is used to differentiate between other schemas which may satisfy the payload description + * + * @see https://spec.openapis.org/oas/v3.1.1.html#discriminator-object + */ + discriminator?: OpenAPI3Discriminator; + + /** + * Additional external documentation for this schema. + * + * @see https://spec.openapis.org/oas/v3.1.1.html#external-documentation-object + */ + externalDocs?: OpenAPI3ExternalDocs; + + /** + * This MAY be used only on properties schemas. + * It has no effect on root schemas. + * Adds additional metadata to describe the XML representation of this property. + */ + xml?: OpenAPI3XmlSchema; + } & Extensions +>; + +export interface OpenAPIDocument3_1 extends Extensions { + openapi: "3.1.0"; + + /** + * Provides metadata about the API. The metadata can be used by the clients if needed. + */ + info: OpenAPI3Info; + + /** + * The default value for the $schema keyword within Schema Objects contained within this document. + * This MUST be in the form of a URI. + */ + jsonSchemaDialect?: string; + + /** Additional external documentation. */ + externalDocs?: OpenAPI3ExternalDocs; + + /** The available paths and operations for the API */ + paths: Record; + + /** + * The incoming webhooks that may be received as part of this API. + * The key name is a unique string to refer to each webhook. + */ + webhooks?: Record; + + /** + * An array of Server Objects, which provide connectivity information to a target server. + * If the servers property is not provided, or is an empty array, the default value would be a Server Object with a url value of /. + */ + servers?: OpenAPI3Server[]; + + /** + * A list of tags used by the specification with additional metadata. + * The order of the tags can be used to reflect on their order by the parsing tools. + * Not all tags that are used by the Operation Object must be declared. + * The tags that are not declared MAY be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique. + */ + tags?: OpenAPI3Tag[]; + + /** An element to hold various schemas for the specification. */ + components?: OpenAPIComponents3_1; + + /** + * A declaration of which security mechanisms can be used across the API. + * The list of values includes alternative security requirement objects that can be used. + * Only one of the security requirement objects need to be satisfied to authorize a request. + * Individual operations can override this definition. + */ + security?: Record[]; +} + +export interface OpenAPIComponents3_1 extends Extensions { + schemas?: Record; + responses?: Record>; + parameters?: Record>; + examples?: Record>; + requestBodies?: Record>; + headers?: Record>; + securitySchemes?: Record>; + links?: Record>; + callbacks?: Record>; + pathItems?: Record; +} diff --git a/packages/openapi3/src/util.ts b/packages/openapi3/src/util.ts index d4c02ceae3..929be66094 100644 --- a/packages/openapi3/src/util.ts +++ b/packages/openapi3/src/util.ts @@ -1,5 +1,19 @@ +import { + BooleanLiteral, + getEncode, + IntrinsicScalarName, + isTemplateDeclaration, + Model, + ModelProperty, + NumericLiteral, + Program, + Scalar, + serializeValueAsJson, + StringLiteral, + Type, + Value, +} from "@typespec/compiler"; import { HttpOperation } from "@typespec/http"; - /** * Checks if two objects are deeply equal. * @@ -87,3 +101,60 @@ export function isSharedHttpOperation( ): operation is SharedHttpOperation { return (operation as SharedHttpOperation).kind === "shared"; } + +export function isStdType( + program: Program, + type: Type, +): type is Scalar & { name: IntrinsicScalarName } { + return program.checker.isStdType(type); +} + +export function isLiteralType(type: Type): type is StringLiteral | NumericLiteral | BooleanLiteral { + return type.kind === "Boolean" || type.kind === "String" || type.kind === "Number"; +} + +export function literalType(type: StringLiteral | NumericLiteral | BooleanLiteral) { + switch (type.kind) { + case "String": + return "string"; + case "Number": + return "number"; + case "Boolean": + return "boolean"; + } +} + +export function includeDerivedModel(model: Model): boolean { + return ( + !isTemplateDeclaration(model) && + (model.templateMapper?.args === undefined || + model.templateMapper.args?.length === 0 || + model.derivedModels.length > 0) + ); +} + +export function isScalarExtendsBytes(type: Type): boolean { + if (type.kind !== "Scalar") { + return false; + } + let current: Scalar | undefined = type; + while (current) { + if (current.name === "bytes") { + return true; + } + current = current.baseScalar; + } + return false; +} + +export function getDefaultValue( + program: Program, + defaultType: Value, + modelProperty: ModelProperty, +): any { + return serializeValueAsJson(program, defaultType, modelProperty); +} + +export function isBytesKeptRaw(program: Program, type: Type) { + return type.kind === "Scalar" && type.name === "bytes" && getEncode(program, type) === undefined; +} diff --git a/packages/openapi3/src/xml-module.ts b/packages/openapi3/src/xml-module.ts index ac9c4e5e19..03c50fb586 100644 --- a/packages/openapi3/src/xml-module.ts +++ b/packages/openapi3/src/xml-module.ts @@ -12,20 +12,20 @@ import { ArrayBuilder, ObjectBuilder } from "@typespec/compiler/emitter-framewor import { reportDiagnostic } from "./lib.js"; import { ResolvedOpenAPI3EmitterOptions } from "./openapi.js"; import { getSchemaForStdScalars } from "./std-scalar-schemas.js"; -import { OpenAPI3Schema, OpenAPI3XmlSchema } from "./types.js"; +import { OpenAPI3Schema, OpenAPI3XmlSchema, OpenAPISchema3_1 } from "./types.js"; export interface XmlModule { attachXmlObjectForScalarOrModel( program: Program, type: Scalar | Model, - emitObject: OpenAPI3Schema, + emitObject: OpenAPI3Schema | OpenAPISchema3_1, ): void; attachXmlObjectForModelProperty( program: Program, options: ResolvedOpenAPI3EmitterOptions, prop: ModelProperty, - emitObject: OpenAPI3Schema, + emitObject: OpenAPI3Schema | OpenAPISchema3_1, ref?: Record, ): void; } @@ -38,7 +38,7 @@ export async function resolveXmlModule(): Promise { attachXmlObjectForScalarOrModel: ( program: Program, type: Scalar | Model, - emitObject: OpenAPI3Schema, + emitObject: OpenAPI3Schema | OpenAPISchema3_1, ) => { const isXmlModel = isXmlModelChecker(program, type, []); if (!isXmlModel) { diff --git a/packages/openapi3/test/additional-properties.test.ts b/packages/openapi3/test/additional-properties.test.ts index 0fd065f5d9..52d3662382 100644 --- a/packages/openapi3/test/additional-properties.test.ts +++ b/packages/openapi3/test/additional-properties.test.ts @@ -1,8 +1,8 @@ import { deepStrictEqual, ok } from "assert"; import { describe, it } from "vitest"; -import { oapiForModel } from "./test-host.js"; +import { worksFor } from "./works-for.js"; -describe("openapi3: Additional properties", () => { +worksFor(["3.0.0", "3.1.0"], ({ oapiForModel }) => { describe("extends Record", () => { it("doesn't set additionalProperties on model itself", async () => { const res = await oapiForModel("Pet", `model Pet extends Record {};`); diff --git a/packages/openapi3/test/array.test.ts b/packages/openapi3/test/array.test.ts index 8ce34be1bd..c56b4a806d 100644 --- a/packages/openapi3/test/array.test.ts +++ b/packages/openapi3/test/array.test.ts @@ -1,8 +1,8 @@ import { deepStrictEqual, ok, strictEqual } from "assert"; -import { describe, it } from "vitest"; -import { oapiForModel, openApiFor } from "./test-host.js"; +import { it } from "vitest"; +import { worksFor } from "./works-for.js"; -describe("openapi3: Array", () => { +worksFor(["3.0.0", "3.1.0"], ({ oapiForModel, openApiFor }) => { it("defines array inline", async () => { const res = await oapiForModel( "Pet", @@ -150,6 +150,32 @@ describe("openapi3: Array", () => { }); }); + it("can specify uniqueItems using @JsonSchema.uniqueItems decorator", async () => { + const res = await oapiForModel( + "Pets", + ` + @JsonSchema.uniqueItems + model Pets is Array; + model Pet { + @JsonSchema.uniqueItems + x: string[]; + } + `, + ); + + deepStrictEqual(res.schemas.Pets, { + type: "array", + uniqueItems: true, + items: { $ref: "#/components/schemas/Pet" }, + }); + + deepStrictEqual(res.schemas.Pet.properties.x, { + type: "array", + uniqueItems: true, + items: { type: "string" }, + }); + }); + it("can specify array defaults using tuple syntax", async () => { const res = await oapiForModel( "Pet", @@ -226,8 +252,10 @@ describe("openapi3: Array", () => { strictEqual(res.schemas.Foo.title, "FooArray"); }); +}); - it("can specify tuple defaults using tuple syntax", async () => { +worksFor(["3.0.0"], ({ oapiForModel }) => { + it("can specify tuple defaults using tuple syntax (empty items)", async () => { const res = await oapiForModel( "Pet", ` @@ -258,3 +286,123 @@ describe("openapi3: Array", () => { }); }); }); + +worksFor(["3.1.0"], ({ oapiForModel }) => { + it("works with contains, minContains, and maxContains", async () => { + const res = await oapiForModel( + "Foo", + ` + @JsonSchema.contains(string) + @JsonSchema.minContains(1) + @JsonSchema.maxContains(2) + model Foo is Array; + model Bar { + @JsonSchema.contains(string) + @JsonSchema.minContains(1) + @JsonSchema.maxContains(2) + x: string[]; + } + `, + ); + + deepStrictEqual(res.schemas.Foo, { + type: "array", + items: { + $ref: "#/components/schemas/Bar", + }, + contains: { + type: "string", + }, + minContains: 1, + maxContains: 2, + }); + + deepStrictEqual(res.schemas.Bar.properties.x, { + type: "array", + items: { + type: "string", + }, + contains: { + type: "string", + }, + minContains: 1, + maxContains: 2, + }); + }); + + it("works with prefixItems", async () => { + const res = await oapiForModel( + "Foo", + ` + @JsonSchema.prefixItems([string, { x?: string }, Foo]) + model Foo is Array; + model Bar { + @JsonSchema.prefixItems([string, { x?: string }, Foo]) + x: string[]; + } + `, + ); + + deepStrictEqual(res.schemas.Foo.prefixItems, [ + { type: "string" }, + { properties: { x: { type: "string" } }, type: "object" }, + { $ref: "#/components/schemas/Foo" }, + ]); + + deepStrictEqual(res.schemas.Bar.properties.x.prefixItems, [ + { type: "string" }, + { properties: { x: { type: "string" } }, type: "object" }, + { $ref: "#/components/schemas/Foo" }, + ]); + }); + + it("can specify tuple defaults using tuple syntax (prefix items)", async () => { + const res = await oapiForModel( + "Pet", + ` + model Pet { + names: [string, int32] = #["bismarck", 12]; + decimals: [string, decimal] = #["hi", 456.7]; + decimal128s: [string, decimal128] = #["hi", 456.7]; + }; + `, + ); + + deepStrictEqual(res.schemas.Pet.properties.names, { + type: "array", + prefixItems: [{ type: "string" }, { type: "integer", format: "int32" }], + default: ["bismarck", 12], + }); + + deepStrictEqual(res.schemas.Pet.properties.decimals, { + type: "array", + prefixItems: [{ type: "string" }, { type: "number", format: "decimal" }], + default: ["hi", 456.7], + }); + + deepStrictEqual(res.schemas.Pet.properties.decimal128s, { + type: "array", + prefixItems: [{ type: "string" }, { type: "number", format: "decimal128" }], + default: ["hi", 456.7], + }); + }); + + it("can specify tuple with constants", async () => { + const res = await oapiForModel( + "Pet", + ` + model Pet { + names: ["bismark", 32]; + }; + `, + ); + + deepStrictEqual(res.schemas.Pet.properties.names, { + type: "array", + prefixItems: [ + { type: "string", enum: ["bismark"] }, + { type: "number", enum: [32] }, + ], + }); + }); +}); diff --git a/packages/openapi3/test/circular-references.test.ts b/packages/openapi3/test/circular-references.test.ts index aa2ded70a4..b64934437f 100644 --- a/packages/openapi3/test/circular-references.test.ts +++ b/packages/openapi3/test/circular-references.test.ts @@ -1,8 +1,8 @@ import { deepStrictEqual } from "assert"; -import { describe, it } from "vitest"; -import { oapiForModel } from "./test-host.js"; +import { it } from "vitest"; +import { worksFor } from "./works-for.js"; -describe("openapi3: circular reference", () => { +worksFor(["3.0.0", "3.1.0"], ({ oapiForModel }) => { it("can reference itself via a property", async () => { const res = await oapiForModel( "Pet", diff --git a/packages/openapi3/test/discriminator.test.ts b/packages/openapi3/test/discriminator.test.ts index 88192cd26f..e6629d155e 100644 --- a/packages/openapi3/test/discriminator.test.ts +++ b/packages/openapi3/test/discriminator.test.ts @@ -1,9 +1,9 @@ import { expectDiagnostics } from "@typespec/compiler/testing"; import { deepStrictEqual, ok } from "assert"; -import { describe, it } from "vitest"; -import { checkFor, openApiFor } from "./test-host.js"; +import { it } from "vitest"; +import { worksFor } from "./works-for.js"; -describe("openapi3: polymorphic model inheritance with discriminator", () => { +worksFor(["3.0.0", "3.1.0"], ({ checkFor, openApiFor }) => { it("discriminator can be simple literals", async () => { const openApi = await openApiFor(` @discriminator("kind") diff --git a/packages/openapi3/test/documentation.test.ts b/packages/openapi3/test/documentation.test.ts index 87292fc8c7..61213d28d2 100644 --- a/packages/openapi3/test/documentation.test.ts +++ b/packages/openapi3/test/documentation.test.ts @@ -1,8 +1,8 @@ import { deepStrictEqual, strictEqual } from "assert"; -import { describe, it } from "vitest"; -import { openApiFor } from "./test-host.js"; +import { it } from "vitest"; +import { worksFor } from "./works-for.js"; -describe("openapi3: documentation", () => { +worksFor(["3.0.0", "3.1.0"], ({ openApiFor }) => { it("supports summary and description", async () => { const openApi = await openApiFor(` @summary("This is a summary") diff --git a/packages/openapi3/test/enums.test.ts b/packages/openapi3/test/enums.test.ts index e7882c6306..849c5dc94c 100644 --- a/packages/openapi3/test/enums.test.ts +++ b/packages/openapi3/test/enums.test.ts @@ -1,9 +1,9 @@ import { expectDiagnostics } from "@typespec/compiler/testing"; -import { strictEqual } from "assert"; -import { describe, it } from "vitest"; -import { diagnoseOpenApiFor, oapiForModel } from "./test-host.js"; +import { deepStrictEqual, strictEqual } from "assert"; +import { it } from "vitest"; +import { worksFor } from "./works-for.js"; -describe("openapi3: enums", () => { +worksFor(["3.0.0", "3.1.0"], ({ diagnoseOpenApiFor, oapiForModel }) => { it("throws diagnostics for empty enum definitions", async () => { const diagnostics = await diagnoseOpenApiFor(`enum PetType {}`); @@ -13,15 +13,6 @@ describe("openapi3: enums", () => { }); }); - it("throws diagnostics for enum with different types", async () => { - const diagnostics = await diagnoseOpenApiFor(`enum PetType {asString: "dog", asNumber: 1}`); - - expectDiagnostics(diagnostics, { - code: "@typespec/openapi3/enum-unique-type", - message: "Enums are not supported unless all options are literals of the same type.", - }); - }); - it("supports summary on enums", async () => { const res = await oapiForModel( "Foo", @@ -35,3 +26,25 @@ describe("openapi3: enums", () => { strictEqual(res.schemas.Foo.title, "FooEnum"); }); }); + +worksFor(["3.0.0"], ({ diagnoseOpenApiFor }) => { + it("throws diagnostics for enum with different types", async () => { + const diagnostics = await diagnoseOpenApiFor(`enum PetType {asString: "dog", asNumber: 1}`); + + expectDiagnostics(diagnostics, { + code: "@typespec/openapi3/enum-unique-type", + message: "Enums are not supported unless all options are literals of the same type.", + }); + }); +}); + +worksFor(["3.1.0"], ({ oapiForModel }) => { + it("supports enum with different types", async () => { + const res = await oapiForModel("PetType", `enum PetType {asString: "dog", asNumber: 1}`); + + deepStrictEqual(res.schemas.PetType, { + type: ["string", "number"], + enum: ["dog", 1], + }); + }); +}); diff --git a/packages/openapi3/test/examples.test.ts b/packages/openapi3/test/examples.test.ts index 064e2da47d..25c90a36b2 100644 --- a/packages/openapi3/test/examples.test.ts +++ b/packages/openapi3/test/examples.test.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from "vitest"; import { OpenAPI3Document } from "../src/types.js"; import { openApiFor } from "./test-host.js"; +import { worksFor } from "./works-for.js"; describe("schema examples", () => { it("apply example on model", async () => { @@ -52,7 +53,7 @@ describe("schema examples", () => { }); }); -describe("operation examples", () => { +worksFor(["3.0.0", "3.1.0"], ({ openApiFor }) => { it("set example on the request body", async () => { const res: OpenAPI3Document = await openApiFor( ` diff --git a/packages/openapi3/test/info.test.ts b/packages/openapi3/test/info.test.ts index 174f99a45c..2f03239a73 100644 --- a/packages/openapi3/test/info.test.ts +++ b/packages/openapi3/test/info.test.ts @@ -1,8 +1,8 @@ import { deepStrictEqual, strictEqual } from "assert"; -import { describe, it } from "vitest"; -import { openApiFor } from "./test-host.js"; +import { it } from "vitest"; +import { worksFor } from "./works-for.js"; -describe("openapi3: info", () => { +worksFor(["3.0.0", "3.1.0"], ({ openApiFor }) => { it("set the service title with @service", async () => { const res = await openApiFor( ` diff --git a/packages/openapi3/test/metadata.test.ts b/packages/openapi3/test/metadata.test.ts index de877882cb..b1a2b11d18 100644 --- a/packages/openapi3/test/metadata.test.ts +++ b/packages/openapi3/test/metadata.test.ts @@ -1,8 +1,8 @@ import { deepStrictEqual } from "assert"; -import { describe, it } from "vitest"; -import { openApiFor } from "./test-host.js"; +import { it } from "vitest"; +import { worksFor } from "./works-for.js"; -describe("openapi3: metadata", () => { +worksFor(["3.0.0", "3.1.0"], ({ openApiFor }) => { it("will expose all properties on unreferenced models but filter properties on referenced models", async () => { const res = await openApiFor(` model M { @@ -1080,40 +1080,6 @@ describe("openapi3: metadata", () => { }); }); - it("supports nested bodies", async () => { - const res = await openApiFor( - ` - model Image { - @header contentType: "application/octet-stream"; - @body body: bytes; - } - op doStuffWithBytes(data: Image): int32; - `, - ); - - const requestSchema = - res.paths["/"].post.requestBody.content["application/octet-stream"].schema; - - deepStrictEqual(requestSchema, { format: "binary", type: "string" }); - }); - - it("supports deeply nested bodies", async () => { - const res = await openApiFor( - ` - model Image { - @header contentType: "application/octet-stream"; - moreNesting: { @body body: bytes }; - } - op doStuffWithBytes(data: Image): int32; - `, - ); - - const requestSchema = - res.paths["/"].post.requestBody.content["application/octet-stream"].schema; - - deepStrictEqual(requestSchema, { format: "binary", type: "string" }); - }); - it("don't create multiple scalars with different visibility if they are the same", async () => { const res = await openApiFor(` scalar uuid extends string; @@ -1242,3 +1208,75 @@ describe("openapi3: metadata", () => { }); }); }); + +worksFor(["3.0.0"], ({ openApiFor }) => { + it("supports nested bodies (binary payloads)", async () => { + const res = await openApiFor( + ` + model Image { + @header contentType: "application/octet-stream"; + @body body: bytes; + } + op doStuffWithBytes(data: Image): int32; + `, + ); + + const requestSchema = + res.paths["/"].post.requestBody.content["application/octet-stream"].schema; + + deepStrictEqual(requestSchema, { format: "binary", type: "string" }); + }); + + it("supports deeply nested bodies (binary payloads)", async () => { + const res = await openApiFor( + ` + model Image { + @header contentType: "application/octet-stream"; + moreNesting: { @body body: bytes }; + } + op doStuffWithBytes(data: Image): int32; + `, + ); + + const requestSchema = + res.paths["/"].post.requestBody.content["application/octet-stream"].schema; + + deepStrictEqual(requestSchema, { format: "binary", type: "string" }); + }); +}); + +worksFor(["3.1.0"], ({ openApiFor }) => { + it("supports nested bodies (unencoded binary payloads)", async () => { + const res = await openApiFor( + ` + model Image { + @header contentType: "application/octet-stream"; + @body body: bytes; + } + op doStuffWithBytes(data: Image): int32; + `, + ); + + const requestSchema = + res.paths["/"].post.requestBody.content["application/octet-stream"].schema; + + deepStrictEqual(requestSchema, { contentMediaType: "application/octet-stream" }); + }); + + it("supports deeply nested bodies (unencoded binary payloads)", async () => { + const res = await openApiFor( + ` + model Image { + @header contentType: "application/octet-stream"; + moreNesting: { @body body: bytes }; + } + op doStuffWithBytes(data: Image): int32; + `, + ); + + const requestSchema = + res.paths["/"].post.requestBody.content["application/octet-stream"].schema; + + deepStrictEqual(requestSchema, { contentMediaType: "application/octet-stream" }); + }); +}); diff --git a/packages/openapi3/test/models.test.ts b/packages/openapi3/test/models.test.ts index 774c7deec9..cbaf257ebe 100644 --- a/packages/openapi3/test/models.test.ts +++ b/packages/openapi3/test/models.test.ts @@ -1,9 +1,9 @@ import { expectDiagnostics } from "@typespec/compiler/testing"; import { deepStrictEqual, ok, strictEqual } from "assert"; import { describe, expect, it } from "vitest"; -import { diagnoseOpenApiFor, oapiForModel, openApiFor } from "./test-host.js"; +import { worksFor } from "./works-for.js"; -describe("openapi3: models", () => { +worksFor(["3.0.0", "3.1.0"], ({ diagnoseOpenApiFor, oapiForModel, openApiFor }) => { it("defines models", async () => { const res = await oapiForModel( "Foo", @@ -290,29 +290,6 @@ describe("openapi3: models", () => { }); }); - it("specify default value on nullable property", async () => { - const res = await oapiForModel( - "Foo", - ` - model Foo { - optional?: string | null = null; - }; - `, - ); - - ok(res.schemas.Foo, "expected definition named Foo"); - deepStrictEqual(res.schemas.Foo, { - type: "object", - properties: { - optional: { - type: "string", - nullable: true, - default: null, - }, - }, - }); - }); - it("scalar used as a default value", async () => { const res = await oapiForModel( "Pet", @@ -668,54 +645,6 @@ describe("openapi3: models", () => { }); }); - it("defines nullable properties", async () => { - const res = await oapiForModel( - "Pet", - ` - model Pet { - name: string | null; - }; - `, - ); - ok(res.isRef); - deepStrictEqual(res.schemas.Pet, { - type: "object", - properties: { - name: { - type: "string", - nullable: true, - }, - }, - required: ["name"], - }); - }); - - it("defines nullable array", async () => { - const res = await oapiForModel( - "Pet", - ` - model Pet { - name: int32[] | null; - }; - `, - ); - ok(res.isRef); - deepStrictEqual(res.schemas.Pet, { - type: "object", - properties: { - name: { - type: "array", - items: { - type: "integer", - format: "int32", - }, - nullable: true, - }, - }, - required: ["name"], - }); - }); - it("defines request bodies as unions of models", async () => { const openApi = await openApiFor(` model Cat { @@ -1132,3 +1061,154 @@ describe("openapi3: models", () => { }); }); }); + +worksFor(["3.0.0"], ({ oapiForModel }) => { + it("specify default value on nullable property", async () => { + const res = await oapiForModel( + "Foo", + ` + model Foo { + optional?: string | null = null; + }; + `, + ); + + ok(res.schemas.Foo, "expected definition named Foo"); + deepStrictEqual(res.schemas.Foo, { + type: "object", + properties: { + optional: { + type: "string", + nullable: true, + default: null, + }, + }, + }); + }); + + it("defines nullable properties", async () => { + const res = await oapiForModel( + "Pet", + ` + model Pet { + name: string | null; + }; + `, + ); + ok(res.isRef); + deepStrictEqual(res.schemas.Pet, { + type: "object", + properties: { + name: { + type: "string", + nullable: true, + }, + }, + required: ["name"], + }); + }); + + it("defines nullable array", async () => { + const res = await oapiForModel( + "Pet", + ` + model Pet { + name: int32[] | null; + }; + `, + ); + ok(res.isRef); + deepStrictEqual(res.schemas.Pet, { + type: "object", + properties: { + name: { + type: "array", + items: { + type: "integer", + format: "int32", + }, + nullable: true, + }, + }, + required: ["name"], + }); + }); +}); + +worksFor(["3.1.0"], ({ oapiForModel }) => { + // eslint-disable-next-line vitest/no-identical-title + it("specify default value on nullable property", async () => { + const res = await oapiForModel( + "Foo", + ` + model Foo { + optional?: string | null = null; + }; + `, + ); + + ok(res.schemas.Foo, "expected definition named Foo"); + deepStrictEqual(res.schemas.Foo, { + type: "object", + properties: { + optional: { + anyOf: [{ type: "string" }, { type: "null" }], + default: null, + }, + }, + }); + }); + + // eslint-disable-next-line vitest/no-identical-title + it("defines nullable properties", async () => { + const res = await oapiForModel( + "Pet", + ` + model Pet { + name: string | null; + }; + `, + ); + ok(res.isRef); + deepStrictEqual(res.schemas.Pet, { + type: "object", + properties: { + name: { + anyOf: [{ type: "string" }, { type: "null" }], + }, + }, + required: ["name"], + }); + }); + + // eslint-disable-next-line vitest/no-identical-title + it("defines nullable array", async () => { + const res = await oapiForModel( + "Pet", + ` + model Pet { + name: int32[] | null; + }; + `, + ); + ok(res.isRef); + deepStrictEqual(res.schemas.Pet, { + type: "object", + properties: { + name: { + anyOf: [ + { + type: "array", + items: { + type: "integer", + format: "int32", + }, + }, + { type: "null" }, + ], + }, + }, + required: ["name"], + }); + }); +}); diff --git a/packages/openapi3/test/multipart.test.ts b/packages/openapi3/test/multipart.test.ts index 344d7a3b1e..2e117ac863 100644 --- a/packages/openapi3/test/multipart.test.ts +++ b/packages/openapi3/test/multipart.test.ts @@ -1,405 +1,670 @@ import { deepStrictEqual } from "assert"; import { describe, expect, it } from "vitest"; -import { OpenAPI3Encoding, OpenAPI3Schema } from "../src/types.js"; -import { openApiFor } from "./test-host.js"; +import { OpenAPI3Encoding, OpenAPI3Schema, OpenAPISchema3_1 } from "../src/types.js"; +import { worksFor } from "./works-for.js"; -it("create dedicated model for multipart", async () => { - const res = await openApiFor( - ` +worksFor(["3.0.0", "3.1.0"], ({ openApiFor }) => { + it("create dedicated model for multipart", async () => { + const res = await openApiFor( + ` model Form { name: HttpPart, profileImage: HttpPart } op upload(@header contentType: "multipart/form-data", @multipartBody body: Form): void; `, - ); - const op = res.paths["/"].post; - deepStrictEqual(op.requestBody.content["multipart/form-data"], { - schema: { - $ref: "#/components/schemas/Form", - }, + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + $ref: "#/components/schemas/Form", + }, + }); }); -}); -it("part of type `bytes` produce `type: string, format: binary`", async () => { - const res = await openApiFor( - ` - op upload(@header contentType: "multipart/form-data", @multipartBody body: { profileImage: HttpPart }): void; + it("part of type `string` produce `type: string`", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", @multipartBody _: { name: HttpPart }): void; `, - ); - const op = res.paths["/"].post; - deepStrictEqual(op.requestBody.content["multipart/form-data"], { - schema: { - type: "object", - properties: { - profileImage: { - format: "binary", - type: "string", + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + type: "object", + properties: { + name: { + type: "string", + }, }, + required: ["name"], }, - required: ["profileImage"], - }, + }); }); -}); -it("part of type union `HttpPart` produce `type: string, format: binary`", async () => { - const res = await openApiFor( - ` - op upload(@header contentType: "multipart/form-data", @multipartBody _: {profileImage: HttpPart}): void; + it("part of type `object` produce an object", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", @multipartBody _: { address: HttpPart<{city: string, street: string}>}): void; `, - ); - const op = res.paths["/"].post; - deepStrictEqual(op.requestBody.content["multipart/form-data"], { - schema: { - type: "object", - properties: { - profileImage: { - anyOf: [ - { - type: "string", - format: "binary", - }, - { - type: "object", - properties: { - content: { type: "string", format: "byte" }, + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + type: "object", + properties: { + address: { + type: "object", + properties: { + city: { + type: "string", + }, + street: { + type: "string", }, - required: ["content"], }, - ], + required: ["city", "street"], + }, }, + required: ["address"], }, - required: ["profileImage"], - }, - encoding: { - profileImage: { - contentType: "application/octet-stream, application/json", - }, - }, + }); }); -}); -it("part of type `bytes[]` produce `type: array, items: {type: string, format: binary}`", async () => { - const res = await openApiFor( - ` - op upload(@header contentType: "multipart/form-data", @multipartBody _: { profileImage: HttpPart[]}): void; - `, - ); - const op = res.paths["/"].post; - deepStrictEqual(op.requestBody.content["multipart/form-data"], { - schema: { - type: "object", - properties: { - profileImage: { - type: "array", - items: { type: "string", format: "binary" }, + describe("legacy implicit form", () => { + it("add MultiPart suffix to model name", async () => { + const res = await openApiFor( + ` + model Form { @header contentType: "multipart/form-data", name: string, profileImage: bytes } + op upload(...Form): void; + `, + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + $ref: "#/components/schemas/FormMultiPart", }, - }, - required: ["profileImage"], - }, - }); -}); + }); + }); -it("part of type `string` produce `type: string`", async () => { - const res = await openApiFor( - ` - op upload(@header contentType: "multipart/form-data", @multipartBody _: { name: HttpPart }): void; - `, - ); - const op = res.paths["/"].post; - deepStrictEqual(op.requestBody.content["multipart/form-data"], { - schema: { - type: "object", - properties: { - name: { - type: "string", + it("part of union type doesn't conflict if used in json as well`", async () => { + const res = await openApiFor( + ` + union MyUnion {string, int32} + op upload(@header contentType: "multipart/form-data", profileImage: MyUnion): void; + `, + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + type: "object", + properties: { + profileImage: { + $ref: "#/components/schemas/MyUnion", + }, + }, + required: ["profileImage"], }, - }, - required: ["name"], - }, - }); -}); + }); + }); -it("part of type `object` produce an object", async () => { - const res = await openApiFor( - ` - op upload(@header contentType: "multipart/form-data", @multipartBody _: { address: HttpPart<{city: string, street: string}>}): void; - `, - ); - const op = res.paths["/"].post; - deepStrictEqual(op.requestBody.content["multipart/form-data"], { - schema: { - type: "object", - properties: { - address: { + it("part of type `string` produce `type: string`", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", name: string): void; + `, + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { type: "object", properties: { - city: { + name: { type: "string", }, - street: { - type: "string", + }, + required: ["name"], + }, + }); + }); + + it("part of type `object` produce an object", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", address: {city: string, street: string}): void; + `, + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + type: "object", + properties: { + address: { + type: "object", + properties: { + city: { + type: "string", + }, + street: { + type: "string", + }, + }, + required: ["city", "street"], }, }, - required: ["city", "street"], + required: ["address"], }, - }, - required: ["address"], - }, - }); -}); + }); + }); -it("bytes inside a json part will be treated as base64 encoded by default(same as for a json body)", async () => { - const res = await openApiFor( - ` - op upload(@header contentType: "multipart/form-data", @multipartBody _: { address: HttpPart<{city: string, icon: bytes}> }): void; - `, - ); - const op = res.paths["/"].post; - deepStrictEqual( - op.requestBody.content["multipart/form-data"].schema.properties.address.properties.icon, - { - type: "string", - format: "byte", - }, - ); + it("enum used in both a json payload and multipart part shouldn't create 2 models", async () => { + const res = await openApiFor( + ` + enum FilePurpose { + one, + two, + } + + interface Files { + @get listFiles(purpose: FilePurpose): string; + @post uploadFile(@header contentType: "multipart/form-data", purpose: FilePurpose): string; + } + `, + ); + expect(Object.keys(res.components.schemas).length).toBe(1); + deepStrictEqual(res.components.schemas.FilePurpose, { + type: "string", + enum: ["one", "two"], + }); + }); + }); }); -describe("part mapping", () => { - it.each([ - [`string`, { type: "string" }], - [`bytes`, { type: "string", format: "binary" }], - [`string[]`, { type: "array", items: { type: "string" } }, { contentType: "application/json" }], - [ - `bytes[]`, - { type: "array", items: { type: "string", format: "byte" } }, - { contentType: "application/json" }, - ], - [ - `{@header contentType: "image/png", @body image: bytes}`, - { type: "string", format: "binary" }, - { contentType: "image/png" }, - ], - [`File`, { type: "string", format: "binary" }, { contentType: "*/*" }], - [ - `{@header extra: string, @body body: string}`, - { type: "string" }, - { - headers: { - extra: { - required: true, - schema: { +worksFor(["3.0.0"], ({ openApiFor }) => { + describe("Open API 3.0", () => { + it("part of type `bytes` produce `type: string, format: binary`", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", @multipartBody body: { profileImage: HttpPart }): void; + `, + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + type: "object", + properties: { + profileImage: { + format: "binary", type: "string", }, }, + required: ["profileImage"], }, - }, - ], - ] satisfies [string, OpenAPI3Schema, OpenAPI3Encoding?][])( - `HttpPart<%s>`, - async (type: string, expectedSchema: OpenAPI3Schema, expectedEncoding?: OpenAPI3Encoding) => { + }); + }); + + it("part of type union `HttpPart` produce `type: string, format: binary`", async () => { const res = await openApiFor( ` - op upload(@header contentType: "multipart/form-data", @multipartBody _: { part: HttpPart<${type}> }): void; + op upload(@header contentType: "multipart/form-data", @multipartBody _: {profileImage: HttpPart}): void; `, ); - const content = res.paths["/"].post.requestBody.content["multipart/form-data"]; - expect(content.schema.properties.part).toEqual(expectedSchema); - - if (expectedEncoding || content.encoding?.part) { - expect(content.encoding?.part).toEqual(expectedEncoding); - } - }, - ); -}); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + type: "object", + properties: { + profileImage: { + anyOf: [ + { + type: "string", + format: "binary", + }, + { + type: "object", + properties: { + content: { type: "string", format: "byte" }, + }, + required: ["content"], + }, + ], + }, + }, + required: ["profileImage"], + }, + encoding: { + profileImage: { + contentType: "application/octet-stream, application/json", + }, + }, + }); + }); -describe("legacy implicit form", () => { - it("add MultiPart suffix to model name", async () => { - const res = await openApiFor( - ` - model Form { @header contentType: "multipart/form-data", name: string, profileImage: bytes } - op upload(...Form): void; + it("part of type `bytes[]` produce `type: array, items: {type: string, format: binary}`", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", @multipartBody _: { profileImage: HttpPart[]}): void; `, - ); - const op = res.paths["/"].post; - deepStrictEqual(op.requestBody.content["multipart/form-data"], { - schema: { - $ref: "#/components/schemas/FormMultiPart", - }, + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + type: "object", + properties: { + profileImage: { + type: "array", + items: { type: "string", format: "binary" }, + }, + }, + required: ["profileImage"], + }, + }); }); - }); - it("part of type `bytes` produce `type: string, format: binary`", async () => { - const res = await openApiFor( - ` - op upload(@header contentType: "multipart/form-data", profileImage: bytes): void; + it("bytes inside a json part will be treated as base64 encoded by default(same as for a json body)", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", @multipartBody _: { address: HttpPart<{city: string, icon: bytes}> }): void; `, - ); - const op = res.paths["/"].post; - deepStrictEqual(op.requestBody.content["multipart/form-data"], { - schema: { - type: "object", - properties: { - profileImage: { - format: "binary", - type: "string", + ); + const op = res.paths["/"].post; + deepStrictEqual( + op.requestBody.content["multipart/form-data"].schema.properties.address.properties.icon, + { + type: "string", + format: "byte", + }, + ); + }); + + describe("part mapping", () => { + it.each([ + [`string`, { type: "string" }], + [`bytes`, { type: "string", format: "binary" }], + [ + `string[]`, + { type: "array", items: { type: "string" } }, + { contentType: "application/json" }, + ], + [ + `bytes[]`, + { type: "array", items: { type: "string", format: "byte" } }, + { contentType: "application/json" }, + ], + [ + `{@header contentType: "image/png", @body image: bytes}`, + { type: "string", format: "binary" }, + { contentType: "image/png" }, + ], + [`File`, { type: "string", format: "binary" }, { contentType: "*/*" }], + [ + `{@header extra: string, @body body: string}`, + { type: "string" }, + { + headers: { + extra: { + required: true, + schema: { + type: "string", + }, + }, + }, }, + ], + ] satisfies [string, OpenAPI3Schema, OpenAPI3Encoding?][])( + `HttpPart<%s>`, + async ( + type: string, + expectedSchema: OpenAPI3Schema, + expectedEncoding?: OpenAPI3Encoding, + ) => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", @multipartBody _: { part: HttpPart<${type}> }): void; + `, + ); + const content = res.paths["/"].post.requestBody.content["multipart/form-data"]; + expect(content.schema.properties.part).toEqual(expectedSchema); + + if (expectedEncoding || content.encoding?.part) { + expect(content.encoding?.part).toEqual(expectedEncoding); + } }, - required: ["profileImage"], - }, + ); }); - }); - it("part of type union `bytes | {content: bytes}` produce `type: string, format: binary`", async () => { - const res = await openApiFor( - ` - op upload(@header contentType: "multipart/form-data", profileImage: bytes | {content: bytes}): void; - `, - ); - const op = res.paths["/"].post; - deepStrictEqual(op.requestBody.content["multipart/form-data"], { - schema: { - type: "object", - properties: { - profileImage: { - anyOf: [ - { - type: "string", + describe("legacy implicit form", () => { + it("part of type `bytes` produce `type: string, format: binary`", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", profileImage: bytes): void; + `, + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + type: "object", + properties: { + profileImage: { format: "binary", + type: "string", }, - { - type: "object", - properties: { - content: { type: "string", format: "byte" }, - }, - required: ["content"], + }, + required: ["profileImage"], + }, + }); + }); + + it("part of type union `bytes | {content: bytes}` produce `type: string, format: binary`", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", profileImage: bytes | {content: bytes}): void; + `, + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + type: "object", + properties: { + profileImage: { + anyOf: [ + { + type: "string", + format: "binary", + }, + { + type: "object", + properties: { + content: { type: "string", format: "byte" }, + }, + required: ["content"], + }, + ], }, - ], + }, + required: ["profileImage"], }, - }, - required: ["profileImage"], - }, + }); + }); + + it("part of type `bytes[]` produce `type: array, items: {type: string, format: binary}`", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", profileImage: bytes[]): void; + `, + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + type: "object", + properties: { + profileImage: { + type: "array", + items: { type: "string", format: "binary" }, + }, + }, + required: ["profileImage"], + }, + }); + }); + + it("bytes inside a json part will be treated as base64 encoded by default(same as for a json body)", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", address: {city: string, icon: bytes}): void; + `, + ); + const op = res.paths["/"].post; + deepStrictEqual( + op.requestBody.content["multipart/form-data"].schema.properties.address.properties.icon, + { + type: "string", + format: "byte", + }, + ); + }); }); }); +}); - it("part of union type doesn't conflict if used in json as well`", async () => { - const res = await openApiFor( - ` - union MyUnion {string, int32} - op upload(@header contentType: "multipart/form-data", profileImage: MyUnion): void; +worksFor(["3.1.0"], ({ openApiFor }) => { + describe("Open API 3.1", () => { + // @see https://spec.openapis.org/oas/v3.1.1.html#encoding-content-type + it("part of type `bytes` produce empty schema", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", @multipartBody body: { profileImage: HttpPart }): void; `, - ); - const op = res.paths["/"].post; - deepStrictEqual(op.requestBody.content["multipart/form-data"], { - schema: { - type: "object", - properties: { - profileImage: { - $ref: "#/components/schemas/MyUnion", + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + type: "object", + properties: { + profileImage: {}, }, + required: ["profileImage"], }, - required: ["profileImage"], - }, + }); }); - }); - it("part of type `bytes[]` produce `type: array, items: {type: string, format: binary}`", async () => { - const res = await openApiFor( - ` - op upload(@header contentType: "multipart/form-data", profileImage: bytes[]): void; + it("part of type union `HttpPart` produce `{}, type: string, contentEncoding: base64`", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", @multipartBody _: {profileImage: HttpPart}): void; `, - ); - const op = res.paths["/"].post; - deepStrictEqual(op.requestBody.content["multipart/form-data"], { - schema: { - type: "object", - properties: { + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + type: "object", + properties: { + profileImage: { + anyOf: [ + {}, + { + type: "object", + properties: { + content: { + type: "string", + contentEncoding: "base64", + }, + }, + required: ["content"], + }, + ], + }, + }, + required: ["profileImage"], + }, + encoding: { profileImage: { - type: "array", - items: { type: "string", format: "binary" }, + contentType: "application/octet-stream, application/json", }, }, - required: ["profileImage"], - }, + }); }); - }); - it("part of type `string` produce `type: string`", async () => { - const res = await openApiFor( - ` - op upload(@header contentType: "multipart/form-data", name: string): void; + it("part of type `bytes[]` produce `type: array, items: {}`", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", @multipartBody _: { profileImage: HttpPart[]}): void; `, - ); - const op = res.paths["/"].post; - deepStrictEqual(op.requestBody.content["multipart/form-data"], { - schema: { - type: "object", - properties: { - name: { - type: "string", + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + type: "object", + properties: { + profileImage: { + type: "array", + items: {}, + }, }, + required: ["profileImage"], }, - required: ["name"], - }, + }); }); - }); - it("part of type `object` produce an object", async () => { - const res = await openApiFor( - ` - op upload(@header contentType: "multipart/form-data", address: {city: string, street: string}): void; + it("bytes inside a json part will be treated as base64 encoded by default(same as for a json body)", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", @multipartBody _: { address: HttpPart<{city: string, icon: bytes}> }): void; `, - ); - const op = res.paths["/"].post; - deepStrictEqual(op.requestBody.content["multipart/form-data"], { - schema: { - type: "object", - properties: { - address: { - type: "object", - properties: { - city: { - type: "string", - }, - street: { - type: "string", + ); + const op = res.paths["/"].post; + deepStrictEqual( + op.requestBody.content["multipart/form-data"].schema.properties.address.properties.icon, + { + type: "string", + contentEncoding: "base64", + }, + ); + }); + + describe("part mapping", () => { + it.each([ + [`string`, { type: "string" }], + [`bytes`, {}], + [ + `string[]`, + { type: "array", items: { type: "string" } }, + { contentType: "application/json" }, + ], + [ + `bytes[]`, + { + type: "array", + items: { + type: "string", + contentEncoding: "base64", + }, + }, + { contentType: "application/json" }, + ], + [ + `{@header contentType: "image/png", @body image: bytes}`, + {}, + { contentType: "image/png" }, + ], + [`File`, {}, { contentType: "*/*" }], + [ + `{@header extra: string, @body body: string}`, + { type: "string" }, + { + headers: { + extra: { + required: true, + schema: { + type: "string", + }, }, }, - required: ["city", "street"], }, + ], + ] satisfies [string, OpenAPISchema3_1, OpenAPI3Encoding?][])( + `HttpPart<%s>`, + async ( + type: string, + expectedSchema: OpenAPI3Schema, + expectedEncoding?: OpenAPI3Encoding, + ) => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", @multipartBody _: { part: HttpPart<${type}> }): void; + `, + ); + const content = res.paths["/"].post.requestBody.content["multipart/form-data"]; + expect(content.schema.properties.part).toEqual(expectedSchema); + + if (expectedEncoding || content.encoding?.part) { + expect(content.encoding?.part).toEqual(expectedEncoding); + } }, - required: ["address"], - }, + ); }); - }); - it("bytes inside a json part will be treated as base64 encoded by default(same as for a json body)", async () => { - const res = await openApiFor( - ` - op upload(@header contentType: "multipart/form-data", address: {city: string, icon: bytes}): void; - `, - ); - const op = res.paths["/"].post; - deepStrictEqual( - op.requestBody.content["multipart/form-data"].schema.properties.address.properties.icon, - { - type: "string", - format: "byte", - }, - ); - }); + describe("legacy implicit form", () => { + it("part of type `bytes` produce `{}`", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", profileImage: bytes): void; + `, + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + type: "object", + properties: { + profileImage: {}, + }, + required: ["profileImage"], + }, + }); + }); - it("enum used in both a json payload and multipart part shouldn't create 2 models", async () => { - const res = await openApiFor( - ` - enum FilePurpose { - one, - two, - } - - interface Files { - @get listFiles(purpose: FilePurpose): string; - @post uploadFile(@header contentType: "multipart/form-data", purpose: FilePurpose): string; - } - `, - ); - deepStrictEqual(res.components.schemas.FilePurpose, { type: "string", enum: ["one", "two"] }); + it("part of type union `bytes | {content: bytes}` produce `{} | { content: {type: string, contentEncoding: 'base64' }`", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", profileImage: bytes | {content: bytes}): void; + `, + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + type: "object", + properties: { + profileImage: { + anyOf: [ + {}, + { + type: "object", + properties: { + content: { type: "string", contentEncoding: "base64" }, + }, + required: ["content"], + }, + ], + }, + }, + required: ["profileImage"], + }, + }); + }); + + it("part of type `bytes[]` produce `type: array, items: {}`", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", profileImage: bytes[]): void; + `, + ); + const op = res.paths["/"].post; + deepStrictEqual(op.requestBody.content["multipart/form-data"], { + schema: { + type: "object", + properties: { + profileImage: { + type: "array", + items: {}, + }, + }, + required: ["profileImage"], + }, + }); + }); + + it("bytes inside a json part will be treated as base64 encoded by default(same as for a json body)", async () => { + const res = await openApiFor( + ` + op upload(@header contentType: "multipart/form-data", address: {city: string, icon: bytes}): void; + `, + ); + const op = res.paths["/"].post; + deepStrictEqual( + op.requestBody.content["multipart/form-data"].schema.properties.address.properties.icon, + { + type: "string", + contentEncoding: "base64", + }, + ); + }); + }); }); }); diff --git a/packages/openapi3/test/no-service-found.test.ts b/packages/openapi3/test/no-service-found.test.ts index 7bba50e69d..0b1e860752 100644 --- a/packages/openapi3/test/no-service-found.test.ts +++ b/packages/openapi3/test/no-service-found.test.ts @@ -1,8 +1,8 @@ import { expectDiagnosticEmpty, expectDiagnostics } from "@typespec/compiler/testing"; -import { describe, it } from "vitest"; -import { diagnoseOpenApiFor } from "./test-host.js"; +import { it } from "vitest"; +import { worksFor } from "./works-for.js"; -describe("openapi3: no-service-found diagnostic", () => { +worksFor(["3.0.0", "3.1.0"], ({ diagnoseOpenApiFor }) => { it("does not emit warning if a non-service namespace has no routes", async () => { const diagnostics = await diagnoseOpenApiFor( ` diff --git a/packages/openapi3/test/nullable-properties.test.ts b/packages/openapi3/test/nullable-properties.test.ts index e5dc42ed12..6ce8ab114b 100644 --- a/packages/openapi3/test/nullable-properties.test.ts +++ b/packages/openapi3/test/nullable-properties.test.ts @@ -1,9 +1,9 @@ import { deepStrictEqual, ok } from "assert"; import { describe, expect, it } from "vitest"; -import { OpenAPI3SchemaProperty } from "../src/types.js"; -import { oapiForModel, openApiFor } from "./test-host.js"; +import { OpenAPI3SchemaProperty, OpenAPISchema3_1, Refable } from "../src/types.js"; +import { worksFor } from "./works-for.js"; -describe("openapi3: nullable properties", () => { +worksFor(["3.0.0"], ({ oapiForModel, openApiFor }) => { it("makes nullable schema when union with null", async () => { const res = await openApiFor( ` @@ -72,3 +72,70 @@ describe("openapi3: nullable properties", () => { }); }); }); + +worksFor(["3.1.0"], ({ oapiForModel, openApiFor }) => { + // eslint-disable-next-line vitest/no-identical-title + it("makes nullable schema when union with null", async () => { + const res = await openApiFor( + ` + model Thing { + id: string; + properties: Thing | null; + } + op doStuff(): Thing; + `, + ); + deepStrictEqual(res.components.schemas.Thing.properties.properties, { + anyOf: [{ $ref: "#/components/schemas/Thing" }, { type: "null" }], + }); + }); + + // eslint-disable-next-line vitest/no-identical-title + it("handles a nullable enum", async () => { + const res = await oapiForModel( + "X", + ` + enum A { + a: 1 + } + + model X { + prop: A | null + } + `, + ); + deepStrictEqual(res.schemas.X.properties.prop, { + anyOf: [{ $ref: "#/components/schemas/A" }, { type: "null" }], + }); + }); + + // eslint-disable-next-line vitest/no-identical-title + describe("when used in circular references", () => { + async function expectInCircularReference(ref: string, value: Refable) { + const res = await openApiFor( + ` + model Test { + children: ${ref} | null; + } + + op test(filters: ${ref}): {}[]; + `, + ); + expect(res.components.schemas.Test.properties.children).toEqual(value); + } + it("keep nullable array inline", async () => { + await expectInCircularReference("Test[]", { + anyOf: [{ type: "array", items: { $ref: "#/components/schemas/Test" } }, { type: "null" }], + }); + }); + + it("keep nullable Record inline", async () => { + await expectInCircularReference("Record", { + anyOf: [ + { type: "object", additionalProperties: { $ref: "#/components/schemas/Test" } }, + { type: "null" }, + ], + }); + }); + }); +}); diff --git a/packages/openapi3/test/openapi-output.test.ts b/packages/openapi3/test/openapi-output.test.ts index 5230e5b080..2380aa8942 100644 --- a/packages/openapi3/test/openapi-output.test.ts +++ b/packages/openapi3/test/openapi-output.test.ts @@ -1,134 +1,111 @@ -import { resolvePath } from "@typespec/compiler"; -import { expectDiagnosticEmpty } from "@typespec/compiler/testing"; import { deepStrictEqual, ok, strictEqual } from "assert"; import { describe, it } from "vitest"; -import { OpenAPI3EmitterOptions } from "../src/lib.js"; -import { OpenAPI3Document } from "../src/types.js"; -import { createOpenAPITestRunner, oapiForModel, openApiFor } from "./test-host.js"; - -async function openapiWithOptions( - code: string, - options: OpenAPI3EmitterOptions, -): Promise { - const runner = await createOpenAPITestRunner(); - - const outPath = resolvePath("/openapi.json"); - - const diagnostics = await runner.diagnose(code, { - noEmit: false, - emit: ["@typespec/openapi3"], - options: { "@typespec/openapi3": { ...options, "output-file": outPath } }, - }); - - expectDiagnosticEmpty(diagnostics); +import { worksFor } from "./works-for.js"; - const content = runner.fs.get(outPath)!; - return JSON.parse(content); -} - -describe("openapi3: types included", () => { - it("emit unreferenced types by default", async () => { - const output = await openapiWithOptions( - ` +worksFor(["3.0.0", "3.1.0"], ({ oapiForModel, openApiFor, openapiWithOptions }) => { + describe("openapi3: types included", () => { + it("emit unreferenced types by default", async () => { + const output = await openapiWithOptions( + ` model NotReferenced {name: string} model Referenced {name: string} op test(): Referenced; `, - {}, - ); - deepStrictEqual(Object.keys(output.components!.schemas!), ["NotReferenced", "Referenced"]); - }); + {}, + ); + deepStrictEqual(Object.keys(output.components!.schemas!), ["NotReferenced", "Referenced"]); + }); - it("emit only referenced types when using omit-unreachable-types", async () => { - const output = await openapiWithOptions( - ` + it("emit only referenced types when using omit-unreachable-types", async () => { + const output = await openapiWithOptions( + ` model NotReferenced {name: string} model Referenced {name: string} op test(): Referenced; `, - { - "omit-unreachable-types": true, - }, - ); - deepStrictEqual(Object.keys(output.components!.schemas!), ["Referenced"]); + { + "omit-unreachable-types": true, + }, + ); + deepStrictEqual(Object.keys(output.components!.schemas!), ["Referenced"]); + }); }); -}); -describe("openapi3: x-typespec-name", () => { - it("doesn't include x-typespec-name by default", async () => { - const output = await openapiWithOptions( - ` + describe("openapi3: x-typespec-name", () => { + it("doesn't include x-typespec-name by default", async () => { + const output = await openapiWithOptions( + ` model Foo {names: string[]} `, - {}, - ); - ok(!("x-typespec-name" in output.components!.schemas!.Foo.properties!.names)); - }); + {}, + ); + ok(!("x-typespec-name" in output.components!.schemas!.Foo.properties!.names)); + }); - it(`doesn't include x-typespec-name when option include-x-typespec-name: "never"`, async () => { - const output = await openapiWithOptions( - ` + it(`doesn't include x-typespec-name when option include-x-typespec-name: "never"`, async () => { + const output = await openapiWithOptions( + ` model Foo {names: string[]} `, - { "include-x-typespec-name": "never" }, - ); - ok(!("x-typespec-name" in output.components!.schemas!.Foo.properties!.names)); - }); + { "include-x-typespec-name": "never" }, + ); + ok(!("x-typespec-name" in output.components!.schemas!.Foo.properties!.names)); + }); - it(`include x-typespec-name when option include-x-typespec-name: "inline-only"`, async () => { - const output = await openapiWithOptions( - ` + it(`include x-typespec-name when option include-x-typespec-name: "inline-only"`, async () => { + const output = await openapiWithOptions( + ` model Foo {names: string[]} `, - { "include-x-typespec-name": "inline-only" }, - ); - const prop: any = output.components!.schemas!.Foo.properties!.names; - strictEqual(prop["x-typespec-name"], `string[]`); + { "include-x-typespec-name": "inline-only" }, + ); + const prop: any = output.components!.schemas!.Foo.properties!.names; + strictEqual(prop["x-typespec-name"], `string[]`); + }); }); -}); -describe("openapi3: literals", () => { - const cases = [ - ["1", { type: "number", enum: [1] }], - ['"hello"', { type: "string", enum: ["hello"] }], - ["false", { type: "boolean", enum: [false] }], - ["true", { type: "boolean", enum: [true] }], - ]; - - for (const test of cases) { - it("knows schema for " + test[0], async () => { - const res = await oapiForModel( - "Pet", - ` + describe("openapi3: literals", () => { + const cases = [ + ["1", { type: "number", enum: [1] }], + ['"hello"', { type: "string", enum: ["hello"] }], + ["false", { type: "boolean", enum: [false] }], + ["true", { type: "boolean", enum: [true] }], + ]; + + for (const test of cases) { + it("knows schema for " + test[0], async () => { + const res = await oapiForModel( + "Pet", + ` model Pet { name: ${test[0]} }; `, - ); + ); - const schema = res.schemas.Pet.properties.name; - deepStrictEqual(schema, test[1]); - }); - } -}); + const schema = res.schemas.Pet.properties.name; + deepStrictEqual(schema, test[1]); + }); + } + }); -describe("openapi3: operations", () => { - it("define operations with param with defaults", async () => { - const res = await openApiFor( - ` + describe("openapi3: operations", () => { + it("define operations with param with defaults", async () => { + const res = await openApiFor( + ` @route("/") @get() op read(@query queryWithDefault?: string = "defaultValue"): string; `, - ); + ); - strictEqual(res.paths["/"].get.operationId, "read"); - deepStrictEqual(res.paths["/"].get.parameters[0].schema.default, "defaultValue"); - }); + strictEqual(res.paths["/"].get.operationId, "read"); + deepStrictEqual(res.paths["/"].get.parameters[0].schema.default, "defaultValue"); + }); - it("define operations with param with decorators", async () => { - const res = await openApiFor( - ` + it("define operations with param with decorators", async () => { + const res = await openApiFor( + ` @get @route("/thing/{name}") op getThing( @@ -140,35 +117,35 @@ describe("openapi3: operations", () => { @query count: int32 ): string; `, - ); + ); - const getThing = res.paths["/thing/{name}"].get; + const getThing = res.paths["/thing/{name}"].get; - strictEqual(getThing.operationId, "getThing"); + strictEqual(getThing.operationId, "getThing"); - ok(getThing); - ok(getThing.parameters[0].schema); - ok(getThing.parameters[0].schema.pattern); - strictEqual(getThing.parameters[0].schema.pattern, "^[a-zA-Z0-9-]{3,24}$"); + ok(getThing); + ok(getThing.parameters[0].schema); + ok(getThing.parameters[0].schema.pattern); + strictEqual(getThing.parameters[0].schema.pattern, "^[a-zA-Z0-9-]{3,24}$"); - ok(getThing.parameters[1].schema); - ok(getThing.parameters[1].schema.minimum); - ok(getThing.parameters[1].schema.maximum); - strictEqual(getThing.parameters[1].schema.minimum, 1); - strictEqual(getThing.parameters[1].schema.maximum, 10); - }); + ok(getThing.parameters[1].schema); + ok(getThing.parameters[1].schema.minimum); + ok(getThing.parameters[1].schema.maximum); + strictEqual(getThing.parameters[1].schema.minimum, 1); + strictEqual(getThing.parameters[1].schema.maximum, 10); + }); - it("deprecate operations with #deprecated", async () => { - const res = await openApiFor( - ` + it("deprecate operations with #deprecated", async () => { + const res = await openApiFor( + ` #deprecated "use something else" op read(@query query: string): string; `, - ); + ); - strictEqual(res.paths["/"].get.deprecated, true); + strictEqual(res.paths["/"].get.deprecated, true); + }); }); - it("deprecate inline parameters with #deprecated", async () => { const res = await openApiFor( ` @@ -215,50 +192,23 @@ describe("openapi3: operations", () => { strictEqual(res.components.parameters["PetId.foo"].deprecated, true); strictEqual(res.components.parameters["PetId.name"].deprecated, undefined); }); -}); -describe("openapi3: request", () => { - describe("binary request", () => { - it("bytes request should default to application/json byte", async () => { - const res = await openApiFor(` - @post op read(@body body: bytes): {}; - `); - - const requestBody = res.paths["/"].post.requestBody; - ok(requestBody); - strictEqual(requestBody.content["application/json"].schema.type, "string"); - strictEqual(requestBody.content["application/json"].schema.format, "byte"); - }); - - it("bytes request should respect @header contentType and use binary format when not json or text", async () => { - const res = await openApiFor(` - @post op read(@header contentType: "image/png", @body body: bytes): {}; - `); - - const requestBody = res.paths["/"].post.requestBody; - ok(requestBody); - strictEqual(requestBody.content["image/png"].schema.type, "string"); - strictEqual(requestBody.content["image/png"].schema.format, "binary"); - }); - }); -}); - -describe("openapi3: extension decorator", () => { - it("adds an arbitrary extension to a model", async () => { - const oapi = await openApiFor(` + describe("openapi3: extension decorator", () => { + it("adds an arbitrary extension to a model", async () => { + const oapi = await openApiFor(` @extension("x-model-extension", "foobar") model Pet { name: string; } @get() op read(): Pet; `); - ok(oapi.components.schemas.Pet); - strictEqual(oapi.components.schemas.Pet["x-model-extension"], "foobar"); - }); + ok(oapi.components.schemas.Pet); + strictEqual(oapi.components.schemas.Pet["x-model-extension"], "foobar"); + }); - it("adds an arbitrary extension to an operation", async () => { - const oapi = await openApiFor( - ` + it("adds an arbitrary extension to an operation", async () => { + const oapi = await openApiFor( + ` model Pet { name: string; } @@ -266,14 +216,14 @@ describe("openapi3: extension decorator", () => { @extension("x-operation-extension", "barbaz") op list(): Pet[]; `, - ); - ok(oapi.paths["/"].get); - strictEqual(oapi.paths["/"].get["x-operation-extension"], "barbaz"); - }); + ); + ok(oapi.paths["/"].get); + strictEqual(oapi.paths["/"].get["x-operation-extension"], "barbaz"); + }); - it("adds an arbitrary extension to a parameter", async () => { - const oapi = await openApiFor( - ` + it("adds an arbitrary extension to a parameter", async () => { + const oapi = await openApiFor( + ` model Pet { name: string; } @@ -286,30 +236,30 @@ describe("openapi3: extension decorator", () => { @get() op get(... PetId): Pet; `, - ); - ok(oapi.paths["/Pets/{petId}"].get); - strictEqual( - oapi.paths["/Pets/{petId}"].get.parameters[0]["$ref"], - "#/components/parameters/PetId", - ); - strictEqual(oapi.components.parameters.PetId.name, "petId"); - strictEqual(oapi.components.parameters.PetId["x-parameter-extension"], "foobaz"); - }); + ); + ok(oapi.paths["/Pets/{petId}"].get); + strictEqual( + oapi.paths["/Pets/{petId}"].get.parameters[0]["$ref"], + "#/components/parameters/PetId", + ); + strictEqual(oapi.components.parameters.PetId.name, "petId"); + strictEqual(oapi.components.parameters.PetId["x-parameter-extension"], "foobaz"); + }); - it("adds an extension to a namespace", async () => { - const oapi = await openApiFor( - ` + it("adds an extension to a namespace", async () => { + const oapi = await openApiFor( + ` @extension("x-namespace-extension", "foobar") @service namespace Service {}; `, - ); + ); - strictEqual(oapi["x-namespace-extension"], "foobar"); - }); + strictEqual(oapi["x-namespace-extension"], "foobar"); + }); - it("check format and pattern decorator on model", async () => { - const oapi = await openApiFor( - ` + it("check format and pattern decorator on model", async () => { + const oapi = await openApiFor( + ` model Pet extends PetId { @pattern("^[a-zA-Z0-9-]{3,24}$") name: string; @@ -324,22 +274,22 @@ describe("openapi3: extension decorator", () => { @get() op get(... PetId): Pet; `, - ); - ok(oapi.paths["/Pets/{petId}"].get); - strictEqual( - oapi.paths["/Pets/{petId}"].get.parameters[0]["$ref"], - "#/components/parameters/PetId", - ); - strictEqual(oapi.components.parameters.PetId.name, "petId"); - strictEqual(oapi.components.schemas.Pet.properties.name.pattern, "^[a-zA-Z0-9-]{3,24}$"); - strictEqual(oapi.components.parameters.PetId.schema.format, "UUID"); - strictEqual(oapi.components.parameters.PetId.schema.pattern, "^[a-zA-Z0-9-]{3,24}$"); + ); + ok(oapi.paths["/Pets/{petId}"].get); + strictEqual( + oapi.paths["/Pets/{petId}"].get.parameters[0]["$ref"], + "#/components/parameters/PetId", + ); + strictEqual(oapi.components.parameters.PetId.name, "petId"); + strictEqual(oapi.components.schemas.Pet.properties.name.pattern, "^[a-zA-Z0-9-]{3,24}$"); + strictEqual(oapi.components.parameters.PetId.schema.format, "UUID"); + strictEqual(oapi.components.parameters.PetId.schema.pattern, "^[a-zA-Z0-9-]{3,24}$"); + }); }); -}); -describe("openapi3: useRef decorator", () => { - it("adds a ref extension to a model", async () => { - const oapi = await openApiFor(` + describe("openapi3: useRef decorator", () => { + it("adds a ref extension to a model", async () => { + const oapi = await openApiFor(` @test @useRef("../common.json#/definitions/Foo") model Foo { @statusCode @@ -348,12 +298,12 @@ describe("openapi3: useRef decorator", () => { } @get op get(): Foo; `); - ok(oapi.paths["/"].get); - strictEqual(oapi.paths["/"].get.responses["200"]["$ref"], "../common.json#/definitions/Foo"); - }); + ok(oapi.paths["/"].get); + strictEqual(oapi.paths["/"].get.responses["200"]["$ref"], "../common.json#/definitions/Foo"); + }); - it("adds a ref extension to a multiple models", async () => { - const oapi = await openApiFor(` + it("adds a ref extension to a multiple models", async () => { + const oapi = await openApiFor(` @test @useRef("../common.json#/definitions/Foo") model Foo { @statusCode @@ -368,8 +318,66 @@ describe("openapi3: useRef decorator", () => { } @get op get(): Foo | Foo2; `); - ok(oapi.paths["/"].get); - strictEqual(oapi.paths["/"].get.responses["200"]["$ref"], "../common.json#/definitions/Foo"); - strictEqual(oapi.paths["/"].get.responses["201"]["$ref"], "https://example.com/example.yml"); + ok(oapi.paths["/"].get); + strictEqual(oapi.paths["/"].get.responses["200"]["$ref"], "../common.json#/definitions/Foo"); + strictEqual(oapi.paths["/"].get.responses["201"]["$ref"], "https://example.com/example.yml"); + }); + }); +}); + +worksFor(["3.0.0"], ({ openApiFor }) => { + describe("openapi 3.0: request", () => { + describe("binary request", () => { + it("bytes request should default to application/json byte", async () => { + const res = await openApiFor(` + @post op read(@body body: bytes): {}; + `); + + const requestBody = res.paths["/"].post.requestBody; + ok(requestBody); + strictEqual(requestBody.content["application/json"].schema.type, "string"); + strictEqual(requestBody.content["application/json"].schema.format, "byte"); + }); + + it("bytes request should respect @header contentType and use binary format when not json or text", async () => { + const res = await openApiFor(` + @post op read(@header contentType: "image/png", @body body: bytes): {}; + `); + + const requestBody = res.paths["/"].post.requestBody; + ok(requestBody); + strictEqual(requestBody.content["image/png"].schema.type, "string"); + strictEqual(requestBody.content["image/png"].schema.format, "binary"); + }); + }); + }); +}); + +worksFor(["3.1.0"], ({ openApiFor }) => { + describe("openapi 3.1: request", () => { + describe("binary request", () => { + it("bytes request should default to application/json with base64 contentEncoding", async () => { + const res = await openApiFor(` + @post op read(@body body: bytes): {}; + `); + + const requestBody = res.paths["/"].post.requestBody; + ok(requestBody); + deepStrictEqual(requestBody.content["application/json"].schema, { + type: "string", + contentEncoding: "base64", + }); + }); + + it("bytes request should respect @header contentType and use contentMediaType when not json or text", async () => { + const res = await openApiFor(` + @post op read(@header contentType: "image/png", @body body: bytes): {}; + `); + + const requestBody = res.paths["/"].post.requestBody; + ok(requestBody); + deepStrictEqual(requestBody.content["image/png"].schema, { contentMediaType: "image/png" }); + }); + }); }); }); diff --git a/packages/openapi3/test/output-spec-versions.test.ts b/packages/openapi3/test/output-spec-versions.test.ts new file mode 100644 index 0000000000..2ced94b0a3 --- /dev/null +++ b/packages/openapi3/test/output-spec-versions.test.ts @@ -0,0 +1,61 @@ +import { resolvePath } from "@typespec/compiler"; +import { + BasicTestRunner, + expectDiagnosticEmpty, + resolveVirtualPath, +} from "@typespec/compiler/testing"; +import { ok } from "assert"; +import { beforeEach, expect, it } from "vitest"; +import { OpenAPI3EmitterOptions } from "../src/lib.js"; +import { createOpenAPITestRunner } from "./test-host.js"; + +const outputDir = resolveVirtualPath("test-output"); +let runner: BasicTestRunner; +beforeEach(async () => { + runner = await createOpenAPITestRunner(); +}); + +async function compileOpenAPI(options: OpenAPI3EmitterOptions, code: string = ""): Promise { + const diagnostics = await runner.diagnose(code, { + noEmit: false, + emit: ["@typespec/openapi3"], + options: { "@typespec/openapi3": { ...options, "emitter-output-dir": outputDir } }, + }); + + expectDiagnosticEmpty(diagnostics); +} + +function expectHasOutput(filename: string) { + const outPath = resolvePath(outputDir, filename); + const content = runner.fs.get(outPath); + ok(content, `Expected ${outPath} to exist.`); +} + +it("creates nested directory if multiple spec versions are specified", async () => { + await compileOpenAPI({ "openapi-versions": ["3.0.0", "3.1.0"] }); + expectHasOutput("3.0.0/openapi.yaml"); + expectHasOutput("3.1.0/openapi.yaml"); +}); + +it("does not create nested directory if only 1 spec version is specified", async () => { + await compileOpenAPI({ "openapi-versions": ["3.0.0"] }); + expectHasOutput("openapi.yaml"); +}); + +it("defaults to 3.0.0 if not specified", async () => { + await compileOpenAPI({ "file-type": "json" }); + const outPath = resolvePath(outputDir, "openapi.json"); + const content = runner.fs.get(outPath); + ok(content, `Expected ${outPath} to exist.`); + const doc = JSON.parse(content); + expect(doc.openapi).toBe("3.0.0"); +}); + +it("supports 3.1.0", async () => { + await compileOpenAPI({ "openapi-versions": ["3.1.0"], "file-type": "json" }); + const outPath = resolvePath(outputDir, "openapi.json"); + const content = runner.fs.get(outPath); + ok(content, `Expected ${outPath} to exist.`); + const doc = JSON.parse(content); + expect(doc.openapi).toBe("3.1.0"); +}); diff --git a/packages/openapi3/test/overloads.test.ts b/packages/openapi3/test/overloads.test.ts index d0b3d55fe7..2d017fa6db 100644 --- a/packages/openapi3/test/overloads.test.ts +++ b/packages/openapi3/test/overloads.test.ts @@ -1,9 +1,9 @@ import { deepStrictEqual, ok, strictEqual } from "assert"; import { beforeEach, describe, it } from "vitest"; import { OpenAPI3Document } from "../src/types.js"; -import { openApiFor } from "./test-host.js"; +import { worksFor } from "./works-for.js"; -describe("openapi3: overloads", () => { +worksFor(["3.0.0", "3.1.0"], ({ openApiFor }) => { describe("overloads use same endpoint", () => { let res: OpenAPI3Document; beforeEach(async () => { diff --git a/packages/openapi3/test/parameters.test.ts b/packages/openapi3/test/parameters.test.ts index d646df97bb..5f6f267b3e 100644 --- a/packages/openapi3/test/parameters.test.ts +++ b/packages/openapi3/test/parameters.test.ts @@ -2,68 +2,71 @@ import { expectDiagnostics } from "@typespec/compiler/testing"; import { deepStrictEqual, ok, strictEqual } from "assert"; import { describe, expect, it } from "vitest"; import { OpenAPI3PathParameter, OpenAPI3QueryParameter } from "../src/types.js"; -import { diagnoseOpenApiFor, openApiFor } from "./test-host.js"; - -describe("query parameters", () => { - async function getQueryParam(code: string): Promise { - const res = await openApiFor(code); - const param = res.paths[`/`].get.parameters[0]; - strictEqual(param.in, "query"); - return param; - } - - it("create a query param", async () => { - const param = await getQueryParam( - `op test(@query myParam: string): void; +import { worksFor } from "./works-for.js"; + +worksFor(["3.0.0", "3.1.0"], ({ diagnoseOpenApiFor, openApiFor }) => { + describe("query parameters", () => { + async function getQueryParam(code: string): Promise { + const res = await openApiFor(code); + const param = res.paths[`/`].get.parameters[0]; + strictEqual(param.in, "query"); + return param; + } + + it("create a query param", async () => { + const param = await getQueryParam( + `op test(@query myParam: string): void; `, - ); - strictEqual(param.name, "myParam"); - deepStrictEqual(param.schema, { type: "string" }); - }); + ); + strictEqual(param.name, "myParam"); + deepStrictEqual(param.schema, { type: "string" }); + }); - it("create a query param with a different name", async () => { - const param = await getQueryParam( - ` + it("create a query param with a different name", async () => { + const param = await getQueryParam( + ` op test(@query("$select") select: string): void; `, - ); - strictEqual(param.in, "query"); - strictEqual(param.name, "$select"); - }); - - describe("doesn't set explode if explode: true (Openapi3.0 inverse default)", () => { - it("with option", async () => { - const param = await getQueryParam(`op test(@query(#{explode: true}) myParam: string): void;`); - expect(param).not.toHaveProperty("explode"); + ); + strictEqual(param.in, "query"); + strictEqual(param.name, "$select"); }); - it("with uri template", async () => { - const param = await getQueryParam(`@route("{?myParam*}") op test(myParam: string): void;`); - expect(param).not.toHaveProperty("explode"); - }); - }); + describe("doesn't set explode if explode: true (Openapi3.0 inverse default)", () => { + it("with option", async () => { + const param = await getQueryParam( + `op test(@query(#{explode: true}) myParam: string): void;`, + ); + expect(param).not.toHaveProperty("explode"); + }); - describe("set explode: false if explode is not set", () => { - it("with option", async () => { - const param = await getQueryParam( - `op test(@query(#{explode: false}) myParam: string): void;`, - ); - expect(param).toMatchObject({ - explode: false, + it("with uri template", async () => { + const param = await getQueryParam(`@route("{?myParam*}") op test(myParam: string): void;`); + expect(param).not.toHaveProperty("explode"); }); }); - it("with uri template", async () => { - const param = await getQueryParam(`@route("{?myParam}") op test(myParam: string): void;`); - expect(param).toMatchObject({ - explode: false, + describe("set explode: false if explode is not set", () => { + it("with option", async () => { + const param = await getQueryParam( + `op test(@query(#{explode: false}) myParam: string): void;`, + ); + expect(param).toMatchObject({ + explode: false, + }); + }); + + it("with uri template", async () => { + const param = await getQueryParam(`@route("{?myParam}") op test(myParam: string): void;`); + expect(param).toMatchObject({ + explode: false, + }); }); }); - }); - it("LEGACY: specify the format", async () => { - const res = await openApiFor( - ` + it("LEGACY: specify the format", async () => { + const res = await openApiFor( + ` #suppress "deprecated" "test" op test( @query({name: "$multi", format: "multi"}) multis: string[], @@ -74,112 +77,112 @@ describe("query parameters", () => { @query({name: "$pipes", format: "pipes"}) pipes: string[] ): void; `, - ); - const params = res.paths["/"].get.parameters; - deepStrictEqual(params[0], { - in: "query", - name: "$multi", - required: true, - schema: { - type: "array", - items: { - type: "string", + ); + const params = res.paths["/"].get.parameters; + deepStrictEqual(params[0], { + in: "query", + name: "$multi", + required: true, + schema: { + type: "array", + items: { + type: "string", + }, }, - }, - }); - deepStrictEqual(params[1], { - in: "query", - name: "$csv", - explode: false, - schema: { - type: "array", - items: { - type: "string", + }); + deepStrictEqual(params[1], { + in: "query", + name: "$csv", + explode: false, + schema: { + type: "array", + items: { + type: "string", + }, }, - }, - required: true, - }); - deepStrictEqual(params[2], { - in: "query", - name: "$tsv", - schema: { - type: "string", - }, - required: true, - }); - deepStrictEqual(params[3], { - in: "query", - name: "$ssv", - style: "spaceDelimited", - required: true, - schema: { - type: "array", - items: { + required: true, + }); + deepStrictEqual(params[2], { + in: "query", + name: "$tsv", + schema: { type: "string", }, - }, - explode: false, - }); - deepStrictEqual(params[4], { - in: "query", - name: "$pipes", - style: "pipeDelimited", - required: true, - schema: { - type: "array", - items: { - type: "string", + required: true, + }); + deepStrictEqual(params[3], { + in: "query", + name: "$ssv", + style: "spaceDelimited", + required: true, + schema: { + type: "array", + items: { + type: "string", + }, }, - }, - explode: false, + explode: false, + }); + deepStrictEqual(params[4], { + in: "query", + name: "$pipes", + style: "pipeDelimited", + required: true, + schema: { + type: "array", + items: { + type: "string", + }, + }, + explode: false, + }); }); - }); - it("create a query param that is a model property", async () => { - const res = await openApiFor( - ` + it("create a query param that is a model property", async () => { + const res = await openApiFor( + ` op test(@query id: UserContext.id): void; model UserContext { id: string; } `, - ); - deepStrictEqual(res.paths["/"].get.parameters[0], { - in: "query", - name: "id", - explode: false, - required: true, - schema: { - type: "string", - }, + ); + deepStrictEqual(res.paths["/"].get.parameters[0], { + in: "query", + name: "id", + explode: false, + required: true, + schema: { + type: "string", + }, + }); }); - }); - it("create an header param", async () => { - const res = await openApiFor( - ` + it("create an header param", async () => { + const res = await openApiFor( + ` op test(@header arg1: string): void; `, - ); - strictEqual(res.paths["/"].get.parameters[0].in, "header"); - strictEqual(res.paths["/"].get.parameters[0].name, "arg1"); - deepStrictEqual(res.paths["/"].get.parameters[0].schema, { type: "string" }); - }); + ); + strictEqual(res.paths["/"].get.parameters[0].in, "header"); + strictEqual(res.paths["/"].get.parameters[0].name, "arg1"); + deepStrictEqual(res.paths["/"].get.parameters[0].schema, { type: "string" }); + }); - it("create an header param with a different name", async () => { - const res = await openApiFor( - ` + it("create an header param with a different name", async () => { + const res = await openApiFor( + ` op test(@header("foo-bar") foo: string): void; `, - ); - strictEqual(res.paths["/"].get.parameters[0].in, "header"); - strictEqual(res.paths["/"].get.parameters[0].name, "foo-bar"); - }); + ); + strictEqual(res.paths["/"].get.parameters[0].in, "header"); + strictEqual(res.paths["/"].get.parameters[0].name, "foo-bar"); + }); - it("create a header param of array type", async () => { - const res = await openApiFor( - ` + it("create a header param of array type", async () => { + const res = await openApiFor( + ` op test( @header({name: "$csv", format: "csv"}) csvs: string[], #suppress "@typespec/openapi3/invalid-format" "test" @@ -192,89 +195,89 @@ describe("query parameters", () => { @header({name: "$pipes", format: "pipes"}) pipes: string[] ): void; `, - ); - const params = res.paths["/"].get.parameters; - deepStrictEqual(params[0], { - in: "header", - name: "$csv", - style: "simple", - schema: { - type: "array", - items: { + ); + const params = res.paths["/"].get.parameters; + deepStrictEqual(params[0], { + in: "header", + name: "$csv", + style: "simple", + schema: { + type: "array", + items: { + type: "string", + }, + }, + required: true, + }); + deepStrictEqual(params[1], { + in: "header", + name: "$multi", + required: true, + schema: { + type: "string", + }, + }); + deepStrictEqual(params[2], { + in: "header", + name: "$tsv", + schema: { + type: "string", + }, + required: true, + }); + deepStrictEqual(params[3], { + in: "header", + name: "$ssv", + required: true, + schema: { + type: "string", + }, + }); + deepStrictEqual(params[4], { + in: "header", + name: "$pipes", + required: true, + schema: { type: "string", }, - }, - required: true, - }); - deepStrictEqual(params[1], { - in: "header", - name: "$multi", - required: true, - schema: { - type: "string", - }, - }); - deepStrictEqual(params[2], { - in: "header", - name: "$tsv", - schema: { - type: "string", - }, - required: true, - }); - deepStrictEqual(params[3], { - in: "header", - name: "$ssv", - required: true, - schema: { - type: "string", - }, - }); - deepStrictEqual(params[4], { - in: "header", - name: "$pipes", - required: true, - schema: { - type: "string", - }, + }); }); - }); - it("create a cookie param", async () => { - const res = await openApiFor( - ` + it("create a cookie param", async () => { + const res = await openApiFor( + ` op test(@cookie arg1: string): void; `, - ); - strictEqual(res.paths["/"].get.parameters[0].in, "cookie"); - strictEqual(res.paths["/"].get.parameters[0].name, "arg1"); - deepStrictEqual(res.paths["/"].get.parameters[0].schema, { type: "string" }); - }); + ); + strictEqual(res.paths["/"].get.parameters[0].in, "cookie"); + strictEqual(res.paths["/"].get.parameters[0].name, "arg1"); + deepStrictEqual(res.paths["/"].get.parameters[0].schema, { type: "string" }); + }); - it("create a cookie param with a different name", async () => { - const res = await openApiFor( - ` + it("create a cookie param with a different name", async () => { + const res = await openApiFor( + ` op test(@cookie("foo_bar") foo: string): void; `, - ); - strictEqual(res.paths["/"].get.parameters[0].in, "cookie"); - strictEqual(res.paths["/"].get.parameters[0].name, "foo_bar"); - }); + ); + strictEqual(res.paths["/"].get.parameters[0].in, "cookie"); + strictEqual(res.paths["/"].get.parameters[0].name, "foo_bar"); + }); - // Regression test for https://github.com/microsoft/typespec/issues/414 - it("@doc set the description on the parameter not its schema", async () => { - const res = await openApiFor( - ` + // Regression test for https://github.com/microsoft/typespec/issues/414 + it("@doc set the description on the parameter not its schema", async () => { + const res = await openApiFor( + ` op test(@query @doc("my-doc") arg1: string): void; `, - ); - strictEqual(res.paths["/"].get.parameters[0].description, "my-doc"); - strictEqual(res.paths["/"].get.parameters[0].schema.description, undefined); - }); + ); + strictEqual(res.paths["/"].get.parameters[0].description, "my-doc"); + strictEqual(res.paths["/"].get.parameters[0].schema.description, undefined); + }); - it("errors on duplicate parameter keys", async () => { - const diagnostics = await diagnoseOpenApiFor( - ` + it("errors on duplicate parameter keys", async () => { + const diagnostics = await diagnoseOpenApiFor( + ` model P { @query id: string; } @@ -290,20 +293,20 @@ describe("query parameters", () => { @route("/test2") op test2(...Q): void; `, - { "omit-unreachable-types": true }, - ); - - expectDiagnostics(diagnostics, [ - { - code: "@typespec/openapi/duplicate-type-name", - message: /parameter/, - }, - ]); - }); + { "omit-unreachable-types": true }, + ); + + expectDiagnostics(diagnostics, [ + { + code: "@typespec/openapi/duplicate-type-name", + message: /parameter/, + }, + ]); + }); - it("errors on invalid parameter keys", async () => { - const diagnostics = await diagnoseOpenApiFor( - ` + it("errors on invalid parameter keys", async () => { + const diagnostics = await diagnoseOpenApiFor( + ` model Pet { @query() $take?: int32; @@ -316,59 +319,59 @@ describe("query parameters", () => { op list(...Pet): void; } `, - { "omit-unreachable-types": true }, - ); - - expectDiagnostics(diagnostics, [ - { - code: "@typespec/openapi3/invalid-component-fixed-field-key", - }, - { - code: "@typespec/openapi3/invalid-component-fixed-field-key", - }, - ]); - }); + { "omit-unreachable-types": true }, + ); - it("inline spread of parameters from anonymous model", async () => { - const oapi = await openApiFor( - ` + expectDiagnostics(diagnostics, [ + { + code: "@typespec/openapi3/invalid-component-fixed-field-key", + }, + { + code: "@typespec/openapi3/invalid-component-fixed-field-key", + }, + ]); + }); + + it("inline spread of parameters from anonymous model", async () => { + const oapi = await openApiFor( + ` op template(...TParameters): TReturn; op instantiation is template<{@path id: string}, void>; `, - ); + ); - ok(oapi.paths["/{id}"].get); + ok(oapi.paths["/{id}"].get); - deepStrictEqual(oapi.paths["/{id}"].get.parameters, [ - { - name: "id", - in: "path", - required: true, - schema: { - type: "string", + deepStrictEqual(oapi.paths["/{id}"].get.parameters, [ + { + name: "id", + in: "path", + required: true, + schema: { + type: "string", + }, }, - }, - ]); - }); + ]); + }); - it("omit parameters with type never", async () => { - const res = await openApiFor( - ` + it("omit parameters with type never", async () => { + const res = await openApiFor( + ` op test(@query select: never, @query top: int32): void; `, - ); - strictEqual(res.paths["/"].get.parameters.length, 1); - strictEqual(res.paths["/"].get.parameters[0].in, "query"); - strictEqual(res.paths["/"].get.parameters[0].name, "top"); - }); + ); + strictEqual(res.paths["/"].get.parameters.length, 1); + strictEqual(res.paths["/"].get.parameters[0].in, "query"); + strictEqual(res.paths["/"].get.parameters[0].name, "top"); + }); - it("omit request body if type is void", async () => { - const res = await openApiFor(`op test(@body foo: void ): void;`); - strictEqual(res.paths["/"].post.requestBody, undefined); - }); + it("omit request body if type is void", async () => { + const res = await openApiFor(`op test(@body foo: void ): void;`); + strictEqual(res.paths["/"].post.requestBody, undefined); + }); - it("using @body ignore any metadata property underneath", async () => { - const res = await openApiFor(`@get op read( + it("using @body ignore any metadata property underneath", async () => { + const res = await openApiFor(`@get op read( @body body: { #suppress "@typespec/http/metadata-ignored" @header header: string, @@ -380,30 +383,30 @@ describe("query parameters", () => { @statusCode code: 201, } ): void;`); - expect(res.paths["/"].get.requestBody.content["application/json"].schema).toEqual({ - type: "object", - properties: { - header: { type: "string" }, - cookie: { type: "string" }, - query: { type: "string" }, - code: { type: "number", enum: [201] }, - }, - required: ["header", "cookie", "query", "code"], + expect(res.paths["/"].get.requestBody.content["application/json"].schema).toEqual({ + type: "object", + properties: { + header: { type: "string" }, + cookie: { type: "string" }, + query: { type: "string" }, + code: { type: "number", enum: [201] }, + }, + required: ["header", "cookie", "query", "code"], + }); }); - }); - describe("request parameters resolving to no property in the body produce no body", () => { - it.each(["()", "(@header prop: string)", `(@visibility("none") prop: string)`])( - "%s", - async (params) => { - const res = await openApiFor(`op test${params}: void;`); - strictEqual(res.paths["/"].get.requestBody, undefined); - }, - ); - }); + describe("request parameters resolving to no property in the body produce no body", () => { + it.each(["()", "(@header prop: string)", `(@visibility("none") prop: string)`])( + "%s", + async (params) => { + const res = await openApiFor(`op test${params}: void;`); + strictEqual(res.paths["/"].get.requestBody, undefined); + }, + ); + }); - it("property in body with only metadata properties should still be included", async () => { - const res = await openApiFor(`op read( + it("property in body with only metadata properties should still be included", async () => { + const res = await openApiFor(`op read( headers: { @header header1: string; @header header2: string; @@ -414,19 +417,19 @@ describe("query parameters", () => { }; name: string; ): void;`); - expect(res.paths["/"].post.requestBody.content["application/json"].schema).toEqual({ - type: "object", - properties: { - headers: { type: "object" }, - cookies: { type: "object" }, - name: { type: "string" }, - }, - required: ["headers", "cookies", "name"], + expect(res.paths["/"].post.requestBody.content["application/json"].schema).toEqual({ + type: "object", + properties: { + headers: { type: "object" }, + cookies: { type: "object" }, + name: { type: "string" }, + }, + required: ["headers", "cookies", "name"], + }); }); - }); - it("property in body with only metadata properties and @bodyIgnore should not be included", async () => { - const res = await openApiFor(`op read( + it("property in body with only metadata properties and @bodyIgnore should not be included", async () => { + const res = await openApiFor(`op read( @bodyIgnore headers: { @header header1: string; @header header2: string; @@ -437,203 +440,218 @@ describe("query parameters", () => { }; name: string; ): void;`); - expect(res.paths["/"].post.requestBody.content["application/json"].schema).toEqual({ - type: "object", - properties: { - name: { type: "string" }, - }, - required: ["name"], + expect(res.paths["/"].post.requestBody.content["application/json"].schema).toEqual({ + type: "object", + properties: { + name: { type: "string" }, + }, + required: ["name"], + }); }); - }); - describe("content type parameter", () => { - it("header named with 'Content-Type' gets resolved as content type for operation.", async () => { - const res = await openApiFor( - ` + describe("content type parameter", () => { + it("header named with 'Content-Type' gets resolved as content type for operation.", async () => { + const res = await openApiFor( + ` op test( @header("Content-Type") explicitContentType: "application/octet-stream", @body foo: string ): void; `, - ); - ok(res.paths["/"].post.requestBody.content["application/octet-stream"]); - deepStrictEqual(res.paths["/"].post.requestBody.content["application/octet-stream"].schema, { - type: "string", + ); + ok(res.paths["/"].post.requestBody.content["application/octet-stream"]); + deepStrictEqual( + res.paths["/"].post.requestBody.content["application/octet-stream"].schema, + { + type: "string", + }, + ); }); - }); - it("header named contentType gets resolved as content type for operation.", async () => { - const res = await openApiFor( - ` + it("header named contentType gets resolved as content type for operation.", async () => { + const res = await openApiFor( + ` op test( @header contentType: "application/octet-stream", @body foo: string ): void; `, - ); - ok(res.paths["/"].post.requestBody.content["application/octet-stream"]); - deepStrictEqual(res.paths["/"].post.requestBody.content["application/octet-stream"].schema, { - type: "string", + ); + ok(res.paths["/"].post.requestBody.content["application/octet-stream"]); + deepStrictEqual( + res.paths["/"].post.requestBody.content["application/octet-stream"].schema, + { + type: "string", + }, + ); + strictEqual(res.paths["/"].post.parameters.length, 0); }); - strictEqual(res.paths["/"].post.parameters.length, 0); - }); - it("query named contentType doesn't get resolved as the content type parameter.", async () => { - const res = await openApiFor( - ` + it("query named contentType doesn't get resolved as the content type parameter.", async () => { + const res = await openApiFor( + ` op test( @query contentType: "application/octet-stream", @body foo: string ): void; `, - ); - strictEqual(res.paths["/"].post.requestBody.content["application/octet-stream"], undefined); - ok(res.paths["/"].post.requestBody.content["application/json"]); + ); + strictEqual(res.paths["/"].post.requestBody.content["application/octet-stream"], undefined); + ok(res.paths["/"].post.requestBody.content["application/json"]); + }); }); }); -}); -describe("path parameters", () => { - async function getPathParam(code: string, name = "myParam"): Promise { - const res = await openApiFor(code); - return res.paths[`/{${name}}`].get.parameters[0]; - } + describe("path parameters", () => { + async function getPathParam(code: string, name = "myParam"): Promise { + const res = await openApiFor(code); + return res.paths[`/{${name}}`].get.parameters[0]; + } - it("figure out the route parameter from the name of the param", async () => { - const res = await openApiFor(`op test(@path myParam: string): void;`); - expect(res.paths).toHaveProperty("/{myParam}"); - }); + it("figure out the route parameter from the name of the param", async () => { + const res = await openApiFor(`op test(@path myParam: string): void;`); + expect(res.paths).toHaveProperty("/{myParam}"); + }); - it("uses explicit name provided from @path", async () => { - const res = await openApiFor(`op test(@path("my-custom-path") myParam: string): void;`); - expect(res.paths).toHaveProperty("/{my-custom-path}"); - }); + it("uses explicit name provided from @path", async () => { + const res = await openApiFor(`op test(@path("my-custom-path") myParam: string): void;`); + expect(res.paths).toHaveProperty("/{my-custom-path}"); + }); - it("inline adds an arbitrary extension to a parameter", async () => { - const oapi = await openApiFor( - ` + it("inline adds an arbitrary extension to a parameter", async () => { + const oapi = await openApiFor( + ` op get( @path @extension("x-parameter-extension", "foobaz") petId: string; ): void; `, - ); - strictEqual(oapi.paths["/{petId}"].get.parameters[0]["x-parameter-extension"], "foobaz"); - }); - - describe("set explode: true", () => { - it("with option", async () => { - const param = await getPathParam(`op test(@path(#{explode: true}) myParam: string[]): void;`); - expect(param).toMatchObject({ - explode: true, - schema: { - type: "array", - items: { type: "string" }, - }, + ); + strictEqual(oapi.paths["/{petId}"].get.parameters[0]["x-parameter-extension"], "foobaz"); + }); + + describe("set explode: true", () => { + it("with option", async () => { + const param = await getPathParam( + `op test(@path(#{explode: true}) myParam: string[]): void;`, + ); + expect(param).toMatchObject({ + explode: true, + schema: { + type: "array", + items: { type: "string" }, + }, + }); }); - }); - it("with uri template", async () => { - const param = await getPathParam(`@route("{myParam*}") op test(myParam: string[]): void;`); - expect(param).toMatchObject({ - explode: true, - schema: { - type: "array", - items: { type: "string" }, - }, + it("with uri template", async () => { + const param = await getPathParam(`@route("{myParam*}") op test(myParam: string[]): void;`); + expect(param).toMatchObject({ + explode: true, + schema: { + type: "array", + items: { type: "string" }, + }, + }); }); }); - }); - describe("set style: simple", () => { - it("with option", async () => { - const param = await getPathParam(`op test(@path(#{style: "simple"}) myParam: string): void;`); - expect(param).not.toHaveProperty("style"); - }); + describe("set style: simple", () => { + it("with option", async () => { + const param = await getPathParam( + `op test(@path(#{style: "simple"}) myParam: string): void;`, + ); + expect(param).not.toHaveProperty("style"); + }); - it("with uri template", async () => { - const param = await getPathParam(`@route("{myParam}") op test(myParam: string): void;`); - expect(param).not.toHaveProperty("style"); + it("with uri template", async () => { + const param = await getPathParam(`@route("{myParam}") op test(myParam: string): void;`); + expect(param).not.toHaveProperty("style"); + }); }); - }); - describe("set style: label", () => { - it("with option", async () => { - const param = await getPathParam(`op test(@path(#{style: "label"}) myParam: string): void;`); - expect(param).toMatchObject({ - style: "label", + describe("set style: label", () => { + it("with option", async () => { + const param = await getPathParam( + `op test(@path(#{style: "label"}) myParam: string): void;`, + ); + expect(param).toMatchObject({ + style: "label", + }); }); - }); - it("with uri template", async () => { - const param = await getPathParam(`@route("{.myParam}") op test(myParam: string): void;`); - expect(param).toMatchObject({ - style: "label", + it("with uri template", async () => { + const param = await getPathParam(`@route("{.myParam}") op test(myParam: string): void;`); + expect(param).toMatchObject({ + style: "label", + }); }); }); - }); - describe("set style: matrix", () => { - it("with option", async () => { - const param = await getPathParam(`op test(@path(#{style: "matrix"}) myParam: string): void;`); - expect(param).toMatchObject({ - style: "matrix", + describe("set style: matrix", () => { + it("with option", async () => { + const param = await getPathParam( + `op test(@path(#{style: "matrix"}) myParam: string): void;`, + ); + expect(param).toMatchObject({ + style: "matrix", + }); }); - }); - it("with uri template", async () => { - const param = await getPathParam(`@route("{;myParam}") op test(myParam: string): void;`); - expect(param).toMatchObject({ - style: "matrix", + it("with uri template", async () => { + const param = await getPathParam(`@route("{;myParam}") op test(myParam: string): void;`); + expect(param).toMatchObject({ + style: "matrix", + }); }); }); - }); - describe("emit diagnostic when using style: path", () => { - it("with option", async () => { - const diagnostics = await diagnoseOpenApiFor( - `op test(@path(#{style: "path"}) myParam: string): void;`, - ); - expectDiagnostics(diagnostics, { code: "@typespec/openapi3/invalid-style" }); - }); + describe("emit diagnostic when using style: path", () => { + it("with option", async () => { + const diagnostics = await diagnoseOpenApiFor( + `op test(@path(#{style: "path"}) myParam: string): void;`, + ); + expectDiagnostics(diagnostics, { code: "@typespec/openapi3/invalid-style" }); + }); - it("with uri template", async () => { - const diagnostics = await diagnoseOpenApiFor( - `@route("{/myParam}") op test(myParam: string): void;`, - ); - expectDiagnostics(diagnostics, { code: "@typespec/openapi3/invalid-style" }); + it("with uri template", async () => { + const diagnostics = await diagnoseOpenApiFor( + `@route("{/myParam}") op test(myParam: string): void;`, + ); + expectDiagnostics(diagnostics, { code: "@typespec/openapi3/invalid-style" }); + }); }); - }); - describe("emit diagnostic when using style: fragment", () => { - it("with option", async () => { - const diagnostics = await diagnoseOpenApiFor( - `op test(@path(#{style: "fragment"}) myParam: string): void;`, - ); - expectDiagnostics(diagnostics, { code: "@typespec/openapi3/invalid-style" }); - }); + describe("emit diagnostic when using style: fragment", () => { + it("with option", async () => { + const diagnostics = await diagnoseOpenApiFor( + `op test(@path(#{style: "fragment"}) myParam: string): void;`, + ); + expectDiagnostics(diagnostics, { code: "@typespec/openapi3/invalid-style" }); + }); - it("with uri template", async () => { - const diagnostics = await diagnoseOpenApiFor( - `@route("{#myParam}") op test(myParam: string): void;`, - ); - expectDiagnostics(diagnostics, { code: "@typespec/openapi3/invalid-style" }); + it("with uri template", async () => { + const diagnostics = await diagnoseOpenApiFor( + `@route("{#myParam}") op test(myParam: string): void;`, + ); + expectDiagnostics(diagnostics, { code: "@typespec/openapi3/invalid-style" }); + }); }); - }); - describe("emit diagnostic when using reserved expansion", () => { - it("with option", async () => { - const diagnostics = await diagnoseOpenApiFor( - `op test(@path(#{allowReserved: true}) myParam: string): void;`, - ); - expectDiagnostics(diagnostics, { code: "@typespec/openapi3/path-reserved-expansion" }); - }); + describe("emit diagnostic when using reserved expansion", () => { + it("with option", async () => { + const diagnostics = await diagnoseOpenApiFor( + `op test(@path(#{allowReserved: true}) myParam: string): void;`, + ); + expectDiagnostics(diagnostics, { code: "@typespec/openapi3/path-reserved-expansion" }); + }); - it("with uri template", async () => { - const diagnostics = await diagnoseOpenApiFor( - `@route("{+myParam}") op test(myParam: string): void;`, - ); - expectDiagnostics(diagnostics, { code: "@typespec/openapi3/path-reserved-expansion" }); + it("with uri template", async () => { + const diagnostics = await diagnoseOpenApiFor( + `@route("{+myParam}") op test(myParam: string): void;`, + ); + expectDiagnostics(diagnostics, { code: "@typespec/openapi3/path-reserved-expansion" }); + }); }); }); }); diff --git a/packages/openapi3/test/primitive-types.test.ts b/packages/openapi3/test/primitive-types.test.ts index 634d07f320..c1b509e9bb 100644 --- a/packages/openapi3/test/primitive-types.test.ts +++ b/packages/openapi3/test/primitive-types.test.ts @@ -1,13 +1,12 @@ import { deepStrictEqual, ok, strictEqual } from "assert"; import { describe, it } from "vitest"; import { OpenAPI3Schema } from "../src/types.js"; -import { oapiForModel, openApiFor } from "./test-host.js"; +import { worksFor } from "./works-for.js"; -describe("openapi3: primitives", () => { +worksFor(["3.0.0", "3.1.0"], ({ oapiForModel, openApiFor }) => { describe("handle TypeSpec intrinsic types", () => { const cases = [ ["unknown", {}], - ["null", { nullable: true }], ["numeric", { type: "number" }], ["integer", { type: "integer" }], ["int8", { type: "integer", format: "int8" }], @@ -29,7 +28,6 @@ describe("openapi3: primitives", () => { ["offsetDateTime", { type: "string", format: "date-time" }], ["plainTime", { type: "string", format: "time" }], ["duration", { type: "string", format: "duration" }], - ["bytes", { type: "string", format: "byte" }], ["decimal", { type: "number", format: "decimal" }], ["decimal128", { type: "number", format: "decimal128" }], ]; @@ -308,13 +306,6 @@ describe("openapi3: primitives", () => { testEncode("duration", { type: "integer", format: "int32" }, "seconds", "int32")); }); - describe("bytes", () => { - it("set format to 'base64' by default", () => - testEncode("bytes", { type: "string", format: "byte" })); - it("set format to base64url when encoding bytes as base64url", () => - testEncode("bytes", { type: "string", format: "base64url" }, "base64url")); - }); - describe("int64", () => { it("set type: integer and format to 'int64' by default", () => testEncode("int64", { type: "integer", format: "int64" })); @@ -330,3 +321,79 @@ describe("openapi3: primitives", () => { }); }); }); + +worksFor(["3.0.0"], ({ oapiForModel }) => { + describe("Open API 3.0", () => { + it("handle null type as nullable", async () => { + const res = await oapiForModel( + "Pet", + ` + model Pet { name: null }; + `, + ); + + const schema = res.schemas.Pet.properties.name; + deepStrictEqual(schema, { nullable: true }); + }); + + it("set format to 'base64' by default", async () => { + const res1 = await oapiForModel("s", "scalar s extends bytes;"); + deepStrictEqual(res1.schemas.s, { type: "string", format: "byte" }); + const res2 = await oapiForModel("Test", "model Test { prop: bytes };"); + deepStrictEqual(res2.schemas.Test.properties.prop, { type: "string", format: "byte" }); + }); + + it("set format to 'base64Url' when encoding bytes as base64url", async () => { + const res1 = await oapiForModel("s", `@encode("base64url") scalar s extends bytes;`); + deepStrictEqual(res1.schemas.s, { type: "string", format: "base64url" }); + const res2 = await oapiForModel("Test", `model Test { @encode("base64url") prop: bytes };`); + deepStrictEqual(res2.schemas.Test.properties.prop, { type: "string", format: "base64url" }); + }); + }); +}); + +worksFor(["3.1.0"], ({ oapiForModel }) => { + it("handle null type as null", async () => { + const res = await oapiForModel( + "Pet", + ` + model Pet { name: null }; + `, + ); + + const schema = res.schemas.Pet.properties.name; + deepStrictEqual(schema, { type: "null" }); + }); + + it("set contentEncoding to 'base64' by default", async () => { + const res1 = await oapiForModel("s", "scalar s extends bytes;"); + deepStrictEqual(res1.schemas.s, { type: "string", contentEncoding: "base64" }); + const res2 = await oapiForModel("Test", "model Test { prop: bytes };"); + deepStrictEqual(res2.schemas.Test.properties.prop, { + type: "string", + contentEncoding: "base64", + }); + }); + + it("set contentEncoding to 'base64Url' when encoding bytes as base64url", async () => { + const res1 = await oapiForModel("s", `@encode("base64url") scalar s extends bytes;`); + deepStrictEqual(res1.schemas.s, { type: "string", contentEncoding: "base64url" }); + const res2 = await oapiForModel("Test", `model Test { @encode("base64url") prop: bytes };`); + deepStrictEqual(res2.schemas.Test.properties.prop, { + type: "string", + contentEncoding: "base64url", + }); + }); + + it("set contentEncoding and contentMediaType via decorators on bytes property", async () => { + const res = await oapiForModel( + "Test", + `model Test { @JsonSchema.contentEncoding("base64url") @JsonSchema.contentMediaType("text/plain") prop: bytes };`, + ); + deepStrictEqual(res.schemas.Test.properties.prop, { + type: "string", + contentMediaType: "text/plain", + contentEncoding: "base64url", + }); + }); +}); diff --git a/packages/openapi3/test/record.test.ts b/packages/openapi3/test/record.test.ts index 076fe300d9..04a5529f4d 100644 --- a/packages/openapi3/test/record.test.ts +++ b/packages/openapi3/test/record.test.ts @@ -1,8 +1,8 @@ import { deepStrictEqual, ok } from "assert"; -import { describe, it } from "vitest"; -import { oapiForModel } from "./test-host.js"; +import { it } from "vitest"; +import { worksFor } from "./works-for.js"; -describe("openapi3: Record", () => { +worksFor(["3.0.0", "3.1.0"], ({ oapiForModel }) => { it("defines record inline", async () => { const res = await oapiForModel( "Pet", diff --git a/packages/openapi3/test/response-descriptions.test.ts b/packages/openapi3/test/response-descriptions.test.ts index e744c2e54c..4935047cc6 100644 --- a/packages/openapi3/test/response-descriptions.test.ts +++ b/packages/openapi3/test/response-descriptions.test.ts @@ -1,8 +1,8 @@ import { strictEqual } from "assert"; -import { describe, it } from "vitest"; -import { openApiFor } from "./test-host.js"; +import { it } from "vitest"; +import { worksFor } from "./works-for.js"; -describe("openapi3: response descriptions", () => { +worksFor(["3.0.0", "3.1.0"], ({ openApiFor }) => { it("use a default message by status code if not specified", async () => { const res = await openApiFor( ` diff --git a/packages/openapi3/test/return-types.test.ts b/packages/openapi3/test/return-types.test.ts index 0c7e29cadb..06870a0049 100644 --- a/packages/openapi3/test/return-types.test.ts +++ b/packages/openapi3/test/return-types.test.ts @@ -1,9 +1,9 @@ import { expectDiagnosticEmpty, expectDiagnostics } from "@typespec/compiler/testing"; import { deepStrictEqual, ok, strictEqual } from "assert"; import { describe, expect, it } from "vitest"; -import { checkFor, openApiFor } from "./test-host.js"; +import { worksFor } from "./works-for.js"; -describe("openapi3: return types", () => { +worksFor(["3.0.0", "3.1.0"], ({ checkFor, openApiFor }) => { it("model used with @body and without shouldn't conflict if it contains no metadata", async () => { const res = await openApiFor( ` @@ -577,56 +577,6 @@ describe("openapi3: return types", () => { }); }); - describe("binary responses", () => { - it("bytes responses should default to application/json with byte format", async () => { - const res = await openApiFor(` - @get op read(): bytes; - `); - - const response = res.paths["/"].get.responses["200"]; - ok(response); - ok(response.content); - strictEqual(response.content["application/json"].schema.type, "string"); - strictEqual(response.content["application/json"].schema.format, "byte"); - }); - - it("@body body: bytes responses default to application/json with bytes format", async () => { - const res = await openApiFor(` - @get op read(): {@body body: bytes}; - `); - - const response = res.paths["/"].get.responses["200"]; - ok(response); - ok(response.content); - strictEqual(response.content["application/json"].schema.type, "string"); - strictEqual(response.content["application/json"].schema.format, "byte"); - }); - - it("@header contentType text/plain should keep format to byte", async () => { - const res = await openApiFor(` - @get op read(): {@header contentType: "text/plain", @body body: bytes}; - `); - - const response = res.paths["/"].get.responses["200"]; - ok(response); - ok(response.content); - strictEqual(response.content["text/plain"].schema.type, "string"); - strictEqual(response.content["text/plain"].schema.format, "byte"); - }); - - it("@header contentType not json or text should set format to binary", async () => { - const res = await openApiFor(` - @get op read(): {@header contentType: "image/png", @body body: bytes}; - `); - - const response = res.paths["/"].get.responses["200"]; - ok(response); - ok(response.content); - strictEqual(response.content["image/png"].schema.type, "string"); - strictEqual(response.content["image/png"].schema.format, "binary"); - }); - }); - describe("multiple responses", () => { it("handles multiple response types for the same status code", async () => { const res = await openApiFor(` @@ -735,3 +685,112 @@ describe("openapi3: return types", () => { }); }); }); + +worksFor(["3.0.0"], ({ openApiFor }) => { + describe("open api 3.0.0 binary responses", () => { + it("bytes responses should default to application/json with byte format", async () => { + const res = await openApiFor(` + @get op read(): bytes; + `); + + const response = res.paths["/"].get.responses["200"]; + ok(response); + ok(response.content); + strictEqual(response.content["application/json"].schema.type, "string"); + strictEqual(response.content["application/json"].schema.format, "byte"); + }); + + it("@body body: bytes responses default to application/json with bytes format", async () => { + const res = await openApiFor(` + @get op read(): {@body body: bytes}; + `); + + const response = res.paths["/"].get.responses["200"]; + ok(response); + ok(response.content); + strictEqual(response.content["application/json"].schema.type, "string"); + strictEqual(response.content["application/json"].schema.format, "byte"); + }); + + it("@header contentType text/plain should keep format to byte", async () => { + const res = await openApiFor(` + @get op read(): {@header contentType: "text/plain", @body body: bytes}; + `); + + const response = res.paths["/"].get.responses["200"]; + ok(response); + ok(response.content); + strictEqual(response.content["text/plain"].schema.type, "string"); + strictEqual(response.content["text/plain"].schema.format, "byte"); + }); + + it("@header contentType not json or text should set format to binary", async () => { + const res = await openApiFor(` + @get op read(): {@header contentType: "image/png", @body body: bytes}; + `); + + const response = res.paths["/"].get.responses["200"]; + ok(response); + ok(response.content); + strictEqual(response.content["image/png"].schema.type, "string"); + strictEqual(response.content["image/png"].schema.format, "binary"); + }); + }); +}); + +worksFor(["3.1.0"], ({ openApiFor }) => { + describe("open api 3.1.0 binary responses", () => { + it("bytes responses should default to application/json with base64 contentEncoding", async () => { + const res = await openApiFor(` + @get op read(): bytes; + `); + + const response = res.paths["/"].get.responses["200"]; + ok(response); + ok(response.content); + deepStrictEqual(response.content["application/json"].schema, { + type: "string", + contentEncoding: "base64", + }); + }); + + it("@body body: bytes responses default to application/json with base64 contentEncoding", async () => { + const res = await openApiFor(` + @get op read(): {@body body: bytes}; + `); + + const response = res.paths["/"].get.responses["200"]; + ok(response); + ok(response.content); + deepStrictEqual(response.content["application/json"].schema, { + type: "string", + contentEncoding: "base64", + }); + }); + + it("@header contentType text/plain should set contentEncoding to base64", async () => { + const res = await openApiFor(` + @get op read(): {@header contentType: "text/plain", @body body: bytes}; + `); + + const response = res.paths["/"].get.responses["200"]; + ok(response); + ok(response.content); + deepStrictEqual(response.content["text/plain"].schema, { + type: "string", + contentEncoding: "base64", + }); + }); + + it("@header contentType not json or text should set contentMediaType", async () => { + const res = await openApiFor(` + @get op read(): {@header contentType: "image/png", @body body: bytes}; + `); + + const response = res.paths["/"].get.responses["200"]; + ok(response); + ok(response.content); + deepStrictEqual(response.content["image/png"].schema, { contentMediaType: "image/png" }); + }); + }); +}); diff --git a/packages/openapi3/test/scalar-constraints.test.ts b/packages/openapi3/test/scalar-constraints.test.ts index 12ca28cf68..dd5654ee83 100644 --- a/packages/openapi3/test/scalar-constraints.test.ts +++ b/packages/openapi3/test/scalar-constraints.test.ts @@ -1,25 +1,26 @@ -import { strictEqual } from "assert"; +/* eslint-disable vitest/no-identical-title */ +import { deepStrictEqual, strictEqual } from "assert"; import { describe, it } from "vitest"; -import { oapiForModel } from "./test-host.js"; - -describe("scalar constraints", () => { - describe("numeric constraints", () => { - const scalarNumberTypes = [ - "int8", - "int16", - "int32", - "uint8", - "uint16", - "uint32", - "integer", - "float32", - "float64", - "numeric", - "float", - "safeint", - ]; - - describe("@minValue/@maxValue", () => { +import { worksFor } from "./works-for.js"; + +describe("numeric constraints", () => { + const scalarNumberTypes = [ + "int8", + "int16", + "int32", + "uint8", + "uint16", + "uint32", + "integer", + "float32", + "float64", + "numeric", + "float", + "safeint", + ]; + + worksFor(["3.0.0", "3.1.0"], ({ oapiForModel }) => { + describe("@minValue/@maxValue/@multipleOf", () => { for (const numType of scalarNumberTypes) { it(numType, async () => { const schemas = await oapiForModel( @@ -27,12 +28,14 @@ describe("scalar constraints", () => { ` @minValue(1) @maxValue(2) + @JsonSchema.multipleOf(10) scalar Test extends ${numType}; `, ); strictEqual(schemas.schemas.Test.minimum, 1); strictEqual(schemas.schemas.Test.maximum, 2); + strictEqual(schemas.schemas.Test.multipleOf, 10); }); } @@ -42,16 +45,20 @@ describe("scalar constraints", () => { ` @minValue(1) @maxValue(2) + @JsonSchema.multipleOf(10) union Test {int32, string, null}; `, ); strictEqual(schemas.schemas.Test.minimum, 1); strictEqual(schemas.schemas.Test.maximum, 2); + strictEqual(schemas.schemas.Test.multipleOf, 10); }); }); + }); - describe("@minValueExclusive/@maxValueExclusive", () => { + worksFor(["3.0.0"], ({ oapiForModel }) => { + describe("@minValueExclusive/@maxValueExclusive (boolean)", () => { for (const numType of scalarNumberTypes) { it(numType, async () => { const schemas = await oapiForModel( @@ -88,27 +95,67 @@ describe("scalar constraints", () => { }); }); - describe("string constraints", () => { - function assertStringConstraints(schema: any) { - strictEqual(schema.minLength, 1); - strictEqual(schema.maxLength, 2); - strictEqual(schema.pattern, "a|b"); - strictEqual(schema.format, "ipv4"); - } + worksFor(["3.1.0"], ({ oapiForModel }) => { + describe("@minValueExclusive/@maxValueExclusive (value)", () => { + for (const numType of scalarNumberTypes) { + it(numType, async () => { + const schemas = await oapiForModel( + "Test", + ` + @minValueExclusive(1) + @maxValueExclusive(2) + scalar Test extends ${numType}; + `, + ); - const decorators = ` - @minLength(1) - @maxLength(2) - @pattern("a|b") - @format("ipv4")`; + strictEqual(schemas.schemas.Test.minimum, undefined); + strictEqual(schemas.schemas.Test.exclusiveMinimum, 1); + strictEqual(schemas.schemas.Test.maximum, undefined); + strictEqual(schemas.schemas.Test.exclusiveMaximum, 2); + }); + it("can be applied on a union", async () => { + const schemas = await oapiForModel( + "Test", + ` + @minValueExclusive(1) + @maxValueExclusive(2) + union Test {int32, string, null}; + `, + ); + + strictEqual(schemas.schemas.Test.minimum, undefined); + strictEqual(schemas.schemas.Test.exclusiveMinimum, 1); + strictEqual(schemas.schemas.Test.maximum, undefined); + strictEqual(schemas.schemas.Test.exclusiveMaximum, 2); + }); + } + }); + }); +}); + +describe("string constraints", () => { + function assertStringConstraints(schema: any) { + strictEqual(schema.minLength, 1); + strictEqual(schema.maxLength, 2); + strictEqual(schema.pattern, "a|b"); + strictEqual(schema.format, "ipv4"); + } + + const decorators = ` + @minLength(1) + @maxLength(2) + @pattern("a|b") + @format("ipv4")`; + + worksFor(["3.0.0", "3.1.0"], ({ oapiForModel }) => { it("on scalar declaration", async () => { const schemas = await oapiForModel( "Test", ` - ${decorators} - scalar Test extends string; - `, + ${decorators} + scalar Test extends string; + `, ); assertStringConstraints(schemas.schemas.Test); @@ -117,12 +164,52 @@ describe("scalar constraints", () => { const schemas = await oapiForModel( "Test", ` - ${decorators} - union Test {string, int32, null}; - `, + ${decorators} + union Test {string, int32, null}; + `, ); assertStringConstraints(schemas.schemas.Test); }); }); + + worksFor(["3.1.0"], ({ oapiForModel }) => { + const jsonSchemaDecorators = ` + @JsonSchema.contentEncoding("base64url") + @JsonSchema.contentMediaType("application/jwt") + @JsonSchema.contentSchema(JwtToken) + `; + + function assertJsonSchemaStringConstraints(schema: any) { + strictEqual(schema.contentEncoding, "base64url"); + strictEqual(schema.contentMediaType, "application/jwt"); + deepStrictEqual(schema.contentSchema, { $ref: "#/components/schemas/JwtToken" }); + } + + it("on scalar declaration", async () => { + const schemas = await oapiForModel( + "Test", + ` + ${jsonSchemaDecorators} + scalar Test extends string; + model JwtToken is Array>; + `, + ); + + assertJsonSchemaStringConstraints(schemas.schemas.Test); + }); + + it("on union declaration", async () => { + const schemas = await oapiForModel( + "Test", + ` + ${jsonSchemaDecorators} + union Test {string, int32, null}; + model JwtToken is Array>; + `, + ); + + assertJsonSchemaStringConstraints(schemas.schemas.Test); + }); + }); }); diff --git a/packages/openapi3/test/security.test.ts b/packages/openapi3/test/security.test.ts index 67f6667940..b70b3bcccc 100644 --- a/packages/openapi3/test/security.test.ts +++ b/packages/openapi3/test/security.test.ts @@ -1,9 +1,9 @@ import { expectDiagnostics } from "@typespec/compiler/testing"; import { deepStrictEqual } from "assert"; -import { describe, expect, it } from "vitest"; -import { diagnoseOpenApiFor, openApiFor } from "./test-host.js"; +import { expect, it } from "vitest"; +import { worksFor } from "./works-for.js"; -describe("openapi3: security", () => { +worksFor(["3.0.0", "3.1.0"], ({ diagnoseOpenApiFor, openApiFor }) => { it("set a basic auth", async () => { const res = await openApiFor( ` diff --git a/packages/openapi3/test/servers.test.ts b/packages/openapi3/test/servers.test.ts index 7807b609b3..cdab3fde4f 100644 --- a/packages/openapi3/test/servers.test.ts +++ b/packages/openapi3/test/servers.test.ts @@ -1,9 +1,9 @@ import { expectDiagnostics } from "@typespec/compiler/testing"; import { deepStrictEqual } from "assert"; -import { describe, it } from "vitest"; -import { diagnoseOpenApiFor, openApiFor } from "./test-host.js"; +import { it } from "vitest"; +import { worksFor } from "./works-for.js"; -describe("openapi3: servers", () => { +worksFor(["3.0.0", "3.1.0"], ({ diagnoseOpenApiFor, openApiFor }) => { it("set a basic server(url)", async () => { const res = await openApiFor( ` diff --git a/packages/openapi3/test/shared-routes.test.ts b/packages/openapi3/test/shared-routes.test.ts index 4a8950a45f..d73c5b4c42 100644 --- a/packages/openapi3/test/shared-routes.test.ts +++ b/packages/openapi3/test/shared-routes.test.ts @@ -1,9 +1,9 @@ import { expectDiagnostics } from "@typespec/compiler/testing"; import { deepStrictEqual } from "assert"; -import { describe, it } from "vitest"; -import { diagnoseOpenApiFor, openApiFor } from "./test-host.js"; +import { it } from "vitest"; +import { worksFor } from "./works-for.js"; -describe("openapi3: shared routes", () => { +worksFor(["3.0.0", "3.1.0"], ({ diagnoseOpenApiFor, openApiFor }) => { it("emits warning for routes containing query parameters", async () => { const diagnostics = await diagnoseOpenApiFor( ` diff --git a/packages/openapi3/test/status-codes.test.ts b/packages/openapi3/test/status-codes.test.ts index 491ced884a..c5abe8abb4 100644 --- a/packages/openapi3/test/status-codes.test.ts +++ b/packages/openapi3/test/status-codes.test.ts @@ -1,9 +1,9 @@ import { expectDiagnostics } from "@typespec/compiler/testing"; import { deepStrictEqual } from "assert"; -import { describe, it } from "vitest"; -import { diagnoseOpenApiFor, openApiFor } from "./test-host.js"; +import { it } from "vitest"; +import { worksFor } from "./works-for.js"; -describe("openapi3: response status codes", () => { +worksFor(["3.0.0", "3.1.0"], ({ diagnoseOpenApiFor, openApiFor }) => { async function expectStatusCodes(code: string, statusCodes: string[]) { const res = await openApiFor(code); deepStrictEqual(Object.keys(res.paths["/"].get.responses), statusCodes); diff --git a/packages/openapi3/test/string-template.test.ts b/packages/openapi3/test/string-template.test.ts index 0412a6112e..e89d72cad8 100644 --- a/packages/openapi3/test/string-template.test.ts +++ b/packages/openapi3/test/string-template.test.ts @@ -1,9 +1,9 @@ import { expectDiagnostics } from "@typespec/compiler/testing"; import { deepStrictEqual } from "assert"; import { describe, it } from "vitest"; -import { emitOpenApiWithDiagnostics, openApiFor } from "./test-host.js"; +import { worksFor } from "./works-for.js"; -describe("openapi3: string templates", () => { +worksFor(["3.0.0", "3.1.0"], ({ emitOpenApiWithDiagnostics, openApiFor }) => { describe("handle interpolating literals", () => { it("string", async () => { const schemas = await openApiFor(` diff --git a/packages/openapi3/test/tagmetadata.test.ts b/packages/openapi3/test/tagmetadata.test.ts index d5380a23ac..8b7e4ea1c0 100644 --- a/packages/openapi3/test/tagmetadata.test.ts +++ b/packages/openapi3/test/tagmetadata.test.ts @@ -1,9 +1,8 @@ import { deepStrictEqual } from "assert"; -import { describe, it } from "vitest"; +import { it } from "vitest"; +import { worksFor } from "./works-for.js"; -import { openApiFor } from "./test-host.js"; - -describe("emit results when set value with @tagMetadata decorator", () => { +worksFor(["3.0.0", "3.1.0"], ({ openApiFor }) => { const testCases: [string, string, string, any][] = [ [ "set tag metadata", diff --git a/packages/openapi3/test/test-host.ts b/packages/openapi3/test/test-host.ts index 2aa902decb..84b9655b89 100644 --- a/packages/openapi3/test/test-host.ts +++ b/packages/openapi3/test/test-host.ts @@ -1,4 +1,4 @@ -import { Diagnostic, interpolatePath } from "@typespec/compiler"; +import { Diagnostic, interpolatePath, resolvePath } from "@typespec/compiler"; import { createTestHost, createTestWrapper, @@ -6,6 +6,7 @@ import { resolveVirtualPath, } from "@typespec/compiler/testing"; import { HttpTestLibrary } from "@typespec/http/testing"; +import { JsonSchemaTestLibrary } from "@typespec/json-schema/testing"; import { OpenAPITestLibrary } from "@typespec/openapi/testing"; import { RestTestLibrary } from "@typespec/rest/testing"; import { VersioningTestLibrary } from "@typespec/versioning/testing"; @@ -20,6 +21,7 @@ export async function createOpenAPITestHost() { return createTestHost({ libraries: [ HttpTestLibrary, + JsonSchemaTestLibrary, RestTestLibrary, VersioningTestLibrary, XmlTestLibrary, @@ -30,12 +32,14 @@ export async function createOpenAPITestHost() { } export async function createOpenAPITestRunner({ + emitterOptions, withVersioning, -}: { withVersioning?: boolean } = {}) { +}: { withVersioning?: boolean; emitterOptions?: OpenAPI3EmitterOptions } = {}) { const host = await createOpenAPITestHost(); const importAndUsings = ` import "@typespec/http"; import "@typespec/rest"; + import "@typespec/json-schema"; import "@typespec/openapi"; import "@typespec/openapi3"; import "@typespec/xml"; @@ -50,6 +54,9 @@ export async function createOpenAPITestRunner({ wrapper: (code) => `${importAndUsings} ${code}`, compilerOptions: { emit: ["@typespec/openapi3"], + options: { + "@typespec/openapi3": { ...emitterOptions }, + }, }, }); } @@ -92,7 +99,7 @@ export async function openApiFor( const outPath = resolveVirtualPath("{version}.openapi.json"); host.addTypeSpecFile( "./main.tsp", - `import "@typespec/http"; import "@typespec/rest"; import "@typespec/openapi"; import "@typespec/openapi3";import "@typespec/xml"; ${ + `import "@typespec/http"; import "@typespec/json-schema"; import "@typespec/rest"; import "@typespec/openapi"; import "@typespec/openapi3";import "@typespec/xml"; ${ versions ? `import "@typespec/versioning"; using TypeSpec.Versioning;` : "" }using TypeSpec.Rest;using TypeSpec.Http;using TypeSpec.OpenAPI;using TypeSpec.Xml;${code}`, ); @@ -114,20 +121,32 @@ export async function openApiFor( } } -export async function checkFor(code: string) { +export async function checkFor(code: string, options: OpenAPI3EmitterOptions = {}) { const host = await createOpenAPITestRunner(); - return await host.diagnose(code); + return await host.diagnose(code, { + noEmit: true, + emit: ["@typespec/openapi3"], + options: { "@typespec/openapi3": { ...options } }, + }); } -export async function oapiForModel(name: string, modelDef: string) { - const oapi = await openApiFor(` +export async function oapiForModel( + name: string, + modelDef: string, + options: OpenAPI3EmitterOptions = {}, +) { + const oapi = await openApiFor( + ` ${modelDef}; @service({title: "Testing model"}) @route("/") namespace root { op read(): { @body body: ${name} }; } - `); + `, + undefined, + options, + ); const useSchema = oapi.paths["/"].get.responses[200].content["application/json"].schema; @@ -137,3 +156,23 @@ export async function oapiForModel(name: string, modelDef: string) { schemas: oapi.components.schemas || {}, }; } + +export async function openapiWithOptions( + code: string, + options: OpenAPI3EmitterOptions, +): Promise { + const runner = await createOpenAPITestRunner(); + + const outPath = resolvePath("/openapi.json"); + + const diagnostics = await runner.diagnose(code, { + noEmit: false, + emit: ["@typespec/openapi3"], + options: { "@typespec/openapi3": { ...options, "output-file": outPath } }, + }); + + expectDiagnosticEmpty(diagnostics); + + const content = runner.fs.get(outPath)!; + return JSON.parse(content); +} diff --git a/packages/openapi3/test/union-schema.test.ts b/packages/openapi3/test/union-schema.test.ts index 7af9f0136d..c8aad08112 100644 --- a/packages/openapi3/test/union-schema.test.ts +++ b/packages/openapi3/test/union-schema.test.ts @@ -1,9 +1,9 @@ import { expectDiagnostics } from "@typespec/compiler/testing"; import { deepStrictEqual, ok, strictEqual } from "assert"; import { describe, expect, it } from "vitest"; -import { diagnoseOpenApiFor, oapiForModel, openApiFor } from "./test-host.js"; +import { worksFor } from "./works-for.js"; -describe("openapi3: union type", () => { +worksFor(["3.0.0", "3.1.0"], ({ diagnoseOpenApiFor, oapiForModel, openApiFor }) => { it("handles discriminated unions", async () => { const res = await openApiFor( ` @@ -160,51 +160,6 @@ describe("openapi3: union type", () => { }); }); - it("defines nullable properties with multiple variants", async () => { - const res = await oapiForModel( - "Pet", - ` - model Pet { - name: int32 | string | null; - }; - `, - ); - ok(res.isRef); - ok(res.schemas.Pet.properties.name.nullable); - deepStrictEqual(res.schemas.Pet.properties.name.anyOf, [ - { - type: "integer", - format: "int32", - }, - { - type: "string", - }, - ]); - }); - - it("defines enums with a nullable variant", async () => { - const res = await oapiForModel( - "Pet", - ` - model Pet { - type: "cat" | "dog" | null; - }; - `, - ); - ok(res.isRef); - deepStrictEqual(res.schemas.Pet, { - type: "object", - properties: { - type: { - type: "string", - enum: ["cat", "dog"], - nullable: true, - }, - }, - required: ["type"], - }); - }); - it("handles unions of heterogenous types", async () => { const res = await oapiForModel( "X", @@ -463,15 +418,6 @@ describe("openapi3: union type", () => { }); }); - it("throws diagnostics for null enum definitions", async () => { - const diagnostics = await diagnoseOpenApiFor(`union Pet {null}`); - - expectDiagnostics(diagnostics, { - code: "@typespec/openapi3/union-null", - message: "Cannot have a union containing only null types.", - }); - }); - it("supports description on unions that reduce to enums", async () => { const res = await oapiForModel( "Foo", @@ -527,70 +473,234 @@ describe("openapi3: union type", () => { strictEqual(variant.description, undefined); } }); +}); + +worksFor(["3.0.0"], ({ diagnoseOpenApiFor, oapiForModel, openApiFor }) => { + describe("openapi 3.0.0 union with null", () => { + it("defines nullable properties with multiple variants", async () => { + const res = await oapiForModel( + "Pet", + ` + model Pet { + name: int32 | string | null; + }; + `, + ); + ok(res.isRef); + ok(res.schemas.Pet.properties.name.nullable); + deepStrictEqual(res.schemas.Pet.properties.name.anyOf, [ + { + type: "integer", + format: "int32", + }, + { + type: "string", + }, + ]); + }); - it("type property should always be set when nullable property is present", async () => { - const openApi = await openApiFor(` + it("defines enums with a nullable variant", async () => { + const res = await oapiForModel( + "Pet", + ` + model Pet { + type: "cat" | "dog" | null; + }; + `, + ); + ok(res.isRef); + deepStrictEqual(res.schemas.Pet, { + type: "object", + properties: { + type: { + type: "string", + enum: ["cat", "dog"], + nullable: true, + }, + }, + required: ["type"], + }); + }); + + it("type property should always be set when nullable property is present", async () => { + const openApi = await openApiFor(` scalar MyStr extends string; model Foo {}; model A { x: MyStr |Foo| null; } `); - deepStrictEqual(openApi.components.schemas.A.properties, { - x: { - anyOf: [ - { - type: "object", - allOf: [{ $ref: "#/components/schemas/MyStr" }], - nullable: true, - }, - { - type: "object", - allOf: [{ $ref: "#/components/schemas/Foo" }], - nullable: true, - }, - ], - }, + deepStrictEqual(openApi.components.schemas.A.properties, { + x: { + anyOf: [ + { + type: "object", + allOf: [{ $ref: "#/components/schemas/MyStr" }], + nullable: true, + }, + { + type: "object", + allOf: [{ $ref: "#/components/schemas/Foo" }], + nullable: true, + }, + ], + }, + }); + }); + + it("scalar type property should always be set when nullable property is present", async () => { + const openApi = await openApiFor(` + model Foo {}; + model A { + x: Foo |string| null; + } + `); + deepStrictEqual(openApi.components.schemas.A.properties, { + x: { + anyOf: [ + { + type: "object", + allOf: [{ $ref: "#/components/schemas/Foo" }], + nullable: true, + }, + { + type: "string", + nullable: true, + }, + ], + }, + }); + }); + + describe("null and another single variant produce allOf", () => { + it.each([ + ["model", "model Other {}"], + ["enum", "enum Other {a, b}"], + ])("%s variant", async (_, code) => { + const openApi = await openApiFor(` + union Test { Other, null } + ${code} + `); + + expect(openApi.components.schemas.Test).toMatchObject({ + allOf: [{ $ref: "#/components/schemas/Other" }], + nullable: true, + }); + }); + }); + + it("throws diagnostics for null enum definitions", async () => { + const diagnostics = await diagnoseOpenApiFor(`union Pet {null}`); + + expectDiagnostics(diagnostics, { + code: "@typespec/openapi3/union-null", + message: "Cannot have a union containing only null types.", + }); }); }); +}); - it("scalar type property should always be set when nullable property is present", async () => { - const openApi = await openApiFor(` - model Foo {}; - model A { - x: Foo |string| null; - } - `); - deepStrictEqual(openApi.components.schemas.A.properties, { - x: { - anyOf: [ - { - type: "object", - allOf: [{ $ref: "#/components/schemas/Foo" }], - nullable: true, - }, - { - type: "string", - nullable: true, +worksFor(["3.1.0"], ({ oapiForModel, openApiFor }) => { + describe("openapi 3.1.0 union with null", () => { + it("defines nullable properties with multiple variants", async () => { + const res = await oapiForModel( + "Pet", + ` + model Pet { + name: int32 | string | null; + }; + `, + ); + ok(res.isRef); + deepStrictEqual(res.schemas.Pet.properties.name.anyOf, [ + { + type: "integer", + format: "int32", + }, + { + type: "string", + }, + { + type: "null", + }, + ]); + }); + + it("defines enums with a nullable variant", async () => { + const res = await oapiForModel( + "Pet", + ` + model Pet { + type: "cat" | "dog" | null; + }; + `, + ); + ok(res.isRef); + deepStrictEqual(res.schemas.Pet, { + type: "object", + properties: { + type: { + anyOf: [ + { + type: "string", + enum: ["cat", "dog"], + }, + { + type: "null", + }, + ], }, - ], - }, + }, + required: ["type"], + }); }); - }); - describe("null and another single variant produce allOf", () => { - it.each([ - ["model", "model Other {}"], - ["enum", "enum Other {a, b}"], - ])("%s variant", async (_, code) => { + it("supports refs and nullable property present", async () => { const openApi = await openApiFor(` + scalar MyStr extends string; + model Foo {}; + model A { + x: MyStr | Foo | null; + } + `); + deepStrictEqual(openApi.components.schemas.A.properties, { + x: { + anyOf: [ + { + $ref: "#/components/schemas/MyStr", + }, + { + $ref: "#/components/schemas/Foo", + }, + { + type: "null", + }, + ], + }, + }); + }); + + describe("null and another single variant produce anyOf", () => { + it.each([ + ["model", "model Other {}"], + ["enum", "enum Other {a, b}"], + ])("%s variant", async (_, code) => { + const openApi = await openApiFor(` union Test { Other, null } ${code} `); - expect(openApi.components.schemas.Test).toMatchObject({ - allOf: [{ $ref: "#/components/schemas/Other" }], - nullable: true, + expect(openApi.components.schemas.Test).toMatchObject({ + anyOf: [{ $ref: "#/components/schemas/Other" }, { type: "null" }], + }); + }); + }); + + it("supports null enum definitions", async () => { + const openApi = await openApiFor(`union Pet {null}`); + + deepStrictEqual(openApi.components.schemas.Pet, { + type: "null", }); }); }); diff --git a/packages/openapi3/test/versioning.test.ts b/packages/openapi3/test/versioning.test.ts index 400a4cf8f3..10b59a3ff0 100644 --- a/packages/openapi3/test/versioning.test.ts +++ b/packages/openapi3/test/versioning.test.ts @@ -1,10 +1,11 @@ -import { DecoratorContext, Namespace, getNamespaceFullName } from "@typespec/compiler"; +import { DecoratorContext, getNamespaceFullName, Namespace } from "@typespec/compiler"; import { createTestWrapper, expectDiagnostics } from "@typespec/compiler/testing"; import { deepStrictEqual, strictEqual } from "assert"; import { describe, it } from "vitest"; -import { createOpenAPITestHost, createOpenAPITestRunner, openApiFor } from "./test-host.js"; +import { createOpenAPITestHost, createOpenAPITestRunner } from "./test-host.js"; +import { worksFor } from "./works-for.js"; -describe("openapi3: versioning", () => { +worksFor(["3.0.0", "3.1.0"], ({ openApiFor, version: specVersion }) => { it("works with models", async () => { const { v1, v2, v3 } = await openApiFor( ` @@ -120,7 +121,10 @@ describe("openapi3: versioning", () => { const runner = createTestWrapper(host, { autoImports: [...host.libraries.map((x) => x.name), "./test.js"], autoUsings: ["TypeSpec.Rest", "TypeSpec.Http", "TypeSpec.OpenAPI", "TypeSpec.Versioning"], - compilerOptions: { emit: ["@typespec/openapi3"] }, + compilerOptions: { + emit: ["@typespec/openapi3"], + options: { "@typespec/openapi3": { "openapi-versions": [specVersion] } }, + }, }); await runner.compile(` @@ -152,7 +156,10 @@ describe("openapi3: versioning", () => { it("doesn't throw errors when using UpdateableProperties", async () => { // if this test throws a duplicate name diagnostic, check that getEffectiveType // is returning the projected type. - const runner = await createOpenAPITestRunner({ withVersioning: true }); + const runner = await createOpenAPITestRunner({ + withVersioning: true, + emitterOptions: { "openapi-versions": [specVersion] }, + }); await runner.compile(` @versioned(Library.Versions) namespace Library { @@ -179,7 +186,10 @@ describe("openapi3: versioning", () => { describe("versioned resource", () => { it("reports diagnostic without crashing for mismatched versions", async () => { - const runner = await createOpenAPITestRunner({ withVersioning: true }); + const runner = await createOpenAPITestRunner({ + withVersioning: true, + emitterOptions: { "openapi-versions": [specVersion] }, + }); const diagnostics = await runner.diagnose(` @versioned(Versions) @service @@ -216,7 +226,10 @@ describe("openapi3: versioning", () => { }); it("succeeds for aligned versions", async () => { - const runner = await createOpenAPITestRunner({ withVersioning: true }); + const runner = await createOpenAPITestRunner({ + withVersioning: true, + emitterOptions: { "openapi-versions": [specVersion] }, + }); await runner.compile(` @versioned(Versions) @service diff --git a/packages/openapi3/test/works-for.ts b/packages/openapi3/test/works-for.ts new file mode 100644 index 0000000000..3bcd0d71ea --- /dev/null +++ b/packages/openapi3/test/works-for.ts @@ -0,0 +1,53 @@ +import { describe } from "vitest"; +import { OpenAPIVersion } from "../src/lib.js"; +import { + checkFor, + diagnoseOpenApiFor, + emitOpenApiWithDiagnostics, + oapiForModel, + openApiFor, + openapiWithOptions, +} from "./test-host.js"; + +export const OpenAPISpecHelpers: Record = { + "3.0.0": createSpecHelpers("3.0.0"), + "3.1.0": createSpecHelpers("3.1.0"), +}; + +export type SpecHelper = { + version: OpenAPIVersion; + oapiForModel: typeof oapiForModel; + openApiFor: typeof openApiFor; + openapiWithOptions: typeof openapiWithOptions; + checkFor: typeof checkFor; + diagnoseOpenApiFor: typeof diagnoseOpenApiFor; + emitOpenApiWithDiagnostics: typeof emitOpenApiWithDiagnostics; +}; + +export type WorksForCb = (specHelpers: SpecHelper) => void; + +function createSpecHelpers(version: OpenAPIVersion): SpecHelper { + return { + version, + oapiForModel: (...[name, modelDef, options]: Parameters) => + oapiForModel(name, modelDef, { ...options, "openapi-versions": [version] }), + openApiFor: (...[code, versions, options]: Parameters) => + openApiFor(code, versions, { ...options, "openapi-versions": [version] }), + openapiWithOptions: (...[code, options]: Parameters) => + openapiWithOptions(code, { ...options, "openapi-versions": [version] }), + checkFor: (...[code, options]: Parameters) => + checkFor(code, { ...options, "openapi-versions": [version] }), + diagnoseOpenApiFor: (...[code, options]: Parameters) => + diagnoseOpenApiFor(code, { ...options, "openapi-versions": [version] }), + emitOpenApiWithDiagnostics: ( + ...[code, options]: Parameters + ) => emitOpenApiWithDiagnostics(code, { ...options, "openapi-versions": [version] }), + }; +} + +export function worksFor(versions: OpenAPIVersion[], cb: WorksForCb) { + const specsHelpers = versions.map((version) => OpenAPISpecHelpers[version]); + describe.each(specsHelpers)("openapi $version", (specHelpers) => { + cb(specHelpers); + }); +} diff --git a/packages/openapi3/test/xml-models.test.ts b/packages/openapi3/test/xml-models.test.ts index a6962a182a..3b2bbd0f6b 100644 --- a/packages/openapi3/test/xml-models.test.ts +++ b/packages/openapi3/test/xml-models.test.ts @@ -1,217 +1,199 @@ import { expectDiagnostics } from "@typespec/compiler/testing"; import { deepStrictEqual } from "assert"; import { describe, expect, it } from "vitest"; -import { createOpenAPITestRunner, emitOpenApiWithDiagnostics, oapiForModel } from "./test-host.js"; +import { createOpenAPITestRunner } from "./test-host.js"; +import { worksFor } from "./works-for.js"; -describe("@name", () => { - it("set xml.name for schema", async () => { - const res = await oapiForModel( - "Book", - ` +worksFor(["3.0.0", "3.1.0"], ({ emitOpenApiWithDiagnostics, oapiForModel }) => { + describe("@name", () => { + it("set xml.name for schema", async () => { + const res = await oapiForModel( + "Book", + ` @name("xmlBook") model Book { content: string; };`, - ); + ); - expect(res.schemas.Book).toMatchInlineSnapshot( - ` - { - "properties": { - "content": { - "type": "string", + deepStrictEqual(res.schemas.Book, { + properties: { + content: { + type: "string", }, }, - "required": [ - "content", - ], - "type": "object", - "xml": { - "name": "xmlBook", + required: ["content"], + type: "object", + xml: { + name: "xmlBook", }, - } - `, - ); - }); + }); + }); - it("set the element value for array property via @name", async () => { - const res = await oapiForModel( - "Book", - ` + it("set the element value for array property via @name", async () => { + const res = await oapiForModel( + "Book", + ` @name("xmlBook") model Book { tags: string[]; };`, - ); + ); - expect(res.schemas.Book).toMatchInlineSnapshot(` - { - "properties": { - "tags": { - "items": { - "type": "string", - "xml": { - "name": "string", + deepStrictEqual(res.schemas.Book, { + properties: { + tags: { + items: { + type: "string", + xml: { + name: "string", }, }, - "type": "array", - "xml": { - "wrapped": true, + type: "array", + xml: { + wrapped: true, }, }, }, - "required": [ - "tags", - ], - "type": "object", - "xml": { - "name": "xmlBook", + required: ["tags"], + type: "object", + xml: { + name: "xmlBook", }, - } - `); - }); + }); + }); - it.each([ - ["string", "string", "string"], - ["array", "string[]", "array"], - ["number", "numeric", "number"], - ["enum", `"a" | "b"`, "string"], - ])(`%s => %s`, async (_, type, output) => { - const res = await oapiForModel( - "Book", - `model Book { + it.each([ + ["string", "string", "string"], + ["array", "string[]", "array"], + ["number", "numeric", "number"], + ["enum", `"a" | "b"`, "string"], + ])(`%s => %s`, async (_, type, output) => { + const res = await oapiForModel( + "Book", + `model Book { @name("xmlcontent") content: ${type}; };`, - ); - expect(res.schemas.Book).toMatchObject({ - properties: { - content: { type: `${output}`, xml: { name: "xmlcontent" } }, - }, - required: ["content"], + ); + expect(res.schemas.Book).toMatchObject({ + properties: { + content: { type: `${output}`, xml: { name: "xmlcontent" } }, + }, + required: ["content"], + }); }); - }); - it.each([ - ["object", "unknown"], - ["Union", `string | numeric`], - ])(`%s => %s`, async (_, type) => { - const res = await oapiForModel( - "Book", - `model Book { + it.each([ + ["object", "unknown"], + ["Union", `string | numeric`], + ])(`%s => %s`, async (_, type) => { + const res = await oapiForModel( + "Book", + `model Book { @name("xmlcontent") content: ${type}; };`, - ); - expect(res.schemas.Book).toMatchObject({ - properties: { - content: { xml: { name: "xmlcontent" } }, - }, - required: ["content"], + ); + expect(res.schemas.Book).toMatchObject({ + properties: { + content: { xml: { name: "xmlcontent" } }, + }, + required: ["content"], + }); }); - }); - it("set the value on scalar via @name", async () => { - const res = await oapiForModel( - "Book", - ` + it("set the value on scalar via @name", async () => { + const res = await oapiForModel( + "Book", + ` @name("xmlBook") scalar Book extends string;`, - ); + ); - expect(res.schemas.Book).toMatchInlineSnapshot(` - { - "type": "string", - "xml": { - "name": "xmlBook", + deepStrictEqual(res.schemas.Book, { + type: "string", + xml: { + name: "xmlBook", }, - } - `); - }); + }); + }); - it("compare with the json name", async () => { - const res = await oapiForModel( - "Book", - ` + it("compare with the json name", async () => { + const res = await oapiForModel( + "Book", + ` model Book { @name("xmlContent") @encodedName("application/json", "jsonContent") content: string; };`, - ); + ); - expect(res.schemas.Book).toMatchInlineSnapshot(` - { - "properties": { - "jsonContent": { - "type": "string", - "xml": { - "name": "xmlContent", + deepStrictEqual(res.schemas.Book, { + properties: { + jsonContent: { + type: "string", + xml: { + name: "xmlContent", }, }, }, - "required": [ - "jsonContent", - ], - "type": "object", - } - `); - }); + required: ["jsonContent"], + type: "object", + }); + }); - it("set the json name and no xml name", async () => { - const res = await oapiForModel( - "Book", - ` + it("set the json name and no xml name", async () => { + const res = await oapiForModel( + "Book", + ` model Book { @encodedName("application/json", "jsonContent") content: string; };`, - ); + ); - expect(res.schemas.Book).toMatchInlineSnapshot(` - { - "properties": { - "jsonContent": { - "type": "string", + deepStrictEqual(res.schemas.Book, { + properties: { + jsonContent: { + type: "string", }, }, - "required": [ - "jsonContent", - ], - "type": "object", - } - `); + required: ["jsonContent"], + type: "object", + }); + }); }); -}); -describe("@attribute", () => { - it.each([ - ["numeric", "numeric"], - ["string", "string"], - ["unknown", "unknown"], - ["Union", `string | numeric`], - ["enum", `"a" | "b"`], - ])(`%s => %s`, async (_, type) => { - const res = await oapiForModel( - "Book", - `model Book { + describe("@attribute", () => { + it.each([ + ["numeric", "numeric"], + ["string", "string"], + ["unknown", "unknown"], + ["Union", `string | numeric`], + ["enum", `"a" | "b"`], + ])(`%s => %s`, async (_, type) => { + const res = await oapiForModel( + "Book", + `model Book { @attribute id: ${type}; };`, - ); - expect(res.schemas.Book).toMatchObject({ - properties: { - id: { xml: { attribute: true } }, - }, + ); + expect(res.schemas.Book).toMatchObject({ + properties: { + id: { xml: { attribute: true } }, + }, + }); }); - }); - describe("warning and change the type to be type: string if attribute is object/objects", () => { - it.each([ - ["one", "Tag"], - ["ones", "Tag[]"], - ])(`%s => %s`, async (_, type) => { - const [res, diagnostics] = await emitOpenApiWithDiagnostics(` + describe("warning and change the type to be type: string if attribute is object/objects", () => { + it.each([ + ["one", "Tag"], + ["ones", "Tag[]"], + ])(`%s => %s`, async (_, type) => { + const [res, diagnostics] = await emitOpenApiWithDiagnostics(` model Tag { name: string; } @@ -221,106 +203,98 @@ describe("@attribute", () => { } `); - expectDiagnostics(diagnostics, { - code: "@typespec/openapi3/xml-attribute-invalid-property-type", - message: `XML \`@attribute\` can only be primitive types in the OpenAPI 3 emitter, Property 'tags' type will be changed to type: string.`, - }); - deepStrictEqual( - res.components?.schemas?.Pet, + expectDiagnostics(diagnostics, { + code: "@typespec/openapi3/xml-attribute-invalid-property-type", + message: `XML \`@attribute\` can only be primitive types in the OpenAPI 3 emitter, Property 'tags' type will be changed to type: string.`, + }); + deepStrictEqual( + res.components?.schemas?.Pet, - { - properties: { - tags: { - type: "string", - xml: { - attribute: true, + { + properties: { + tags: { + type: "string", + xml: { + attribute: true, + }, }, }, + required: ["tags"], + type: "object", }, - required: ["tags"], - type: "object", - }, - ); + ); + }); }); }); -}); -describe("@unwrapped", () => { - it("warning if unwrapped not array", async () => { - const runner = await createOpenAPITestRunner(); - const diagnostics = await runner.diagnose( - `model Book { + describe("@unwrapped", () => { + it("warning if unwrapped not array", async () => { + const runner = await createOpenAPITestRunner(); + const diagnostics = await runner.diagnose( + `model Book { @unwrapped id: string; };`, - ); - expectDiagnostics(diagnostics, { - code: "@typespec/openapi3/xml-unwrapped-invalid-property-type", - message: `XML \`@unwrapped\` can only used on array properties or primitive ones in the OpenAPI 3 emitter, Property 'id' will be ignored.`, + ); + expectDiagnostics(diagnostics, { + code: "@typespec/openapi3/xml-unwrapped-invalid-property-type", + message: `XML \`@unwrapped\` can only used on array properties or primitive ones in the OpenAPI 3 emitter, Property 'id' will be ignored.`, + }); }); }); -}); -describe("@ns", () => { - it("provide the namespace and prefix", async () => { - const res = await oapiForModel( - "Book", - ` + describe("@ns", () => { + it("provide the namespace and prefix", async () => { + const res = await oapiForModel( + "Book", + ` @ns("https://example.com/ns1", "ns1") model Book { id: string; };`, - ); - expect(res.schemas.Book).toMatchInlineSnapshot(` - { - "properties": { - "id": { - "type": "string", + ); + deepStrictEqual(res.schemas.Book, { + properties: { + id: { + type: "string", }, }, - "required": [ - "id", - ], - "type": "object", - "xml": { - "namespace": "https://example.com/ns1", - "prefix": "ns1", + required: ["id"], + type: "object", + xml: { + namespace: "https://example.com/ns1", + prefix: "ns1", }, - } - `); - }); + }); + }); - it("provide the namespace and prefix using string", async () => { - const res = await oapiForModel( - "Book", - `model Book { + it("provide the namespace and prefix using string", async () => { + const res = await oapiForModel( + "Book", + `model Book { @ns("https://example.com/ns1", "ns1") id: string; };`, - ); - expect(res.schemas.Book).toMatchInlineSnapshot(` - { - "properties": { - "id": { - "type": "string", - "xml": { - "namespace": "https://example.com/ns1", - "prefix": "ns1", + ); + deepStrictEqual(res.schemas.Book, { + properties: { + id: { + type: "string", + xml: { + namespace: "https://example.com/ns1", + prefix: "ns1", }, }, }, - "required": [ - "id", - ], - "type": "object", - } - `); - }); + required: ["id"], + type: "object", + }); + }); - it("provide the namespace and prefix using enum on model", async () => { - const res = await oapiForModel( - "Book", - ` + it("provide the namespace and prefix using enum on model", async () => { + const res = await oapiForModel( + "Book", + ` @nsDeclarations enum Namespaces { smp:"http://example.com/schema", @@ -330,30 +304,26 @@ describe("@ns", () => { model Book { id: string; };`, - ); - expect(res.schemas.Book).toMatchInlineSnapshot(` - { - "properties": { - "id": { - "type": "string", + ); + deepStrictEqual(res.schemas.Book, { + properties: { + id: { + type: "string", }, }, - "required": [ - "id", - ], - "type": "object", - "xml": { - "namespace": "http://example.com/schema", - "prefix": "smp", + required: ["id"], + type: "object", + xml: { + namespace: "http://example.com/schema", + prefix: "smp", }, - } - `); - }); + }); + }); - it("provide the namespace and prefix using enum on model and properties", async () => { - const res = await oapiForModel( - "Book", - ` + it("provide the namespace and prefix using enum on model and properties", async () => { + const res = await oapiForModel( + "Book", + ` @nsDeclarations enum Namespaces { smp:"http://example.com/schema", @@ -368,219 +338,205 @@ describe("@ns", () => { @ns(Namespaces.ns2) author: string; };`, - ); - expect(res.schemas.Book).toMatchInlineSnapshot(` - { - "properties": { - "author": { - "type": "string", - "xml": { - "namespace": "http://example.com/ns2", - "prefix": "ns2", + ); + deepStrictEqual(res.schemas.Book, { + properties: { + author: { + type: "string", + xml: { + namespace: "http://example.com/ns2", + prefix: "ns2", }, }, - "id": { - "type": "string", + id: { + type: "string", }, - "title": { - "type": "string", - "xml": { - "namespace": "http://example.com/schema", - "prefix": "smp", + title: { + type: "string", + xml: { + namespace: "http://example.com/schema", + prefix: "smp", }, }, }, - "required": [ - "id", - "title", - "author", - ], - "type": "object", - "xml": { - "namespace": "http://example.com/schema", - "prefix": "smp", + required: ["id", "title", "author"], + type: "object", + xml: { + namespace: "http://example.com/schema", + prefix: "smp", }, - } - `); + }); + }); }); -}); -describe("Array of primitive types", () => { - it("unwrapped tags array in the xmlBook model.", async () => { - const res = await oapiForModel( - "Book", - ` + describe("Array of primitive types", () => { + it("unwrapped tags array in the xmlBook model.", async () => { + const res = await oapiForModel( + "Book", + ` @name("xmlBook") model Book { @unwrapped tags: string[]; };`, - ); + ); - expect(res.schemas.Book).toMatchInlineSnapshot(` - { - "properties": { - "tags": { - "items": { - "type": "string", - "xml": { - "name": "tags", + deepStrictEqual(res.schemas.Book, { + properties: { + tags: { + items: { + type: "string", + xml: { + name: "tags", }, }, - "type": "array", + type: "array", }, }, - "required": [ - "tags", - ], - "type": "object", - "xml": { - "name": "xmlBook", + required: ["tags"], + type: "object", + xml: { + name: "xmlBook", }, - } - `); - }); + }); + }); - it("wrapped tags array in the xmlBook model.", async () => { - const res = await oapiForModel( - "Book", - ` + it("wrapped tags array in the xmlBook model.", async () => { + const res = await oapiForModel( + "Book", + ` @name("xmlBook") model Book { @name("ItemsTags") tags: string[]; };`, - ); - - expect(res.schemas.Book).toMatchInlineSnapshot(` - { - "properties": { - "tags": { - "items": { - "type": "string", - "xml": { - "name": "string", - }, - }, - "type": "array", - "xml": { - "name": "ItemsTags", - "wrapped": true, - }, - }, - }, - "required": [ - "tags", - ], - "type": "object", - "xml": { - "name": "xmlBook", - }, - } - `); - }); - - describe("scalar, @xml.unwrapped=true, and rename xml name.", () => { - it.each([ - ["string", "string"], - ["numeric", "number"], - ["integer", "integer"], - ["float", "number"], - ["boolean", "boolean"], - ])(`%s => %s`, async (target, type) => { - const res = await oapiForModel( - "Book", - `@name("ItemsName") - scalar tag extends ${target}; - - @name("xmlBook") - model Book { - @unwrapped - tags: tag[] - };`, ); - expect(res.schemas.tag).toMatchObject({ - type: `${type}`, - xml: { - name: "ItemsName", - }, - }); - expect(res.schemas.Book).toMatchObject({ - type: "object", + deepStrictEqual(res.schemas.Book, { properties: { tags: { - type: "array", items: { - type: `${type}`, - xml: { name: "tags" }, + type: "string", + xml: { + name: "string", + }, + }, + type: "array", + xml: { + name: "ItemsTags", + wrapped: true, }, }, }, required: ["tags"], + type: "object", xml: { name: "xmlBook", }, }); }); - }); - describe("scalar, @xml.unwrapped=false, and rename xml name.", () => { - it.each([ - ["string", "string"], - ["numeric", "number"], - ["integer", "integer"], - ["float", "number"], - ["boolean", "boolean"], - ])(`%s => %s`, async (target, type) => { - const res = await oapiForModel( - "Book", - `@name("ItemsName") + describe("scalar, @xml.unwrapped=true, and rename xml name.", () => { + it.each([ + ["string", "string"], + ["numeric", "number"], + ["integer", "integer"], + ["float", "number"], + ["boolean", "boolean"], + ])(`%s => %s`, async (target, type) => { + const res = await oapiForModel( + "Book", + `@name("ItemsName") scalar tag extends ${target}; @name("xmlBook") model Book { - @name("ItemsTags") + @unwrapped tags: tag[] };`, - ); - expect(res.schemas.tag).toMatchObject({ - type: `${type}`, - xml: { - name: "ItemsName", - }, - }); + ); + expect(res.schemas.tag).toMatchObject({ + type: `${type}`, + xml: { + name: "ItemsName", + }, + }); - expect(res.schemas.Book).toMatchObject({ - type: "object", - properties: { - tags: { - type: "array", - xml: { - name: "ItemsTags", - wrapped: true, + expect(res.schemas.Book).toMatchObject({ + type: "object", + properties: { + tags: { + type: "array", + items: { + type: `${type}`, + xml: { name: "tags" }, + }, }, - items: { - type: `${type}`, + }, + required: ["tags"], + xml: { + name: "xmlBook", + }, + }); + }); + }); + + describe("scalar, @xml.unwrapped=false, and rename xml name.", () => { + it.each([ + ["string", "string"], + ["numeric", "number"], + ["integer", "integer"], + ["float", "number"], + ["boolean", "boolean"], + ])(`%s => %s`, async (target, type) => { + const res = await oapiForModel( + "Book", + `@name("ItemsName") + scalar tag extends ${target}; + + @name("xmlBook") + model Book { + @name("ItemsTags") + tags: tag[] + };`, + ); + expect(res.schemas.tag).toMatchObject({ + type: `${type}`, + xml: { + name: "ItemsName", + }, + }); + + expect(res.schemas.Book).toMatchObject({ + type: "object", + properties: { + tags: { + type: "array", xml: { - name: "ItemsName", + name: "ItemsTags", + wrapped: true, + }, + items: { + type: `${type}`, + xml: { + name: "ItemsName", + }, }, }, }, - }, - required: ["tags"], - xml: { - name: "xmlBook", - }, + required: ["tags"], + xml: { + name: "xmlBook", + }, + }); }); }); }); -}); -describe("Complex array types", () => { - it("unwrapped the tags object array in the XmlPet model.", async () => { - const res = await oapiForModel( - "Pet", - ` + describe("Complex array types", () => { + it("unwrapped the tags object array in the XmlPet model.", async () => { + const res = await oapiForModel( + "Pet", + ` @name("XmlPet") model Pet { @unwrapped @@ -591,56 +547,48 @@ describe("Complex array types", () => { model Tag { name: string; }`, - ); + ); - expect(res.schemas.Tag).toMatchInlineSnapshot(` - { - "properties": { - "name": { - "type": "string", + deepStrictEqual(res.schemas.Tag, { + properties: { + name: { + type: "string", }, }, - "required": [ - "name", - ], - "type": "object", - "xml": { - "name": "XmlTag", + required: ["name"], + type: "object", + xml: { + name: "XmlTag", }, - } - `); - expect(res.schemas.Pet).toMatchInlineSnapshot(` - { - "properties": { - "tags": { - "items": { - "allOf": [ + }); + deepStrictEqual(res.schemas.Pet, { + properties: { + tags: { + items: { + allOf: [ { - "$ref": "#/components/schemas/Tag", + $ref: "#/components/schemas/Tag", }, ], - "xml": { - "name": "tags", + xml: { + name: "tags", }, }, - "type": "array", + type: "array", }, }, - "required": [ - "tags", - ], - "type": "object", - "xml": { - "name": "XmlPet", + required: ["tags"], + type: "object", + xml: { + name: "XmlPet", }, - } - `); - }); + }); + }); - it("wrapped the tags object array in the XmlPet model.", async () => { - const res = await oapiForModel( - "Pet", - ` + it("wrapped the tags object array in the XmlPet model.", async () => { + const res = await oapiForModel( + "Pet", + ` @name("XmlPet") model Pet { @name("ItemsTags") @@ -651,61 +599,53 @@ describe("Complex array types", () => { model Tag { name: string; }`, - ); + ); - expect(res.schemas.Tag).toMatchInlineSnapshot(` - { - "properties": { - "name": { - "type": "string", + deepStrictEqual(res.schemas.Tag, { + properties: { + name: { + type: "string", }, }, - "required": [ - "name", - ], - "type": "object", - "xml": { - "name": "XmlTag", + required: ["name"], + type: "object", + xml: { + name: "XmlTag", }, - } - `); + }); - expect(res.schemas.Pet).toMatchInlineSnapshot(` - { - "properties": { - "tags": { - "items": { - "allOf": [ + deepStrictEqual(res.schemas.Pet, { + properties: { + tags: { + items: { + allOf: [ { - "$ref": "#/components/schemas/Tag", + $ref: "#/components/schemas/Tag", }, ], - "xml": { - "name": "XmlTag", + xml: { + name: "XmlTag", }, }, - "type": "array", - "xml": { - "name": "ItemsTags", - "wrapped": true, + type: "array", + xml: { + name: "ItemsTags", + wrapped: true, }, }, }, - "required": [ - "tags", - ], - "type": "object", - "xml": { - "name": "XmlPet", + required: ["tags"], + type: "object", + xml: { + name: "XmlPet", }, - } - `); - }); + }); + }); - it("unwrapped and renamed Tags object array in xmlPet Model.", async () => { - const res = await oapiForModel( - "Pet", - ` + it("unwrapped and renamed Tags object array in xmlPet Model.", async () => { + const res = await oapiForModel( + "Pet", + ` @name("XmlPet") model Pet { @name("ItemsTags") @@ -717,55 +657,47 @@ describe("Complex array types", () => { model Tag { name: string; }`, - ); - expect(res.schemas.Tag).toMatchInlineSnapshot(` - { - "properties": { - "name": { - "type": "string", + ); + deepStrictEqual(res.schemas.Tag, { + properties: { + name: { + type: "string", }, }, - "required": [ - "name", - ], - "type": "object", - "xml": { - "name": "XmlTag", + required: ["name"], + type: "object", + xml: { + name: "XmlTag", }, - } - `); - expect(res.schemas.Pet).toMatchInlineSnapshot(` - { - "properties": { - "tags": { - "items": { - "allOf": [ + }); + deepStrictEqual(res.schemas.Pet, { + properties: { + tags: { + items: { + allOf: [ { - "$ref": "#/components/schemas/Tag", + $ref: "#/components/schemas/Tag", }, ], - "xml": { - "name": "ItemsTags", + xml: { + name: "ItemsTags", }, }, - "type": "array", + type: "array", }, }, - "required": [ - "tags", - ], - "type": "object", - "xml": { - "name": "XmlPet", + required: ["tags"], + type: "object", + xml: { + name: "XmlPet", }, - } - `); - }); + }); + }); - it("rename all names in array model.", async () => { - const res = await oapiForModel( - "Pet", - ` + it("rename all names in array model.", async () => { + const res = await oapiForModel( + "Pet", + ` @name("XmlPet") model Pet { @name("ItemsTags") @@ -776,472 +708,464 @@ describe("Complex array types", () => { model Tag { name: string; }`, - ); + ); - expect(res.schemas.Tag).toMatchInlineSnapshot(` - { - "properties": { - "name": { - "type": "string", + deepStrictEqual(res.schemas.Tag, { + properties: { + name: { + type: "string", }, }, - "required": [ - "name", - ], - "type": "object", - "xml": { - "name": "XmlTag", + required: ["name"], + type: "object", + xml: { + name: "XmlTag", }, - } - `); - expect(res.schemas.Pet).toMatchInlineSnapshot(` - { - "properties": { - "tags": { - "items": { - "allOf": [ + }); + deepStrictEqual(res.schemas.Pet, { + properties: { + tags: { + items: { + allOf: [ { - "$ref": "#/components/schemas/Tag", + $ref: "#/components/schemas/Tag", }, ], - "xml": { - "name": "XmlTag", + xml: { + name: "XmlTag", }, }, - "type": "array", - "xml": { - "name": "ItemsTags", - "wrapped": true, + type: "array", + xml: { + name: "ItemsTags", + wrapped: true, }, }, }, - "required": [ - "tags", - ], - "type": "object", - "xml": { - "name": "XmlPet", + required: ["tags"], + type: "object", + xml: { + name: "XmlPet", }, - } - `); + }); + }); }); -}); -describe("set xml name in items if that object is used in an xml payload.", () => { - const testCases: [string, string, string, any][] = [ - [ - "@name model, is arrays: true", - "model Book { author: Author[]; }", - `@name("xmlAuthor") model Author { id:string; }`, - { - Book: { - type: "object", - properties: { - author: { - type: "array", - items: { - allOf: [{ $ref: "#/components/schemas/Author" }], - xml: { name: "xmlAuthor" }, - }, - xml: { - wrapped: true, + describe("set xml name in items if that object is used in an xml payload.", () => { + const testCases: [string, string, string, any][] = [ + [ + "@name model, is arrays: true", + "model Book { author: Author[]; }", + `@name("xmlAuthor") model Author { id:string; }`, + { + Book: { + type: "object", + properties: { + author: { + type: "array", + items: { + allOf: [{ $ref: "#/components/schemas/Author" }], + xml: { name: "xmlAuthor" }, + }, + xml: { + wrapped: true, + }, }, }, + required: ["author"], }, - required: ["author"], - }, - Author: { - type: "object", - properties: { - id: { - type: "string", + Author: { + type: "object", + properties: { + id: { + type: "string", + }, }, + xml: { + name: "xmlAuthor", + }, + required: ["id"], }, - xml: { - name: "xmlAuthor", - }, - required: ["id"], }, - }, - ], - [ - "@name model property, is arrays: true", - "model Book { author: Author[]; }", - `model Author { @name("xmlId") id:string; }`, - { - Book: { - type: "object", - properties: { - author: { - type: "array", - items: { - allOf: [{ $ref: "#/components/schemas/Author" }], - xml: { name: "Author" }, - }, - xml: { - wrapped: true, + ], + [ + "@name model property, is arrays: true", + "model Book { author: Author[]; }", + `model Author { @name("xmlId") id:string; }`, + { + Book: { + type: "object", + properties: { + author: { + type: "array", + items: { + allOf: [{ $ref: "#/components/schemas/Author" }], + xml: { name: "Author" }, + }, + xml: { + wrapped: true, + }, }, }, + required: ["author"], }, - required: ["author"], - }, - Author: { - type: "object", - properties: { - id: { - type: "string", - xml: { - name: "xmlId", + Author: { + type: "object", + properties: { + id: { + type: "string", + xml: { + name: "xmlId", + }, }, }, + required: ["id"], }, - required: ["id"], }, - }, - ], - [ - "@attribute, is arrays: true", - "model Book { author: Author[]; }", - `model Author { @attribute id:string; }`, - { - Book: { - type: "object", - properties: { - author: { - type: "array", - items: { - allOf: [{ $ref: "#/components/schemas/Author" }], - xml: { name: "Author" }, - }, - xml: { - wrapped: true, + ], + [ + "@attribute, is arrays: true", + "model Book { author: Author[]; }", + `model Author { @attribute id:string; }`, + { + Book: { + type: "object", + properties: { + author: { + type: "array", + items: { + allOf: [{ $ref: "#/components/schemas/Author" }], + xml: { name: "Author" }, + }, + xml: { + wrapped: true, + }, }, }, + required: ["author"], }, - required: ["author"], - }, - Author: { - type: "object", - properties: { - id: { - type: "string", - xml: { - attribute: true, + Author: { + type: "object", + properties: { + id: { + type: "string", + xml: { + attribute: true, + }, }, }, + required: ["id"], }, - required: ["id"], }, - }, - ], - [ - "@attribute deeply, is arrays: true", - "model Book { author: Author[]; }", - `model Author { card: Card[]; } model Card { @attribute id:string;}`, - { - Book: { - type: "object", - properties: { - author: { - type: "array", - items: { - allOf: [{ $ref: "#/components/schemas/Author" }], - xml: { name: "Author" }, - }, - xml: { - wrapped: true, + ], + [ + "@attribute deeply, is arrays: true", + "model Book { author: Author[]; }", + `model Author { card: Card[]; } model Card { @attribute id:string;}`, + { + Book: { + type: "object", + properties: { + author: { + type: "array", + items: { + allOf: [{ $ref: "#/components/schemas/Author" }], + xml: { name: "Author" }, + }, + xml: { + wrapped: true, + }, }, }, + required: ["author"], }, - required: ["author"], - }, - Author: { - type: "object", - properties: { - card: { - type: "array", - items: { - allOf: [{ $ref: "#/components/schemas/Card" }], - xml: { name: "Card" }, - }, - xml: { - wrapped: true, + Author: { + type: "object", + properties: { + card: { + type: "array", + items: { + allOf: [{ $ref: "#/components/schemas/Card" }], + xml: { name: "Card" }, + }, + xml: { + wrapped: true, + }, }, }, + required: ["card"], }, - required: ["card"], - }, - Card: { - properties: { - id: { - type: "string", - xml: { - attribute: true, + Card: { + properties: { + id: { + type: "string", + xml: { + attribute: true, + }, }, }, + required: ["id"], + type: "object", }, - required: ["id"], - type: "object", }, - }, - ], - [ - "circular reference child, is arrays: true", - "model Book { author: Author[]; }", - `model Author { @attribute id: string; card: Card[]; } model Card { author:Author[];}`, - { - Book: { - type: "object", - properties: { - author: { - type: "array", - items: { - allOf: [{ $ref: "#/components/schemas/Author" }], - xml: { name: "Author" }, - }, - xml: { - wrapped: true, + ], + [ + "circular reference child, is arrays: true", + "model Book { author: Author[]; }", + `model Author { @attribute id: string; card: Card[]; } model Card { author:Author[];}`, + { + Book: { + type: "object", + properties: { + author: { + type: "array", + items: { + allOf: [{ $ref: "#/components/schemas/Author" }], + xml: { name: "Author" }, + }, + xml: { + wrapped: true, + }, }, }, + required: ["author"], }, - required: ["author"], - }, - Author: { - type: "object", - properties: { - card: { - type: "array", - items: { - allOf: [{ $ref: "#/components/schemas/Card" }], - xml: { name: "Card" }, + Author: { + type: "object", + properties: { + card: { + type: "array", + items: { + allOf: [{ $ref: "#/components/schemas/Card" }], + xml: { name: "Card" }, + }, + xml: { + wrapped: true, + }, }, - xml: { - wrapped: true, + id: { + type: "string", + xml: { + attribute: true, + }, }, }, - id: { - type: "string", - xml: { - attribute: true, + required: ["id", "card"], + }, + Card: { + properties: { + author: { + items: { + $ref: "#/components/schemas/Author", + }, + type: "array", }, }, + required: ["author"], + type: "object", }, - required: ["id", "card"], }, - Card: { - properties: { - author: { - items: { - $ref: "#/components/schemas/Author", + ], + [ + "circular reference root, is arrays: true", + "model Book { author: Author[]; }", + `model Author { @attribute id: string; book?: Book[]; }`, + { + Book: { + type: "object", + properties: { + author: { + type: "array", + items: { + allOf: [{ $ref: "#/components/schemas/Author" }], + xml: { name: "Author" }, + }, + xml: { + wrapped: true, + }, }, - type: "array", }, + required: ["author"], }, - required: ["author"], - type: "object", - }, - }, - ], - [ - "circular reference root, is arrays: true", - "model Book { author: Author[]; }", - `model Author { @attribute id: string; book?: Book[]; }`, - { - Book: { - type: "object", - properties: { - author: { - type: "array", - items: { - allOf: [{ $ref: "#/components/schemas/Author" }], - xml: { name: "Author" }, + Author: { + type: "object", + properties: { + book: { + type: "array", + items: { + allOf: [{ $ref: "#/components/schemas/Book" }], + xml: { name: "Book" }, + }, + xml: { + wrapped: true, + }, }, - xml: { - wrapped: true, + id: { + type: "string", + xml: { + attribute: true, + }, }, }, + required: ["id"], }, - required: ["author"], }, - Author: { - type: "object", - properties: { - book: { - type: "array", - items: { - allOf: [{ $ref: "#/components/schemas/Book" }], - xml: { name: "Book" }, - }, - xml: { - wrapped: true, + ], + [ + "@name model, is arrays: false", + "model Book { author: Author; }", + `@name("XmlAuthor") model Author { name: string; }`, + { + Book: { + type: "object", + properties: { + author: { + allOf: [{ $ref: "#/components/schemas/Author" }], + xml: { name: "author" }, }, }, - id: { - type: "string", - xml: { - attribute: true, + required: ["author"], + }, + Author: { + type: "object", + properties: { + name: { + type: "string", }, }, - }, - required: ["id"], - }, - }, - ], - [ - "@name model, is arrays: false", - "model Book { author: Author; }", - `@name("XmlAuthor") model Author { name: string; }`, - { - Book: { - type: "object", - properties: { - author: { - allOf: [{ $ref: "#/components/schemas/Author" }], - xml: { name: "author" }, + xml: { + name: "XmlAuthor", }, + required: ["name"], }, - required: ["author"], }, - Author: { - type: "object", - properties: { - name: { - type: "string", + ], + [ + "@name model property, is arrays: false", + "model Book { author: Author; }", + `model Author { @name("xmlId") name: string; }`, + { + Book: { + type: "object", + properties: { + author: { + allOf: [{ $ref: "#/components/schemas/Author" }], + xml: { name: "author" }, + }, }, + required: ["author"], }, - xml: { - name: "XmlAuthor", - }, - required: ["name"], - }, - }, - ], - [ - "@name model property, is arrays: false", - "model Book { author: Author; }", - `model Author { @name("xmlId") name: string; }`, - { - Book: { - type: "object", - properties: { - author: { - allOf: [{ $ref: "#/components/schemas/Author" }], - xml: { name: "author" }, + Author: { + type: "object", + properties: { + name: { + type: "string", + xml: { + name: "xmlId", + }, + }, }, + required: ["name"], }, - required: ["author"], }, - Author: { - type: "object", - properties: { - name: { - type: "string", - xml: { - name: "xmlId", + ], + [ + "@attribute, is arrays: false", + "model Book { author: Author; }", + "model Author { @attribute name: string; }", + { + Book: { + type: "object", + properties: { + author: { + allOf: [{ $ref: "#/components/schemas/Author" }], + xml: { name: "author" }, }, }, + required: ["author"], }, - required: ["name"], - }, - }, - ], - [ - "@attribute, is arrays: false", - "model Book { author: Author; }", - "model Author { @attribute name: string; }", - { - Book: { - type: "object", - properties: { - author: { - allOf: [{ $ref: "#/components/schemas/Author" }], - xml: { name: "author" }, + Author: { + type: "object", + properties: { + name: { + type: "string", + xml: { + attribute: true, + }, + }, }, + required: ["name"], }, - required: ["author"], }, - Author: { - type: "object", - properties: { - name: { - type: "string", - xml: { - attribute: true, + ], + [ + "circular reference root, is arrays: false", + "model Book { author: Author; }", + `model Author { @attribute id: string; book?: Book; }`, + { + Book: { + type: "object", + properties: { + author: { + allOf: [{ $ref: "#/components/schemas/Author" }], + xml: { name: "author" }, }, }, + required: ["author"], }, - required: ["name"], - }, - }, - ], - [ - "circular reference root, is arrays: false", - "model Book { author: Author; }", - `model Author { @attribute id: string; book?: Book; }`, - { - Book: { - type: "object", - properties: { - author: { - allOf: [{ $ref: "#/components/schemas/Author" }], - xml: { name: "author" }, + Author: { + type: "object", + properties: { + id: { + type: "string", + xml: { attribute: true }, + }, + book: { + allOf: [{ $ref: "#/components/schemas/Book" }], + xml: { name: "book" }, + }, }, + required: ["id"], }, - required: ["author"], }, - Author: { - type: "object", - properties: { - id: { - type: "string", - xml: { attribute: true }, - }, - book: { - allOf: [{ $ref: "#/components/schemas/Book" }], - xml: { name: "book" }, + ], + [ + "scalar, is arrays: false", + "model Book { author: Author; }", + `@name("XmlAuthor") scalar Author extends string;`, + { + Book: { + type: "object", + properties: { + author: { + allOf: [{ $ref: "#/components/schemas/Author" }], + xml: { name: "author" }, + }, }, + required: ["author"], }, - required: ["id"], - }, - }, - ], - [ - "scalar, is arrays: false", - "model Book { author: Author; }", - `@name("XmlAuthor") scalar Author extends string;`, - { - Book: { - type: "object", - properties: { - author: { - allOf: [{ $ref: "#/components/schemas/Author" }], - xml: { name: "author" }, - }, + Author: { + type: "string", + xml: { name: "XmlAuthor" }, }, - required: ["author"], - }, - Author: { - type: "string", - xml: { name: "XmlAuthor" }, }, - }, - ], - ]; - it.each(testCases)("%s", async (_, mainModel, refModel, expected) => { - const res = await oapiForModel( - "Book", - `${mainModel} + ], + ]; + it.each(testCases)("%s", async (_, mainModel, refModel, expected) => { + const res = await oapiForModel( + "Book", + `${mainModel} ${refModel}`, - ); + ); - deepStrictEqual(res?.schemas, expected); + deepStrictEqual(res?.schemas, expected); + }); }); -}); -it("test.", async () => { - const res = await oapiForModel( - "Author", - ` + it("test.", async () => { + const res = await oapiForModel( + "Author", + ` model Book { author: Author[]; } @@ -1249,19 +1173,18 @@ it("test.", async () => { model Author { book?: Book[]; }`, - ); + ); - expect(res.schemas.Author).toMatchInlineSnapshot(` - { - "properties": { - "book": { - "items": { - "$ref": "#/components/schemas/Book", + deepStrictEqual(res.schemas.Author, { + properties: { + book: { + items: { + $ref: "#/components/schemas/Book", }, - "type": "array", + type: "array", }, }, - "type": "object", - } - `); + type: "object", + }); + }); }); diff --git a/packages/playground/src/react/settings/emitter-options-form.tsx b/packages/playground/src/react/settings/emitter-options-form.tsx index 35324c270f..2f24c5fc7c 100644 --- a/packages/playground/src/react/settings/emitter-options-form.tsx +++ b/packages/playground/src/react/settings/emitter-options-form.tsx @@ -1,15 +1,17 @@ import { + Checkbox, Input, Label, Radio, RadioGroup, Switch, useId, + type CheckboxOnChangeData, type InputOnChangeData, type RadioGroupOnChangeData, type SwitchOnChangeData, } from "@fluentui/react-components"; -import { useCallback, useMemo, type FunctionComponent } from "react"; +import { useCallback, useMemo, useState, type FunctionComponent } from "react"; import type { PlaygroundTspLibrary } from "../../types.js"; import type { EmitterOptions } from "../types.js"; import style from "./emitter-options-form.module.css"; @@ -49,12 +51,21 @@ export const EmitterOptionsForm: FunctionComponent = ({ {entries.map(([key, value]) => { return (
- + {(value as any).type === "array" ? ( + + ) : ( + + )}
); })} @@ -62,13 +73,84 @@ export const EmitterOptionsForm: FunctionComponent = ({ ); }; -interface JsonSchemaProperty { +type JsonSchemaProperty = JsonSchemaScalarProperty; + +interface JsonSchemaScalarProperty { readonly type: "string" | "boolean" | "number"; readonly description?: string; readonly enum?: string[]; readonly default?: any; } +interface JsonSchemaArrayProperty { + readonly type: "array"; + readonly description?: string; + readonly items: JsonSchemaScalarProperty; +} + +type JsonSchemaArrayPropertyInputProps = Omit & { + readonly prop: JsonSchemaArrayProperty; +}; + +const JsonSchemaArrayPropertyInput: FunctionComponent = ({ + emitterOptions, + name, + prop, + onChange, +}) => { + const itemsSchema = prop.items; + const value = emitterOptions[name] ?? itemsSchema.default; + const prettyName = useMemo( + () => name[0].toUpperCase() + name.slice(1).replace(/-/g, " "), + [name], + ); + const inputId = useId("input"); + const [selectedValues, setSelectedValues] = useState(new Set(value)); + + const handleChange = useCallback( + ( + _: unknown, + data: RadioGroupOnChangeData | SwitchOnChangeData | InputOnChangeData | CheckboxOnChangeData, + value?: string, + ) => { + const modifiedSelectedValues = new Set(selectedValues); + if ("checked" in data) { + data.checked ? modifiedSelectedValues.add(value) : modifiedSelectedValues.delete(value); + } else { + modifiedSelectedValues.clear(); + modifiedSelectedValues.add(data.value); + } + setSelectedValues(modifiedSelectedValues); + onChange({ name, value: Array.from(modifiedSelectedValues) }); + }, + [name, onChange, selectedValues], + ); + + // Currently only have example of what `enum`-based arrays look like, + // so just handle a single element for other arrays for now. + if (!itemsSchema.enum) { + return JsonSchemaPropertyInput({ emitterOptions, name, prop: itemsSchema, onChange }); + } + + const itemsEnum = itemsSchema.enum; + return ( +
+ + {itemsEnum.map((x) => ( + handleChange(...args, x)} + /> + ))} +
+ ); +}; + interface JsonSchemaPropertyInputProps { readonly emitterOptions: Record; readonly name: string; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b3453a5853..94db194d1d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -908,6 +908,9 @@ importers: '@typespec/http': specifier: workspace:~ version: link:../http + '@typespec/json-schema': + specifier: workspace:~ + version: link:../json-schema '@typespec/library-linter': specifier: workspace:~ version: link:../library-linter diff --git a/website/src/content/docs/docs/emitters/openapi3/reference/emitter.md b/website/src/content/docs/docs/emitters/openapi3/reference/emitter.md index 9449b86098..9fe02c3b99 100644 --- a/website/src/content/docs/docs/emitters/openapi3/reference/emitter.md +++ b/website/src/content/docs/docs/emitters/openapi3/reference/emitter.md @@ -68,6 +68,10 @@ Example Multiple service with versioning - `openapi.Org1.Service2.v1.0.yaml` - `openapi.Org1.Service2.v1.1.yaml` +### `openapi-versions` + +**Type:** `array` + ### `new-line` **Type:** `"crlf" | "lf"` From 98f7cd575be123cafc14c8c99f6e15ddf597b8b0 Mon Sep 17 00:00:00 2001 From: Crystal YU Date: Wed, 15 Jan 2025 03:41:05 +0800 Subject: [PATCH 08/16] Generate Code from TypeSpec in VSCode (#5312) Fix https://github.com/microsoft/typespec/issues/5025 Fix https://github.com/microsoft/typespec/issues/5463 Integrate Code Generation in VSCode extension --- .../generateSDK-2024-11-10-10-45-35.md | 7 + .../changes/generateSDK-2025-0-10-0-6-24.md | 7 + .../src/generate-third-party-notice.ts | 20 +- .../typespec-vscode/ThirdPartyNotices.txt | 31 +- .../typespec-vscode/icons/client.dark.svg | 12 + .../typespec-vscode/icons/client.light.svg | 8 + .../typespec-vscode/icons/dotnet.dark.svg | 8 + .../typespec-vscode/icons/dotnet.light.svg | 3 + packages/typespec-vscode/icons/java.dark.svg | 3 + packages/typespec-vscode/icons/java.light.svg | 3 + .../typespec-vscode/icons/javascript.dark.svg | 8 + .../icons/javascript.light.svg | 3 + .../typespec-vscode/icons/openapi.dark.svg | 16 + .../typespec-vscode/icons/openapi.light.svg | 16 + .../typespec-vscode/icons/openapi3.dark.svg | 7 + .../typespec-vscode/icons/openapi3.light.svg | 7 + .../typespec-vscode/icons/python.dark.svg | 7 + .../typespec-vscode/icons/python.light.svg | 3 + .../typespec-vscode/icons/server.dark.svg | 27 + .../typespec-vscode/icons/server.light.svg | 9 + packages/typespec-vscode/package.json | 122 +++- packages/typespec-vscode/src/const.ts | 2 + packages/typespec-vscode/src/extension.ts | 15 + packages/typespec-vscode/src/npm-utils.ts | 163 +++++ packages/typespec-vscode/src/task-provider.ts | 5 +- .../src/tsp-language-client.ts | 5 +- packages/typespec-vscode/src/types.ts | 2 + .../typespec-vscode/src/typespec-utils.ts | 55 ++ .../src/vscode-cmd/emit-code/emit-code.ts | 617 ++++++++++++++++++ .../emit-code/emit-quick-pick-item.ts | 13 + .../src/vscode-cmd/emit-code/emitter.ts | 95 +++ pnpm-lock.yaml | 15 +- 32 files changed, 1295 insertions(+), 19 deletions(-) create mode 100644 .chronus/changes/generateSDK-2024-11-10-10-45-35.md create mode 100644 .chronus/changes/generateSDK-2025-0-10-0-6-24.md create mode 100644 packages/typespec-vscode/icons/client.dark.svg create mode 100644 packages/typespec-vscode/icons/client.light.svg create mode 100644 packages/typespec-vscode/icons/dotnet.dark.svg create mode 100644 packages/typespec-vscode/icons/dotnet.light.svg create mode 100644 packages/typespec-vscode/icons/java.dark.svg create mode 100644 packages/typespec-vscode/icons/java.light.svg create mode 100644 packages/typespec-vscode/icons/javascript.dark.svg create mode 100644 packages/typespec-vscode/icons/javascript.light.svg create mode 100644 packages/typespec-vscode/icons/openapi.dark.svg create mode 100644 packages/typespec-vscode/icons/openapi.light.svg create mode 100644 packages/typespec-vscode/icons/openapi3.dark.svg create mode 100644 packages/typespec-vscode/icons/openapi3.light.svg create mode 100644 packages/typespec-vscode/icons/python.dark.svg create mode 100644 packages/typespec-vscode/icons/python.light.svg create mode 100644 packages/typespec-vscode/icons/server.dark.svg create mode 100644 packages/typespec-vscode/icons/server.light.svg create mode 100644 packages/typespec-vscode/src/const.ts create mode 100644 packages/typespec-vscode/src/npm-utils.ts create mode 100644 packages/typespec-vscode/src/typespec-utils.ts create mode 100644 packages/typespec-vscode/src/vscode-cmd/emit-code/emit-code.ts create mode 100644 packages/typespec-vscode/src/vscode-cmd/emit-code/emit-quick-pick-item.ts create mode 100644 packages/typespec-vscode/src/vscode-cmd/emit-code/emitter.ts diff --git a/.chronus/changes/generateSDK-2024-11-10-10-45-35.md b/.chronus/changes/generateSDK-2024-11-10-10-45-35.md new file mode 100644 index 0000000000..6c70a9ff96 --- /dev/null +++ b/.chronus/changes/generateSDK-2024-11-10-10-45-35.md @@ -0,0 +1,7 @@ +--- +changeKind: feature +packages: + - typespec-vscode +--- + +integrate client SDK generation \ No newline at end of file diff --git a/.chronus/changes/generateSDK-2025-0-10-0-6-24.md b/.chronus/changes/generateSDK-2025-0-10-0-6-24.md new file mode 100644 index 0000000000..3f6bd062e8 --- /dev/null +++ b/.chronus/changes/generateSDK-2025-0-10-0-6-24.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/internal-build-utils" +--- + +resolve the program crash when there is no package name in package.json \ No newline at end of file diff --git a/packages/internal-build-utils/src/generate-third-party-notice.ts b/packages/internal-build-utils/src/generate-third-party-notice.ts index 68ecb9123b..4e22acc398 100644 --- a/packages/internal-build-utils/src/generate-third-party-notice.ts +++ b/packages/internal-build-utils/src/generate-third-party-notice.ts @@ -52,17 +52,23 @@ async function findThirdPartyPackages() { const sources = contents.sources; for (const source of sources) { const sourcePath = resolve(dirname(map), source); - const packageRoot = await getPackageRoot(sourcePath); + let packageRoot = await getPackageRoot(sourcePath); if (packageRoot === undefined) { continue; } - const pkg = JSON.parse(await readFile(join(packageRoot, "package.json"), "utf-8")); - - if (pkg.name === rootName || /microsoft/i.test(JSON.stringify(pkg.author))) { - continue; - } - if (!packages.has(packageRoot)) { + let pkg = JSON.parse(await readFile(join(packageRoot, "package.json"), "utf-8")); + + if (!pkg.name) { + packageRoot = await getPackageRoot(packageRoot); + while (!pkg.name && packageRoot) { + pkg = JSON.parse(await readFile(join(packageRoot, "package.json"), "utf-8")); + packageRoot = await getPackageRoot(packageRoot); + } + } + if (!pkg.name || pkg.name === rootName || /microsoft/i.test(JSON.stringify(pkg.author))) { + continue; + } packages.set(packageRoot, pkg); } } diff --git a/packages/typespec-vscode/ThirdPartyNotices.txt b/packages/typespec-vscode/ThirdPartyNotices.txt index 681acb4e65..301be2d7f7 100644 --- a/packages/typespec-vscode/ThirdPartyNotices.txt +++ b/packages/typespec-vscode/ThirdPartyNotices.txt @@ -12,6 +12,7 @@ granted herein, whether by implication, estoppel or otherwise. 2. brace-expansion version 2.0.1 (https://github.com/juliangruber/brace-expansion) 3. minimatch version 5.1.6 (https://github.com/isaacs/minimatch) 4. semver version 7.6.3 (https://github.com/npm/node-semver) +5. yaml version 2.5.1 (github:eemeli/yaml) %% balanced-match NOTICES AND INFORMATION BEGIN HERE @@ -111,4 +112,32 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ====================================================="); -END OF semver NOTICES AND INFORMATION \ No newline at end of file +END OF semver NOTICES AND INFORMATION + + +%% yaml NOTICES AND INFORMATION BEGIN HERE +===================================================== + MIT License + + Copyright (c) Microsoft Corporation. All rights reserved. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE + +====================================================="); +END OF yaml NOTICES AND INFORMATION \ No newline at end of file diff --git a/packages/typespec-vscode/icons/client.dark.svg b/packages/typespec-vscode/icons/client.dark.svg new file mode 100644 index 0000000000..18aa6ebd5d --- /dev/null +++ b/packages/typespec-vscode/icons/client.dark.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/typespec-vscode/icons/client.light.svg b/packages/typespec-vscode/icons/client.light.svg new file mode 100644 index 0000000000..b493a458d1 --- /dev/null +++ b/packages/typespec-vscode/icons/client.light.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/packages/typespec-vscode/icons/dotnet.dark.svg b/packages/typespec-vscode/icons/dotnet.dark.svg new file mode 100644 index 0000000000..39be6a20c6 --- /dev/null +++ b/packages/typespec-vscode/icons/dotnet.dark.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/packages/typespec-vscode/icons/dotnet.light.svg b/packages/typespec-vscode/icons/dotnet.light.svg new file mode 100644 index 0000000000..9c614b11d5 --- /dev/null +++ b/packages/typespec-vscode/icons/dotnet.light.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/packages/typespec-vscode/icons/java.dark.svg b/packages/typespec-vscode/icons/java.dark.svg new file mode 100644 index 0000000000..649dcb26c8 --- /dev/null +++ b/packages/typespec-vscode/icons/java.dark.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/packages/typespec-vscode/icons/java.light.svg b/packages/typespec-vscode/icons/java.light.svg new file mode 100644 index 0000000000..649dcb26c8 --- /dev/null +++ b/packages/typespec-vscode/icons/java.light.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/packages/typespec-vscode/icons/javascript.dark.svg b/packages/typespec-vscode/icons/javascript.dark.svg new file mode 100644 index 0000000000..978d95f5cd --- /dev/null +++ b/packages/typespec-vscode/icons/javascript.dark.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/packages/typespec-vscode/icons/javascript.light.svg b/packages/typespec-vscode/icons/javascript.light.svg new file mode 100644 index 0000000000..a400bccfd0 --- /dev/null +++ b/packages/typespec-vscode/icons/javascript.light.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/packages/typespec-vscode/icons/openapi.dark.svg b/packages/typespec-vscode/icons/openapi.dark.svg new file mode 100644 index 0000000000..3f05bbddf6 --- /dev/null +++ b/packages/typespec-vscode/icons/openapi.dark.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/typespec-vscode/icons/openapi.light.svg b/packages/typespec-vscode/icons/openapi.light.svg new file mode 100644 index 0000000000..3f05bbddf6 --- /dev/null +++ b/packages/typespec-vscode/icons/openapi.light.svg @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/typespec-vscode/icons/openapi3.dark.svg b/packages/typespec-vscode/icons/openapi3.dark.svg new file mode 100644 index 0000000000..22b781fe93 --- /dev/null +++ b/packages/typespec-vscode/icons/openapi3.dark.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/packages/typespec-vscode/icons/openapi3.light.svg b/packages/typespec-vscode/icons/openapi3.light.svg new file mode 100644 index 0000000000..22b781fe93 --- /dev/null +++ b/packages/typespec-vscode/icons/openapi3.light.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/packages/typespec-vscode/icons/python.dark.svg b/packages/typespec-vscode/icons/python.dark.svg new file mode 100644 index 0000000000..5e792117a7 --- /dev/null +++ b/packages/typespec-vscode/icons/python.dark.svg @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/packages/typespec-vscode/icons/python.light.svg b/packages/typespec-vscode/icons/python.light.svg new file mode 100644 index 0000000000..3490261bed --- /dev/null +++ b/packages/typespec-vscode/icons/python.light.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/packages/typespec-vscode/icons/server.dark.svg b/packages/typespec-vscode/icons/server.dark.svg new file mode 100644 index 0000000000..8289d77d3a --- /dev/null +++ b/packages/typespec-vscode/icons/server.dark.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/typespec-vscode/icons/server.light.svg b/packages/typespec-vscode/icons/server.light.svg new file mode 100644 index 0000000000..828b762e17 --- /dev/null +++ b/packages/typespec-vscode/icons/server.light.svg @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/packages/typespec-vscode/package.json b/packages/typespec-vscode/package.json index a0e1feb1bc..ac437f9cab 100644 --- a/packages/typespec-vscode/package.json +++ b/packages/typespec-vscode/package.json @@ -108,6 +108,104 @@ ], "default": "off", "description": "Define whether/how the TypeSpec language server should send traces to client. For the traces to show properly in vscode Output, make sure 'Log Level' is also set to 'Trace' so that they won't be filtered at client side, which can be set through 'Developer: Set Log Level...' command." + }, + "typespec.generateCode.emitters": { + "scope": "window", + "type": "array", + "items": { + "type": "object", + "properties": { + "language": { + "type": "string", + "enum": [ + ".NET", + "Java", + "JavaScript", + "Python", + "Go", + "OpenAPI3", + "ProtoBuf", + "JsonSchema" + ], + "description": "Define the language the emitter will emit." + }, + "package": { + "type": "string", + "description": "Define the emitter package.\n\nExample (with version): @typespec/http-client-csharp@1.0.0\n\nExample (without version): @typespec/http-client-csharp" + }, + "sourceRepo": { + "type": "string", + "description": "Define the source repository of the emitter package." + }, + "requisites": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Define the requisites of the emitter package." + }, + "kind": { + "type": "string", + "enum": [ + "client", + "server", + "openapi" + ], + "description": "Define the emitter kind." + } + } + }, + "default": [ + { + "language": ".NET", + "package": "@typespec/http-client-csharp", + "sourceRepo": "https://github.com/microsoft/typespec/tree/main/packages/http-client-csharp", + "requisites": [ + ".NET 8.0 SDK" + ], + "kind": "client" + }, + { + "language": "Java", + "package": "@typespec/http-client-java", + "sourceRepo": "https://github.com/microsoft/typespec/tree/main/packages/http-client-java", + "requisites": [ + "Java 17 or above", + "Maven" + ], + "kind": "client" + }, + { + "language": "JavaScript", + "package": "@azure-tools/typespec-ts", + "sourceRepo": "https://github.com/Azure/autorest.typescript/tree/main/packages/typespec-ts", + "kind": "client" + }, + { + "language": "Python", + "package": "@typespec/http-client-python", + "sourceRepo": "https://github.com/microsoft/typespec/tree/main/packages/http-client-python", + "kind": "client" + }, + { + "language": ".NET", + "package": "@typespec/http-server-csharp", + "sourceRepo": "https://github.com/microsoft/typespec/tree/main/packages/http-server-csharp", + "kind": "server" + }, + { + "language": "JavaScript", + "package": "@typespec/http-server-javascript", + "sourceRepo": "https://github.com/microsoft/typespec/tree/main/packages/http-server-javascript", + "kind": "server" + }, + { + "language": "OpenAPI3", + "package": "@typespec/openapi3", + "sourceRepo": "https://github.com/microsoft/typespec/tree/main/packages/openapi3", + "kind": "openapi" + } + ] } } } @@ -141,6 +239,11 @@ "title": "Show Output Channel", "category": "TypeSpec" }, + { + "command": "typespec.generateCode", + "title": "Generate from TypeSpec", + "category": "TypeSpec" + }, { "command": "typespec.createProject", "title": "Create TypeSpec Project", @@ -152,6 +255,22 @@ "category": "TypeSpec" } ], + "menus": { + "explorer/context": [ + { + "command": "typespec.generateCode", + "when": "explorerResourceIsFolder || resourceLangId == typespec", + "group": "code_generation" + } + ], + "editor/context": [ + { + "command": "typespec.generateCode", + "when": "resourceLangId == typespec", + "group": "code_generation" + } + ] + }, "semanticTokenScopes": [ { "scopes": { @@ -229,6 +348,7 @@ "typescript": "~5.6.3", "vitest": "^2.1.5", "vscode-languageclient": "~9.0.1", - "semver": "^7.6.3" + "semver": "^7.6.3", + "yaml": "~2.5.1" } } diff --git a/packages/typespec-vscode/src/const.ts b/packages/typespec-vscode/src/const.ts new file mode 100644 index 0000000000..8a5d3e4b8f --- /dev/null +++ b/packages/typespec-vscode/src/const.ts @@ -0,0 +1,2 @@ +export const StartFileName = "main.tsp"; +export const TspConfigFileName = "tspconfig.yaml"; diff --git a/packages/typespec-vscode/src/extension.ts b/packages/typespec-vscode/src/extension.ts index da1b73a8ae..2d0f0cc45a 100644 --- a/packages/typespec-vscode/src/extension.ts +++ b/packages/typespec-vscode/src/extension.ts @@ -13,6 +13,7 @@ import { SettingName, } from "./types.js"; import { createTypeSpecProject } from "./vscode-cmd/create-tsp-project.js"; +import { emitCode } from "./vscode-cmd/emit-code/emit-code.js"; import { installCompilerGlobally } from "./vscode-cmd/install-tsp-compiler.js"; let client: TspLanguageClient | undefined; @@ -44,6 +45,20 @@ export async function activate(context: ExtensionContext) { }), ); + /* emit command. */ + context.subscriptions.push( + commands.registerCommand(CommandName.GenerateCode, async (uri: vscode.Uri) => { + await vscode.window.withProgress( + { + location: vscode.ProgressLocation.Window, + title: "Generate from TypeSpec...", + cancellable: false, + }, + async () => await emitCode(context, uri), + ); + }), + ); + context.subscriptions.push( commands.registerCommand( CommandName.RestartServer, diff --git a/packages/typespec-vscode/src/npm-utils.ts b/packages/typespec-vscode/src/npm-utils.ts new file mode 100644 index 0000000000..d3b5f61867 --- /dev/null +++ b/packages/typespec-vscode/src/npm-utils.ts @@ -0,0 +1,163 @@ +import { readFile } from "fs/promises"; +import path from "path"; +import semver from "semver"; +import logger from "./log/logger.js"; +import { ExecOutput, loadModule, spawnExecutionAndLogToOutput } from "./utils.js"; + +export enum InstallAction { + Install = "Install", + Upgrade = "Upgrade", + Skip = "Skip", + Cancel = "Cancel", +} + +export enum npmDependencyType { + dependencies = "dependencies", + peerDependencies = "peerDependencies", + devDependencies = "devDependencies", +} + +export interface NpmPackageInfo { + name: string; + version?: string; + resolved?: string; + overridden?: string; + dependencies?: Record; +} + +export class NpmUtil { + private cwd: string; + + constructor(cwd: string) { + this.cwd = cwd; + } + + public async npmInstallPackages(packages: string[] = [], options: any = {}): Promise { + return spawnExecutionAndLogToOutput("npm", ["install", ...packages], this.cwd); + } + + /* identify the action to take for a package. install or skip or cancel or upgrade */ + public async calculateNpmPackageInstallAction( + packageName: string, + version?: string, + ): Promise<{ action: InstallAction; version?: string }> { + const { installed: isPackageInstalled, version: installedVersion } = + await this.isPackageInstalled(packageName); + if (isPackageInstalled) { + if (version && installedVersion !== version) { + if (semver.gt(version, installedVersion!)) { + return { action: InstallAction.Upgrade, version: version }; + } else { + logger.info( + "The version to intall is less than the installed version. Skip installation.", + ); + return { action: InstallAction.Skip, version: installedVersion }; + } + } + return { action: InstallAction.Skip, version: installedVersion }; + } else { + return { action: InstallAction.Install, version: version }; + } + } + + /* identify the dependency packages need to be upgraded */ + public async calculateNpmPackageDependencyToUpgrade( + packageName: string, + version?: string, + dependencyTypes: npmDependencyType[] = [npmDependencyType.dependencies], + ): Promise<{ name: string; version: string }[]> { + const dependenciesToInstall: { name: string; version: string }[] = []; + let packageFullName = packageName; + if (version) { + packageFullName = `${packageName}@${version}`; + } + + /* get dependencies. */ + if (dependencyTypes.length === 0) { + logger.info("No dependency to check."); + return dependenciesToInstall; + } + + try { + const dependenciesResult = await spawnExecutionAndLogToOutput( + "npm", + ["view", packageFullName, ...dependencyTypes, "--json"], + this.cwd, + ); + + if (dependenciesResult.exitCode === 0) { + const json = JSON.parse(dependenciesResult.stdout); + const jsonDependencies: any[] = []; + if (dependencyTypes.length > 1) { + jsonDependencies.push(...Object.values(json)); + } else { + jsonDependencies.push(json); + } + const dependencies = parseDependency(jsonDependencies); + for (const [key, value] of Object.entries(dependencies)) { + const { installed, version: installedVersion } = await this.isPackageInstalled(key); + if (installed && installedVersion) { + if (!this.isValidVersion(installedVersion, value.join("||"))) { + dependenciesToInstall.push({ name: key, version: "latest" }); + } + } + } + } else { + logger.error("Error getting dependencies.", [dependenciesResult.stderr]); + } + } catch (err) { + logger.error("Error getting dependencies.", [err]); + } + + function parseDependency(jsonDependencies: any[]): Record { + const dependencies: Record = {}; + for (const dependency of jsonDependencies) { + for (const [key, value] of Object.entries(dependency)) { + if (dependencies[key]) { + dependencies[key].push(value as string); + } else { + dependencies[key] = [value as string]; + } + } + } + return dependencies; + } + + return dependenciesToInstall; + } + + private isValidVersion(version: string, range: string): boolean { + return semver.satisfies(version, range); + } + + private async isPackageInstalled( + packageName: string, + ): Promise<{ installed: boolean; version: string | undefined }> { + const packageInfo = await this.loadNpmPackage(packageName); + if (packageInfo) return { installed: true, version: packageInfo.version }; + return { installed: false, version: undefined }; + } + + private async loadNpmPackage(packageName: string): Promise { + const executable = await loadModule(this.cwd, packageName); + if (executable) { + const packageJsonPath = path.resolve(executable.path, "package.json"); + + /* get the package version. */ + let version; + try { + const data = await readFile(packageJsonPath, { encoding: "utf-8" }); + const packageJson = JSON.parse(data); + version = packageJson.version; + } catch (error) { + logger.error("Error reading package.json.", [error]); + } + return { + name: packageName, + version: version, + }; + } + + return undefined; + } +} diff --git a/packages/typespec-vscode/src/task-provider.ts b/packages/typespec-vscode/src/task-provider.ts index 39d8da558e..c0f0c16ee5 100644 --- a/packages/typespec-vscode/src/task-provider.ts +++ b/packages/typespec-vscode/src/task-provider.ts @@ -1,6 +1,7 @@ import { resolve } from "path"; import vscode, { workspace } from "vscode"; import { Executable } from "vscode-languageclient/node.js"; +import { StartFileName } from "./const.js"; import logger from "./log/logger.js"; import { normalizeSlashes } from "./path-utils.js"; import { resolveTypeSpecCli } from "./tsp-executable-resolver.js"; @@ -11,13 +12,13 @@ export function createTaskProvider() { provideTasks: async () => { logger.info("Providing tsp tasks"); const targetPathes = await vscode.workspace - .findFiles("**/main.tsp", "**/node_modules/**") + .findFiles(`**/${StartFileName}`, "**/node_modules/**") .then((uris) => uris .filter((uri) => uri.scheme === "file" && !uri.fsPath.includes("node_modules")) .map((uri) => normalizeSlashes(uri.fsPath)), ); - logger.info(`Found ${targetPathes.length} main.tsp files`); + logger.info(`Found ${targetPathes.length} ${StartFileName} files`); const tasks: vscode.Task[] = []; for (const targetPath of targetPathes) { tasks.push(...(await createBuiltInTasks(targetPath))); diff --git a/packages/typespec-vscode/src/tsp-language-client.ts b/packages/typespec-vscode/src/tsp-language-client.ts index 43b24433fb..e72b263a8d 100644 --- a/packages/typespec-vscode/src/tsp-language-client.ts +++ b/packages/typespec-vscode/src/tsp-language-client.ts @@ -7,6 +7,7 @@ import type { } from "@typespec/compiler"; import { ExtensionContext, LogOutputChannel, RelativePattern, workspace } from "vscode"; import { Executable, LanguageClient, LanguageClientOptions } from "vscode-languageclient/node.js"; +import { TspConfigFileName } from "./const.js"; import logger from "./log/logger.js"; import { resolveTypeSpecServer } from "./tsp-executable-resolver.js"; import { @@ -191,7 +192,7 @@ export class TspLanguageClient { workspace.createFileSystemWatcher("**/*.cadl"), workspace.createFileSystemWatcher("**/cadl-project.yaml"), workspace.createFileSystemWatcher("**/*.tsp"), - workspace.createFileSystemWatcher("**/tspconfig.yaml"), + workspace.createFileSystemWatcher(`**/${TspConfigFileName}`), // please be aware that the vscode watch with '**' will honer the files.watcherExclude settings // so we won't get notification for those package.json under node_modules // if our customers exclude the node_modules folder in files.watcherExclude settings. @@ -213,7 +214,7 @@ export class TspLanguageClient { documentSelector: [ { scheme: "file", language: "typespec" }, { scheme: "untitled", language: "typespec" }, - { scheme: "file", language: "yaml", pattern: "**/tspconfig.yaml" }, + { scheme: "file", language: "yaml", pattern: `**/${TspConfigFileName}` }, ], outputChannel, }; diff --git a/packages/typespec-vscode/src/types.ts b/packages/typespec-vscode/src/types.ts index 99af0a7fa0..9abd25fb26 100644 --- a/packages/typespec-vscode/src/types.ts +++ b/packages/typespec-vscode/src/types.ts @@ -1,6 +1,7 @@ export const enum SettingName { TspServerPath = "typespec.tsp-server.path", InitTemplatesUrls = "typespec.initTemplatesUrls", + GenerateCodeEmitters = "typespec.generateCode.emitters", } export const enum CommandName { @@ -9,6 +10,7 @@ export const enum CommandName { InstallGlobalCompilerCli = "typespec.installGlobalCompilerCli", CreateProject = "typespec.createProject", OpenUrl = "typespec.openUrl", + GenerateCode = "typespec.generateCode", } export interface InstallGlobalCliCommandArgs { diff --git a/packages/typespec-vscode/src/typespec-utils.ts b/packages/typespec-vscode/src/typespec-utils.ts new file mode 100644 index 0000000000..fc112a6cc5 --- /dev/null +++ b/packages/typespec-vscode/src/typespec-utils.ts @@ -0,0 +1,55 @@ +import { readFile } from "fs/promises"; +import path from "path"; +import vscode from "vscode"; +import { StartFileName } from "./const.js"; +import logger from "./log/logger.js"; +import { getDirectoryPath, normalizeSlashes } from "./path-utils.js"; +import { isFile } from "./utils.js"; + +export async function getEntrypointTspFile(tspPath: string): Promise { + const isFilePath = await isFile(tspPath); + let baseDir = isFilePath ? getDirectoryPath(tspPath) : tspPath; + + while (true) { + const pkgPath = path.resolve(baseDir, "package.json"); + if (await isFile(pkgPath)) { + /* get the tspMain from package.json. */ + try { + const data = await readFile(pkgPath, { encoding: "utf-8" }); + const packageJson = JSON.parse(data); + const tspMain = packageJson.tspMain; + if (typeof tspMain === "string") { + const tspMainFile = path.resolve(baseDir, tspMain); + if (await isFile(tspMainFile)) { + logger.debug(`tspMain file ${tspMainFile} selected as entrypoint file.`); + return tspMainFile; + } + } + } catch (error) { + logger.error(`An error occurred while reading the package.json file ${pkgPath}`, [error]); + } + } + + const mainTspFile = path.resolve(baseDir, StartFileName); + if (await isFile(mainTspFile)) { + return mainTspFile; + } + const parentDir = getDirectoryPath(baseDir); + if (parentDir === baseDir) { + break; + } + baseDir = parentDir; + } + + return undefined; +} + +export async function TraverseMainTspFileInWorkspace() { + return vscode.workspace + .findFiles(`**/${StartFileName}`, "**/node_modules/**") + .then((uris) => + uris + .filter((uri) => uri.scheme === "file" && !uri.fsPath.includes("node_modules")) + .map((uri) => normalizeSlashes(uri.fsPath)), + ); +} diff --git a/packages/typespec-vscode/src/vscode-cmd/emit-code/emit-code.ts b/packages/typespec-vscode/src/vscode-cmd/emit-code/emit-code.ts new file mode 100644 index 0000000000..a57114288e --- /dev/null +++ b/packages/typespec-vscode/src/vscode-cmd/emit-code/emit-code.ts @@ -0,0 +1,617 @@ +import { readFile, writeFile } from "fs/promises"; +import path from "path"; +import vscode, { QuickInputButton, Uri } from "vscode"; +import { Executable } from "vscode-languageclient/node.js"; +import { isScalar, isSeq, parseDocument } from "yaml"; +import { StartFileName, TspConfigFileName } from "../../const.js"; +import logger from "../../log/logger.js"; +import { InstallAction, npmDependencyType, NpmUtil } from "../../npm-utils.js"; +import { getDirectoryPath } from "../../path-utils.js"; +import { resolveTypeSpecCli } from "../../tsp-executable-resolver.js"; +import { getEntrypointTspFile, TraverseMainTspFileInWorkspace } from "../../typespec-utils.js"; +import { ExecOutput, isFile, spawnExecutionAndLogToOutput } from "../../utils.js"; +import { EmitQuickPickItem } from "./emit-quick-pick-item.js"; +import { + Emitter, + EmitterKind, + getLanguageAlias, + getRegisterEmitters, + getRegisterEmittersByPackage, + getRegisterEmitterTypes, + PreDefinedEmitterPickItems, +} from "./emitter.js"; + +interface EmitQuickPickButton extends QuickInputButton { + uri: string; +} + +async function configureEmitter( + context: vscode.ExtensionContext, + existingEmitters: string[], +): Promise { + const emitterKinds = getRegisterEmitterTypes(); + const toEmitterTypeQuickPickItem = (kind: EmitterKind): any => { + const registerEmitters = getRegisterEmitters(kind); + const supportedLanguages = registerEmitters.map((e) => e.language).join(", "); + return { + label: PreDefinedEmitterPickItems[kind]?.label ?? kind, + detail: + PreDefinedEmitterPickItems[kind]?.detail ?? + `Generate ${kind} code from TypeSpec files. Supported languages are ${supportedLanguages}.`, + emitterKind: kind, + iconPath: { + light: Uri.file(context.asAbsolutePath(`./icons/${kind.toLowerCase()}.light.svg`)), + dark: Uri.file(context.asAbsolutePath(`./icons/${kind.toLowerCase()}.dark.svg`)), + }, + }; + }; + const codesToEmit = emitterKinds.map((kind) => toEmitterTypeQuickPickItem(kind)); + const codeType = await vscode.window.showQuickPick(codesToEmit, { + title: "Generate from TypeSpec", + canPickMany: false, + placeHolder: "Select an emitter type", + ignoreFocusOut: true, + }); + if (!codeType) { + logger.info("No emitter Type selected. Generating Cancelled."); + return undefined; + } + + const toQuickPickItem = (e: Emitter): EmitQuickPickItem => { + const buttons = e.sourceRepo + ? [ + { + iconPath: new vscode.ThemeIcon("link-external"), + tooltip: "More details", + uri: e.sourceRepo, + }, + ] + : undefined; + return { + language: e.language, + package: e.package, + version: e.version, + requisites: e.requisites, + sourceRepo: e.sourceRepo, + emitterKind: e.kind, + label: e.language, + detail: `Generate ${e.kind} code for ${e.language} by TypeSpec library ${e.package}.`, + picked: false, + fromConfig: false, + buttons: buttons, + iconPath: { + light: Uri.file( + context.asAbsolutePath(`./icons/${getLanguageAlias(e.language).toLowerCase()}.light.svg`), + ), + dark: Uri.file( + context.asAbsolutePath(`./icons/${getLanguageAlias(e.language).toLowerCase()}.dark.svg`), + ), + }, + }; + }; + + /* filter out already existing emitters. */ + const registerEmitters = getRegisterEmitters(codeType.emitterKind).filter( + (emitter) => !existingEmitters.includes(emitter.package), + ); + const all: EmitQuickPickItem[] = [...registerEmitters].map((e) => toQuickPickItem(e)); + + const emitterSelector = vscode.window.createQuickPick(); + emitterSelector.items = all; + emitterSelector.title = `Generate from TypeSpec`; + emitterSelector.canSelectMany = false; + emitterSelector.placeholder = `Select a Language for ${codeType} code generation`; + emitterSelector.ignoreFocusOut = true; + emitterSelector.onDidTriggerItemButton(async (e) => { + if (e.button.tooltip === "More details") { + const url = (e.button as EmitQuickPickButton).uri; + await vscode.env.openExternal(vscode.Uri.parse(url)); + } + }); + emitterSelector.show(); + const selectedEmitter = await new Promise((resolve) => { + emitterSelector.onDidAccept(() => { + resolve(emitterSelector.selectedItems[0]); + emitterSelector.dispose(); + }); + }); + + if (!selectedEmitter) { + logger.info("No language selected. Generating Cancelled."); + return undefined; + } + return { + language: selectedEmitter.language, + package: selectedEmitter.package, + version: selectedEmitter.version, + sourceRepo: selectedEmitter.sourceRepo, + requisites: selectedEmitter.requisites, + kind: selectedEmitter.emitterKind, + }; +} +async function doEmit(mainTspFile: string, emitter: Emitter) { + if (!mainTspFile || !(await isFile(mainTspFile))) { + logger.error( + "Invalid typespec project. There is no main tsp file in the project. Generating Cancelled.", + [], + { showOutput: false, showPopup: true }, + ); + return; + } + + const baseDir = getDirectoryPath(mainTspFile); + + const npmUtil = new NpmUtil(baseDir); + const packagesToInstall: string[] = []; + + /* install emitter package. */ + logger.info(`select ${emitter.package}`); + const { action, version } = await npmUtil.calculateNpmPackageInstallAction( + emitter.package, + emitter.version, + ); + + const installPackageQuickPickItems = await vscode.window.withProgress( + { + location: vscode.ProgressLocation.Notification, + title: "Calculating packages to install or upgrade ...", + cancellable: false, + }, + async () => { + const packageQuickPickItems = []; + if (action === InstallAction.Upgrade || action === InstallAction.Install) { + const minimumRequisites = emitter.requisites + ? ` Minimum requisites: install ${emitter.requisites?.join(", ")}` + : ""; + let packageFullName = emitter.package; + if (version) { + packageFullName = `${emitter.package}@${version}`; + } + packageQuickPickItems.push({ + label: `${emitter.package}`, + description: `TypeSpec library for emitting ${emitter.language} from TypeSpec files.`, + detail: minimumRequisites, + packageFullName: packageFullName, + sourceRepo: emitter.sourceRepo, + picked: true, + buttons: emitter.sourceRepo + ? [ + { + iconPath: new vscode.ThemeIcon("link-external"), + tooltip: "More details", + uri: emitter.sourceRepo, + }, + ] + : undefined, + }); + packagesToInstall.push(packageFullName); + } + + for (const p of packagesToInstall) { + /* verify dependency packages. */ + try { + const dependenciesToInstall = await npmUtil.calculateNpmPackageDependencyToUpgrade( + p, + version, + [npmDependencyType.dependencies, npmDependencyType.peerDependencies], + ); + if (dependenciesToInstall.length > 0) { + packagesToInstall.push(...dependenciesToInstall.map((d) => `${d.name}@${d.version}`)); + for (const dep of dependenciesToInstall) { + const packageFullName = `${dep.name}@${version ?? "latest"}`; + packageQuickPickItems.push({ + label: `${dep.name}`, + description: "Required for enabling the emitter library.", + packageFullName: packageFullName, + picked: true, + }); + } + } + } catch (err) { + logger.error(`Exception occurred when check dependency packages for ${p}.`); + } + } + return packageQuickPickItems; + }, + ); + + if (installPackageQuickPickItems.length > 0) { + const installPackagesSelector = vscode.window.createQuickPick(); + installPackagesSelector.items = installPackageQuickPickItems; + installPackagesSelector.title = `Generate from TypeSpec`; + installPackagesSelector.canSelectMany = true; + installPackagesSelector.placeholder = "Here are libraries to install or update."; + installPackagesSelector.ignoreFocusOut = true; + installPackagesSelector.selectedItems = [...installPackageQuickPickItems]; + installPackagesSelector.onDidTriggerItemButton(async (e) => { + if (e.button.tooltip === "More details") { + const url = (e.button as EmitQuickPickButton).uri; + await vscode.env.openExternal(vscode.Uri.parse(url)); + } + }); + installPackagesSelector.show(); + const selectedPackages = await new Promise((resolve) => { + installPackagesSelector.onDidAccept(() => { + resolve(installPackagesSelector.selectedItems); + installPackagesSelector.dispose(); + }); + }); + if (!selectedPackages || selectedPackages.length === 0) { + logger.info("No package selected. Generating Cancelled.", [], { + showOutput: true, + showPopup: true, + }); + return; + } + /* npm install packages. */ + if (selectedPackages.length > 0) { + const installPackages = selectedPackages.map((p) => p.packageFullName); + logger.info(`Install ${installPackages.join(",")} under directory ${baseDir}`); + const installResult = await vscode.window.withProgress( + { + location: vscode.ProgressLocation.Notification, + title: "Installing packages...", + cancellable: false, + }, + async () => { + try { + const npmInstallResult = await npmUtil.npmInstallPackages(installPackages, undefined); + if (npmInstallResult.exitCode !== 0) { + return false; + } else { + return true; + } + } catch (err: any) { + return false; + } + }, + ); + if (!installResult) { + logger.error(`Error occurred when installing packages. Generating Cancelled.`, [], { + showOutput: false, + showPopup: true, + }); + return; + } + } + } + + /* emit */ + const cli = await resolveTypeSpecCli(baseDir); + if (!cli) { + logger.error( + "Cannot find TypeSpec CLI. Please install @typespec/compiler. Generating Cancelled.", + [], + { + showOutput: true, + showPopup: true, + }, + ); + return; + } + /*Config emitter output dir and emit in tspconfig.yaml. */ + const defaultEmitOutputDirInConfig = `{project-root}/${emitter.kind}/${getLanguageAlias(emitter.language)}`; + const tspConfigFile = path.join(baseDir, TspConfigFileName); + let configYaml = parseDocument(""); //generate a empty yaml + if (await isFile(tspConfigFile)) { + const content = await readFile(tspConfigFile); + configYaml = parseDocument(content.toString()); + } + let outputDir = defaultEmitOutputDirInConfig; + try { + /*update emitter in config.yaml. */ + const emitNode = configYaml.get("emit"); + if (emitNode) { + if (isSeq(emitNode)) { + if (Array.isArray(emitNode.items)) { + const index = emitNode.items.findIndex((item) => { + if (isScalar(item)) { + return item.value === emitter.package; + } + return false; + }); + if (index === -1) { + emitNode.items.push(emitter.package); + } + } + } + } else { + configYaml.set("emit", [emitter.package]); + } + const emitOutputDir = configYaml.getIn(["options", emitter.package, "emitter-output-dir"]); + if (!emitOutputDir) { + configYaml.setIn( + ["options", emitter.package, "emitter-output-dir"], + defaultEmitOutputDirInConfig, + ); + } else { + outputDir = emitOutputDir as string; + } + const newYamlContent = configYaml.toString(); + await writeFile(tspConfigFile, newYamlContent); + } catch (error: any) { + logger.error(error); + } + + outputDir = outputDir.replace("{project-root}", baseDir); + const options: Record = {}; + logger.info( + `Start to generate ${emitter.language} ${emitter.kind} code under directory ${outputDir}`, + ); + await vscode.window.withProgress( + { + location: vscode.ProgressLocation.Notification, + title: `Generating ${emitter.kind} code for ${emitter.language}...`, + cancellable: false, + }, + async () => { + try { + const compileResult = await compile(cli, mainTspFile, emitter.package, options, false); + if (compileResult.exitCode !== 0) { + logger.error(`Generating ${emitter.kind} code for ${emitter.language}...Failed`, [], { + showOutput: true, + showPopup: true, + }); + } else { + logger.info(`Generating ${emitter.kind} code for ${emitter.language}...Succeeded`, [], { + showOutput: true, + showPopup: true, + }); + } + } catch (err: any) { + if (typeof err === "object" && "stdout" in err && "stderr" in err && `error` in err) { + const execOutput = err as ExecOutput; + const details = []; + if (execOutput.stdout !== "") details.push(execOutput.stdout); + if (execOutput.stderr !== "") details.push(execOutput.stderr); + if (execOutput.error) details.push(execOutput.error); + logger.error( + `Generating ${emitter.kind} code for ${emitter.language}...Failed.`, + details, + { + showOutput: true, + showPopup: true, + }, + ); + } else { + logger.error(`Generating ${emitter.kind} code for ${emitter.language}...Failed.`, [err], { + showOutput: true, + showPopup: true, + }); + } + } + }, + ); +} + +export async function emitCode(context: vscode.ExtensionContext, uri: vscode.Uri) { + let tspProjectFile: string = ""; + if (!uri) { + const targetPathes = await TraverseMainTspFileInWorkspace(); + logger.info(`Found ${targetPathes.length} ${StartFileName} files`); + if (targetPathes.length === 0) { + logger.info(`No entrypoint file (${StartFileName}) found. Generating Cancelled.`, [], { + showOutput: true, + showPopup: true, + }); + return; + } else if (targetPathes.length === 1) { + tspProjectFile = targetPathes[0]; + } else { + const toProjectPickItem = (filePath: string): any => { + return { + label: `Project: ${filePath}`, + path: filePath, + iconPath: { + light: Uri.file(context.asAbsolutePath(`./icons/tsp-file.light.svg`)), + dark: Uri.file(context.asAbsolutePath(`./icons/tsp-file.dark.svg`)), + }, + }; + }; + const typespecProjectQuickPickItems: any[] = targetPathes.map((filePath) => + toProjectPickItem(filePath), + ); + const selectedProjectFile = await vscode.window.showQuickPick(typespecProjectQuickPickItems, { + title: "Generate from TypeSpec", + canPickMany: false, + placeHolder: "Select a project", + ignoreFocusOut: true, + }); + if (!selectedProjectFile) { + logger.info("No project selected. Generating Cancelled.", [], { + showOutput: true, + showPopup: true, + }); + return; + } + tspProjectFile = selectedProjectFile.path; + } + } else { + const tspStartFile = await getEntrypointTspFile(uri.fsPath); + if (!tspStartFile) { + logger.info(`No entrypoint file (${StartFileName}). Invalid typespec project.`, [], { + showOutput: true, + showPopup: true, + }); + return; + } + tspProjectFile = tspStartFile; + } + + logger.info(`Generate from entrypoint file: ${tspProjectFile}`); + const baseDir = getDirectoryPath(tspProjectFile); + const tspConfigFile = path.join(baseDir, TspConfigFileName); + let configYaml = parseDocument(""); //generate a empty yaml + if (await isFile(tspConfigFile)) { + const content = await readFile(tspConfigFile); + configYaml = parseDocument(content.toString()); + } + + let existingEmitters; + try { + const emitNode = configYaml.get("emit"); + if (emitNode) { + if (isSeq(emitNode)) { + if (Array.isArray(emitNode.items)) { + existingEmitters = emitNode.items.map((item) => { + if (isScalar(item)) { + return item.value as string; + } + return ""; + }); + } + } + } + } catch (error: any) { + logger.error(error); + } + + const toEmitterQuickPickItem = (e: Emitter): EmitQuickPickItem => { + const buttons = e.sourceRepo + ? [ + { + iconPath: new vscode.ThemeIcon("link-external"), + tooltip: "More details", + uri: e.sourceRepo, + }, + ] + : undefined; + return { + language: e.language, + package: e.package, + version: e.version, + requisites: e.requisites, + sourceRepo: e.sourceRepo, + emitterKind: e.kind, + label: `${e.language} ${e.kind} code emitter`, + description: `${e.package}.`, + // detail: `Generate ${e.kind} code for ${e.language} by TypeSpec library ${e.package}.`, + picked: false, + fromConfig: false, + buttons: buttons, + iconPath: { + light: Uri.file( + context.asAbsolutePath(`./icons/${getLanguageAlias(e.language).toLowerCase()}.light.svg`), + ), + dark: Uri.file( + context.asAbsolutePath(`./icons/${getLanguageAlias(e.language).toLowerCase()}.dark.svg`), + ), + }, + }; + }; + /* display existing emitters in config.yaml. */ + if (existingEmitters && existingEmitters.length > 0) { + const existingEmitterQuickPickItems = existingEmitters.map((e) => { + const emitter = getRegisterEmittersByPackage(e); + if (emitter) { + return toEmitterQuickPickItem(emitter); + } else { + return { + label: e, + description: "Emit code by the emitter library.", + picked: true, + fromConfig: true, + package: e, + kind: vscode.QuickPickItemKind.Default, + }; + } + }); + const separatorItem = { + label: "Settings", + description: "settings", + kind: vscode.QuickPickItemKind.Separator, + info: undefined, + package: "", + fromConfig: false, + picked: false, + }; + const newEmitterQuickPickItem = { + label: "Configure a new emitter", + description: "Configure a new emitter for code generation", + picked: false, + fromConfig: false, + package: "", + kind: vscode.QuickPickItemKind.Default, + buttons: [ + { + iconPath: new vscode.ThemeIcon("settings-gear"), + tooltip: "Configure a new emitter for code generation", + }, + ], + }; + + const allPickItems = []; + allPickItems.push(...existingEmitterQuickPickItems, separatorItem, newEmitterQuickPickItem); + const existingEmittersSelector = vscode.window.createQuickPick(); + existingEmittersSelector.items = allPickItems; + existingEmittersSelector.title = `Generate from TypeSpec`; + existingEmittersSelector.canSelectMany = false; + existingEmittersSelector.placeholder = "Select an emitter for code generation"; + existingEmittersSelector.ignoreFocusOut = true; + existingEmittersSelector.show(); + const selectedExistingEmitter = await new Promise((resolve) => { + existingEmittersSelector.onDidAccept(async () => { + const selectedItem = existingEmittersSelector.selectedItems[0]; + if (selectedItem === newEmitterQuickPickItem) { + const newEmitter = await configureEmitter(context, existingEmitters); + const allPickItems = []; + if (newEmitter) { + allPickItems.push(toEmitterQuickPickItem(newEmitter)); + } + allPickItems.push(...existingEmitterQuickPickItems); + allPickItems.push(separatorItem, newEmitterQuickPickItem); + existingEmittersSelector.items = allPickItems; + existingEmittersSelector.show(); + } else { + resolve(existingEmittersSelector.selectedItems[0]); + existingEmittersSelector.dispose(); + } + }); + }); + if (!selectedExistingEmitter) { + logger.info("No emitter selected. Generating Cancelled."); + return; + } + await doEmit( + tspProjectFile, + getRegisterEmittersByPackage(selectedExistingEmitter.package) ?? { + package: selectedExistingEmitter.package, + language: "Unknown", + kind: EmitterKind.Unknown, + }, + ); + } else { + const newEmitter = await configureEmitter(context, existingEmitters ?? []); + if (newEmitter) { + await doEmit(tspProjectFile, newEmitter); + } else { + logger.info("No emitter selected. Generating Cancelled."); + return; + } + } +} + +async function compile( + cli: Executable, + startFile: string, + emitter: string, + options: Record, + logPretty?: boolean, +): Promise { + const args: string[] = cli.args ?? []; + args.push("compile"); + args.push(startFile); + if (emitter) { + args.push("--emit", emitter); + } + if (logPretty !== undefined) { + args.push("--pretty"); + args.push(logPretty ? "true" : "false"); + } + + for (const [key, value] of Object.entries(options)) { + args.push("--option", `${emitter}.${key}=${value}`); + } + + return await spawnExecutionAndLogToOutput(cli.command, args, getDirectoryPath(startFile)); +} diff --git a/packages/typespec-vscode/src/vscode-cmd/emit-code/emit-quick-pick-item.ts b/packages/typespec-vscode/src/vscode-cmd/emit-code/emit-quick-pick-item.ts new file mode 100644 index 0000000000..e98fc48a9a --- /dev/null +++ b/packages/typespec-vscode/src/vscode-cmd/emit-code/emit-quick-pick-item.ts @@ -0,0 +1,13 @@ +import vscode from "vscode"; +import { EmitterKind } from "./emitter.js"; + +export interface EmitQuickPickItem extends vscode.QuickPickItem { + language: string; + package: string; + version?: string; + sourceRepo?: string; + requisites?: string[]; + fromConfig: boolean; + outputDir?: string; + emitterKind: EmitterKind; +} diff --git a/packages/typespec-vscode/src/vscode-cmd/emit-code/emitter.ts b/packages/typespec-vscode/src/vscode-cmd/emit-code/emitter.ts new file mode 100644 index 0000000000..3fe1fb4137 --- /dev/null +++ b/packages/typespec-vscode/src/vscode-cmd/emit-code/emitter.ts @@ -0,0 +1,95 @@ +import vscode from "vscode"; +import logger from "../../log/logger.js"; +import { SettingName } from "../../types.js"; + +export enum EmitterKind { + Schema = "openapi", + Client = "client", + Server = "server", + Unknown = "unknown", +} + +export interface Emitter { + language: string; + package: string; + version?: string; + sourceRepo?: string; + requisites?: string[]; + kind: EmitterKind; +} + +export const PreDefinedEmitterPickItems: Record = { + openapi: { + label: "OpenAPI Document", + detail: "Generating OpenAPI3 Document from TypeSpec files.", + }, + client: { + label: "Client Code", + detail: + "Generating Client Code from TypeSpec files. Supported languages are .NET, Python, Java, JavaScript.", + }, + server: { + label: " Server Stub", + detail: "Generating Server Stub from TypeSpec files. Supported languages are .NET, JavaScript.", + }, +}; + +function getEmitter(kind: EmitterKind, emitter: Emitter): Emitter | undefined { + let packageFullName: string = emitter.package; + if (!packageFullName) { + logger.error("Emitter package name is required."); + return undefined; + } + packageFullName = packageFullName.trim(); + const index = packageFullName.lastIndexOf("@"); + let version = undefined; + let packageName = packageFullName; + if (index !== -1 && index !== 0) { + version = packageFullName.substring(index + 1); + packageName = packageFullName.substring(0, index); + } + + return { + language: emitter.language, + package: packageName, + version: version, + sourceRepo: emitter.sourceRepo, + requisites: emitter.requisites, + kind: kind, + }; +} + +export function getRegisterEmitters(kind: EmitterKind): ReadonlyArray { + const extensionConfig = vscode.workspace.getConfiguration(); + const emitters: ReadonlyArray = + extensionConfig.get(SettingName.GenerateCodeEmitters) ?? []; + return emitters + .filter((emitter) => emitter.kind === kind) + .map((emitter) => getEmitter(kind, emitter)) + .filter((emitter) => emitter !== undefined) as Emitter[]; +} + +export function getRegisterEmitterTypes(): ReadonlyArray { + const extensionConfig = vscode.workspace.getConfiguration(); + const emitters: ReadonlyArray = + extensionConfig.get(SettingName.GenerateCodeEmitters) ?? []; + return Array.from(new Set(emitters.map((emitter) => emitter.kind))); +} + +export function getRegisterEmittersByPackage(packageName: string): Emitter | undefined { + const extensionConfig = vscode.workspace.getConfiguration(); + const emitters: ReadonlyArray = + extensionConfig.get(SettingName.GenerateCodeEmitters) ?? []; + return emitters.find( + (emitter) => emitter.package === packageName || emitter.package.startsWith(packageName + "@"), + ); +} + +const languageAlias: Record = { + ".NET": "dotnet", +}; + +/*return the alias of the language if it exists, otherwise return the original language. */ +export function getLanguageAlias(language: string): string { + return languageAlias[language] ?? language; +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 94db194d1d..fce60e79dc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1942,6 +1942,9 @@ importers: vscode-languageclient: specifier: ~9.0.1 version: 9.0.1 + yaml: + specifier: ~2.5.1 + version: 2.5.1 packages/versioning: devDependencies: @@ -11218,8 +11221,8 @@ packages: terser: optional: true - vitefu@1.0.4: - resolution: {integrity: sha512-y6zEE3PQf6uu/Mt6DTJ9ih+kyJLr4XcSgHR2zUkM8SWDhuixEJxfJ6CZGMHh1Ec3vPLoEA0IHU5oWzVqw8ulow==} + vitefu@1.0.5: + resolution: {integrity: sha512-h4Vflt9gxODPFNGPwp4zAMZRpZR7eslzwH2c5hn5kNZ5rhnKyRJ50U+yGCdc2IRaBs8O4haIgLNGrV5CrpMsCA==} peerDependencies: vite: ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 peerDependenciesMeta: @@ -16428,7 +16431,7 @@ snapshots: dependencies: '@vitest/spy': 2.1.5 estree-walker: 3.0.3 - magic-string: 0.30.17 + magic-string: 0.30.13 optionalDependencies: vite: 5.4.11(@types/node@22.7.9) @@ -16448,7 +16451,7 @@ snapshots: '@vitest/snapshot@2.1.5': dependencies: '@vitest/pretty-format': 2.1.5 - magic-string: 0.30.17 + magic-string: 0.30.13 pathe: 1.1.2 '@vitest/spy@2.0.5': @@ -16977,7 +16980,7 @@ snapshots: unist-util-visit: 5.0.0 vfile: 6.0.3 vite: 5.4.11(@types/node@22.7.9) - vitefu: 1.0.4(vite@5.4.11(@types/node@22.7.9)) + vitefu: 1.0.5(vite@5.4.11(@types/node@22.7.9)) which-pm: 3.0.0 xxhash-wasm: 1.1.0 yargs-parser: 21.1.1 @@ -23237,7 +23240,7 @@ snapshots: '@types/node': 22.7.9 fsevents: 2.3.3 - vitefu@1.0.4(vite@5.4.11(@types/node@22.7.9)): + vitefu@1.0.5(vite@5.4.11(@types/node@22.7.9)): optionalDependencies: vite: 5.4.11(@types/node@22.7.9) From 5d179808091b5ec9a4b4b9920a823172e9e8ef72 Mon Sep 17 00:00:00 2001 From: iscai-msft <43154838+iscai-msft@users.noreply.github.com> Date: Tue, 14 Jan 2025 15:30:56 -0500 Subject: [PATCH 09/16] [python] unify credential type description (#5600) fixes #5582 --------- Co-authored-by: iscai-msft --- packages/http-client-python/CHANGELOG.md | 4 ++++ .../generator/pygen/codegen/models/combined_type.py | 7 ++++--- .../generator/pygen/codegen/models/credential_types.py | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/http-client-python/CHANGELOG.md b/packages/http-client-python/CHANGELOG.md index a13f39518b..8c28113084 100644 --- a/packages/http-client-python/CHANGELOG.md +++ b/packages/http-client-python/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.6.3 +### Bug Fixes + +- Unify descriptions for credentials in documentation + ### Other Changes - Remove Python2 specific datetime logic from internal serialization. diff --git a/packages/http-client-python/generator/pygen/codegen/models/combined_type.py b/packages/http-client-python/generator/pygen/codegen/models/combined_type.py index 8170758f23..fa8c72a517 100644 --- a/packages/http-client-python/generator/pygen/codegen/models/combined_type.py +++ b/packages/http-client-python/generator/pygen/codegen/models/combined_type.py @@ -53,9 +53,10 @@ def client_default_value(self) -> Any: return self.yaml_data.get("clientDefaultValue") def description(self, *, is_operation_file: bool) -> str: - if len(self.types) == 2: - return f"Is either a {self.types[0].type_description} type or a {self.types[1].type_description} type." - return f"Is one of the following types: {', '.join([t.type_description for t in self.types])}" + type_descriptions = list({t.type_description: None for t in self.types}.keys()) + if len(type_descriptions) == 2: + return f"Is either a {type_descriptions[0]} type or a {type_descriptions[1]} type." + return f"Is one of the following types: {', '.join(t for t in type_descriptions)}" def docstring_text(self, **kwargs: Any) -> str: return " or ".join(t.docstring_text(**kwargs) for t in self.types) diff --git a/packages/http-client-python/generator/pygen/codegen/models/credential_types.py b/packages/http-client-python/generator/pygen/codegen/models/credential_types.py index 28154d2f1c..3830e3deb5 100644 --- a/packages/http-client-python/generator/pygen/codegen/models/credential_types.py +++ b/packages/http-client-python/generator/pygen/codegen/models/credential_types.py @@ -198,6 +198,10 @@ def docstring_type(self, **kwargs: Any) -> str: def type_annotation(self, **kwargs: Any) -> str: return self.policy.credential_name + @property + def type_description(self) -> str: + return "key credential" + @property def instance_check_template(self) -> str: return "isinstance({}, " + f"{self.policy.credential_name})" From 365a92b91d0ac60cd7056be2de0c8084468e7bf3 Mon Sep 17 00:00:00 2001 From: iscai-msft <43154838+iscai-msft@users.noreply.github.com> Date: Tue, 14 Jan 2025 15:34:59 -0500 Subject: [PATCH 10/16] [python] add mypy typing to operation group init (#5604) fixes https://github.com/Azure/autorest.python/issues/2046 --------- Co-authored-by: iscai-msft --- packages/http-client-python/CHANGELOG.md | 1 + .../pygen/codegen/models/operation_group.py | 23 ++++++++++++++++++- .../templates/operation_group.py.jinja2 | 8 +++---- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/packages/http-client-python/CHANGELOG.md b/packages/http-client-python/CHANGELOG.md index 8c28113084..130d160a01 100644 --- a/packages/http-client-python/CHANGELOG.md +++ b/packages/http-client-python/CHANGELOG.md @@ -8,6 +8,7 @@ ### Other Changes +- Add mypy typing to operation group inits - Remove Python2 specific datetime logic from internal serialization. ## 0.6.2 diff --git a/packages/http-client-python/generator/pygen/codegen/models/operation_group.py b/packages/http-client-python/generator/pygen/codegen/models/operation_group.py index 978a6c3736..c9c25b1108 100644 --- a/packages/http-client-python/generator/pygen/codegen/models/operation_group.py +++ b/packages/http-client-python/generator/pygen/codegen/models/operation_group.py @@ -9,7 +9,7 @@ from .base import BaseModel from .operation import get_operation -from .imports import FileImport, ImportType, TypingSection +from .imports import FileImport, ImportType, TypingSection, MsrestImportType from .utils import add_to_pylint_disable, NamespaceType from .lro_operation import LROOperation from .lro_paging_operation import LROPagingOperation @@ -152,6 +152,27 @@ def imports(self, async_mode: bool, **kwargs: Any) -> FileImport: f"{self.client.name}MixinABC", ImportType.LOCAL, ) + else: + file_import.add_submodule_import( + "" if self.code_model.is_azure_flavor else "runtime", + f"{'Async' if async_mode else ''}PipelineClient", + ImportType.SDKCORE, + ) + file_import.add_submodule_import( + ".._configuration", + f"{self.client.name}Configuration", + ImportType.LOCAL, + ) + file_import.add_msrest_import( + serialize_namespace=kwargs.get("serialize_namespace", self.code_model.namespace), + msrest_import_type=MsrestImportType.Serializer, + typing_section=TypingSection.REGULAR, + ) + file_import.add_msrest_import( + serialize_namespace=kwargs.get("serialize_namespace", self.code_model.namespace), + msrest_import_type=MsrestImportType.SerializerDeserializer, + typing_section=TypingSection.REGULAR, + ) if self.has_abstract_operations: file_import.add_submodule_import( # raise_if_not_implemented is always defined in _vendor of top namespace diff --git a/packages/http-client-python/generator/pygen/codegen/templates/operation_group.py.jinja2 b/packages/http-client-python/generator/pygen/codegen/templates/operation_group.py.jinja2 index 1ee2846535..bba82eaccb 100644 --- a/packages/http-client-python/generator/pygen/codegen/templates/operation_group.py.jinja2 +++ b/packages/http-client-python/generator/pygen/codegen/templates/operation_group.py.jinja2 @@ -31,10 +31,10 @@ class {{ operation_group.class_name }}: {{ operation_group.pylint_disable() }} {% endif %} def __init__(self, *args, **kwargs){{ return_none_type_annotation }}: input_args = list(args) - self._client = input_args.pop(0) if input_args else kwargs.pop("client") - self._config = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self._client: {{ 'Async' if async_mode else ''}}PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: {{ operation_group.client.name }}Configuration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") {% if code_model.options["multiapi"] %} self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") {% endif %} From 2d34919fe2fbe9e7f6df517ee9420db9f11ac924 Mon Sep 17 00:00:00 2001 From: iscai-msft <43154838+iscai-msft@users.noreply.github.com> Date: Tue, 14 Jan 2025 16:54:53 -0500 Subject: [PATCH 11/16] [python] add type annotations to initialized properties for msrest models (#5606) fixes https://github.com/Azure/autorest.python/issues/2930 --------- Co-authored-by: iscai-msft --- packages/http-client-python/CHANGELOG.md | 1 + .../generator/pygen/codegen/models/property.py | 4 ++-- .../generator/pygen/codegen/serializers/model_serializer.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/http-client-python/CHANGELOG.md b/packages/http-client-python/CHANGELOG.md index 130d160a01..789369c145 100644 --- a/packages/http-client-python/CHANGELOG.md +++ b/packages/http-client-python/CHANGELOG.md @@ -8,6 +8,7 @@ ### Other Changes +- Add type annotations for initialized properties in msrest model inits - Add mypy typing to operation group inits - Remove Python2 specific datetime logic from internal serialization. diff --git a/packages/http-client-python/generator/pygen/codegen/models/property.py b/packages/http-client-python/generator/pygen/codegen/models/property.py index f7adafd351..27d4ce8e72 100644 --- a/packages/http-client-python/generator/pygen/codegen/models/property.py +++ b/packages/http-client-python/generator/pygen/codegen/models/property.py @@ -102,7 +102,7 @@ def type_annotation(self, *, is_operation_file: bool = False, **kwargs: Any) -> if self.is_base_discriminator: return "str" types_type_annotation = self.type.type_annotation(is_operation_file=is_operation_file, **kwargs) - if self.optional and self.client_default_value is None: + if (self.optional and self.client_default_value is None) or self.readonly: return f"Optional[{types_type_annotation}]" return types_type_annotation @@ -144,7 +144,7 @@ def imports(self, **kwargs) -> FileImport: if self.is_discriminator and isinstance(self.type, EnumType): return file_import file_import.merge(self.type.imports(**kwargs)) - if self.optional and self.client_default_value is None: + if (self.optional and self.client_default_value is None) or self.readonly: file_import.add_submodule_import("typing", "Optional", ImportType.STDLIB) if self.code_model.options["models_mode"] == "dpg": serialize_namespace = kwargs.get("serialize_namespace", self.code_model.namespace) diff --git a/packages/http-client-python/generator/pygen/codegen/serializers/model_serializer.py b/packages/http-client-python/generator/pygen/codegen/serializers/model_serializer.py index 8063725443..cab548be4f 100644 --- a/packages/http-client-python/generator/pygen/codegen/serializers/model_serializer.py +++ b/packages/http-client-python/generator/pygen/codegen/serializers/model_serializer.py @@ -192,9 +192,9 @@ def initialize_properties(self, model: ModelType) -> List[str]: if prop.is_discriminator: init_args.append(self.initialize_discriminator_property(model, prop)) elif prop.readonly: - init_args.append(f"self.{prop.client_name} = None") + init_args.append(f"self.{prop.client_name}: {prop.type_annotation()} = None") elif not prop.constant: - init_args.append(f"self.{prop.client_name} = {prop.client_name}") + init_args.append(f"self.{prop.client_name}: {prop.type_annotation()} = {prop.client_name}") return init_args @staticmethod From f260ff0bf12612d3e0c583003b733b17066f36de Mon Sep 17 00:00:00 2001 From: Nisha Bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Tue, 14 Jan 2025 14:11:38 -0800 Subject: [PATCH 12/16] Update ConditionalRequestHeaderTests.cs (#5586) Resolves: #5530 --- .../ConditionalRequestHeaderTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/SpecialHeaders/{ConditionalRequests => ConditionalRequest}/ConditionalRequestHeaderTests.cs (93%) diff --git a/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/SpecialHeaders/ConditionalRequests/ConditionalRequestHeaderTests.cs b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/SpecialHeaders/ConditionalRequest/ConditionalRequestHeaderTests.cs similarity index 93% rename from packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/SpecialHeaders/ConditionalRequests/ConditionalRequestHeaderTests.cs rename to packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/SpecialHeaders/ConditionalRequest/ConditionalRequestHeaderTests.cs index 8149b0701f..0199ba3f09 100644 --- a/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/SpecialHeaders/ConditionalRequests/ConditionalRequestHeaderTests.cs +++ b/packages/http-client-csharp/generator/TestProjects/CadlRanch.Tests/Http/SpecialHeaders/ConditionalRequest/ConditionalRequestHeaderTests.cs @@ -6,14 +6,14 @@ using NUnit.Framework; using SpecialHeaders.ConditionalRequest; -namespace TestProjects.CadlRanch.Tests.Http.SpecialHeaders.ConditionalRequests +namespace TestProjects.CadlRanch.Tests.Http.SpecialHeaders.ConditionalRequest { public class ConditionalRequestHeaderTests : CadlRanchTestBase { [CadlRanchTest] public Task Special_Headers_Conditional_Request_PostIfMatch() => Test(async (host) => { - string ifMatch = new string("valid"); + string ifMatch = "\"valid\""; var response = await new ConditionalRequestClient(host, null).PostIfMatchAsync(ifMatch); Assert.AreEqual(204, response.GetRawResponse().Status); }); @@ -21,7 +21,7 @@ public Task Special_Headers_Conditional_Request_PostIfMatch() => Test(async (hos [CadlRanchTest] public Task Special_Headers_Conditional_Request_PostIfNoneMatch() => Test(async (host) => { - string ifNoneMatch = new string("invalid"); + string ifNoneMatch = "\"invalid\""; var response = await new ConditionalRequestClient(host, null).PostIfNoneMatchAsync(ifNoneMatch); Assert.AreEqual(204, response.GetRawResponse().Status); }); From ff056eb7d4e53f29f23b1f2729849e084f6a9e1b Mon Sep 17 00:00:00 2001 From: iscai-msft <43154838+iscai-msft@users.noreply.github.com> Date: Tue, 14 Jan 2025 17:45:52 -0500 Subject: [PATCH 13/16] [python] import json encoder only when needed (#5607) fixes https://github.com/Azure/autorest.python/issues/3005 --------- Co-authored-by: iscai-msft --- packages/http-client-python/CHANGELOG.md | 1 + .../generator/pygen/codegen/models/operation.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/http-client-python/CHANGELOG.md b/packages/http-client-python/CHANGELOG.md index 789369c145..b96d339115 100644 --- a/packages/http-client-python/CHANGELOG.md +++ b/packages/http-client-python/CHANGELOG.md @@ -4,6 +4,7 @@ ### Bug Fixes +- Only import helpers for serialization if input body is not binary - Unify descriptions for credentials in documentation ### Other Changes diff --git a/packages/http-client-python/generator/pygen/codegen/models/operation.py b/packages/http-client-python/generator/pygen/codegen/models/operation.py index 880d1daa8b..7345882aec 100644 --- a/packages/http-client-python/generator/pygen/codegen/models/operation.py +++ b/packages/http-client-python/generator/pygen/codegen/models/operation.py @@ -35,6 +35,7 @@ ) from .parameter_list import ParameterList from .model_type import ModelType +from .primitive_types import BinaryType from .base import BaseType from .combined_type import CombinedType from .request_builder import OverloadedRequestBuilder, RequestBuilder @@ -432,7 +433,8 @@ def imports( # pylint: disable=too-many-branches, disable=too-many-statements file_import.add_submodule_import("typing", "overload", ImportType.STDLIB) if self.code_model.options["models_mode"] == "dpg": relative_path = self.code_model.get_relative_import_path(serialize_namespace, module_name="_model_base") - if self.parameters.has_body: + body_param = self.parameters.body_parameter if self.parameters.has_body else None + if body_param and not isinstance(body_param.type, BinaryType): if self.has_form_data_body: file_import.add_submodule_import( self.code_model.get_relative_import_path(serialize_namespace), "_model_base", ImportType.LOCAL From dd0b687731482b7a4b2e9425921efc17f5792989 Mon Sep 17 00:00:00 2001 From: Rodge Fu Date: Wed, 15 Jan 2025 09:26:08 +0800 Subject: [PATCH 14/16] Support Emitter section in init-template when creating TypeSpec project in vscode (#5594) Support Emitter section in init-template when creating TypeSpec project in vscode fixes: #5426 --- .../scaffolding-emitter-2025-0-14-11-30-33.md | 8 ++ packages/compiler/src/server/types.ts | 3 +- .../src/extension-state-manager.ts | 61 ++++++++++++ packages/typespec-vscode/src/extension.ts | 43 ++++++++- .../src/log/extension-log-listener.ts | 48 +++++++--- .../src/vscode-cmd/create-tsp-project.ts | 92 ++++++++++++++++++- 6 files changed, 235 insertions(+), 20 deletions(-) create mode 100644 .chronus/changes/scaffolding-emitter-2025-0-14-11-30-33.md create mode 100644 packages/typespec-vscode/src/extension-state-manager.ts diff --git a/.chronus/changes/scaffolding-emitter-2025-0-14-11-30-33.md b/.chronus/changes/scaffolding-emitter-2025-0-14-11-30-33.md new file mode 100644 index 0000000000..e0a563a43a --- /dev/null +++ b/.chronus/changes/scaffolding-emitter-2025-0-14-11-30-33.md @@ -0,0 +1,8 @@ +--- +changeKind: feature +packages: + - "@typespec/compiler" + - typespec-vscode +--- + +Support Emitters section in Init Template when creating TypeSpec project in vscode \ No newline at end of file diff --git a/packages/compiler/src/server/types.ts b/packages/compiler/src/server/types.ts index 1cbf9b6905..7601637da0 100644 --- a/packages/compiler/src/server/types.ts +++ b/packages/compiler/src/server/types.ts @@ -39,7 +39,7 @@ import { import { TextDocument, TextEdit } from "vscode-languageserver-textdocument"; import type { CompilerHost, Program, SourceFile, TypeSpecScriptNode } from "../core/index.js"; import { LoadedCoreTemplates } from "../init/core-templates.js"; -import { InitTemplate, InitTemplateLibrarySpec } from "../init/init-template.js"; +import { EmitterTemplate, InitTemplate, InitTemplateLibrarySpec } from "../init/init-template.js"; import { ScaffoldingConfig } from "../init/scaffold.js"; export type ServerLogLevel = "trace" | "debug" | "info" | "warning" | "error"; @@ -172,3 +172,4 @@ export interface InitProjectContext { export type InitProjectConfig = ScaffoldingConfig; export type InitProjectTemplate = InitTemplate; export type InitProjectTemplateLibrarySpec = InitTemplateLibrarySpec; +export type InitProjectTemplateEmitterTemplate = EmitterTemplate; diff --git a/packages/typespec-vscode/src/extension-state-manager.ts b/packages/typespec-vscode/src/extension-state-manager.ts new file mode 100644 index 0000000000..05a6960cfa --- /dev/null +++ b/packages/typespec-vscode/src/extension-state-manager.ts @@ -0,0 +1,61 @@ +import { LogLevel } from "rollup"; +import vscode from "vscode"; +import { normalizePath } from "./path-utils.js"; + +export interface StartUpMessage { + /** + * the message to show in the popup notification + */ + popupMessage: string; + /** + * the detail logged to the Output window + */ + detail: string; + /** + * the level used to show notification and log + */ + level: LogLevel; +} + +/** manage data stored in vscode extension's state (ExtensionContext.globalState/workspaceState) */ +export class ExtensionStateManager { + constructor(private vscodeContext: vscode.ExtensionContext) {} + + private getValue(key: string, defaultValue: T, isGlobal: boolean): T { + return isGlobal + ? this.vscodeContext.globalState.get(key, defaultValue) + : this.vscodeContext.workspaceState.get(key, defaultValue); + } + + /** + * + * @param key + * @param value must be JSON stringifyable, set to undefined to delete the key + * @param isGlobal + */ + private setValue(key: string, value: T | undefined, isGlobal: boolean) { + isGlobal + ? this.vscodeContext.globalState.update(key, value) + : this.vscodeContext.workspaceState.update(key, value); + } + + private getStartUpMessageKey(workspaceFolder: string) { + const ON_START_UP_MESSAGE_KEY_PREFIX = "onStartUpMessage-"; + const path = normalizePath(workspaceFolder); + return `${ON_START_UP_MESSAGE_KEY_PREFIX}${path}`; + } + + saveStartUpMessage(msg: StartUpMessage, workspaceFolder: string) { + const key = this.getStartUpMessageKey(workspaceFolder); + this.setValue(key, msg, true); + } + loadStartUpMessage(workspaceFolder: string): StartUpMessage | undefined { + const key = this.getStartUpMessageKey(workspaceFolder); + const value = this.getValue(key, undefined, true); + return value; + } + cleanUpStartUpMessage(workspaceFolder: string) { + const key = this.getStartUpMessageKey(workspaceFolder); + this.setValue(key, undefined, true); + } +} diff --git a/packages/typespec-vscode/src/extension.ts b/packages/typespec-vscode/src/extension.ts index 2d0f0cc45a..b45cca7e63 100644 --- a/packages/typespec-vscode/src/extension.ts +++ b/packages/typespec-vscode/src/extension.ts @@ -1,7 +1,8 @@ import vscode, { commands, ExtensionContext, TabInputText } from "vscode"; import { State } from "vscode-languageclient"; import { createCodeActionProvider } from "./code-action-provider.js"; -import { ExtensionLogListener } from "./log/extension-log-listener.js"; +import { ExtensionStateManager } from "./extension-state-manager.js"; +import { ExtensionLogListener, getPopupAction } from "./log/extension-log-listener.js"; import logger from "./log/logger.js"; import { TypeSpecLogOutputChannel } from "./log/typespec-log-output-channel.js"; import { createTaskProvider } from "./task-provider.js"; @@ -12,6 +13,7 @@ import { RestartServerCommandArgs, SettingName, } from "./types.js"; +import { isWhitespaceStringOrUndefined } from "./utils.js"; import { createTypeSpecProject } from "./vscode-cmd/create-tsp-project.js"; import { emitCode } from "./vscode-cmd/emit-code/emit-code.js"; import { installCompilerGlobally } from "./vscode-cmd/install-tsp-compiler.js"; @@ -25,6 +27,8 @@ const outputChannel = new TypeSpecLogOutputChannel("TypeSpec"); logger.registerLogListener("extension-log", new ExtensionLogListener(outputChannel)); export async function activate(context: ExtensionContext) { + const stateManager = new ExtensionStateManager(context); + context.subscriptions.push(createTaskProvider()); context.subscriptions.push(createCodeActionProvider()); @@ -99,7 +103,7 @@ export async function activate(context: ExtensionContext) { context.subscriptions.push( commands.registerCommand(CommandName.CreateProject, async () => { - await createTypeSpecProject(client); + await createTypeSpecProject(client, stateManager); }), ); @@ -143,7 +147,7 @@ export async function activate(context: ExtensionContext) { return t.input.uri.fsPath.endsWith(".tsp"); }) >= 0 ) { - return await vscode.window.withProgress( + await vscode.window.withProgress( { title: "Launching TypeSpec language service...", location: vscode.ProgressLocation.Notification, @@ -155,6 +159,7 @@ export async function activate(context: ExtensionContext) { } else { logger.info("No workspace opened, Skip starting TypeSpec language service."); } + showStartUpMessages(stateManager); } export async function deactivate() { @@ -169,3 +174,35 @@ async function recreateLSPClient(context: ExtensionContext) { await client.start(); return client; } + +function showStartUpMessages(stateManager: ExtensionStateManager) { + vscode.workspace.workspaceFolders?.forEach((workspaceFolder) => { + const msg = stateManager.loadStartUpMessage(workspaceFolder.uri.fsPath); + if (msg) { + logger.log("debug", "Start up message found for folder: " + workspaceFolder.uri.fsPath); + if (isWhitespaceStringOrUndefined(msg.detail)) { + logger.log(msg.level, msg.popupMessage, [], { + showPopup: true, + }); + } else { + const SHOW_DETAIL = "View Details in Output"; + const popupAction = getPopupAction(msg.level); + if (popupAction) { + popupAction(msg.popupMessage, SHOW_DETAIL).then((action) => { + if (action === SHOW_DETAIL) { + outputChannel.show(true); + } + // log the start up message to Output no matter user clicked the button or not + // and there are many logs coming when starting the extension, so + // log the message when the popup is clicked (or disappearing) to make sure these logs are shown at the end of the Output window to catch + // user's attention. + logger.log(msg.level, msg.popupMessage + "\n", [msg.detail]); + }); + } + } + } else { + logger.log("debug", "No start up message found for folder: " + workspaceFolder.uri.fsPath); + } + stateManager.cleanUpStartUpMessage(workspaceFolder.uri.fsPath); + }); +} diff --git a/packages/typespec-vscode/src/log/extension-log-listener.ts b/packages/typespec-vscode/src/log/extension-log-listener.ts index bc793cfb2f..c422057ea2 100644 --- a/packages/typespec-vscode/src/log/extension-log-listener.ts +++ b/packages/typespec-vscode/src/log/extension-log-listener.ts @@ -1,11 +1,29 @@ import vscode from "vscode"; -import { LogItem, LogListener, LogOptions } from "./logger.js"; +import { LogItem, LogLevel, LogListener, LogOptions } from "./logger.js"; export interface ExtensionLogOptions extends LogOptions { /** show the Output window in vscode */ - showOutput: boolean; + showOutput?: boolean; /** show the log in vscode popup */ - showPopup: boolean; + showPopup?: boolean; + /** the text of the button in the popup notification, default is 'View details in Output' */ + popupButtonText?: string; + /** callback when the button in the popup notification is clicked, default is to open the TypeSpec Output */ + onPopupButtonClicked?: () => void; +} + +export function getPopupAction(loglevel: LogLevel) { + switch (loglevel) { + case "error": + return vscode.window.showErrorMessage; + case "warn": + return vscode.window.showWarningMessage; + case "debug": + case "info": + return vscode.window.showInformationMessage; + default: // trace + return undefined; + } } export class ExtensionLogListener implements LogListener { @@ -13,27 +31,30 @@ export class ExtensionLogListener implements LogListener { Log(log: LogItem) { const VIEW_DETAIL_IN_OUTPUT = "View details in Output"; - const { showOutput, showPopup } = log.options ?? { showOutput: false, showPopup: false }; + const { showOutput, showPopup, popupButtonText, onPopupButtonClicked } = log.options ?? { + showOutput: false, + showPopup: false, + }; let popupAction: ((msg: string, ...items: string[]) => Thenable) | undefined; switch (log.level) { case "error": this.outputChannel?.error(log.message, ...(log.details ?? [])); - popupAction = vscode.window.showErrorMessage; + popupAction = getPopupAction(log.level); break; case "trace": this.outputChannel?.trace(log.message, ...(log.details ?? [])); break; case "debug": this.outputChannel?.debug(log.message, ...(log.details ?? [])); - popupAction = vscode.window.showInformationMessage; + popupAction = getPopupAction(log.level); break; case "info": this.outputChannel?.info(log.message, ...(log.details ?? [])); - popupAction = vscode.window.showInformationMessage; + popupAction = getPopupAction(log.level); break; case "warn": this.outputChannel?.warn(log.message, ...(log.details ?? [])); - popupAction = vscode.window.showWarningMessage; + popupAction = getPopupAction(log.level); break; } if (showOutput && this.outputChannel) { @@ -41,9 +62,14 @@ export class ExtensionLogListener implements LogListener { } if (showPopup && popupAction) { - void popupAction(log.message, VIEW_DETAIL_IN_OUTPUT).then((value) => { - if (value === VIEW_DETAIL_IN_OUTPUT) { - this.outputChannel?.show(true /*preserveFocus*/); + const buttonText = popupButtonText ?? VIEW_DETAIL_IN_OUTPUT; + void popupAction(log.message, buttonText).then((value) => { + if (value === buttonText) { + if (onPopupButtonClicked) { + onPopupButtonClicked(); + } else { + this.outputChannel?.show(true /*preserveFocus*/); + } } }); } diff --git a/packages/typespec-vscode/src/vscode-cmd/create-tsp-project.ts b/packages/typespec-vscode/src/vscode-cmd/create-tsp-project.ts index aaf0c667b0..404cc45fd1 100644 --- a/packages/typespec-vscode/src/vscode-cmd/create-tsp-project.ts +++ b/packages/typespec-vscode/src/vscode-cmd/create-tsp-project.ts @@ -1,14 +1,16 @@ import type { InitProjectConfig, InitProjectTemplate, + InitProjectTemplateEmitterTemplate, InitProjectTemplateLibrarySpec, } from "@typespec/compiler"; import { readdir } from "fs/promises"; import * as semver from "semver"; import vscode, { OpenDialogOptions, QuickPickItem, window } from "vscode"; import { State } from "vscode-languageclient"; +import { ExtensionStateManager } from "../extension-state-manager.js"; import logger from "../log/logger.js"; -import { getBaseFileName, getDirectoryPath, joinPaths } from "../path-utils.js"; +import { getBaseFileName, getDirectoryPath, joinPaths, normalizePath } from "../path-utils.js"; import { TspLanguageClient } from "../tsp-language-client.js"; import { CommandName, @@ -50,9 +52,17 @@ interface LibraryQuickPickItem extends QuickPickItem { version?: string; } +interface EmitterQuickPickItem extends QuickPickItem { + name: string; + emitterTemplate: InitProjectTemplateEmitterTemplate; +} + const COMPILER_CORE_TEMPLATES = "compiler-core-templates"; const TITLE = "Create a TypeSpec project"; -export async function createTypeSpecProject(client: TspLanguageClient | undefined) { +export async function createTypeSpecProject( + client: TspLanguageClient | undefined, + stateManager: ExtensionStateManager, +) { await vscode.window.withProgress( { location: vscode.ProgressLocation.Window, @@ -173,13 +183,18 @@ export async function createTypeSpecProject(client: TspLanguageClient | undefine return; } + const selectedEmitters = await selectEmitters(info); + if (selectedEmitters === undefined) { + logger.info("Creating TypeSpec Project cancelled when selecting emitters."); + return; + } + const inputs = await setInputs(info); if (inputs === undefined) { logger.info("Creating TypeSpec Project cancelled when setting inputs."); return; } - // TODO: add support for emitters picking const initTemplateConfig: InitProjectConfig = { template: info.template!, directory: selectedRootFolder, @@ -189,7 +204,7 @@ export async function createTypeSpecProject(client: TspLanguageClient | undefine parameters: inputs ?? {}, includeGitignore: includeGitignore, libraries: librariesToInclude, - emitters: {}, + emitters: selectedEmitters, }; const initResult = await initProject(client, initTemplateConfig); if (!initResult) { @@ -207,16 +222,83 @@ export async function createTypeSpecProject(client: TspLanguageClient | undefine // just ignore the result from tsp install. We will open the project folder anyway. await tspInstall(client, selectedRootFolder); } + + const msg = Object.entries(selectedEmitters) + .filter(([_k, e]) => !isWhitespaceStringOrUndefined(e.message)) + .map(([k, e]) => `\t${k}: \n\t\t${e.message}`) + .join("\n"); + + if (!isWhitespaceStringOrUndefined(msg)) { + const p = normalizePath(selectedRootFolder); + if ( + vscode.workspace.workspaceFolders?.find((x) => normalizePath(x.uri.fsPath) === p) === + undefined + ) { + // if the folder is not opened as workspace, persist the message to extension state because + // openProjectFolder will reinitialize the extension. + stateManager.saveStartUpMessage( + { + popupMessage: + "Please review the message from emitters when creating TypeSpec Project", + detail: msg, + level: "warn", + }, + selectedRootFolder, + ); + } else { + logger.warning("Please review the message from emitters\n", [msg], { + showPopup: true, + notificationButtonText: "Review in Output", + }); + } + } + vscode.commands.executeCommand("vscode.openFolder", vscode.Uri.file(selectedRootFolder), { forceNewWindow: false, forceReuseWindow: true, noRecentEntry: false, }); - return; + logger.info(`Creating TypeSpec Project completed successfully in ${selectedRootFolder}.`); }, ); } +async function selectEmitters( + info: InitTemplateInfo, +): Promise | undefined> { + if (!info.template.emitters || typeof info.template.emitters !== "object") { + return {}; + } + + const emitterList: EmitterQuickPickItem[] = Object.entries(info.template.emitters).map( + ([name, emitter]) => { + return { + label: emitter.version ? `${name} (ver: ${emitter.version})` : name, + name: name, + detail: emitter.description, + picked: emitter.selected, + emitterTemplate: emitter, + }; + }, + ); + if (emitterList.length === 0) { + return {}; + } + + const selectedEmitters = await vscode.window.showQuickPick(emitterList, { + title: "Select emitters?", + canPickMany: true, + placeHolder: "Select emitters?", + ignoreFocusOut: true, + }); + + if (!selectedEmitters) { + return undefined; + } + + return Object.fromEntries(selectedEmitters.map((x) => [x.name, x.emitterTemplate])); +} + async function tspInstall( client: TspLanguageClient, directory: string, From c66168647646666fdfbafe7ee2aca7351fec7a55 Mon Sep 17 00:00:00 2001 From: Rodge Fu Date: Wed, 15 Jan 2025 09:43:53 +0800 Subject: [PATCH 15/16] Remove the vscode settings for CodeGeneration (#5612) We are changing to load the default emitters from compiler and will consolidate the related schema into compiler, so removing the related vscode settings for now to avoid releasing it publicly which is not necessary for now considering template+emitters+tspconfig.yaml has already fulfilled what we want. --- .../hide-codegen-config-2025-0-15-9-4-57.md | 7 ++ packages/typespec-vscode/package.json | 98 ------------------- packages/typespec-vscode/src/types.ts | 1 - .../src/vscode-cmd/emit-code/emitter.ts | 61 ++++++++++-- 4 files changed, 58 insertions(+), 109 deletions(-) create mode 100644 .chronus/changes/hide-codegen-config-2025-0-15-9-4-57.md diff --git a/.chronus/changes/hide-codegen-config-2025-0-15-9-4-57.md b/.chronus/changes/hide-codegen-config-2025-0-15-9-4-57.md new file mode 100644 index 0000000000..8c051f4208 --- /dev/null +++ b/.chronus/changes/hide-codegen-config-2025-0-15-9-4-57.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - typespec-vscode +--- + +remove vscode settings for code generation \ No newline at end of file diff --git a/packages/typespec-vscode/package.json b/packages/typespec-vscode/package.json index ac437f9cab..4942a3fdc2 100644 --- a/packages/typespec-vscode/package.json +++ b/packages/typespec-vscode/package.json @@ -108,104 +108,6 @@ ], "default": "off", "description": "Define whether/how the TypeSpec language server should send traces to client. For the traces to show properly in vscode Output, make sure 'Log Level' is also set to 'Trace' so that they won't be filtered at client side, which can be set through 'Developer: Set Log Level...' command." - }, - "typespec.generateCode.emitters": { - "scope": "window", - "type": "array", - "items": { - "type": "object", - "properties": { - "language": { - "type": "string", - "enum": [ - ".NET", - "Java", - "JavaScript", - "Python", - "Go", - "OpenAPI3", - "ProtoBuf", - "JsonSchema" - ], - "description": "Define the language the emitter will emit." - }, - "package": { - "type": "string", - "description": "Define the emitter package.\n\nExample (with version): @typespec/http-client-csharp@1.0.0\n\nExample (without version): @typespec/http-client-csharp" - }, - "sourceRepo": { - "type": "string", - "description": "Define the source repository of the emitter package." - }, - "requisites": { - "type": "array", - "items": { - "type": "string" - }, - "description": "Define the requisites of the emitter package." - }, - "kind": { - "type": "string", - "enum": [ - "client", - "server", - "openapi" - ], - "description": "Define the emitter kind." - } - } - }, - "default": [ - { - "language": ".NET", - "package": "@typespec/http-client-csharp", - "sourceRepo": "https://github.com/microsoft/typespec/tree/main/packages/http-client-csharp", - "requisites": [ - ".NET 8.0 SDK" - ], - "kind": "client" - }, - { - "language": "Java", - "package": "@typespec/http-client-java", - "sourceRepo": "https://github.com/microsoft/typespec/tree/main/packages/http-client-java", - "requisites": [ - "Java 17 or above", - "Maven" - ], - "kind": "client" - }, - { - "language": "JavaScript", - "package": "@azure-tools/typespec-ts", - "sourceRepo": "https://github.com/Azure/autorest.typescript/tree/main/packages/typespec-ts", - "kind": "client" - }, - { - "language": "Python", - "package": "@typespec/http-client-python", - "sourceRepo": "https://github.com/microsoft/typespec/tree/main/packages/http-client-python", - "kind": "client" - }, - { - "language": ".NET", - "package": "@typespec/http-server-csharp", - "sourceRepo": "https://github.com/microsoft/typespec/tree/main/packages/http-server-csharp", - "kind": "server" - }, - { - "language": "JavaScript", - "package": "@typespec/http-server-javascript", - "sourceRepo": "https://github.com/microsoft/typespec/tree/main/packages/http-server-javascript", - "kind": "server" - }, - { - "language": "OpenAPI3", - "package": "@typespec/openapi3", - "sourceRepo": "https://github.com/microsoft/typespec/tree/main/packages/openapi3", - "kind": "openapi" - } - ] } } } diff --git a/packages/typespec-vscode/src/types.ts b/packages/typespec-vscode/src/types.ts index 9abd25fb26..fdf3d58ed7 100644 --- a/packages/typespec-vscode/src/types.ts +++ b/packages/typespec-vscode/src/types.ts @@ -1,7 +1,6 @@ export const enum SettingName { TspServerPath = "typespec.tsp-server.path", InitTemplatesUrls = "typespec.initTemplatesUrls", - GenerateCodeEmitters = "typespec.generateCode.emitters", } export const enum CommandName { diff --git a/packages/typespec-vscode/src/vscode-cmd/emit-code/emitter.ts b/packages/typespec-vscode/src/vscode-cmd/emit-code/emitter.ts index 3fe1fb4137..a7f8222286 100644 --- a/packages/typespec-vscode/src/vscode-cmd/emit-code/emitter.ts +++ b/packages/typespec-vscode/src/vscode-cmd/emit-code/emitter.ts @@ -1,6 +1,5 @@ import vscode from "vscode"; import logger from "../../log/logger.js"; -import { SettingName } from "../../types.js"; export enum EmitterKind { Schema = "openapi", @@ -34,6 +33,54 @@ export const PreDefinedEmitterPickItems: Record = }, }; +// TODO: remove this when we can load default emitters from the compiler +const PreDefinedEmitters: ReadonlyArray = [ + { + language: ".NET", + package: "@typespec/http-client-csharp", + sourceRepo: "https://github.com/microsoft/typespec/tree/main/packages/http-client-csharp", + requisites: [".NET 8.0 SDK"], + kind: EmitterKind.Client, + }, + { + language: "Java", + package: "@typespec/http-client-java", + sourceRepo: "https://github.com/microsoft/typespec/tree/main/packages/http-client-java", + requisites: ["Java 17 or above", "Maven"], + kind: EmitterKind.Client, + }, + { + language: "JavaScript", + package: "@azure-tools/typespec-ts", + sourceRepo: "https://github.com/Azure/autorest.typescript/tree/main/packages/typespec-ts", + kind: EmitterKind.Client, + }, + { + language: "Python", + package: "@typespec/http-client-python", + sourceRepo: "https://github.com/microsoft/typespec/tree/main/packages/http-client-python", + kind: EmitterKind.Client, + }, + { + language: ".NET", + package: "@typespec/http-server-csharp", + sourceRepo: "https://github.com/microsoft/typespec/tree/main/packages/http-server-csharp", + kind: EmitterKind.Server, + }, + { + language: "JavaScript", + package: "@typespec/http-server-javascript", + sourceRepo: "https://github.com/microsoft/typespec/tree/main/packages/http-server-javascript", + kind: EmitterKind.Server, + }, + { + language: "OpenAPI3", + package: "@typespec/openapi3", + sourceRepo: "https://github.com/microsoft/typespec/tree/main/packages/openapi3", + kind: EmitterKind.Schema, + }, +]; + function getEmitter(kind: EmitterKind, emitter: Emitter): Emitter | undefined { let packageFullName: string = emitter.package; if (!packageFullName) { @@ -60,9 +107,7 @@ function getEmitter(kind: EmitterKind, emitter: Emitter): Emitter | undefined { } export function getRegisterEmitters(kind: EmitterKind): ReadonlyArray { - const extensionConfig = vscode.workspace.getConfiguration(); - const emitters: ReadonlyArray = - extensionConfig.get(SettingName.GenerateCodeEmitters) ?? []; + const emitters: ReadonlyArray = PreDefinedEmitters; return emitters .filter((emitter) => emitter.kind === kind) .map((emitter) => getEmitter(kind, emitter)) @@ -70,16 +115,12 @@ export function getRegisterEmitters(kind: EmitterKind): ReadonlyArray { } export function getRegisterEmitterTypes(): ReadonlyArray { - const extensionConfig = vscode.workspace.getConfiguration(); - const emitters: ReadonlyArray = - extensionConfig.get(SettingName.GenerateCodeEmitters) ?? []; + const emitters: ReadonlyArray = PreDefinedEmitters; return Array.from(new Set(emitters.map((emitter) => emitter.kind))); } export function getRegisterEmittersByPackage(packageName: string): Emitter | undefined { - const extensionConfig = vscode.workspace.getConfiguration(); - const emitters: ReadonlyArray = - extensionConfig.get(SettingName.GenerateCodeEmitters) ?? []; + const emitters: ReadonlyArray = PreDefinedEmitters; return emitters.find( (emitter) => emitter.package === packageName || emitter.package.startsWith(packageName + "@"), ); From 138173398f3d9bcc64cd2ec0f8bdc747fb4ba4da Mon Sep 17 00:00:00 2001 From: Wei Hu Date: Wed, 15 Jan 2025 09:48:37 +0800 Subject: [PATCH 16/16] Expose public APIs for Azure plugin to generate ResourceData (#5544) Expose more public APIs: - MrwSerializationtypeDefinition to manipulate serialization in sub-plugin - TypeFacotry.CreateModelCore to create ResourceData in Azure plugin The corresponding Azure plugin PR: https://github.com/Azure/azure-sdk-for-net/pull/47730 --- .../src/Providers/MrwSerializationTypeDefinition.cs | 3 +-- .../generator/Microsoft.Generator.CSharp/src/TypeFactory.cs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs index 80b55075be..b4e794f93a 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.ClientModel; using System.ClientModel.Primitives; using System.Collections.Generic; using System.Diagnostics; @@ -26,7 +25,7 @@ namespace Microsoft.Generator.CSharp.ClientModel.Providers /// /// This class provides the set of serialization models, methods, and interfaces for a given model. /// - internal class MrwSerializationTypeDefinition : TypeProvider + public class MrwSerializationTypeDefinition : TypeProvider { private const string JsonModelWriteCoreMethodName = "JsonModelWriteCore"; private const string JsonModelCreateCoreMethodName = "JsonModelCreateCore"; diff --git a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/TypeFactory.cs b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/TypeFactory.cs index 5dbaecfa82..e6f4f10277 100644 --- a/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/TypeFactory.cs +++ b/packages/http-client-csharp/generator/Microsoft.Generator.CSharp/src/TypeFactory.cs @@ -151,7 +151,7 @@ protected internal TypeFactory() return modelProvider; } - private ModelProvider? CreateModelCore(InputModelType model) + protected virtual ModelProvider? CreateModelCore(InputModelType model) { ModelProvider? type = new ModelProvider(model); if (Visitors.Count == 0)