diff --git a/README.md b/README.md index 600ba841e8..cbda7e27c3 100755 --- a/README.md +++ b/README.md @@ -28,13 +28,15 @@ More information about these can be found [here](https://github.com/Azure/autore ```yaml version: 3.0.6246 use-extension: - "@autorest/modelerfour": "4.10.258" + "@autorest/modelerfour": "4.10.268" modelerfour: # this runs a pre-namer step to clean up names prenamer: true # this will flatten modelers marked with 'x-ms-client-flatten' flatten-models: true + # this will make the content-type parameter always specified + always-create-content-type-parameter: true pipeline: typescript: # <- name of plugin diff --git a/src/generators/modelsGenerator.ts b/src/generators/modelsGenerator.ts index e2cf7ee6ac..1399b3db8a 100644 --- a/src/generators/modelsGenerator.ts +++ b/src/generators/modelsGenerator.ts @@ -402,13 +402,6 @@ function writeOptionalParameters( })) }); } - - modelsIndexFile.addTypeAlias({ - name: `${operationGroupName}${operationName}OptionalParams`, - docs: ["Optional parameters."], - isExported: true, - type: interfaceNames.join(" | ") - }); } else { modelsIndexFile.addInterface({ name: `${operationGroupName}${operationName}OptionalParams`, diff --git a/src/generators/operationGenerator.ts b/src/generators/operationGenerator.ts index 6c7ac99703..dcb5bf2a6e 100644 --- a/src/generators/operationGenerator.ts +++ b/src/generators/operationGenerator.ts @@ -34,7 +34,8 @@ import { SchemaType, ParameterLocation, ChoiceSchema, - SealedChoiceSchema + SealedChoiceSchema, + ConstantSchema } from "@azure-tools/codemodel"; import { getLanguageMetadata } from "../utils/languageHelpers"; @@ -201,7 +202,10 @@ function getOptionsParameter( operation: OperationDetails, parameters: ParameterDetails[], importedModels: Set, - { isOptional = true } = {} + { + isOptional = true, + mediaType + }: { isOptional?: boolean; mediaType?: string } = {} ): ParameterWithDescription { let type: string = "coreHttp.OperationOptions"; if ( @@ -209,7 +213,8 @@ function getOptionsParameter( includeOptional: true }).some(p => !p.required) ) { - type = `${operation.typeDetails.typeName}OptionalParams`; + const mediaPrefix = mediaType ? `$${mediaType}` : ""; + type = `${operation.typeDetails.typeName}${mediaPrefix}OptionalParams`; importedModels.add(type); } return { @@ -286,23 +291,44 @@ type ParameterWithDescription = OptionalKind< >; /** - * Write operations implementation, extracted from OperationGroupDetails, to the generated file + * Gets a list of parameter declarations for each overload the operation supports, + * and the list of parameter declarations for the base operation. */ -export function writeOperations( - operationGroupDetails: OperationGroupDetails, - operationGroupClass: ClassDeclaration, - importedModels: Set, +function getOperationParameterSignatures( + operation: OperationDetails, parameters: ParameterDetails[], - isInline = false + importedModels: Set, + operationGroupClass: ClassDeclaration ) { - operationGroupDetails.operations.forEach(operation => { - const responseName = getResponseType(operation, importedModels); - const paramDeclarations = filterOperationParameters( - parameters, - operation - ).map(param => { + const operationParameters = filterOperationParameters(parameters, operation, { + includeContentType: true + }); + + const operationRequests = operation.requests; + const overloadParameterDeclarations: ParameterWithDescription[][] = []; + const hasMultipleOverloads = operationRequests.length > 1; + + for (const request of operationRequests) { + const requestMediaType = request.mediaType; + // filter out parameters that belong to a different media type + const requestParameters = operationParameters.filter( + ({ targetMediaType }) => + !targetMediaType || requestMediaType === targetMediaType + ); + + // Convert parameters into TypeScript parameter declarations. + const parameterDeclarations = requestParameters.map< + ParameterWithDescription + >(param => { const { usedModels } = param.typeDetails; - const type = normalizeTypeName(param.typeDetails); + let type = normalizeTypeName(param.typeDetails); + if ( + param.typeDetails.isConstant && + param.typeDetails.typeName === "string" && + param.typeDetails.defaultValue + ) { + type = `"${param.typeDetails.defaultValue}"`; + } // If the type collides with the class name, use the alias const typeName = @@ -321,39 +347,141 @@ export function writeOperations( }; }); - const allParams = [ - ...paramDeclarations, - getOptionsParameter(operation, parameters, importedModels) - ]; + // add optional parameter + const optionalParameter = getOptionsParameter( + operation, + parameters, + importedModels, + { + mediaType: hasMultipleOverloads ? requestMediaType : undefined + } + ); + parameterDeclarations.push(optionalParameter); + overloadParameterDeclarations.push(parameterDeclarations); + } + + // Create the parameter declarations for the base method signature. + const baseMethodParameters = getBaseMethodParameterDeclarations( + overloadParameterDeclarations + ); + + return { overloadParameterDeclarations, baseMethodParameters }; +} + +/** + * Given a list of operation parameter declarations per overload, + * returns a list of the parameter declarations that should appear + * in the operation's base signature. + * + * If `overloadParameterDeclarations` contains the parameter declarations for + * just a single overload, then the return value will be the same as the 1st + * element in `overloadParameterDeclarations`. + * @param overloadParameterDeclarations + */ +function getBaseMethodParameterDeclarations( + overloadParameterDeclarations: ParameterWithDescription[][] +): ParameterWithDescription[] { + const baseMethodParameters: ParameterWithDescription[] = []; + // Need to know which overload has the most parameters to set our upper bound. + const maxOverloadSize = Math.max( + ...overloadParameterDeclarations.map(params => params.length) + ); + for (let i = 0; i < maxOverloadSize; i++) { + // attempt to combine types + const declarations: ParameterWithDescription[] = []; + for (const overloadParameterDeclaration of overloadParameterDeclarations) { + if (overloadParameterDeclaration[i]) { + declarations.push(overloadParameterDeclaration[i]); + } + } + + const declaration = declarations.reduce( + (prevDeclaration, curDeclaration) => { + prevDeclaration = { ...prevDeclaration }; + if (curDeclaration.name !== prevDeclaration.name) { + // Currently we only generate overloads if an operation supports multiple media types. + // Since contentType is always required and the 1st parameter, parameter names/ordering + // shouldn't change. + // In order to support more variance in parameter naming/ordering, we'll need to be able + // to construct the OperationArguments separately for each overload. + throw new Error( + `Operation overloads with different parameter names/ordering not supported.` + ); + } + if (curDeclaration.type !== prevDeclaration.type) { + prevDeclaration.type += ` | ${curDeclaration.type}`; + } + // parameters should be optional if any declaration is optional + if (!curDeclaration.hasQuestionToken) { + prevDeclaration.hasQuestionToken = curDeclaration.hasQuestionToken; + } + return prevDeclaration; + } + ); + baseMethodParameters.push(declaration); + } + return baseMethodParameters; +} + +/** + * Write operations implementation, extracted from OperationGroupDetails, to the generated file + */ +export function writeOperations( + operationGroupDetails: OperationGroupDetails, + operationGroupClass: ClassDeclaration, + importedModels: Set, + parameters: ParameterDetails[], + isInline = false +) { + operationGroupDetails.operations.forEach(operation => { + const { + baseMethodParameters, + overloadParameterDeclarations + } = getOperationParameterSignatures( + operation, + parameters, + importedModels, + operationGroupClass + ); + const responseName = getResponseType(operation, importedModels); const operationMethod = operationGroupClass.addMethod({ name: normalizeName(operation.name, NameType.Property), - parameters: allParams, + parameters: baseMethodParameters, returnType: `Promise<${responseName}>`, - docs: [generateOperationJSDoc(allParams, operation.description)] + docs: [ + generateOperationJSDoc(baseMethodParameters, operation.description) + ] }); - const sendParams = paramDeclarations.map(p => p.name).join(","); - - if (operation.mediaTypes.size > 1) { - // This condition implies that the user can specify a contentType, - // and this contentType can change how the request is serialized. - writeMultiMediaTypeOperationBody( - operationMethod, - operation, - sendParams, - responseName, - isInline + const sendParams = baseMethodParameters.map(p => p.name).join(","); + if (overloadParameterDeclarations.length === 1) { + operationMethod.addStatements( + `return this${ + isInline ? "" : ".client" + }.sendOperationRequest({${sendParams}${!!sendParams ? "," : ""}}, ${ + operation.name + }OperationSpec) as Promise<${responseName}>` ); return; } - operationMethod.addStatements( - `return this${ - isInline ? "" : ".client" - }.sendOperationRequest({${sendParams}${ - !!sendParams ? "," : "" - } options}, ${operation.name}OperationSpec) as Promise<${responseName}>` + for (const overload of overloadParameterDeclarations) { + operationMethod.addOverload({ + parameters: overload, + returnType: `Promise<${responseName}>`, + docs: [generateOperationJSDoc(overload, operation.description)] + }); + } + + // This condition implies that the user can specify a contentType, + // and this contentType can change how the request is serialized. + writeMultiMediaTypeOperationBody( + operationMethod, + operation, + sendParams, + responseName, + isInline ); }); } @@ -373,43 +501,39 @@ function writeMultiMediaTypeOperationBody( let statements = `let operationSpec: coreHttp.OperationSpec;`; // We need to use the contentType parameter to determine which spec to use. const conditionals: string[] = []; - let hasOptionalContentType = false; for (const request of operation.requests) { const mediaType = request.mediaType!; - // check for contentType choice const validContentTypes = getContentTypeValues(request); + + // Ensure that a contentType exists, otherwise we won't be able to determine which operation spec to use. if (!validContentTypes) { - if (hasOptionalContentType) { - throw new Error( - `Encountered two operation media types that had unspecified values for contentType for operation "${operation.fullName}".` - ); - } - hasOptionalContentType = true; - // When no value for content-type is present, then we know this is the final 'else' block. - conditionals.push(`{ - operationSpec = ${operation.name}$${mediaType}OperationSpec; - }`); - } else { - conditionals.splice( - 0, - 0, - `if ( - options && "contentType" in options && - [${validContentTypes - .map(type => `"${type}"`) - .join(", ")}].indexOf(options.contentType ?? "") > -1 - ) { - operationSpec = ${operation.name}$${mediaType}OperationSpec; - }` + throw new Error( + `Encountered an operation media type that has unspecified values for the contentType for operation "${operation.fullName}".` ); } + + conditionals.push( + `if ( + [${validContentTypes + .map(type => `"${type}"`) + .join(", ")}].indexOf(contentType) > -1 + ) { + operationSpec = ${operation.name}$${mediaType}OperationSpec; + }` + ); } + + // Add an else clause that throws an error. This should never happen as long as a contentType was provided by the user. + conditionals.push(`{ + throw new TypeError(\`"contentType" must be a valid value but instead was "\${contentType}".\`); + }`); + statements += conditionals.join(" else "); statements += `return this${ isInline ? "" : ".client" }.sendOperationRequest({${sendParams}${ !!sendParams ? "," : "" - } options}, operationSpec) as Promise<${responseName}>`; + }}, operationSpec) as Promise<${responseName}>`; operationMethod.addStatements(statements); } @@ -419,16 +543,25 @@ function getContentTypeValues( const parameters = request.parameters ?? []; for (const parameter of parameters) { const parameterMetadata = getLanguageMetadata(parameter.language); + const paramLowerSerializedName = parameterMetadata.serializedName?.toLowerCase(); + const parameterInHeader = + parameter.protocol.http?.in === ParameterLocation.Header; const schema = parameter.schema; if ( (schema.type === SchemaType.Choice || schema.type === SchemaType.SealedChoice) && - parameterMetadata.serializedName.toLowerCase() === "content-type" && - parameter.protocol.http?.in === ParameterLocation.Header + paramLowerSerializedName === "content-type" && + parameterInHeader ) { return (schema as ChoiceSchema | SealedChoiceSchema).choices.map( c => c.value as string ); + } else if ( + schema.type === SchemaType.Constant && + paramLowerSerializedName === "content-type" && + parameterInHeader + ) { + return [(schema as ConstantSchema).value.value]; } } return; diff --git a/src/generators/utils/parameterUtils.ts b/src/generators/utils/parameterUtils.ts index fe40f91bbb..dc728c0e93 100644 --- a/src/generators/utils/parameterUtils.ts +++ b/src/generators/utils/parameterUtils.ts @@ -3,7 +3,11 @@ import { ParameterDetails } from "../../models/parameterDetails"; import { OperationDetails } from "../../models/operationDetails"; -import { ImplementationLocation, SchemaType } from "@azure-tools/codemodel"; +import { + ImplementationLocation, + SchemaType, + ParameterLocation +} from "@azure-tools/codemodel"; import { wrapString, IndentationType } from "./stringUtils"; interface ParameterFilterOptions { @@ -12,6 +16,8 @@ interface ParameterFilterOptions { includeUriParameters?: boolean; includeGlobalParameters?: boolean; includeConstantParameters?: boolean; + // Whether the contentType parameter should always be included. + includeContentType?: boolean; } /** @@ -28,13 +34,18 @@ export function filterOperationParameters( includeOptional, includeClientParams, includeGlobalParameters, - includeConstantParameters + includeConstantParameters, + includeContentType }: ParameterFilterOptions = {} ) { + const isContentType = (param: ParameterDetails) => + param.name === "contentType" && param.location === ParameterLocation.Header; + const optionalFilter = (param: ParameterDetails) => !!(includeOptional || param.required); const constantFilter = (param: ParameterDetails) => + (includeContentType && isContentType(param)) || !!(includeConstantParameters || param.schemaType !== SchemaType.Constant); const clientParamFilter = (param: ParameterDetails) => diff --git a/src/transforms/extensions.ts b/src/transforms/extensions.ts index d6e7b3fea9..b457f6fd35 100644 --- a/src/transforms/extensions.ts +++ b/src/transforms/extensions.ts @@ -25,10 +25,8 @@ export function normalizeModelWithExtensions(codeModel: CodeModel) { } /** - * This updates parameters that should be serialized as a Content-Type header. - * This logic should be able to be removed once modelerfour includes - * the serializedName and http protocol details: - * https://github.com/Azure/autorest.modelerfour/issues/207 + * This updates the contentType parameter for operations + * that support multiple media types to be required. * @param codeModel */ function normalizeMultipleContentTypes(codeModel: CodeModel) { @@ -38,7 +36,7 @@ function normalizeMultipleContentTypes(codeModel: CodeModel) { for (const operation of operations) { const requests = operation.requests; - if (!requests) { + if (!requests || requests.length <= 1) { continue; } @@ -50,15 +48,8 @@ function normalizeMultipleContentTypes(codeModel: CodeModel) { for (const parameter of parameters) { const parameterMetadata = getLanguageMetadata(parameter.language); - if ( - !parameter.protocol.http && - !parameterMetadata.serializedName && - parameterMetadata.name.toLowerCase() === "contenttype" - ) { - parameterMetadata.serializedName = "Content-Type"; - const http = new Protocol(); - http.in = ParameterLocation.Header; - parameter.protocol.http = http; + if (parameterMetadata.name.toLowerCase() === "contenttype") { + parameter.required = true; } } } diff --git a/src/utils/schemaHelpers.ts b/src/utils/schemaHelpers.ts index 279391c03d..f7c866f84c 100644 --- a/src/utils/schemaHelpers.ts +++ b/src/utils/schemaHelpers.ts @@ -59,7 +59,6 @@ export function getTypeForSchema(schema: Schema): TypeDetails { case SchemaType.Constant: const constantSchema = schema as ConstantSchema; const constantType = getTypeForSchema(constantSchema.valueType); - typeName = constantType.typeName; kind = constantType.kind; if (isModelNeeded(constantType)) { usedModels.push(typeName); @@ -69,6 +68,7 @@ export function getTypeForSchema(schema: Schema): TypeDetails { constantSchema.valueType.type, false ); + typeName = constantType.typeName; break; case SchemaType.DateTime: case SchemaType.Date: diff --git a/test/integration/generated/azureReport/src/reportClient.ts b/test/integration/generated/azureReport/src/reportClient.ts index a60e98319b..91dd024ae5 100644 --- a/test/integration/generated/azureReport/src/reportClient.ts +++ b/test/integration/generated/azureReport/src/reportClient.ts @@ -12,8 +12,8 @@ import * as Models from "./models"; import * as Mappers from "./models/mappers"; import { ReportClientContext } from "./reportClientContext"; import { - ReportClientGetReportResponse, - ReportClientGetReportOptionalParams + ReportClientGetReportOptionalParams, + ReportClientGetReportResponse } from "./models"; class ReportClient extends ReportClientContext { diff --git a/test/integration/generated/bodyArray/src/models/parameters.ts b/test/integration/generated/bodyArray/src/models/parameters.ts index 2f8829e742..ab1f0cf102 100644 --- a/test/integration/generated/bodyArray/src/models/parameters.ts +++ b/test/integration/generated/bodyArray/src/models/parameters.ts @@ -21,6 +21,18 @@ export const $host: coreHttp.OperationURLParameter = { skipEncoding: true }; +export const contentType: coreHttp.OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + serializedName: "Content-Type", + isConstant: true, + type: { + name: "String" + } + } +}; + export const arrayBody: coreHttp.OperationParameter = { parameterPath: "arrayBody", mapper: { diff --git a/test/integration/generated/bodyArray/src/operations/array.ts b/test/integration/generated/bodyArray/src/operations/array.ts index a6f8521e8d..e2b15e30bf 100644 --- a/test/integration/generated/bodyArray/src/operations/array.ts +++ b/test/integration/generated/bodyArray/src/operations/array.ts @@ -1106,6 +1106,7 @@ const putEmptyOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getBooleanTfftOperationSpec: coreHttp.OperationSpec = { @@ -1139,6 +1140,7 @@ const putBooleanTfftOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody1, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getBooleanInvalidNullOperationSpec: coreHttp.OperationSpec = { @@ -1212,6 +1214,7 @@ const putIntegerValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody2, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getIntInvalidNullOperationSpec: coreHttp.OperationSpec = { @@ -1285,6 +1288,7 @@ const putLongValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody3, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getLongInvalidNullOperationSpec: coreHttp.OperationSpec = { @@ -1358,6 +1362,7 @@ const putFloatValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody4, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getFloatInvalidNullOperationSpec: coreHttp.OperationSpec = { @@ -1431,6 +1436,7 @@ const putDoubleValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody5, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getDoubleInvalidNullOperationSpec: coreHttp.OperationSpec = { @@ -1504,6 +1510,7 @@ const putStringValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody6, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getEnumValidOperationSpec: coreHttp.OperationSpec = { @@ -1540,6 +1547,7 @@ const putEnumValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody7, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getStringEnumValidOperationSpec: coreHttp.OperationSpec = { @@ -1573,6 +1581,7 @@ const putStringEnumValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody8, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getStringWithNullOperationSpec: coreHttp.OperationSpec = { @@ -1646,6 +1655,7 @@ const putUuidValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody9, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getUuidInvalidCharsOperationSpec: coreHttp.OperationSpec = { @@ -1699,6 +1709,7 @@ const putDateValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody10, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getDateInvalidNullOperationSpec: coreHttp.OperationSpec = { @@ -1772,6 +1783,7 @@ const putDateTimeValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody11, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getDateTimeInvalidNullOperationSpec: coreHttp.OperationSpec = { @@ -1848,6 +1860,7 @@ const putDateTimeRfc1123ValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody12, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getDurationValidOperationSpec: coreHttp.OperationSpec = { @@ -1881,6 +1894,7 @@ const putDurationValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody13, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getByteValidOperationSpec: coreHttp.OperationSpec = { @@ -1914,6 +1928,7 @@ const putByteValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody14, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getByteInvalidNullOperationSpec: coreHttp.OperationSpec = { @@ -2067,6 +2082,7 @@ const putComplexValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody15, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getArrayNullOperationSpec: coreHttp.OperationSpec = { @@ -2210,6 +2226,7 @@ const putArrayValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody16, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getDictionaryNullOperationSpec: coreHttp.OperationSpec = { @@ -2353,5 +2370,6 @@ const putDictionaryValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody17, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; diff --git a/test/integration/generated/bodyBoolean/src/models/parameters.ts b/test/integration/generated/bodyBoolean/src/models/parameters.ts index 3e7e192825..3b313fa430 100644 --- a/test/integration/generated/bodyBoolean/src/models/parameters.ts +++ b/test/integration/generated/bodyBoolean/src/models/parameters.ts @@ -21,6 +21,18 @@ export const $host: coreHttp.OperationURLParameter = { skipEncoding: true }; +export const contentType: coreHttp.OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + serializedName: "Content-Type", + isConstant: true, + type: { + name: "String" + } + } +}; + export const boolBody: coreHttp.OperationParameter = { parameterPath: "boolBody", mapper: { diff --git a/test/integration/generated/bodyBoolean/src/operations/bool.ts b/test/integration/generated/bodyBoolean/src/operations/bool.ts index 2d1009432a..3e20815ac1 100644 --- a/test/integration/generated/bodyBoolean/src/operations/bool.ts +++ b/test/integration/generated/bodyBoolean/src/operations/bool.ts @@ -130,6 +130,7 @@ const putTrueOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.boolBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getFalseOperationSpec: coreHttp.OperationSpec = { @@ -157,6 +158,7 @@ const putFalseOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.boolBody1, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getNullOperationSpec: coreHttp.OperationSpec = { diff --git a/test/integration/generated/bodyBooleanQuirks/src/models/parameters.ts b/test/integration/generated/bodyBooleanQuirks/src/models/parameters.ts index ef5d8012f3..89d27c0dc4 100644 --- a/test/integration/generated/bodyBooleanQuirks/src/models/parameters.ts +++ b/test/integration/generated/bodyBooleanQuirks/src/models/parameters.ts @@ -21,6 +21,18 @@ export const $host: coreHttp.OperationURLParameter = { skipEncoding: true }; +export const contentType: coreHttp.OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + serializedName: "Content-Type", + isConstant: true, + type: { + name: "String" + } + } +}; + export const boolBody: coreHttp.OperationParameter = { parameterPath: "boolBody", mapper: { diff --git a/test/integration/generated/bodyBooleanQuirks/src/operations/bool.ts b/test/integration/generated/bodyBooleanQuirks/src/operations/bool.ts index 147cd5d679..e1dd0f68aa 100644 --- a/test/integration/generated/bodyBooleanQuirks/src/operations/bool.ts +++ b/test/integration/generated/bodyBooleanQuirks/src/operations/bool.ts @@ -136,6 +136,7 @@ const putTrueOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.boolBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getFalseOperationSpec: coreHttp.OperationSpec = { @@ -163,6 +164,7 @@ const putFalseOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.boolBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getNullOperationSpec: coreHttp.OperationSpec = { diff --git a/test/integration/generated/bodyByte/src/models/parameters.ts b/test/integration/generated/bodyByte/src/models/parameters.ts index 31965601aa..4974a51c7e 100644 --- a/test/integration/generated/bodyByte/src/models/parameters.ts +++ b/test/integration/generated/bodyByte/src/models/parameters.ts @@ -21,6 +21,18 @@ export const $host: coreHttp.OperationURLParameter = { skipEncoding: true }; +export const contentType: coreHttp.OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + serializedName: "Content-Type", + isConstant: true, + type: { + name: "String" + } + } +}; + export const byteBody: coreHttp.OperationParameter = { parameterPath: "byteBody", mapper: { diff --git a/test/integration/generated/bodyByte/src/operations/byte.ts b/test/integration/generated/bodyByte/src/operations/byte.ts index e1318e26dc..6a3ddb6e38 100644 --- a/test/integration/generated/bodyByte/src/operations/byte.ts +++ b/test/integration/generated/bodyByte/src/operations/byte.ts @@ -151,6 +151,7 @@ const putNonAsciiOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.byteBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getInvalidOperationSpec: coreHttp.OperationSpec = { diff --git a/test/integration/generated/bodyComplex/src/models/parameters.ts b/test/integration/generated/bodyComplex/src/models/parameters.ts index 9e4204de5b..2013c7f41c 100644 --- a/test/integration/generated/bodyComplex/src/models/parameters.ts +++ b/test/integration/generated/bodyComplex/src/models/parameters.ts @@ -21,6 +21,18 @@ export const $host: coreHttp.OperationURLParameter = { skipEncoding: true }; +export const contentType: coreHttp.OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + serializedName: "Content-Type", + isConstant: true, + type: { + name: "String" + } + } +}; + export const complexBody: coreHttp.OperationParameter = { parameterPath: "complexBody", mapper: Mappers.Basic diff --git a/test/integration/generated/bodyComplex/src/operations/array.ts b/test/integration/generated/bodyComplex/src/operations/array.ts index cddf2fdfd1..3960b1b65b 100644 --- a/test/integration/generated/bodyComplex/src/operations/array.ts +++ b/test/integration/generated/bodyComplex/src/operations/array.ts @@ -130,6 +130,7 @@ const putValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody12, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getEmptyOperationSpec: coreHttp.OperationSpec = { @@ -157,6 +158,7 @@ const putEmptyOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody13, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getNotProvidedOperationSpec: coreHttp.OperationSpec = { diff --git a/test/integration/generated/bodyComplex/src/operations/basic.ts b/test/integration/generated/bodyComplex/src/operations/basic.ts index 6cc886ab45..f809b9bf41 100644 --- a/test/integration/generated/bodyComplex/src/operations/basic.ts +++ b/test/integration/generated/bodyComplex/src/operations/basic.ts @@ -141,6 +141,7 @@ const putValidOperationSpec: coreHttp.OperationSpec = { requestBody: Parameters.complexBody, queryParameters: [Parameters.apiVersion], urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getInvalidOperationSpec: coreHttp.OperationSpec = { diff --git a/test/integration/generated/bodyComplex/src/operations/dictionary.ts b/test/integration/generated/bodyComplex/src/operations/dictionary.ts index 32106e9509..8b12be5b75 100644 --- a/test/integration/generated/bodyComplex/src/operations/dictionary.ts +++ b/test/integration/generated/bodyComplex/src/operations/dictionary.ts @@ -144,6 +144,7 @@ const putValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody14, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getEmptyOperationSpec: coreHttp.OperationSpec = { @@ -171,6 +172,7 @@ const putEmptyOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody15, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getNullOperationSpec: coreHttp.OperationSpec = { diff --git a/test/integration/generated/bodyComplex/src/operations/inheritance.ts b/test/integration/generated/bodyComplex/src/operations/inheritance.ts index 9590e752ce..75efe76dfa 100644 --- a/test/integration/generated/bodyComplex/src/operations/inheritance.ts +++ b/test/integration/generated/bodyComplex/src/operations/inheritance.ts @@ -85,5 +85,6 @@ const putValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody16, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; diff --git a/test/integration/generated/bodyComplex/src/operations/polymorphicrecursive.ts b/test/integration/generated/bodyComplex/src/operations/polymorphicrecursive.ts index 14df8f4081..6f21f1b221 100644 --- a/test/integration/generated/bodyComplex/src/operations/polymorphicrecursive.ts +++ b/test/integration/generated/bodyComplex/src/operations/polymorphicrecursive.ts @@ -135,5 +135,6 @@ const putValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody20, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; diff --git a/test/integration/generated/bodyComplex/src/operations/polymorphism.ts b/test/integration/generated/bodyComplex/src/operations/polymorphism.ts index 0648ac7c84..83ed4eeb9d 100644 --- a/test/integration/generated/bodyComplex/src/operations/polymorphism.ts +++ b/test/integration/generated/bodyComplex/src/operations/polymorphism.ts @@ -254,6 +254,7 @@ const putValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody17, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getDotSyntaxOperationSpec: coreHttp.OperationSpec = { @@ -323,6 +324,7 @@ const putComplicatedOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody18, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const putMissingDiscriminatorOperationSpec: coreHttp.OperationSpec = { @@ -338,6 +340,7 @@ const putMissingDiscriminatorOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody18, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const putValidMissingRequiredOperationSpec: coreHttp.OperationSpec = { @@ -351,5 +354,6 @@ const putValidMissingRequiredOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody19, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; diff --git a/test/integration/generated/bodyComplex/src/operations/primitive.ts b/test/integration/generated/bodyComplex/src/operations/primitive.ts index c3eb37586a..7c241d7746 100644 --- a/test/integration/generated/bodyComplex/src/operations/primitive.ts +++ b/test/integration/generated/bodyComplex/src/operations/primitive.ts @@ -387,6 +387,7 @@ const putIntOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody1, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getLongOperationSpec: coreHttp.OperationSpec = { @@ -414,6 +415,7 @@ const putLongOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody2, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getFloatOperationSpec: coreHttp.OperationSpec = { @@ -441,6 +443,7 @@ const putFloatOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody3, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getDoubleOperationSpec: coreHttp.OperationSpec = { @@ -468,6 +471,7 @@ const putDoubleOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody4, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getBoolOperationSpec: coreHttp.OperationSpec = { @@ -495,6 +499,7 @@ const putBoolOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody5, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getStringOperationSpec: coreHttp.OperationSpec = { @@ -522,6 +527,7 @@ const putStringOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody6, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getDateOperationSpec: coreHttp.OperationSpec = { @@ -549,6 +555,7 @@ const putDateOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody7, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getDateTimeOperationSpec: coreHttp.OperationSpec = { @@ -576,6 +583,7 @@ const putDateTimeOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody8, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getDateTimeRfc1123OperationSpec: coreHttp.OperationSpec = { @@ -603,6 +611,7 @@ const putDateTimeRfc1123OperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody9, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getDurationOperationSpec: coreHttp.OperationSpec = { @@ -630,6 +639,7 @@ const putDurationOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody10, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getByteOperationSpec: coreHttp.OperationSpec = { @@ -657,5 +667,6 @@ const putByteOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody11, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; diff --git a/test/integration/generated/bodyComplex/src/operations/readonlyproperty.ts b/test/integration/generated/bodyComplex/src/operations/readonlyproperty.ts index 9ea054e83e..46eab57a95 100644 --- a/test/integration/generated/bodyComplex/src/operations/readonlyproperty.ts +++ b/test/integration/generated/bodyComplex/src/operations/readonlyproperty.ts @@ -83,5 +83,6 @@ const putValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.complexBody21, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; diff --git a/test/integration/generated/bodyDate/src/models/parameters.ts b/test/integration/generated/bodyDate/src/models/parameters.ts index 4a46525500..c5de1e55ae 100644 --- a/test/integration/generated/bodyDate/src/models/parameters.ts +++ b/test/integration/generated/bodyDate/src/models/parameters.ts @@ -21,6 +21,18 @@ export const $host: coreHttp.OperationURLParameter = { skipEncoding: true }; +export const contentType: coreHttp.OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + serializedName: "Content-Type", + isConstant: true, + type: { + name: "String" + } + } +}; + export const dateBody: coreHttp.OperationParameter = { parameterPath: "dateBody", mapper: { diff --git a/test/integration/generated/bodyDate/src/operations/date.ts b/test/integration/generated/bodyDate/src/operations/date.ts index 69fcfec8f4..1a997a4eef 100644 --- a/test/integration/generated/bodyDate/src/operations/date.ts +++ b/test/integration/generated/bodyDate/src/operations/date.ts @@ -212,6 +212,7 @@ const putMaxDateOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.dateBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getMaxDateOperationSpec: coreHttp.OperationSpec = { @@ -239,6 +240,7 @@ const putMinDateOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.dateBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getMinDateOperationSpec: coreHttp.OperationSpec = { diff --git a/test/integration/generated/bodyDateTime/src/models/parameters.ts b/test/integration/generated/bodyDateTime/src/models/parameters.ts index 8be62c3fc8..8e73e59172 100644 --- a/test/integration/generated/bodyDateTime/src/models/parameters.ts +++ b/test/integration/generated/bodyDateTime/src/models/parameters.ts @@ -21,6 +21,18 @@ export const $host: coreHttp.OperationURLParameter = { skipEncoding: true }; +export const contentType: coreHttp.OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + serializedName: "Content-Type", + isConstant: true, + type: { + name: "String" + } + } +}; + export const datetimeBody: coreHttp.OperationParameter = { parameterPath: "datetimeBody", mapper: { diff --git a/test/integration/generated/bodyDateTime/src/operations/datetime.ts b/test/integration/generated/bodyDateTime/src/operations/datetime.ts index 236a31d9dd..2501e430bb 100644 --- a/test/integration/generated/bodyDateTime/src/operations/datetime.ts +++ b/test/integration/generated/bodyDateTime/src/operations/datetime.ts @@ -399,6 +399,7 @@ const putUtcMaxDateTimeOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.datetimeBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const putUtcMaxDateTime7DigitsOperationSpec: coreHttp.OperationSpec = { @@ -412,6 +413,7 @@ const putUtcMaxDateTime7DigitsOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.datetimeBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getUtcLowercaseMaxDateTimeOperationSpec: coreHttp.OperationSpec = { @@ -467,6 +469,7 @@ const putLocalPositiveOffsetMaxDateTimeOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.datetimeBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getLocalPositiveOffsetLowercaseMaxDateTimeOperationSpec: coreHttp.OperationSpec = { @@ -508,6 +511,7 @@ const putLocalNegativeOffsetMaxDateTimeOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.datetimeBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getLocalNegativeOffsetUppercaseMaxDateTimeOperationSpec: coreHttp.OperationSpec = { @@ -549,6 +553,7 @@ const putUtcMinDateTimeOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.datetimeBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getUtcMinDateTimeOperationSpec: coreHttp.OperationSpec = { @@ -576,6 +581,7 @@ const putLocalPositiveOffsetMinDateTimeOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.datetimeBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getLocalPositiveOffsetMinDateTimeOperationSpec: coreHttp.OperationSpec = { @@ -603,6 +609,7 @@ const putLocalNegativeOffsetMinDateTimeOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.datetimeBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getLocalNegativeOffsetMinDateTimeOperationSpec: coreHttp.OperationSpec = { diff --git a/test/integration/generated/bodyDateTimeRfc1123/src/models/parameters.ts b/test/integration/generated/bodyDateTimeRfc1123/src/models/parameters.ts index f79e884199..becf933193 100644 --- a/test/integration/generated/bodyDateTimeRfc1123/src/models/parameters.ts +++ b/test/integration/generated/bodyDateTimeRfc1123/src/models/parameters.ts @@ -21,6 +21,18 @@ export const $host: coreHttp.OperationURLParameter = { skipEncoding: true }; +export const contentType: coreHttp.OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + serializedName: "Content-Type", + isConstant: true, + type: { + name: "String" + } + } +}; + export const datetimeBody: coreHttp.OperationParameter = { parameterPath: "datetimeBody", mapper: { diff --git a/test/integration/generated/bodyDateTimeRfc1123/src/operations/datetimerfc1123.ts b/test/integration/generated/bodyDateTimeRfc1123/src/operations/datetimerfc1123.ts index 25d1309cfe..0a67f033aa 100644 --- a/test/integration/generated/bodyDateTimeRfc1123/src/operations/datetimerfc1123.ts +++ b/test/integration/generated/bodyDateTimeRfc1123/src/operations/datetimerfc1123.ts @@ -238,6 +238,7 @@ const putUtcMaxDateTimeOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.datetimeBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getUtcLowercaseMaxDateTimeOperationSpec: coreHttp.OperationSpec = { @@ -285,6 +286,7 @@ const putUtcMinDateTimeOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.datetimeBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getUtcMinDateTimeOperationSpec: coreHttp.OperationSpec = { diff --git a/test/integration/generated/bodyDictionary/src/models/parameters.ts b/test/integration/generated/bodyDictionary/src/models/parameters.ts index a69ece5850..a9c6504563 100644 --- a/test/integration/generated/bodyDictionary/src/models/parameters.ts +++ b/test/integration/generated/bodyDictionary/src/models/parameters.ts @@ -21,6 +21,18 @@ export const $host: coreHttp.OperationURLParameter = { skipEncoding: true }; +export const contentType: coreHttp.OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + serializedName: "Content-Type", + isConstant: true, + type: { + name: "String" + } + } +}; + export const arrayBody: coreHttp.OperationParameter = { parameterPath: "arrayBody", mapper: { diff --git a/test/integration/generated/bodyDictionary/src/operations/dictionary.ts b/test/integration/generated/bodyDictionary/src/operations/dictionary.ts index 3f7bbec76f..dace8ac9d1 100644 --- a/test/integration/generated/bodyDictionary/src/operations/dictionary.ts +++ b/test/integration/generated/bodyDictionary/src/operations/dictionary.ts @@ -1025,6 +1025,7 @@ const putEmptyOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getNullValueOperationSpec: coreHttp.OperationSpec = { @@ -1138,6 +1139,7 @@ const putBooleanTfftOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody1, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getBooleanInvalidNullOperationSpec: coreHttp.OperationSpec = { @@ -1211,6 +1213,7 @@ const putIntegerValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody2, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getIntInvalidNullOperationSpec: coreHttp.OperationSpec = { @@ -1284,6 +1287,7 @@ const putLongValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody3, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getLongInvalidNullOperationSpec: coreHttp.OperationSpec = { @@ -1357,6 +1361,7 @@ const putFloatValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody4, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getFloatInvalidNullOperationSpec: coreHttp.OperationSpec = { @@ -1430,6 +1435,7 @@ const putDoubleValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody5, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getDoubleInvalidNullOperationSpec: coreHttp.OperationSpec = { @@ -1503,6 +1509,7 @@ const putStringValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody6, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getStringWithNullOperationSpec: coreHttp.OperationSpec = { @@ -1576,6 +1583,7 @@ const putDateValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody7, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getDateInvalidNullOperationSpec: coreHttp.OperationSpec = { @@ -1649,6 +1657,7 @@ const putDateTimeValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody8, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getDateTimeInvalidNullOperationSpec: coreHttp.OperationSpec = { @@ -1725,6 +1734,7 @@ const putDateTimeRfc1123ValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody9, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getDurationValidOperationSpec: coreHttp.OperationSpec = { @@ -1758,6 +1768,7 @@ const putDurationValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody10, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getByteValidOperationSpec: coreHttp.OperationSpec = { @@ -1791,6 +1802,7 @@ const putByteValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody11, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getByteInvalidNullOperationSpec: coreHttp.OperationSpec = { @@ -1944,6 +1956,7 @@ const putComplexValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody12, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getArrayNullOperationSpec: coreHttp.OperationSpec = { @@ -2096,6 +2109,7 @@ const putArrayValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody13, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getDictionaryNullOperationSpec: coreHttp.OperationSpec = { @@ -2209,5 +2223,6 @@ const putDictionaryValidOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.arrayBody14, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; diff --git a/test/integration/generated/bodyDuration/src/models/parameters.ts b/test/integration/generated/bodyDuration/src/models/parameters.ts index 5dbfc2b310..066cd0d602 100644 --- a/test/integration/generated/bodyDuration/src/models/parameters.ts +++ b/test/integration/generated/bodyDuration/src/models/parameters.ts @@ -21,6 +21,18 @@ export const $host: coreHttp.OperationURLParameter = { skipEncoding: true }; +export const contentType: coreHttp.OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + serializedName: "Content-Type", + isConstant: true, + type: { + name: "String" + } + } +}; + export const durationBody: coreHttp.OperationParameter = { parameterPath: "durationBody", mapper: { diff --git a/test/integration/generated/bodyDuration/src/operations/duration.ts b/test/integration/generated/bodyDuration/src/operations/duration.ts index 4d3a64a3a4..af1bf2dd08 100644 --- a/test/integration/generated/bodyDuration/src/operations/duration.ts +++ b/test/integration/generated/bodyDuration/src/operations/duration.ts @@ -113,6 +113,7 @@ const putPositiveDurationOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.durationBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getPositiveDurationOperationSpec: coreHttp.OperationSpec = { diff --git a/test/integration/generated/bodyInteger/src/models/parameters.ts b/test/integration/generated/bodyInteger/src/models/parameters.ts index 1b42ea6d99..10d5202de1 100644 --- a/test/integration/generated/bodyInteger/src/models/parameters.ts +++ b/test/integration/generated/bodyInteger/src/models/parameters.ts @@ -21,6 +21,18 @@ export const $host: coreHttp.OperationURLParameter = { skipEncoding: true }; +export const contentType: coreHttp.OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + serializedName: "Content-Type", + isConstant: true, + type: { + name: "String" + } + } +}; + export const intBody: coreHttp.OperationParameter = { parameterPath: "intBody", mapper: { diff --git a/test/integration/generated/bodyInteger/src/operations/int.ts b/test/integration/generated/bodyInteger/src/operations/int.ts index 34c7d6bbca..36c55ab87e 100644 --- a/test/integration/generated/bodyInteger/src/operations/int.ts +++ b/test/integration/generated/bodyInteger/src/operations/int.ts @@ -325,6 +325,7 @@ const putMax32OperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.intBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const putMax64OperationSpec: coreHttp.OperationSpec = { @@ -338,6 +339,7 @@ const putMax64OperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.intBody1, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const putMin32OperationSpec: coreHttp.OperationSpec = { @@ -351,6 +353,7 @@ const putMin32OperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.intBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const putMin64OperationSpec: coreHttp.OperationSpec = { @@ -364,6 +367,7 @@ const putMin64OperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.intBody1, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getUnixTimeOperationSpec: coreHttp.OperationSpec = { @@ -391,6 +395,7 @@ const putUnixTimeDateOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.intBody2, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getInvalidUnixTimeOperationSpec: coreHttp.OperationSpec = { diff --git a/test/integration/generated/bodyNumber/src/models/parameters.ts b/test/integration/generated/bodyNumber/src/models/parameters.ts index 5f42e7310c..3899142a2a 100644 --- a/test/integration/generated/bodyNumber/src/models/parameters.ts +++ b/test/integration/generated/bodyNumber/src/models/parameters.ts @@ -21,6 +21,18 @@ export const $host: coreHttp.OperationURLParameter = { skipEncoding: true }; +export const contentType: coreHttp.OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + serializedName: "Content-Type", + isConstant: true, + type: { + name: "String" + } + } +}; + export const numberBody: coreHttp.OperationParameter = { parameterPath: "numberBody", mapper: { diff --git a/test/integration/generated/bodyNumber/src/operations/number.ts b/test/integration/generated/bodyNumber/src/operations/number.ts index 2182865760..f9477181ee 100644 --- a/test/integration/generated/bodyNumber/src/operations/number.ts +++ b/test/integration/generated/bodyNumber/src/operations/number.ts @@ -434,6 +434,7 @@ const putBigFloatOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.numberBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getBigFloatOperationSpec: coreHttp.OperationSpec = { @@ -461,6 +462,7 @@ const putBigDoubleOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.numberBody1, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getBigDoubleOperationSpec: coreHttp.OperationSpec = { @@ -488,6 +490,7 @@ const putBigDoublePositiveDecimalOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.numberBody2, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getBigDoublePositiveDecimalOperationSpec: coreHttp.OperationSpec = { @@ -515,6 +518,7 @@ const putBigDoubleNegativeDecimalOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.numberBody3, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getBigDoubleNegativeDecimalOperationSpec: coreHttp.OperationSpec = { @@ -542,6 +546,7 @@ const putBigDecimalOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.numberBody4, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getBigDecimalOperationSpec: coreHttp.OperationSpec = { @@ -569,6 +574,7 @@ const putBigDecimalPositiveDecimalOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.numberBody5, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getBigDecimalPositiveDecimalOperationSpec: coreHttp.OperationSpec = { @@ -596,6 +602,7 @@ const putBigDecimalNegativeDecimalOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.numberBody6, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getBigDecimalNegativeDecimalOperationSpec: coreHttp.OperationSpec = { @@ -623,6 +630,7 @@ const putSmallFloatOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.numberBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getSmallFloatOperationSpec: coreHttp.OperationSpec = { @@ -650,6 +658,7 @@ const putSmallDoubleOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.numberBody1, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getSmallDoubleOperationSpec: coreHttp.OperationSpec = { @@ -677,6 +686,7 @@ const putSmallDecimalOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.numberBody4, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getSmallDecimalOperationSpec: coreHttp.OperationSpec = { diff --git a/test/integration/generated/bodyString/src/models/parameters.ts b/test/integration/generated/bodyString/src/models/parameters.ts index 297a69f8dd..62c7ad1be3 100644 --- a/test/integration/generated/bodyString/src/models/parameters.ts +++ b/test/integration/generated/bodyString/src/models/parameters.ts @@ -21,6 +21,18 @@ export const $host: coreHttp.OperationURLParameter = { skipEncoding: true }; +export const contentType: coreHttp.OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + serializedName: "Content-Type", + isConstant: true, + type: { + name: "String" + } + } +}; + export const stringBody: coreHttp.OperationParameter = { parameterPath: ["options", "stringBody"], mapper: { diff --git a/test/integration/generated/bodyString/src/operations/enum.ts b/test/integration/generated/bodyString/src/operations/enum.ts index b496d79fef..e2b29fa35e 100644 --- a/test/integration/generated/bodyString/src/operations/enum.ts +++ b/test/integration/generated/bodyString/src/operations/enum.ts @@ -151,6 +151,7 @@ const putNotExpandableOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.stringBody5, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getReferencedOperationSpec: coreHttp.OperationSpec = { @@ -184,6 +185,7 @@ const putReferencedOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.enumStringBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getReferencedConstantOperationSpec: coreHttp.OperationSpec = { @@ -211,5 +213,6 @@ const putReferencedConstantOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.enumStringBody1, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; diff --git a/test/integration/generated/bodyString/src/operations/string.ts b/test/integration/generated/bodyString/src/operations/string.ts index cc0fd8b3d0..5bd649098f 100644 --- a/test/integration/generated/bodyString/src/operations/string.ts +++ b/test/integration/generated/bodyString/src/operations/string.ts @@ -229,6 +229,7 @@ const putNullOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.stringBody, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getEmptyOperationSpec: coreHttp.OperationSpec = { @@ -256,6 +257,7 @@ const putEmptyOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.stringBody1, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getMbcsOperationSpec: coreHttp.OperationSpec = { @@ -283,6 +285,7 @@ const putMbcsOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.stringBody2, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getWhitespaceOperationSpec: coreHttp.OperationSpec = { @@ -310,6 +313,7 @@ const putWhitespaceOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.stringBody3, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getNotProvidedOperationSpec: coreHttp.OperationSpec = { @@ -365,6 +369,7 @@ const putBase64UrlEncodedOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.stringBody4, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getNullBase64UrlEncodedOperationSpec: coreHttp.OperationSpec = { diff --git a/test/integration/generated/mediaTypes/src/mediaTypesClient.ts b/test/integration/generated/mediaTypes/src/mediaTypesClient.ts index 3e8cc4573c..04fc99b782 100644 --- a/test/integration/generated/mediaTypes/src/mediaTypesClient.ts +++ b/test/integration/generated/mediaTypes/src/mediaTypesClient.ts @@ -12,8 +12,10 @@ import * as Models from "./models"; import * as Mappers from "./models/mappers"; import { MediaTypesClientContext } from "./mediaTypesClientContext"; import { - MediaTypesClientAnalyzeBodyResponse, - MediaTypesClientAnalyzeBodyOptionalParams + ContentType, + MediaTypesClientAnalyzeBody$binaryOptionalParams, + MediaTypesClientAnalyzeBody$jsonOptionalParams, + MediaTypesClientAnalyzeBodyResponse } from "./models"; class MediaTypesClient extends MediaTypesClientContext { @@ -27,26 +29,51 @@ class MediaTypesClient extends MediaTypesClientContext { /** * Analyze body, that could be different media types. + * @param contentType Upload file type * @param options The options parameters. */ analyzeBody( - options?: MediaTypesClientAnalyzeBodyOptionalParams + contentType: ContentType, + options?: MediaTypesClientAnalyzeBody$binaryOptionalParams + ): Promise; + /** + * Analyze body, that could be different media types. + * @param contentType Body Parameter content-type + * @param options The options parameters. + */ + analyzeBody( + contentType: "application/json", + options?: MediaTypesClientAnalyzeBody$jsonOptionalParams + ): Promise; + /** + * Analyze body, that could be different media types. + * @param contentType Upload file type + * @param options The options parameters. + */ + analyzeBody( + contentType: ContentType | "application/json", + options?: + | MediaTypesClientAnalyzeBody$binaryOptionalParams + | MediaTypesClientAnalyzeBody$jsonOptionalParams ): Promise { let operationSpec: coreHttp.OperationSpec; if ( - options && - "contentType" in options && ["application/pdf", "image/jpeg", "image/png", "image/tiff"].indexOf( - options.contentType ?? "" + contentType ) > -1 ) { operationSpec = analyzeBody$binaryOperationSpec; - } else { + } else if (["application/json"].indexOf(contentType) > -1) { operationSpec = analyzeBody$jsonOperationSpec; + } else { + throw new TypeError( + `"contentType" must be a valid value but instead was "${contentType}".` + ); } - return this.sendOperationRequest({ options }, operationSpec) as Promise< - MediaTypesClientAnalyzeBodyResponse - >; + return this.sendOperationRequest( + { contentType, options }, + operationSpec + ) as Promise; } } // Operation Specifications @@ -76,6 +103,7 @@ const analyzeBody$jsonOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.input1, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType1], serializer }; diff --git a/test/integration/generated/mediaTypes/src/models/index.ts b/test/integration/generated/mediaTypes/src/models/index.ts index cdec3d7896..85a82b90cf 100644 --- a/test/integration/generated/mediaTypes/src/models/index.ts +++ b/test/integration/generated/mediaTypes/src/models/index.ts @@ -32,10 +32,6 @@ export type ContentType = */ export interface MediaTypesClientAnalyzeBody$binaryOptionalParams extends coreHttp.OperationOptions { - /** - * Upload file type - */ - contentType?: ContentType; /** * Input parameter. */ @@ -53,13 +49,6 @@ export interface MediaTypesClientAnalyzeBody$jsonOptionalParams input?: SourcePath; } -/** - * Optional parameters. - */ -export type MediaTypesClientAnalyzeBodyOptionalParams = - | MediaTypesClientAnalyzeBody$binaryOptionalParams - | MediaTypesClientAnalyzeBody$jsonOptionalParams; - /** * Contains response data for the analyzeBody operation. */ diff --git a/test/integration/generated/mediaTypes/src/models/parameters.ts b/test/integration/generated/mediaTypes/src/models/parameters.ts index c8442654aa..e21b790e2e 100644 --- a/test/integration/generated/mediaTypes/src/models/parameters.ts +++ b/test/integration/generated/mediaTypes/src/models/parameters.ts @@ -10,9 +10,10 @@ import * as coreHttp from "@azure/core-http"; import * as Mappers from "../models/mappers"; export const contentType: coreHttp.OperationParameter = { - parameterPath: ["options", "contentType"], + parameterPath: "contentType", mapper: { serializedName: "Content-Type", + required: true, type: { name: "Enum", allowedValues: [ @@ -35,6 +36,18 @@ export const input: coreHttp.OperationParameter = { } }; +export const contentType1: coreHttp.OperationParameter = { + parameterPath: "contentType", + mapper: { + defaultValue: "application/json", + serializedName: "Content-Type", + isConstant: true, + type: { + name: "String" + } + } +}; + export const input1: coreHttp.OperationParameter = { parameterPath: ["options", "input"], mapper: Mappers.SourcePath diff --git a/test/integration/generated/modelFlattening/src/modelFlatteningClient.ts b/test/integration/generated/modelFlattening/src/modelFlatteningClient.ts index 5050c08c46..6a94ba8ea8 100644 --- a/test/integration/generated/modelFlattening/src/modelFlatteningClient.ts +++ b/test/integration/generated/modelFlattening/src/modelFlatteningClient.ts @@ -20,12 +20,12 @@ import { ModelFlatteningClientGetDictionaryResponse, ModelFlatteningClientPutResourceCollectionOptionalParams, ModelFlatteningClientGetResourceCollectionResponse, - ModelFlatteningClientPutSimpleProductResponse, ModelFlatteningClientPutSimpleProductOptionalParams, - ModelFlatteningClientPostFlattenedSimpleProductResponse, + ModelFlatteningClientPutSimpleProductResponse, ModelFlatteningClientPostFlattenedSimpleProductOptionalParams, - ModelFlatteningClientPutSimpleProductWithGroupingResponse, - ModelFlatteningClientPutSimpleProductWithGroupingOptionalParams + ModelFlatteningClientPostFlattenedSimpleProductResponse, + ModelFlatteningClientPutSimpleProductWithGroupingOptionalParams, + ModelFlatteningClientPutSimpleProductWithGroupingResponse } from "./models"; class ModelFlatteningClient extends ModelFlatteningClientContext { @@ -199,6 +199,7 @@ const putArrayOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.resourceArray, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getArrayOperationSpec: coreHttp.OperationSpec = { @@ -234,6 +235,7 @@ const putWrappedArrayOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.resourceArray1, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getWrappedArrayOperationSpec: coreHttp.OperationSpec = { @@ -267,6 +269,7 @@ const putDictionaryOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.resourceDictionary, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getDictionaryOperationSpec: coreHttp.OperationSpec = { @@ -300,6 +303,7 @@ const putResourceCollectionOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.resourceComplexObject, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const getResourceCollectionOperationSpec: coreHttp.OperationSpec = { @@ -329,6 +333,7 @@ const putSimpleProductOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.simpleBodyProduct, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const postFlattenedSimpleProductOperationSpec: coreHttp.OperationSpec = { @@ -344,6 +349,7 @@ const postFlattenedSimpleProductOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.simpleBodyProduct1, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], serializer }; const putSimpleProductWithGroupingOperationSpec: coreHttp.OperationSpec = { @@ -359,6 +365,7 @@ const putSimpleProductWithGroupingOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.simpleBodyProduct2, urlParameters: [Parameters.$host, Parameters.name], + headerParameters: [Parameters.contentType], serializer }; diff --git a/test/integration/generated/modelFlattening/src/models/parameters.ts b/test/integration/generated/modelFlattening/src/models/parameters.ts index 5c4d0e6dac..f68383fb7f 100644 --- a/test/integration/generated/modelFlattening/src/models/parameters.ts +++ b/test/integration/generated/modelFlattening/src/models/parameters.ts @@ -9,6 +9,18 @@ import * as coreHttp from "@azure/core-http"; import * as Mappers from "../models/mappers"; +export const contentType: coreHttp.OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + serializedName: "Content-Type", + isConstant: true, + type: { + name: "String" + } + } +}; + export const resourceArray: coreHttp.OperationParameter = { parameterPath: ["options", "resourceArray"], mapper: { diff --git a/test/integration/generated/paging/src/operations/paging.ts b/test/integration/generated/paging/src/operations/paging.ts index e602c0f6e5..8f26b37dd0 100644 --- a/test/integration/generated/paging/src/operations/paging.ts +++ b/test/integration/generated/paging/src/operations/paging.ts @@ -14,12 +14,12 @@ import { PagingGetNoItemNamePagesResponse, PagingGetNullNextLinkNamePagesResponse, PagingGetSinglePagesResponse, - PagingGetMultiplePagesResponse, PagingGetMultiplePagesOptionalParams, - PagingGetOdataMultiplePagesResponse, + PagingGetMultiplePagesResponse, PagingGetOdataMultiplePagesOptionalParams, - PagingGetMultiplePagesWithOffsetResponse, + PagingGetOdataMultiplePagesResponse, PagingGetMultiplePagesWithOffsetOptionalParams, + PagingGetMultiplePagesWithOffsetResponse, PagingGetMultiplePagesRetryFirstResponse, PagingGetMultiplePagesRetrySecondResponse, PagingGetSinglePagesFailureResponse, @@ -27,25 +27,25 @@ import { PagingGetMultiplePagesFailureUriResponse, PagingGetMultiplePagesFragmentNextLinkResponse, PagingGetMultiplePagesFragmentWithGroupingNextLinkResponse, - PagingGetMultiplePagesLROResponse, PagingGetMultiplePagesLROOptionalParams, + PagingGetMultiplePagesLROResponse, PagingNextFragmentResponse, PagingNextFragmentWithGroupingResponse, PagingGetNoItemNamePagesNextResponse, PagingGetSinglePagesNextResponse, - PagingGetMultiplePagesNextResponse, PagingGetMultiplePagesNextOptionalParams, - PagingGetOdataMultiplePagesNextResponse, + PagingGetMultiplePagesNextResponse, PagingGetOdataMultiplePagesNextOptionalParams, - PagingGetMultiplePagesWithOffsetNextResponse, + PagingGetOdataMultiplePagesNextResponse, PagingGetMultiplePagesWithOffsetNextOptionalParams, + PagingGetMultiplePagesWithOffsetNextResponse, PagingGetMultiplePagesRetryFirstNextResponse, PagingGetMultiplePagesRetrySecondNextResponse, PagingGetSinglePagesFailureNextResponse, PagingGetMultiplePagesFailureNextResponse, PagingGetMultiplePagesFailureUriNextResponse, - PagingGetMultiplePagesLRONextResponse, - PagingGetMultiplePagesLRONextOptionalParams + PagingGetMultiplePagesLRONextOptionalParams, + PagingGetMultiplePagesLRONextResponse } from "../models"; /** diff --git a/test/integration/generated/report/src/reportClient.ts b/test/integration/generated/report/src/reportClient.ts index 5ba602b57d..873d207a21 100644 --- a/test/integration/generated/report/src/reportClient.ts +++ b/test/integration/generated/report/src/reportClient.ts @@ -12,10 +12,10 @@ import * as Models from "./models"; import * as Mappers from "./models/mappers"; import { ReportClientContext } from "./reportClientContext"; import { - ReportClientGetReportResponse, ReportClientGetReportOptionalParams, - ReportClientGetOptionalReportResponse, - ReportClientGetOptionalReportOptionalParams + ReportClientGetReportResponse, + ReportClientGetOptionalReportOptionalParams, + ReportClientGetOptionalReportResponse } from "./models"; class ReportClient extends ReportClientContext { diff --git a/test/integration/generated/xmlservice/src/models/parameters.ts b/test/integration/generated/xmlservice/src/models/parameters.ts index 44436cb956..e012c2d992 100644 --- a/test/integration/generated/xmlservice/src/models/parameters.ts +++ b/test/integration/generated/xmlservice/src/models/parameters.ts @@ -22,6 +22,18 @@ export const $host: coreHttp.OperationURLParameter = { skipEncoding: true }; +export const contentType: coreHttp.OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/xml", + serializedName: "Content-Type", + isConstant: true, + type: { + name: "String" + } + } +}; + export const model: coreHttp.OperationParameter = { parameterPath: "model", mapper: Mappers.RootWithRefAndNoMeta @@ -147,6 +159,18 @@ export const properties1: coreHttp.OperationParameter = { } }; +export const contentType1: coreHttp.OperationParameter = { + parameterPath: ["options", "contentType"], + mapper: { + defaultValue: "application/json", + serializedName: "Content-Type", + isConstant: true, + type: { + name: "String" + } + } +}; + export const properties2: coreHttp.OperationParameter = { parameterPath: "properties", mapper: Mappers.JsonInput diff --git a/test/integration/generated/xmlservice/src/operations/xml.ts b/test/integration/generated/xmlservice/src/operations/xml.ts index 14c0989c91..9ed25cd76f 100644 --- a/test/integration/generated/xmlservice/src/operations/xml.ts +++ b/test/integration/generated/xmlservice/src/operations/xml.ts @@ -475,6 +475,7 @@ const putComplexTypeRefNoMetaOperationSpec: coreHttp.OperationSpec = { responses: { 201: {} }, requestBody: Parameters.model, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], isXML: true, contentType: "application/xml; charset=utf-8", serializer @@ -497,6 +498,7 @@ const putComplexTypeRefWithMetaOperationSpec: coreHttp.OperationSpec = { responses: { 201: {} }, requestBody: Parameters.model1, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], isXML: true, contentType: "application/xml; charset=utf-8", serializer @@ -527,6 +529,7 @@ const putSimpleOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.slideshow, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], isXML: true, contentType: "application/xml; charset=utf-8", serializer @@ -554,6 +557,7 @@ const putWrappedListsOperationSpec: coreHttp.OperationSpec = { }, requestBody: Parameters.wrappedLists, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], isXML: true, contentType: "application/xml; charset=utf-8", serializer @@ -587,6 +591,7 @@ const putEmptyListOperationSpec: coreHttp.OperationSpec = { responses: { 201: {} }, requestBody: Parameters.slideshow, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], isXML: true, contentType: "application/xml; charset=utf-8", serializer @@ -609,6 +614,7 @@ const putEmptyWrappedListsOperationSpec: coreHttp.OperationSpec = { responses: { 201: {} }, requestBody: Parameters.appleBarrel, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], isXML: true, contentType: "application/xml; charset=utf-8", serializer @@ -639,6 +645,7 @@ const putRootListOperationSpec: coreHttp.OperationSpec = { responses: { 201: {} }, requestBody: Parameters.bananas, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], isXML: true, contentType: "application/xml; charset=utf-8", serializer @@ -669,6 +676,7 @@ const putRootListSingleItemOperationSpec: coreHttp.OperationSpec = { responses: { 201: {} }, requestBody: Parameters.bananas, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], isXML: true, contentType: "application/xml; charset=utf-8", serializer @@ -699,6 +707,7 @@ const putEmptyRootListOperationSpec: coreHttp.OperationSpec = { responses: { 201: {} }, requestBody: Parameters.bananas, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], isXML: true, contentType: "application/xml; charset=utf-8", serializer @@ -721,6 +730,7 @@ const putEmptyChildElementOperationSpec: coreHttp.OperationSpec = { responses: { 201: {} }, requestBody: Parameters.banana, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], isXML: true, contentType: "application/xml; charset=utf-8", serializer @@ -758,6 +768,7 @@ const putServicePropertiesOperationSpec: coreHttp.OperationSpec = { requestBody: Parameters.properties, queryParameters: [Parameters.comp1, Parameters.restype], urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], isXML: true, contentType: "application/xml; charset=utf-8", serializer @@ -793,6 +804,7 @@ const putAclsOperationSpec: coreHttp.OperationSpec = { requestBody: Parameters.properties1, queryParameters: [Parameters.comp2, Parameters.restype1], urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType], isXML: true, contentType: "application/xml; charset=utf-8", serializer @@ -816,6 +828,7 @@ const jsonInputOperationSpec: coreHttp.OperationSpec = { responses: { 200: {} }, requestBody: Parameters.properties2, urlParameters: [Parameters.$host], + headerParameters: [Parameters.contentType1], serializer }; const jsonOutputOperationSpec: coreHttp.OperationSpec = { diff --git a/test/integration/mediaType.spec.ts b/test/integration/mediaType.spec.ts index 6bf5f58b44..d2b6c1f743 100644 --- a/test/integration/mediaType.spec.ts +++ b/test/integration/mediaType.spec.ts @@ -31,8 +31,7 @@ describe("Integration tests for MediaTypes", () => { describe("#analyzeBody", () => { it("works with binary content type", async () => { - const response = await client.analyzeBody({ - contentType: "application/pdf", + const response = await client.analyzeBody("application/pdf", { input: "PDF" }); @@ -47,7 +46,7 @@ describe("Integration tests for MediaTypes", () => { }); it("works with json content type", async () => { - const response = await client.analyzeBody({ + const response = await client.analyzeBody("application/json", { input: { source: "foo" } });