From 239f023d32c056b02cdabbdd49a41ea7dff23d56 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Thu, 22 Feb 2024 11:10:22 -0800 Subject: [PATCH 01/14] Uptake change to body consistency --- core | 2 +- packages/typespec-autorest/src/openapi.ts | 167 +++++++++++------- .../typespec-autorest/test/metadata.test.ts | 27 ++- .../typespec-autorest/test/parameters.test.ts | 69 +++++++- .../test/produces-consumes.test.ts | 2 +- .../test/return-types.test.ts | 137 +++++++++----- 6 files changed, 289 insertions(+), 115 deletions(-) diff --git a/core b/core index 753ca1ad9b..937353ad55 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 753ca1ad9b8a98857019c460929de6ac7c9498ab +Subproject commit 937353ad55a8822294c5ec50d38932336dd00424 diff --git a/packages/typespec-autorest/src/openapi.ts b/packages/typespec-autorest/src/openapi.ts index 73539ef146..c8c9ff9496 100644 --- a/packages/typespec-autorest/src/openapi.ts +++ b/packages/typespec-autorest/src/openapi.ts @@ -94,6 +94,7 @@ import { HttpOperation, HttpOperationParameters, HttpOperationResponse, + HttpOperationResponseBody, HttpStatusCodeRange, HttpStatusCodesEntry, MetadataInfo, @@ -109,6 +110,7 @@ import { getStatusCodeDescription, getVisibilitySuffix, isContentTypeHeader, + isExplicitBodyValid, isSharedRoute, reportIfNoRoutes, resolveRequestVisibility, @@ -148,6 +150,10 @@ import { } from "./types.js"; import { AutorestEmitterContext, resolveOperationId } from "./utils.js"; +interface SchemaContext { + readonly visibility: Visibility; + readonly ignoreMetadataAnnotations: boolean; +} const defaultOptions = { "output-file": "{azure-resource-provider-folder}/{service-name}/{version-status}/{version}/openapi.json", @@ -441,7 +447,10 @@ function createOAPIEmitter( } const parameters: OpenAPI2PathParameter[] = []; for (const prop of server.parameters.values()) { - const param = getOpenAPI2Parameter(prop, "path", Visibility.Read); + const param = getOpenAPI2Parameter(prop, "path", { + visibility: Visibility.Read, + ignoreMetadataAnnotations: false, + }); if ( prop.type.kind === "Scalar" && ignoreDiagnostics( @@ -843,7 +852,7 @@ function createOAPIEmitter( openapiResponse["x-ms-error-response"] = true; } const contentTypes: string[] = []; - let body: Type | undefined; + let body: HttpOperationResponseBody | undefined; for (const data of response.responses) { if (data.headers && Object.keys(data.headers).length > 0) { openapiResponse.headers ??= {}; @@ -853,20 +862,26 @@ function createOAPIEmitter( } if (data.body) { - if (body && body !== data.body.type) { + if (body && body.type !== data.body.type) { reportDiagnostic(program, { code: "duplicate-body-types", target: response.type, }); } - body = data.body.type; + body = data.body; contentTypes.push(...data.body.contentTypes); } } if (body) { - const isBinary = contentTypes.every((t) => isBinaryPayload(body!, t)); - openapiResponse.schema = isBinary ? { type: "file" } : getSchemaOrRef(body, Visibility.Read); + const isBinary = contentTypes.every((t) => isBinaryPayload(body!.type, t)); + openapiResponse.schema = isBinary + ? { type: "file" } + : getSchemaOrRef(body.type, { + visibility: Visibility.Read, + ignoreMetadataAnnotations: + body.isExplicit && !isExplicitBodyValid(program, body.property!), + }); } for (const contentType of contentTypes) { @@ -878,7 +893,10 @@ function createOAPIEmitter( function getResponseHeader(prop: ModelProperty): OpenAPI2HeaderDefinition { const header: any = {}; - populateParameter(header, prop, "header", Visibility.Read); + populateParameter(header, prop, "header", { + visibility: Visibility.Read, + ignoreMetadataAnnotations: false, + }); delete header.in; delete header.name; delete header.required; @@ -896,7 +914,7 @@ function createOAPIEmitter( return getRelativePathFromDirectory(getDirectoryPath(outputFile), absoluteRef, false); } - function getSchemaOrRef(type: Type, visibility: Visibility): any { + function getSchemaOrRef(type: Type, schemaContext: SchemaContext): any { const refUrl = getRef(program, type, { version: context.version, service: context.service }); if (refUrl) { return { @@ -930,14 +948,14 @@ function createOAPIEmitter( } if (type.kind === "ModelProperty") { - return resolveProperty(type, visibility); + return resolveProperty(type, schemaContext); } - type = metadataInfo.getEffectivePayloadType(type, visibility); + type = metadataInfo.getEffectivePayloadType(type, schemaContext.visibility); const name = getOpenAPITypeName(program, type, typeNameOptions); if (shouldInline(program, type)) { - const schema = getSchemaForInlineType(type, name, visibility); + const schema = getSchemaForInlineType(type, name, schemaContext); if (schema === undefined && isErrorType(type)) { // Exit early so that syntax errors are exposed. This error will @@ -952,18 +970,18 @@ function createOAPIEmitter( return schema; } else { // Use shared schema when type is not transformed by visibility from the canonical read visibility. - if (!metadataInfo.isTransformed(type, visibility)) { - visibility = Visibility.Read; + if (!metadataInfo.isTransformed(type, schemaContext.visibility)) { + schemaContext = { ...schemaContext, visibility: Visibility.Read }; } - const pending = pendingSchemas.getOrAdd(type, visibility, () => ({ + const pending = pendingSchemas.getOrAdd(type, schemaContext.visibility, () => ({ type, - visibility, - ref: refs.getOrAdd(type, visibility, () => new Ref()), + visibility: schemaContext.visibility, + ref: refs.getOrAdd(type, schemaContext.visibility, () => new Ref()), })); return { $ref: pending.ref }; } } - function getSchemaForInlineType(type: Type, name: string, visibility: Visibility) { + function getSchemaForInlineType(type: Type, name: string, context: SchemaContext) { if (inProgressInlineTypes.has(type)) { reportDiagnostic(program, { code: "inline-cycle", @@ -973,7 +991,7 @@ function createOAPIEmitter( return {}; } inProgressInlineTypes.add(type); - const schema = getSchemaForType(type, visibility); + const schema = getSchemaForType(type, context); inProgressInlineTypes.delete(type); return schema; } @@ -1044,7 +1062,12 @@ function createOAPIEmitter( if (httpOpParam.type === "header" && isContentTypeHeader(program, httpOpParam.param)) { continue; } - emitParameter(httpOpParam.param, httpOpParam.type, visibility, httpOpParam.name); + emitParameter( + httpOpParam.param, + httpOpParam.type, + { visibility, ignoreMetadataAnnotations: false }, + httpOpParam.name + ); } if (consumes.length === 0 && methodParams.body) { @@ -1060,9 +1083,15 @@ function createOAPIEmitter( if (methodParams.body && !isVoidType(methodParams.body.type)) { const isBinary = isBinaryPayload(methodParams.body.type, consumes); + const schemaContext = { + visibility, + ignoreMetadataAnnotations: + methodParams.body.isExplicit && + !isExplicitBodyValid(program, methodParams.body.parameter!), + }; const schema = isBinary ? { type: "string", format: "binary" } - : getSchemaOrRef(methodParams.body.type, visibility); + : getSchemaOrRef(methodParams.body.type, schemaContext); if (currentConsumes.has("multipart/form-data")) { const bodyModelType = methodParams.body.type; @@ -1070,14 +1099,14 @@ function createOAPIEmitter( compilerAssert(bodyModelType.kind === "Model", "Body should always be a Model."); if (bodyModelType) { for (const param of bodyModelType.properties.values()) { - emitParameter(param, "formData", visibility, getJsonName(param)); + emitParameter(param, "formData", schemaContext, getJsonName(param)); } } } else if (methodParams.body.parameter) { emitParameter( methodParams.body.parameter, "body", - visibility, + { visibility, ignoreMetadataAnnotations: false }, getJsonName(methodParams.body.parameter), schema ); @@ -1111,7 +1140,7 @@ function createOAPIEmitter( function emitParameter( param: ModelProperty, kind: OpenAPI2ParameterType, - visibility: Visibility, + schemaContext: SchemaContext, name?: string, typeOverride?: any ) { @@ -1124,17 +1153,17 @@ function createOAPIEmitter( // If the parameter already has a $ref, don't bother populating it if (!("$ref" in ph)) { - populateParameter(ph, param, kind, visibility, name, typeOverride); + populateParameter(ph, param, kind, schemaContext, name, typeOverride); } } function getSchemaForPrimitiveItems( type: Type, - visibility: Visibility, + schemaContext: SchemaContext, paramName: string, multipart?: boolean ): PrimitiveItems | undefined { - const fullSchema = getSchemaForType(type, visibility); + const fullSchema = getSchemaForType(type, schemaContext); if (fullSchema === undefined) { return undefined; } @@ -1152,7 +1181,7 @@ function createOAPIEmitter( function getFormDataSchema( type: Type, - visibility: Visibility, + schemaContext: SchemaContext, paramName: string ): Omit | undefined { if (isBytes(type)) { @@ -1164,7 +1193,7 @@ function createOAPIEmitter( if (isBytes(elementType)) { return { type: "array", items: { type: "string", format: "binary" } }; } - const schema = getSchemaForPrimitiveItems(elementType, visibility, paramName, true); + const schema = getSchemaForPrimitiveItems(elementType, schemaContext, paramName, true); if (schema === undefined) { return undefined; } @@ -1176,7 +1205,7 @@ function createOAPIEmitter( items: schema, }; } else { - const schema = getSchemaForPrimitiveItems(type, visibility, paramName, true); + const schema = getSchemaForPrimitiveItems(type, schemaContext, paramName, true); if (schema === undefined) { return undefined; @@ -1189,7 +1218,7 @@ function createOAPIEmitter( function getOpenAPI2Parameter( param: ModelProperty, kind: T, - visibility: Visibility, + schemaContext: SchemaContext, name?: string, bodySchema?: any ): OpenAPI2Parameter & { in: T } { @@ -1210,7 +1239,7 @@ function createOAPIEmitter( compilerAssert(bodySchema, "bodySchema argument is required to populate body parameter"); ph.schema = bodySchema; } else if (ph.in === "formData") { - Object.assign(ph, getFormDataSchema(param.type, visibility, ph.name)); + Object.assign(ph, getFormDataSchema(param.type, schemaContext, ph.name)); } else { const collectionFormat = ( kind === "query" @@ -1229,12 +1258,12 @@ function createOAPIEmitter( if (param.type.kind === "Model" && isArrayModelType(program, param.type)) { ph.type = "array"; const schema = { - ...getSchemaForPrimitiveItems(param.type.indexer.value, visibility, ph.name), + ...getSchemaForPrimitiveItems(param.type.indexer.value, schemaContext, ph.name), }; delete (schema as any).description; ph.items = schema; } else { - Object.assign(ph, getSchemaForPrimitiveItems(param.type, visibility, ph.name)); + Object.assign(ph, getSchemaForPrimitiveItems(param.type, schemaContext, ph.name)); } } @@ -1252,11 +1281,11 @@ function createOAPIEmitter( ph: OpenAPI2Parameter, param: ModelProperty, kind: OpenAPI2ParameterType, - visibility: Visibility, + schemaContext: SchemaContext, name?: string, bodySchema?: any ) { - Object.assign(ph, getOpenAPI2Parameter(param, kind, visibility, name, bodySchema)); + Object.assign(ph, getOpenAPI2Parameter(param, kind, schemaContext, name, bodySchema)); } function emitParameters() { @@ -1313,7 +1342,10 @@ function createOAPIEmitter( for (const [visibility, pending] of group) { processedSchemas.getOrAdd(type, visibility, () => ({ ...pending, - schema: getSchemaForType(type, visibility), + schema: getSchemaForType(type, { + visibility: visibility, + ignoreMetadataAnnotations: false, + }), })); } pendingSchemas.delete(type); @@ -1324,7 +1356,7 @@ function createOAPIEmitter( function processUnreferencedSchemas() { const addSchema = (type: Type) => { if (!processedSchemas.has(type) && !paramModels.has(type) && !shouldInline(program, type)) { - getSchemaOrRef(type, Visibility.Read); + getSchemaOrRef(type, { visibility: Visibility.Read, ignoreMetadataAnnotations: false }); } }; const skipSubNamespaces = isGlobalNamespace(program, serviceNamespace); @@ -1409,7 +1441,7 @@ function createOAPIEmitter( } } - function getSchemaForType(type: Type, visibility: Visibility): OpenAPI2Schema | undefined { + function getSchemaForType(type: Type, schemaContext: SchemaContext): OpenAPI2Schema | undefined { const builtinType = getSchemaForLiterals(type); if (builtinType !== undefined) { return builtinType; @@ -1419,15 +1451,15 @@ function createOAPIEmitter( case "Intrinsic": return getSchemaForIntrinsicType(type); case "Model": - return getSchemaForModel(type, visibility); + return getSchemaForModel(type, schemaContext); case "ModelProperty": - return getSchemaForType(type.type, visibility); + return getSchemaForType(type.type, schemaContext); case "Scalar": return getSchemaForScalar(type); case "Union": - return getSchemaForUnion(type, visibility); + return getSchemaForUnion(type, schemaContext); case "UnionVariant": - return getSchemaForUnionVariant(type, visibility); + return getSchemaForUnionVariant(type, schemaContext); case "Enum": return getSchemaForEnum(type); case "Tuple": @@ -1541,7 +1573,7 @@ function createOAPIEmitter( return applyIntrinsicDecorators(union, schema); } - function getSchemaForUnion(union: Union, visibility: Visibility): OpenAPI2Schema { + function getSchemaForUnion(union: Union, schemaContext: SchemaContext): OpenAPI2Schema { const nonNullOptions = [...union.variants.values()] .map((x) => x.type) .filter((t) => !isNullType(t)); @@ -1555,7 +1587,7 @@ function createOAPIEmitter( const type = nonNullOptions[0]; // Get the schema for the model type - const schema = getSchemaOrRef(type, visibility); + const schema = getSchemaOrRef(type, schemaContext); if (schema.$ref) { if (type.kind === "Model") { return { type: "object", allOf: [schema], "x-nullable": nullable }; @@ -1589,8 +1621,11 @@ function createOAPIEmitter( ); } - function getSchemaForUnionVariant(variant: UnionVariant, visibility: Visibility): OpenAPI2Schema { - return getSchemaForType(variant.type, visibility)!; + function getSchemaForUnionVariant( + variant: UnionVariant, + schemaContext: SchemaContext + ): OpenAPI2Schema { + return getSchemaForType(variant.type, schemaContext)!; } function getDefaultValue(type: Type): any { @@ -1633,8 +1668,8 @@ function createOAPIEmitter( ); } - function getSchemaForModel(model: Model, visibility: Visibility) { - const array = getArrayType(model, visibility); + function getSchemaForModel(model: Model, schemaContext: SchemaContext) { + const array = getArrayType(model, schemaContext); if (array) { return array; } @@ -1663,14 +1698,14 @@ function createOAPIEmitter( const properties: OpenAPI2Schema["properties"] = {}; if (isRecordModelType(program, model)) { - modelSchema.additionalProperties = getSchemaOrRef(model.indexer.value, visibility); + modelSchema.additionalProperties = getSchemaOrRef(model.indexer.value, schemaContext); } const derivedModels = model.derivedModels.filter(includeDerivedModel); // getSchemaOrRef on all children to push them into components.schemas for (const child of derivedModels) { - getSchemaOrRef(child, visibility); + getSchemaOrRef(child, schemaContext); } const discriminator = getDiscriminator(program, model); @@ -1691,7 +1726,13 @@ function createOAPIEmitter( applyExternalDocs(model, modelSchema); for (const prop of model.properties.values()) { - if (!metadataInfo.isPayloadProperty(prop, visibility)) { + if ( + !metadataInfo.isPayloadProperty( + prop, + schemaContext.visibility, + schemaContext.ignoreMetadataAnnotations + ) + ) { continue; } @@ -1713,7 +1754,10 @@ function createOAPIEmitter( } } - if (!metadataInfo.isOptional(prop, visibility) || prop.name === discriminator?.propertyName) { + if ( + !metadataInfo.isOptional(prop, schemaContext.visibility) || + prop.name === discriminator?.propertyName + ) { if (!modelSchema.required) { modelSchema.required = []; } @@ -1721,7 +1765,7 @@ function createOAPIEmitter( } // Apply decorators on the property to the type's schema - properties[jsonName] = resolveProperty(prop, visibility); + properties[jsonName] = resolveProperty(prop, schemaContext); const property: OpenAPI2SchemaProperty = properties[jsonName]; if (jsonName !== clientName) { property["x-ms-client-name"] = clientName; @@ -1771,10 +1815,10 @@ function createOAPIEmitter( ) { // Take the base model schema but carry across the documentation property // that we set before - const baseSchema = getSchemaForType(model.baseModel, visibility); + const baseSchema = getSchemaForType(model.baseModel, schemaContext); Object.assign(modelSchema, baseSchema, { description: modelSchema.description }); } else if (model.baseModel) { - const baseSchema = getSchemaOrRef(model.baseModel, visibility); + const baseSchema = getSchemaOrRef(model.baseModel, schemaContext); modelSchema.allOf = [baseSchema]; } @@ -1800,7 +1844,7 @@ function createOAPIEmitter( return true; } - function resolveProperty(prop: ModelProperty, visibility: Visibility): OpenAPI2SchemaProperty { + function resolveProperty(prop: ModelProperty, context: SchemaContext): OpenAPI2SchemaProperty { let propSchema; if (prop.type.kind === "Enum" && prop.default) { propSchema = getSchemaForEnum(prop.type); @@ -1809,10 +1853,10 @@ function createOAPIEmitter( if (asEnum) { propSchema = getSchemaForUnionEnum(prop.type, asEnum); } else { - propSchema = getSchemaOrRef(prop.type, visibility); + propSchema = getSchemaOrRef(prop.type, context); } } else { - propSchema = getSchemaOrRef(prop.type, visibility); + propSchema = getSchemaOrRef(prop.type, context); } return applyIntrinsicDecorators(prop, propSchema); @@ -2077,11 +2121,14 @@ function createOAPIEmitter( /** * If the model is an array model return the OpenAPI2Schema for the array type. */ - function getArrayType(typespecType: Model, visibility: Visibility): OpenAPI2Schema | undefined { + function getArrayType(typespecType: Model, context: SchemaContext): OpenAPI2Schema | undefined { if (isArrayModelType(program, typespecType)) { const array: OpenAPI2Schema = { type: "array", - items: getSchemaOrRef(typespecType.indexer.value!, visibility | Visibility.Item), + items: getSchemaOrRef(typespecType.indexer.value!, { + ...context, + visibility: context.visibility | Visibility.Item, + }), }; if (!ifArrayItemContainsIdentifier(program, typespecType as any)) { array["x-ms-identifiers"] = []; diff --git a/packages/typespec-autorest/test/metadata.test.ts b/packages/typespec-autorest/test/metadata.test.ts index d226006210..d29c53d1d1 100644 --- a/packages/typespec-autorest/test/metadata.test.ts +++ b/packages/typespec-autorest/test/metadata.test.ts @@ -334,7 +334,7 @@ describe("typespec-autorest: metadata", () => { @header h: string; } @route("/single") @get op single(...Parameters): string; - @route("/batch") @get op batch(...Body): string; + @route("/batch") @get op batch(@bodyRoot _: Parameters[]): string; ` ); deepStrictEqual(res.paths, { @@ -365,9 +365,8 @@ describe("typespec-autorest: metadata", () => { }, parameters: [ { - description: "The body type of the operation request or response.", in: "body", - name: "body", + name: "_", required: true, schema: { type: "array", @@ -606,15 +605,33 @@ describe("typespec-autorest: metadata", () => { PetCreate: { type: "object", properties: { + headers: { + type: "object", + properties: { + moreHeaders: { + type: "object", + }, + }, + required: ["moreHeaders"], + }, name: { type: "string", }, }, - required: ["name"], + required: ["headers", "name"], }, Pet: { type: "object", properties: { + headers: { + type: "object", + properties: { + moreHeaders: { + type: "object", + }, + }, + required: ["moreHeaders"], + }, id: { type: "string", }, @@ -622,7 +639,7 @@ describe("typespec-autorest: metadata", () => { type: "string", }, }, - required: ["id", "name"], + required: ["headers", "id", "name"], }, }); }); diff --git a/packages/typespec-autorest/test/parameters.test.ts b/packages/typespec-autorest/test/parameters.test.ts index 79bf7c437a..2717eca5bd 100644 --- a/packages/typespec-autorest/test/parameters.test.ts +++ b/packages/typespec-autorest/test/parameters.test.ts @@ -1,6 +1,6 @@ import { expectDiagnostics } from "@typespec/compiler/testing"; import { deepStrictEqual, ok, strictEqual } from "assert"; -import { describe, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { OpenAPI2HeaderParameter, OpenAPI2QueryParameter } from "../src/types.js"; import { diagnoseOpenApiFor, ignoreUseStandardOps, openApiFor } from "./test-host.js"; @@ -221,6 +221,73 @@ describe("typespec-autorest: parameters", () => { deepStrictEqual(res.paths["/"].post.parameters, []); }); + 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, + #suppress "@typespec/http/metadata-ignored" + @query query: string, + #suppress "@typespec/http/metadata-ignored" + @statusCode code: 201, + } + ): void;`); + expect(res.paths["/"].get.parameters[0].schema).toEqual({ + type: "object", + properties: { + header: { type: "string" }, + query: { type: "string" }, + code: { type: "number", enum: [201] }, + }, + required: ["header", "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); + } + ); + }); + + 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; + }; + name: string; + ): void;`); + expect(res.paths["/"].post.parameters[2].schema).toEqual({ + type: "object", + properties: { + headers: { type: "object" }, + name: { type: "string" }, + }, + required: ["headers", "name"], + }); + }); + + 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; + }; + name: string; + ): void;`); + expect(res.paths["/"].post.parameters[2].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( diff --git a/packages/typespec-autorest/test/produces-consumes.test.ts b/packages/typespec-autorest/test/produces-consumes.test.ts index 7e868ffbfa..332c13c807 100644 --- a/packages/typespec-autorest/test/produces-consumes.test.ts +++ b/packages/typespec-autorest/test/produces-consumes.test.ts @@ -128,7 +128,7 @@ function createAdlFromConfig(configuration: ProducesConsumesOperation[]): string configuration.forEach((config) => { const opString = config.type === "consumes" - ? `@delete op remove(@body payload : ${config.modelName}) : NoContentResponse;` + ? `@delete op remove(@bodyRoot payload : ${config.modelName}) : NoContentResponse;` : `@get op read() : ${config.modelName};`; const doc = ` ${config.modelDef} diff --git a/packages/typespec-autorest/test/return-types.test.ts b/packages/typespec-autorest/test/return-types.test.ts index 32305317c6..919f032c25 100644 --- a/packages/typespec-autorest/test/return-types.test.ts +++ b/packages/typespec-autorest/test/return-types.test.ts @@ -1,9 +1,27 @@ import { expectDiagnostics } from "@typespec/compiler/testing"; import { deepStrictEqual, ok, strictEqual } from "assert"; -import { describe, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { createAutorestTestRunner, ignoreUseStandardOps, openApiFor } from "./test-host.js"; describe("typespec-autorest: return types", () => { + it("model used with @body and without shouldn't conflict if it contains no metadata", async () => { + const res = await openApiFor( + ` + model Foo { + name: string; + } + @route("c1") op c1(): Foo; + @route("c2") op c2(): {@body _: Foo}; + ` + ); + deepStrictEqual(res.paths["/c1"].get.responses["200"].schema, { + $ref: "#/definitions/Foo", + }); + deepStrictEqual(res.paths["/c2"].get.responses["200"].schema, { + $ref: "#/definitions/Foo", + }); + }); + it("defines responses with response headers", async () => { const res = await openApiFor( ` @@ -254,34 +272,6 @@ describe("typespec-autorest: return types", () => { strictEqual(res.paths["/"].get.responses["200"].schema.type, "array"); }); - it("return type with no properties should be 200 with empty object as type", async () => { - const res = await openApiFor( - ` - @get op test(): {}; - ` - ); - - const responses = res.paths["/"].get.responses; - ok(responses["200"]); - deepStrictEqual(responses["200"].schema, { - type: "object", - }); - }); - - it("{} return type should produce 200 ", async () => { - const res = await openApiFor( - ` - @get op test(): {}; - ` - ); - - const responses = res.paths["/"].get.responses; - ok(responses["200"]); - deepStrictEqual(responses["200"].schema, { - type: "object", - }); - }); - it("produce additionalProperties schema if response is Record", async () => { const res = await openApiFor( ` @@ -307,23 +297,9 @@ describe("typespec-autorest: return types", () => { ); const responses = res.paths["/"].get.responses; - ok(responses["204"]); - ok(responses["204"].schema === undefined, "response should have no content"); - ok(responses["200"] === undefined); - }); - - it("defaults status code to 204 when implicit body has no content", async () => { - const res = await openApiFor( - ` - @delete - op delete(): { @header date: string }; - ` - ); - const responses = res.paths["/"].delete.responses; - ok(responses["200"] === undefined); - ok(responses["204"]); - ok(responses["204"].headers["date"]); - ok(responses["204"].schema === undefined); + ok(responses["200"]); + ok(responses["200"].schema === undefined, "response should have no content"); + ok(responses["204"] === undefined); }); it("defaults status code to default when model has @error decorator", async () => { @@ -491,7 +467,74 @@ describe("typespec-autorest: return types", () => { it("defaults to 204 no content with void @body", async () => { const res = await openApiFor(`@get op read(): {@body body: void};`); - ok(res.paths["/"].get.responses["204"]); + ok(res.paths["/"].get.responses["200"]); + }); + + 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, + #suppress "@typespec/http/metadata-ignored" + @query query: string, + #suppress "@typespec/http/metadata-ignored" + @statusCode code: 201, + } + };`); + expect(res.paths["/"].get.responses["200"].schema).toEqual({ + type: "object", + properties: { + header: { type: "string" }, + query: { type: "string" }, + code: { type: "number", enum: [201] }, + }, + required: ["header", "query", "code"], + }); + }); + + describe("response model resolving to no property in the body produce no body", () => { + it.each(["{}", "{@header prop: string}", `{@visibility("none") prop: string}`])( + "%s", + async (body) => { + const res = await openApiFor(`op test(): ${body};`); + strictEqual(res.paths["/"].get.responses["200"].schema, undefined); + } + ); + }); + + 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; + }; + name: string; + };`); + expect(res.paths["/"].get.responses["200"].schema).toEqual({ + type: "object", + properties: { + headers: { type: "object" }, + name: { type: "string" }, + }, + required: ["headers", "name"], + }); + }); + + 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; + }; + name: string; + };`); + expect(res.paths["/"].get.responses["200"].schema).toEqual({ + type: "object", + properties: { + name: { type: "string" }, + }, + required: ["name"], + }); }); describe("binary responses", () => { From 80f5211891667be55e613ff6cbd23071b7c6a278 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Thu, 22 Feb 2024 18:00:51 -0800 Subject: [PATCH 02/14] Fix --- core | 2 +- .../liftr.confluent/confluent.tsp | 2 +- .../typespec-autorest/2022-08-31/openapi.json | 26 ++++----- .../openapi3/openapi.2022-08-31.yaml | 26 ++++----- .../typespec-autorest/openapi.json | 26 ++++----- .../@typespec/openapi3/openapi.yaml | 26 ++++----- .../typespec-autorest/2022-08-31/openapi.json | 2 +- .../openapi3/openapi.2022-08-31.yaml | 2 +- .../typespec-autorest/openapi.json | 24 ++++---- .../@typespec/openapi3/openapi.yaml | 24 ++++---- .../typespec-autorest/openapi.json | 32 +++++------ .../authoring/@typespec/openapi3/openapi.yaml | 32 +++++------ .../typespec-autorest/openapi.json | 42 +++++++------- .../Raw/@typespec/openapi3/openapi.yaml | 42 +++++++------- .../typespec-autorest/2022-08-31/openapi.json | 26 ++++----- .../typespec-autorest/2023-02-07/openapi.json | 26 ++++----- .../openapi3/openapi.2022-08-31.yaml | 26 ++++----- .../openapi3/openapi.2023-02-07.yaml | 26 ++++----- .../typespec-autorest/2022-08-31/openapi.json | 56 +++++++++++-------- .../openapi3/openapi.2022-08-31.yaml | 55 ++++++++++-------- .../typespec-autorest/openapi.json | 30 +++++----- .../appconfig/@typespec/openapi3/openapi.yaml | 30 +++++----- .../typespec-autorest/openapi.json | 2 +- .../typespec-azure-core/src/lro-helpers.ts | 10 +++- .../src/rules/request-body-array.ts | 4 +- .../test/operations.test.ts | 26 ++++----- .../lib/arm.foundations.tsp | 4 +- .../lib/responses.tsp | 19 +++++-- .../src/rules/arm-resource-patch.ts | 15 ++++- .../test/resource.test.ts | 7 ++- .../rules/arm-resource-operations.test.ts | 4 +- .../test/rules/core-operations.test.ts | 4 +- .../test/rules/no-response-body.test.ts | 2 +- .../test/rules/patch-envelope.test.ts | 2 +- .../test/rules/patch-operations.test.ts | 2 +- .../test/decorators.test.ts | 16 +++--- 36 files changed, 370 insertions(+), 330 deletions(-) diff --git a/core b/core index 937353ad55..141010518e 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 937353ad55a8822294c5ec50d38932336dd00424 +Subproject commit 141010518ebb7fd7e95857c334e196ddb41a4900 diff --git a/packages/samples/specs/resource-manager/liftr.confluent/confluent.tsp b/packages/samples/specs/resource-manager/liftr.confluent/confluent.tsp index 8d9238161f..fd0e2f4e18 100644 --- a/packages/samples/specs/resource-manager/liftr.confluent/confluent.tsp +++ b/packages/samples/specs/resource-manager/liftr.confluent/confluent.tsp @@ -164,7 +164,7 @@ interface MarketplaceAgreements extends ResourceListBySubscription, @doc("The agreement details.") - @body + @bodyRoot agreement: ConfluentAgreementResource, ): ArmResponse | ErrorResponse; } diff --git a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@azure-tools/typespec-autorest/2022-08-31/openapi.json index 837ba96f12..3e52adb192 100644 --- a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -34,7 +34,7 @@ ], "responses": { "200": { - "description": "The request has succeeded.", + "description": "Paged collection of Manufacturer items", "schema": { "$ref": "#/definitions/PagedManufacturer" }, @@ -47,7 +47,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -114,7 +114,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -256,7 +256,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -368,7 +368,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -437,7 +437,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -486,7 +486,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -526,7 +526,7 @@ ], "responses": { "200": { - "description": "The request has succeeded.", + "description": "Paged collection of Widget items", "schema": { "$ref": "#/definitions/PagedWidget" }, @@ -539,7 +539,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -606,7 +606,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -761,7 +761,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -874,7 +874,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -943,7 +943,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, diff --git a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml index ecef77debb..2d1c7878e9 100644 --- a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml @@ -13,7 +13,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: The request has succeeded. + description: Paged collection of Manufacturer items headers: x-ms-client-request-id: required: false @@ -25,7 +25,7 @@ paths: schema: $ref: '#/components/schemas/PagedManufacturer' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -101,7 +101,7 @@ paths: schema: $ref: '#/components/schemas/Manufacturer' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -154,7 +154,7 @@ paths: schema: $ref: '#/components/schemas/Manufacturer' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -224,7 +224,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -281,7 +281,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -318,7 +318,7 @@ paths: required: - statusString default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -342,7 +342,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: The request has succeeded. + description: Paged collection of Widget items headers: x-ms-client-request-id: required: false @@ -354,7 +354,7 @@ paths: schema: $ref: '#/components/schemas/PagedWidget' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -442,7 +442,7 @@ paths: schema: $ref: '#/components/schemas/Widget' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -495,7 +495,7 @@ paths: schema: $ref: '#/components/schemas/Widget' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -565,7 +565,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -622,7 +622,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false diff --git a/packages/samples/test/output/azure/core/data-plane/confidentialledger/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/core/data-plane/confidentialledger/@azure-tools/typespec-autorest/openapi.json index 56d8aadc7c..0cc7942f71 100644 --- a/packages/samples/test/output/azure/core/data-plane/confidentialledger/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/confidentialledger/@azure-tools/typespec-autorest/openapi.json @@ -81,7 +81,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -110,7 +110,7 @@ "description": "The request has succeeded." }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -139,7 +139,7 @@ "description": "The request has succeeded." }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -168,7 +168,7 @@ "description": "The request has succeeded." }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -200,7 +200,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -249,7 +249,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -291,7 +291,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -330,7 +330,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -369,7 +369,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -404,7 +404,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -444,7 +444,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -500,7 +500,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -535,7 +535,7 @@ "description": "There is no content to send for this request, but the headers may be useful. " }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, diff --git a/packages/samples/test/output/azure/core/data-plane/confidentialledger/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/azure/core/data-plane/confidentialledger/@typespec/openapi3/openapi.yaml index 7d5bee226c..c30a9bb5f1 100644 --- a/packages/samples/test/output/azure/core/data-plane/confidentialledger/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/azure/core/data-plane/confidentialledger/@typespec/openapi3/openapi.yaml @@ -21,7 +21,7 @@ paths: items: $ref: '#/components/schemas/Collection' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -43,7 +43,7 @@ paths: '200': description: The request has succeeded. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -65,7 +65,7 @@ paths: '200': description: The request has succeeded. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -87,7 +87,7 @@ paths: '200': description: The request has succeeded. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -113,7 +113,7 @@ paths: schema: $ref: '#/components/schemas/PagedLedgerEntries' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -141,7 +141,7 @@ paths: type: string format: uri default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -175,7 +175,7 @@ paths: schema: $ref: '#/components/schemas/LedgerEntry' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -208,7 +208,7 @@ paths: schema: $ref: '#/components/schemas/LedgerEntry' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -240,7 +240,7 @@ paths: schema: $ref: '#/components/schemas/TransactionReceipt' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -272,7 +272,7 @@ paths: schema: $ref: '#/components/schemas/TransactionStatus' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -302,7 +302,7 @@ paths: '204': description: 'There is no content to send for this request, but the headers may be useful. ' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -335,7 +335,7 @@ paths: schema: $ref: '#/components/schemas/LedgerUser' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -374,7 +374,7 @@ paths: schema: $ref: '#/components/schemas/LedgerUser' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false diff --git a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@azure-tools/typespec-autorest/2022-08-31/openapi.json index cc9e15912e..1e08a6fda1 100644 --- a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -46,7 +46,7 @@ ], "responses": { "200": { - "description": "The request has succeeded.", + "description": "Paged collection of Widget items", "schema": { "$ref": "#/definitions/PagedWidget" }, diff --git a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml index 42f0686242..679197fe43 100644 --- a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml @@ -17,7 +17,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: The request has succeeded. + description: Paged collection of Widget items headers: x-ms-client-request-id: required: false diff --git a/packages/samples/test/output/azure/core/data-plane/formrecognizer/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/core/data-plane/formrecognizer/@azure-tools/typespec-autorest/openapi.json index 6bae9fd02a..73d00dfc2f 100644 --- a/packages/samples/test/output/azure/core/data-plane/formrecognizer/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/formrecognizer/@azure-tools/typespec-autorest/openapi.json @@ -73,7 +73,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -187,7 +187,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -240,7 +240,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -282,7 +282,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -319,7 +319,7 @@ "description": "There is no content to send for this request, but the headers may be useful. " }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -368,7 +368,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -410,7 +410,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -455,7 +455,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -500,7 +500,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -534,7 +534,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -568,7 +568,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -612,7 +612,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, diff --git a/packages/samples/test/output/azure/core/data-plane/formrecognizer/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/azure/core/data-plane/formrecognizer/@typespec/openapi3/openapi.yaml index 44b7f29492..49d13f4e66 100644 --- a/packages/samples/test/output/azure/core/data-plane/formrecognizer/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/azure/core/data-plane/formrecognizer/@typespec/openapi3/openapi.yaml @@ -25,7 +25,7 @@ paths: schema: $ref: '#/components/schemas/PagedModelSummary' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -58,7 +58,7 @@ paths: schema: $ref: '#/components/schemas/ModelSummary' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -86,7 +86,7 @@ paths: '204': description: 'There is no content to send for this request, but the headers may be useful. ' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -125,7 +125,7 @@ paths: schema: $ref: '#/components/schemas/AnalyzeResultOperation' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -178,7 +178,7 @@ paths: schema: type: string default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -245,7 +245,7 @@ paths: schema: type: string default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -278,7 +278,7 @@ paths: schema: $ref: '#/components/schemas/CopyAuthorization' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -313,7 +313,7 @@ paths: schema: type: string default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -348,7 +348,7 @@ paths: schema: type: string default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -381,7 +381,7 @@ paths: schema: $ref: '#/components/schemas/GetInfoResponse' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -408,7 +408,7 @@ paths: schema: $ref: '#/components/schemas/PagedOperationInfo' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -441,7 +441,7 @@ paths: schema: $ref: '#/components/schemas/GetOperationResponse' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false diff --git a/packages/samples/test/output/azure/core/data-plane/language/authoring/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/core/data-plane/language/authoring/@azure-tools/typespec-autorest/openapi.json index 2ccfe74612..cc23588e7c 100644 --- a/packages/samples/test/output/azure/core/data-plane/language/authoring/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/language/authoring/@azure-tools/typespec-autorest/openapi.json @@ -72,7 +72,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -113,7 +113,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -181,7 +181,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -244,7 +244,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -290,7 +290,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -333,7 +333,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -385,7 +385,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -424,7 +424,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -472,7 +472,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -544,7 +544,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -614,7 +614,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -667,7 +667,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -719,7 +719,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -764,7 +764,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -805,7 +805,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -848,7 +848,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, diff --git a/packages/samples/test/output/azure/core/data-plane/language/authoring/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/azure/core/data-plane/language/authoring/@typespec/openapi3/openapi.yaml index e6c81e819f..758e9efac2 100644 --- a/packages/samples/test/output/azure/core/data-plane/language/authoring/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/azure/core/data-plane/language/authoring/@typespec/openapi3/openapi.yaml @@ -21,7 +21,7 @@ paths: schema: $ref: '#/components/schemas/PagedProject' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -49,7 +49,7 @@ paths: schema: $ref: '#/components/schemas/PagedSupportedLanguage' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -77,7 +77,7 @@ paths: schema: $ref: '#/components/schemas/PagedTrainingConfigVersion' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -128,7 +128,7 @@ paths: schema: $ref: '#/components/schemas/Project' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -165,7 +165,7 @@ paths: schema: $ref: '#/components/schemas/Project' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -218,7 +218,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -249,7 +249,7 @@ paths: schema: $ref: '#/components/schemas/PagedDeployment' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -286,7 +286,7 @@ paths: schema: $ref: '#/components/schemas/Deployment' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -342,7 +342,7 @@ paths: schema: $ref: '#/components/schemas/Deployment' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -408,7 +408,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -451,7 +451,7 @@ paths: schema: $ref: '#/components/schemas/DeploymentJob' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -494,7 +494,7 @@ paths: schema: $ref: '#/components/schemas/SwapDeploymentsJob' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -528,7 +528,7 @@ paths: type: string format: uri default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -570,7 +570,7 @@ paths: type: string format: uri default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -604,7 +604,7 @@ paths: type: string format: uri default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -638,7 +638,7 @@ paths: type: string format: uri default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false diff --git a/packages/samples/test/output/azure/core/data-plane/languageqna/Raw/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/core/data-plane/languageqna/Raw/@azure-tools/typespec-autorest/openapi.json index ec0fe43084..5f03c880f8 100644 --- a/packages/samples/test/output/azure/core/data-plane/languageqna/Raw/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/languageqna/Raw/@azure-tools/typespec-autorest/openapi.json @@ -71,7 +71,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -112,7 +112,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -166,7 +166,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -228,7 +228,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -277,7 +277,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -326,7 +326,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -365,7 +365,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -417,7 +417,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -470,7 +470,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -513,7 +513,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -561,7 +561,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -609,7 +609,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -644,7 +644,7 @@ "description": "There is no content to send for this request, but the headers may be useful. " }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -689,7 +689,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -732,7 +732,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -776,7 +776,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -816,7 +816,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -859,7 +859,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -903,7 +903,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -943,7 +943,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -981,7 +981,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, diff --git a/packages/samples/test/output/azure/core/data-plane/languageqna/Raw/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/azure/core/data-plane/languageqna/Raw/@typespec/openapi3/openapi.yaml index 05e26011e8..22d1686219 100644 --- a/packages/samples/test/output/azure/core/data-plane/languageqna/Raw/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/azure/core/data-plane/languageqna/Raw/@typespec/openapi3/openapi.yaml @@ -21,7 +21,7 @@ paths: schema: $ref: '#/components/schemas/PagedProjectMetadata' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -52,7 +52,7 @@ paths: schema: $ref: '#/components/schemas/DeletionJobState' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -83,7 +83,7 @@ paths: schema: $ref: '#/components/schemas/ProjectMetadata' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -119,7 +119,7 @@ paths: schema: $ref: '#/components/schemas/ProjectMetadata' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -179,7 +179,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -215,7 +215,7 @@ paths: type: string format: uri default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -252,7 +252,7 @@ paths: type: string format: uri default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -284,7 +284,7 @@ paths: schema: $ref: '#/components/schemas/PagedProjectDeployment' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -313,7 +313,7 @@ paths: schema: $ref: '#/components/schemas/PagedSynonymAsset' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -338,7 +338,7 @@ paths: schema: $ref: '#/components/schemas/PagedSynonymAsset' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -387,7 +387,7 @@ paths: type: string format: uri default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -430,7 +430,7 @@ paths: schema: $ref: '#/components/schemas/DeploymentJobState' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -467,7 +467,7 @@ paths: schema: $ref: '#/components/schemas/ExportJobState' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -494,7 +494,7 @@ paths: '204': description: 'There is no content to send for this request, but the headers may be useful. ' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -531,7 +531,7 @@ paths: schema: $ref: '#/components/schemas/JobState' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -560,7 +560,7 @@ paths: schema: $ref: '#/components/schemas/PagedQnaSourceRecord' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -585,7 +585,7 @@ paths: schema: $ref: '#/components/schemas/PagedQnaSourceRecord' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -619,7 +619,7 @@ paths: schema: $ref: '#/components/schemas/JobMetadata' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -648,7 +648,7 @@ paths: schema: $ref: '#/components/schemas/PagedQnaSourceRecord' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -673,7 +673,7 @@ paths: schema: $ref: '#/components/schemas/PagedQnaSourceRecord' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -707,7 +707,7 @@ paths: schema: $ref: '#/components/schemas/JobMetadata' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2022-08-31/openapi.json index 598bae4b0e..c2071eaeb6 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -34,7 +34,7 @@ ], "responses": { "200": { - "description": "The request has succeeded.", + "description": "Paged collection of Manufacturer items", "schema": { "$ref": "#/definitions/PagedManufacturer" }, @@ -47,7 +47,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -98,7 +98,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -220,7 +220,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -320,7 +320,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -389,7 +389,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -438,7 +438,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -478,7 +478,7 @@ ], "responses": { "200": { - "description": "The request has succeeded.", + "description": "Paged collection of Widget items", "schema": { "$ref": "#/definitions/PagedWidget" }, @@ -491,7 +491,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -542,7 +542,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -677,7 +677,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -778,7 +778,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -847,7 +847,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2023-02-07/openapi.json b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2023-02-07/openapi.json index be1e609371..86ee749a55 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2023-02-07/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2023-02-07/openapi.json @@ -34,7 +34,7 @@ ], "responses": { "200": { - "description": "The request has succeeded.", + "description": "Paged collection of Manufacturer items", "schema": { "$ref": "#/definitions/PagedManufacturer" }, @@ -47,7 +47,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -114,7 +114,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -256,7 +256,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -368,7 +368,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -437,7 +437,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -486,7 +486,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -526,7 +526,7 @@ ], "responses": { "200": { - "description": "The request has succeeded.", + "description": "Paged collection of Widget items", "schema": { "$ref": "#/definitions/PagedWidget" }, @@ -539,7 +539,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -606,7 +606,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -761,7 +761,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -874,7 +874,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -943,7 +943,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml index 624d5f4a46..9daf800022 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml @@ -13,7 +13,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: The request has succeeded. + description: Paged collection of Manufacturer items headers: x-ms-client-request-id: required: false @@ -25,7 +25,7 @@ paths: schema: $ref: '#/components/schemas/PagedManufacturer' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -87,7 +87,7 @@ paths: schema: $ref: '#/components/schemas/Manufacturer' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -131,7 +131,7 @@ paths: schema: $ref: '#/components/schemas/Manufacturer' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -197,7 +197,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -254,7 +254,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -291,7 +291,7 @@ paths: required: - statusString default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -315,7 +315,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: The request has succeeded. + description: Paged collection of Widget items headers: x-ms-client-request-id: required: false @@ -327,7 +327,7 @@ paths: schema: $ref: '#/components/schemas/PagedWidget' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -401,7 +401,7 @@ paths: schema: $ref: '#/components/schemas/Widget' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -445,7 +445,7 @@ paths: schema: $ref: '#/components/schemas/Widget' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -511,7 +511,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -568,7 +568,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml index 4e58c53855..a3447df7ab 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml @@ -13,7 +13,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: The request has succeeded. + description: Paged collection of Manufacturer items headers: x-ms-client-request-id: required: false @@ -25,7 +25,7 @@ paths: schema: $ref: '#/components/schemas/PagedManufacturer' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -101,7 +101,7 @@ paths: schema: $ref: '#/components/schemas/Manufacturer' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -154,7 +154,7 @@ paths: schema: $ref: '#/components/schemas/Manufacturer' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -224,7 +224,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -281,7 +281,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -318,7 +318,7 @@ paths: required: - statusString default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -342,7 +342,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: The request has succeeded. + description: Paged collection of Widget items headers: x-ms-client-request-id: required: false @@ -354,7 +354,7 @@ paths: schema: $ref: '#/components/schemas/PagedWidget' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -442,7 +442,7 @@ paths: schema: $ref: '#/components/schemas/Widget' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -495,7 +495,7 @@ paths: schema: $ref: '#/components/schemas/Widget' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -565,7 +565,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -622,7 +622,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false diff --git a/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json index 2c2d8fbfc7..dd3bdb97cd 100644 --- a/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -34,7 +34,7 @@ ], "responses": { "200": { - "description": "The request has succeeded.", + "description": "Paged collection of Manufacturer items", "schema": { "$ref": "#/definitions/PagedManufacturer" }, @@ -47,7 +47,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -114,7 +114,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -256,7 +256,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -368,7 +368,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -437,7 +437,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -486,7 +486,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -526,7 +526,7 @@ ], "responses": { "200": { - "description": "The request has succeeded.", + "description": "Paged collection of Widget items", "schema": { "$ref": "#/definitions/PagedWidget" }, @@ -539,7 +539,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -606,7 +606,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -761,7 +761,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -874,7 +874,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -994,7 +994,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1059,7 +1059,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1204,7 +1204,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1272,7 +1272,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1307,7 +1307,7 @@ ], "responses": { "200": { - "description": "The request has succeeded.", + "description": "Paged collection of WidgetPart items", "schema": { "$ref": "#/definitions/PagedWidgetPart" }, @@ -1320,7 +1320,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1426,7 +1426,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1497,7 +1497,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1589,7 +1589,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1664,7 +1664,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1729,6 +1729,10 @@ "error": { "$ref": "#/definitions/Azure.Core.Foundations.Error", "description": "Error object that describes the error when status is \"Failed\"." + }, + "result": { + "$ref": "#/definitions/TypeSpec.Http.AcceptedResponse", + "description": "The result of the operation." } }, "required": [ @@ -1774,7 +1778,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1839,7 +1843,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "A response containing error details.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -2072,6 +2076,10 @@ "value" ] }, + "TypeSpec.Http.AcceptedResponse": { + "type": "object", + "description": "The request has been accepted for processing, but processing has not yet completed." + }, "Versions": { "type": "string", "description": "The Contoso Widget Manager service version.", diff --git a/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml index a3c96d87b1..a3f8f459fd 100644 --- a/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml @@ -13,7 +13,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: The request has succeeded. + description: Paged collection of Manufacturer items headers: x-ms-client-request-id: required: false @@ -25,7 +25,7 @@ paths: schema: $ref: '#/components/schemas/PagedManufacturer' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -101,7 +101,7 @@ paths: schema: $ref: '#/components/schemas/Manufacturer' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -154,7 +154,7 @@ paths: schema: $ref: '#/components/schemas/Manufacturer' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -224,7 +224,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -281,7 +281,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -318,7 +318,7 @@ paths: required: - statusString default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -342,7 +342,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: The request has succeeded. + description: Paged collection of Widget items headers: x-ms-client-request-id: required: false @@ -354,7 +354,7 @@ paths: schema: $ref: '#/components/schemas/PagedWidget' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -406,7 +406,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -494,7 +494,7 @@ paths: schema: $ref: '#/components/schemas/Widget' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -547,7 +547,7 @@ paths: schema: $ref: '#/components/schemas/Widget' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -617,7 +617,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -664,7 +664,7 @@ paths: schema: $ref: '#/components/schemas/WidgetAnalytics' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -739,7 +739,7 @@ paths: schema: $ref: '#/components/schemas/WidgetAnalytics' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -803,7 +803,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -858,7 +858,7 @@ paths: schema: $ref: '#/components/schemas/Azure.Core.uuid' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -890,7 +890,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: The request has succeeded. + description: Paged collection of WidgetPart items headers: x-ms-client-request-id: required: false @@ -902,7 +902,7 @@ paths: schema: $ref: '#/components/schemas/PagedWidgetPart' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -955,7 +955,7 @@ paths: schema: $ref: '#/components/schemas/WidgetPart' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -1005,7 +1005,7 @@ paths: schema: $ref: '#/components/schemas/Azure.Core.uuid' default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -1068,7 +1068,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -1133,9 +1133,13 @@ paths: allOf: - $ref: '#/components/schemas/Azure.Core.Foundations.Error' description: Error object that describes the error when status is "Failed". + result: + allOf: + - $ref: '#/components/schemas/TypeSpec.Http.AcceptedResponse' + description: The result of the operation. description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -1243,7 +1247,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: An unexpected error response. + description: A response containing error details. headers: x-ms-error-code: required: false @@ -1518,6 +1522,9 @@ components: - accepted - rejected description: Repeatability Result header options + TypeSpec.Http.AcceptedResponse: + type: object + description: The request has been accepted for processing, but processing has not yet completed. Versions: type: string enum: diff --git a/packages/samples/test/output/azure/core/misc/appconfig/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/core/misc/appconfig/@azure-tools/typespec-autorest/openapi.json index 33dd5aa703..2fa259c1b0 100644 --- a/packages/samples/test/output/azure/core/misc/appconfig/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/core/misc/appconfig/@azure-tools/typespec-autorest/openapi.json @@ -66,7 +66,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "Azure App Configuration error object.", "schema": { "$ref": "#/definitions/Error" } @@ -113,7 +113,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "Azure App Configuration error object.", "schema": { "$ref": "#/definitions/Error" } @@ -192,7 +192,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "Azure App Configuration error object.", "schema": { "$ref": "#/definitions/Error" } @@ -258,7 +258,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "Azure App Configuration error object.", "schema": { "$ref": "#/definitions/Error" } @@ -336,7 +336,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "Azure App Configuration error object.", "schema": { "$ref": "#/definitions/Error" } @@ -402,7 +402,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "Azure App Configuration error object.", "schema": { "$ref": "#/definitions/Error" } @@ -472,7 +472,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "Azure App Configuration error object.", "schema": { "$ref": "#/definitions/Error" } @@ -534,7 +534,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "Azure App Configuration error object.", "schema": { "$ref": "#/definitions/Error" } @@ -579,7 +579,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "Azure App Configuration error object.", "schema": { "$ref": "#/definitions/Error" } @@ -633,7 +633,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "Azure App Configuration error object.", "schema": { "$ref": "#/definitions/Error" } @@ -697,7 +697,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "Azure App Configuration error object.", "schema": { "$ref": "#/definitions/Error" } @@ -752,7 +752,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "Azure App Configuration error object.", "schema": { "$ref": "#/definitions/Error" } @@ -805,7 +805,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "Azure App Configuration error object.", "schema": { "$ref": "#/definitions/Error" } @@ -884,7 +884,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "Azure App Configuration error object.", "schema": { "$ref": "#/definitions/Error" } @@ -931,7 +931,7 @@ } }, "default": { - "description": "An unexpected error response.", + "description": "Azure App Configuration error object.", "schema": { "$ref": "#/definitions/Error" } diff --git a/packages/samples/test/output/azure/core/misc/appconfig/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/azure/core/misc/appconfig/@typespec/openapi3/openapi.yaml index 834c2a0a2d..b1dacf90bd 100644 --- a/packages/samples/test/output/azure/core/misc/appconfig/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/azure/core/misc/appconfig/@typespec/openapi3/openapi.yaml @@ -39,7 +39,7 @@ paths: schema: $ref: '#/components/schemas/PagedKey' default: - description: An unexpected error response. + description: Azure App Configuration error object. content: application/problem+json: schema: @@ -71,7 +71,7 @@ paths: schema: type: string default: - description: An unexpected error response. + description: Azure App Configuration error object. content: application/problem+json: schema: @@ -120,7 +120,7 @@ paths: schema: $ref: '#/components/schemas/PagedKeyValue' default: - description: An unexpected error response. + description: Azure App Configuration error object. content: application/problem+json: schema: @@ -159,7 +159,7 @@ paths: schema: type: string default: - description: An unexpected error response. + description: Azure App Configuration error object. content: application/problem+json: schema: @@ -210,7 +210,7 @@ paths: schema: $ref: '#/components/schemas/KeyValue' default: - description: An unexpected error response. + description: Azure App Configuration error object. content: application/problem+json: schema: @@ -239,7 +239,7 @@ paths: type: string format: date default: - description: An unexpected error response. + description: Azure App Configuration error object. content: application/problem+json: schema: @@ -278,7 +278,7 @@ paths: schema: $ref: '#/components/schemas/KeyValue' default: - description: An unexpected error response. + description: Azure App Configuration error object. content: application/problem+json: schema: @@ -340,7 +340,7 @@ paths: schema: $ref: '#/components/schemas/KeyValue' default: - description: An unexpected error response. + description: Azure App Configuration error object. content: application/problem+json: schema: @@ -395,7 +395,7 @@ paths: schema: type: string default: - description: An unexpected error response. + description: Azure App Configuration error object. content: application/problem+json: schema: @@ -435,7 +435,7 @@ paths: schema: $ref: '#/components/schemas/PagedLabel' default: - description: An unexpected error response. + description: Azure App Configuration error object. content: application/problem+json: schema: @@ -476,7 +476,7 @@ paths: schema: type: string default: - description: An unexpected error response. + description: Azure App Configuration error object. content: application/problem+json: schema: @@ -513,7 +513,7 @@ paths: schema: $ref: '#/components/schemas/KeyValue' default: - description: An unexpected error response. + description: Azure App Configuration error object. content: application/problem+json: schema: @@ -549,7 +549,7 @@ paths: schema: $ref: '#/components/schemas/KeyValue' default: - description: An unexpected error response. + description: Azure App Configuration error object. content: application/problem+json: schema: @@ -601,7 +601,7 @@ paths: schema: $ref: '#/components/schemas/PagedKeyValue' default: - description: An unexpected error response. + description: Azure App Configuration error object. content: application/problem+json: schema: @@ -633,7 +633,7 @@ paths: schema: type: string default: - description: An unexpected error response. + description: Azure App Configuration error object. content: application/problem+json: schema: diff --git a/packages/samples/test/output/core/documentation/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/core/documentation/@azure-tools/typespec-autorest/openapi.json index 9d9b9a404a..112c60529a 100644 --- a/packages/samples/test/output/core/documentation/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/core/documentation/@azure-tools/typespec-autorest/openapi.json @@ -98,7 +98,7 @@ } }, "404": { - "description": "The server cannot find the requested resource.", + "description": "Not found", "schema": { "$ref": "#/definitions/NotFoundWithDocsResp" } diff --git a/packages/typespec-azure-core/src/lro-helpers.ts b/packages/typespec-azure-core/src/lro-helpers.ts index 4a4b245120..e3f5ccbd2c 100644 --- a/packages/typespec-azure-core/src/lro-helpers.ts +++ b/packages/typespec-azure-core/src/lro-helpers.ts @@ -24,6 +24,7 @@ import { getOperationVerb, HttpOperation, isBody, + isBodyRoot, isHeader, } from "@typespec/http"; import { @@ -453,7 +454,7 @@ function createLroMetadata( function createOperationLink(program: Program, modelProperty: ModelProperty): OperationLink { let location: "ResponseBody" | "ResponseHeader" | "Self" = "ResponseBody"; if (isHeader(program, modelProperty)) location = "ResponseHeader"; - if (isBody(program, modelProperty)) location = "Self"; + if (isBody(program, modelProperty) || isBodyRoot(program, modelProperty)) location = "Self"; return { kind: "link", location: location, @@ -527,7 +528,10 @@ function ensureContext( } function getBodyType(program: Program, model: Model): Model | undefined { - const bodyProps = filterModelProperties(model, (p) => isBody(program, p)); + const bodyProps = filterModelProperties( + model, + (p) => isBody(program, p) || isBodyRoot(program, p) + ); if (bodyProps.length === 1 && bodyProps[0].type.kind === "Model") return bodyProps[0].type; return undefined; } @@ -834,7 +838,7 @@ function getStatusMonitorLinksFromModel( if (pollingLinks === undefined) return undefined; // favor status monitor links over stepwise polling if (pollingLinks.length > 1) { - pollingLinks = pollingLinks.filter((p) => !isBody(program, p)); + pollingLinks = pollingLinks.filter((p) => !isBody(program, p) && !isBodyRoot(program, p)); } const pollingProperty = pollingLinks[0]; pollingData = getPollingLocationInfo(program, pollingProperty); diff --git a/packages/typespec-azure-core/src/rules/request-body-array.ts b/packages/typespec-azure-core/src/rules/request-body-array.ts index 52d2d21012..4d768ce5d1 100644 --- a/packages/typespec-azure-core/src/rules/request-body-array.ts +++ b/packages/typespec-azure-core/src/rules/request-body-array.ts @@ -1,5 +1,5 @@ import { Operation, createRule } from "@typespec/compiler"; -import { isBody } from "@typespec/http"; +import { isBody, isBodyRoot } from "@typespec/http"; export const bodyArrayRule = createRule({ name: "request-body-problem", @@ -14,7 +14,7 @@ export const bodyArrayRule = createRule({ operation: (op: Operation) => { for (const prop of op.parameters.properties.values()) { if ( - isBody(context.program, prop) && + (isBody(context.program, prop) || isBodyRoot(context.program, prop)) && prop.type.kind === "Model" && prop.type.name === "Array" ) { diff --git a/packages/typespec-azure-core/test/operations.test.ts b/packages/typespec-azure-core/test/operations.test.ts index 48432a9153..64d0a21004 100644 --- a/packages/typespec-azure-core/test/operations.test.ts +++ b/packages/typespec-azure-core/test/operations.test.ts @@ -1356,7 +1356,7 @@ describe("typespec-azure-core: operation templates", () => { @header("operation-id") operate: string, @finalLocation @header("Location") location: ResourceLocation, @pollingLocation @header("Operation-Location") opLink: string, - @lroResult @body body?: SimpleWidget + @lroResult @bodyRoot body?: SimpleWidget }; `, "createWidget" @@ -1412,7 +1412,7 @@ describe("typespec-azure-core: operation templates", () => { @pollingLocation(StatusMonitorPollingOptions) @header("Azure-AsyncOperation") opLink: string, @finalLocation(SimpleWidget) @header location: string; - @body body?: SimpleWidget + @bodyRoot body?: SimpleWidget }; `, "createWidget" @@ -1466,7 +1466,7 @@ describe("typespec-azure-core: operation templates", () => { { @statusCode statusCode: 201; @pollingLocation(StatusMonitorPollingOptions) @header("Azure-AsyncOperation") opLink: string, - @body body?: SimpleWidget + @bodyRoot body?: SimpleWidget }; `, "createWidget" @@ -1513,7 +1513,7 @@ describe("typespec-azure-core: operation templates", () => { { @statusCode statusCode: 201; @pollingLocation(StatusMonitorPollingOptions) @header("location") opLink: string, - @body body?: SimpleWidget + @bodyRoot body?: SimpleWidget }; `, "createWidget" @@ -1565,7 +1565,7 @@ describe("typespec-azure-core: operation templates", () => { @pollingLocation(StatusMonitorPollingOptions) @header("Azure-AsyncOperation") opLink: string, @finalLocation(SimpleWidget) @header location: string; - @body body?: SimpleWidget + @bodyRoot body?: SimpleWidget }; `, "createWidget" @@ -1621,7 +1621,7 @@ describe("typespec-azure-core: operation templates", () => { { @statusCode statusCode: 201; @pollingLocation(StatusMonitorPollingOptions) @header("Azure-AsyncOperation") opLink: string, - @body body?: SimpleWidget + @bodyRoot body?: SimpleWidget }; `, "createWidget" @@ -1671,7 +1671,7 @@ describe("typespec-azure-core: operation templates", () => { { @statusCode statusCode: 201; @finalLocation(SimpleWidget) @pollingLocation(StatusMonitorPollingOptions) @header("location") opLink: string, - @body body?: SimpleWidget + @bodyRoot body?: SimpleWidget }; `, "createWidget" @@ -1728,7 +1728,7 @@ describe("typespec-azure-core: operation templates", () => { @pollingLocation(StatusMonitorPollingOptions) @header("Azure-AsyncOperation") opLink: string, @finalLocation(SimpleWidget) @header location: string; - @body body?: SimpleWidget + @bodyRoot body?: SimpleWidget }; `, "createWidget" @@ -1782,7 +1782,7 @@ describe("typespec-azure-core: operation templates", () => { { @statusCode statusCode: 202; @pollingLocation(StatusMonitorPollingOptions) @header("Azure-AsyncOperation") opLink: string, - @body body?: SimpleWidget + @bodyRoot body?: SimpleWidget }; `, "createWidget" @@ -1830,7 +1830,7 @@ describe("typespec-azure-core: operation templates", () => { { @statusCode statusCode: 202; @finalLocation(SimpleWidget) @pollingLocation(StatusMonitorPollingOptions) @header("location") opLink: string, - @body body?: SimpleWidget + @bodyRoot body?: SimpleWidget }; `, "createWidget" @@ -1973,7 +1973,7 @@ describe("typespec-azure-core: operation templates", () => { @header id: string, @header("operation-id") operate: string, @pollingLocation @header("Operation-Location") opLink: string, - @lroResult @body body?: SimpleWidget + @lroResult @bodyRoot body?: SimpleWidget }; `, "createWidget" @@ -2032,7 +2032,7 @@ describe("typespec-azure-core: operation templates", () => { @header id: string, @header("operation-id") operate: string, @pollingLocation @header("Operation-Location") opLink: string, - @lroResult @body body?: SimpleWidget + @lroResult @bodyRoot body?: SimpleWidget }; `, "createWidget" @@ -2093,7 +2093,7 @@ describe("typespec-azure-core: operation templates", () => { @header id: string; @header("operation-id") operate: string; @pollingLocation @header("Operation-Location") opLink: string; - @lroResult @body body?: SimpleWidget; + @lroResult @bodyRoot body?: SimpleWidget; }; `, "mungeWidget" diff --git a/packages/typespec-azure-resource-manager/lib/arm.foundations.tsp b/packages/typespec-azure-resource-manager/lib/arm.foundations.tsp index 392af0fcb7..aa142651c7 100644 --- a/packages/typespec-azure-resource-manager/lib/arm.foundations.tsp +++ b/packages/typespec-azure-resource-manager/lib/arm.foundations.tsp @@ -776,7 +776,7 @@ op ArmCreateOperation< ErrorResponse extends {} >( ...HttpParameters, - @doc("Resource create parameters.") @body resource: BodyParameter, + @doc("Resource create parameters.") @bodyRoot resource: BodyParameter, ): Response | ErrorResponse; /** @@ -793,5 +793,5 @@ op ArmUpdateOperation< ErrorResponse extends {} >( ...HttpParameters, - @doc("The resource properties to be updated.") @body properties: BodyParameter, + @doc("The resource properties to be updated.") @bodyRoot properties: BodyParameter, ): Response | ErrorResponse; diff --git a/packages/typespec-azure-resource-manager/lib/responses.tsp b/packages/typespec-azure-resource-manager/lib/responses.tsp index 65ce2c68b3..072bb7b52e 100644 --- a/packages/typespec-azure-resource-manager/lib/responses.tsp +++ b/packages/typespec-azure-resource-manager/lib/responses.tsp @@ -13,7 +13,10 @@ namespace Azure.ResourceManager; @doc("Azure operation completed successfully.") model ArmResponse { ...OkResponse; - ...Body; + + @doc("The body type of the operation request or response.") + @bodyRoot + body: ResponseBody; } /** @@ -24,7 +27,10 @@ model ArmResponse { model ArmCreatedResponse { ...CreatedResponse; ...Azure.Core.Foundations.RetryAfterHeader; - ...Body; + + @doc("The body type of the operation request or response.") + @bodyRoot + body: ResponseBody; } /** @@ -211,7 +217,7 @@ model ArmResourceCreatedResponse< @Azure.Core.pollingLocation(Azure.Core.StatusMonitorPollingOptions) @doc("The resource body") - @body + @bodyRoot body: Resource; } @@ -220,9 +226,12 @@ model ArmResourceCreatedResponse< * @template Resource The resource being updated */ @doc("Resource '{name}' create operation succeeded", Resource) -model ArmResourceCreatedSyncResponse - is Body { +model ArmResourceCreatedSyncResponse { ...CreatedResponse; + + @doc("The body type of the operation request or response.") + @bodyRoot + body: Resource; } /** diff --git a/packages/typespec-azure-resource-manager/src/rules/arm-resource-patch.ts b/packages/typespec-azure-resource-manager/src/rules/arm-resource-patch.ts index bb2455adbd..f7023782d6 100644 --- a/packages/typespec-azure-resource-manager/src/rules/arm-resource-patch.ts +++ b/packages/typespec-azure-resource-manager/src/rules/arm-resource-patch.ts @@ -11,7 +11,14 @@ import { isErrorType, paramMessage, } from "@typespec/compiler"; -import { getOperationVerb, isBody, isHeader, isPathParam, isQueryParam } from "@typespec/http"; +import { + getOperationVerb, + isBody, + isBodyRoot, + isHeader, + isPathParam, + isQueryParam, +} from "@typespec/http"; import { getArmResource } from "../resource.js"; import { getSourceModel, isInternalTypeSpec } from "./utils.js"; @@ -121,7 +128,11 @@ function getPatchModel(program: Program, operation: Operation): ModelProperty[] isPathParam(program, property) ) continue; - if (isBody(program, property) && property.type.kind === "Scalar") return undefined; + if ( + (isBody(program, property) || isBodyRoot(program, property)) && + property.type.kind === "Scalar" + ) + return undefined; bodyProperties.push(property); } diff --git a/packages/typespec-azure-resource-manager/test/resource.test.ts b/packages/typespec-azure-resource-manager/test/resource.test.ts index 27d7e866d3..6c48886add 100644 --- a/packages/typespec-azure-resource-manager/test/resource.test.ts +++ b/packages/typespec-azure-resource-manager/test/resource.test.ts @@ -799,6 +799,7 @@ describe("typespec-azure-resource-manager: ARM resource model", () => { version: string, file: string ) { + console.log(">..", openApi.paths[path].get.responses["200"]); assertRef( openApi.paths[path].get.responses["200"].schema, `../../common-types/resource-management/${version}/${file}#/definitions/${defName}` @@ -855,7 +856,7 @@ describe("typespec-azure-resource-manager: ARM resource model", () => { ${versionEnum} @Azure.ResourceManager.Private.armCommonDefinition("Foo", Azure.ResourceManager.CommonTypes.Versions.v3, "foo.json") - model Foo {} + model Foo {prop: string} model FooParam { @path @@ -865,7 +866,7 @@ describe("typespec-azure-resource-manager: ARM resource model", () => { @Azure.ResourceManager.Private.armCommonDefinition("Bar", { version: Azure.ResourceManager.CommonTypes.Versions.v4, isDefault: true }, "bar.json") @Azure.ResourceManager.Private.armCommonDefinition("Bar", Azure.ResourceManager.CommonTypes.Versions.v5, "bar-v5.json") - model Bar {} + model Bar {prop: string} model BarParam { @path @@ -875,7 +876,7 @@ describe("typespec-azure-resource-manager: ARM resource model", () => { } @Azure.ResourceManager.Private.armCommonDefinition("Baz", Azure.ResourceManager.CommonTypes.Versions.v5, "baz.json") - model Baz {} + model Baz {prop: string} model BazParam { @path diff --git a/packages/typespec-azure-resource-manager/test/rules/arm-resource-operations.test.ts b/packages/typespec-azure-resource-manager/test/rules/arm-resource-operations.test.ts index 793a16b148..cb23c81ae6 100644 --- a/packages/typespec-azure-resource-manager/test/rules/arm-resource-operations.test.ts +++ b/packages/typespec-azure-resource-manager/test/rules/arm-resource-operations.test.ts @@ -44,7 +44,7 @@ describe("typespec-azure-resource-manager: arm resource operations rule", () => @armResourceOperations interface FooResources { @get @armResourceRead(FooResource) get(@key("foo") name: string): ArmResponse | ErrorResponse; - @put @armResourceCreateOrUpdate(FooResource) create(...ResourceInstanceParameters, @body resource: FooResource): ArmResponse | ArmCreatedResponse | ErrorResponse; + @put @armResourceCreateOrUpdate(FooResource) create(...ResourceInstanceParameters, @bodyRoot resource: FooResource): ArmResponse | ArmCreatedResponse | ErrorResponse; @get @armResourceList(FooResource) listBySubscription(...SubscriptionScope): ArmResponse> | ErrorResponse; } ` @@ -75,7 +75,7 @@ describe("typespec-azure-resource-manager: arm resource operations rule", () => @armResourceOperations interface FooResources { - @put @armResourceCreateOrUpdate(FooResource) create(...ResourceInstanceParameters, @body resource: FooResource): ArmResponse | ArmCreatedResponse | ErrorResponse; + @put @armResourceCreateOrUpdate(FooResource) create(...ResourceInstanceParameters, @bodyRoot resource: FooResource): ArmResponse | ArmCreatedResponse | ErrorResponse; } ` ) diff --git a/packages/typespec-azure-resource-manager/test/rules/core-operations.test.ts b/packages/typespec-azure-resource-manager/test/rules/core-operations.test.ts index 1afbc517a8..df0444c4a7 100644 --- a/packages/typespec-azure-resource-manager/test/rules/core-operations.test.ts +++ b/packages/typespec-azure-resource-manager/test/rules/core-operations.test.ts @@ -38,9 +38,9 @@ describe("typespec-azure-resource-manager: core operations rule", () => { @armResourceOperations interface FooResources extends ResourceCollectionOperations { - @put createOrUpdate( ...ResourceInstanceParameters, @body resource: FooResource): ArmResponse | ArmCreatedResponse | ErrorResponse; + @put createOrUpdate( ...ResourceInstanceParameters, @bodyRoot resource: FooResource): ArmResponse | ArmCreatedResponse | ErrorResponse; @get get(...ResourceInstanceParameters): ArmResponse | ErrorResponse; - @patch update(...ResourceInstanceParameters, @body properties: ResourceUpdateModel): ArmResponse | ErrorResponse; + @patch update(...ResourceInstanceParameters, @bodyRoot properties: ResourceUpdateModel): ArmResponse | ErrorResponse; @delete delete(...ResourceInstanceParameters): | ArmDeletedResponse | ArmDeleteAcceptedResponse | ArmDeletedNoContentResponse | ErrorResponse; @post action(...ResourceInstanceParameters) : ArmResponse | ErrorResponse; } diff --git a/packages/typespec-azure-resource-manager/test/rules/no-response-body.test.ts b/packages/typespec-azure-resource-manager/test/rules/no-response-body.test.ts index bff70c72d1..833bc656ea 100644 --- a/packages/typespec-azure-resource-manager/test/rules/no-response-body.test.ts +++ b/packages/typespec-azure-resource-manager/test/rules/no-response-body.test.ts @@ -41,7 +41,7 @@ describe("typespec-azure-resource-manager: no response body rule", () => { ` model TestAcceptedResponse { @statusCode statusCode: 202; - @body body: string; + @bodyRoot body: string; } op walk(): TestAcceptedResponse; ` diff --git a/packages/typespec-azure-resource-manager/test/rules/patch-envelope.test.ts b/packages/typespec-azure-resource-manager/test/rules/patch-envelope.test.ts index 25baca7ddc..1f712fe7d0 100644 --- a/packages/typespec-azure-resource-manager/test/rules/patch-envelope.test.ts +++ b/packages/typespec-azure-resource-manager/test/rules/patch-envelope.test.ts @@ -74,7 +74,7 @@ describe("typespec-azure-resource-manager: patch identity should be present in t @patch op update(...ResourceInstanceParameters, @doc("The resource properties to be updated.") - @body + @bodyRoot properties: MyPatchModel):TrackedResource | ErrorResponse; } diff --git a/packages/typespec-azure-resource-manager/test/rules/patch-operations.test.ts b/packages/typespec-azure-resource-manager/test/rules/patch-operations.test.ts index 8f830372ee..876ce34656 100644 --- a/packages/typespec-azure-resource-manager/test/rules/patch-operations.test.ts +++ b/packages/typespec-azure-resource-manager/test/rules/patch-operations.test.ts @@ -66,7 +66,7 @@ describe("typespec-azure-resource-manager: core operations rule", () => { extends ResourceRead, ResourceCreate, ResourceDelete { @doc("Updates my Foos") @armResourceUpdate(FooResource) - @patch myFooUpdate(...ResourceInstanceParameters, @doc("The body") @body body: MyBadPatch) : ArmResponse | ErrorResponse; + @patch myFooUpdate(...ResourceInstanceParameters, @doc("The body") @bodyRoot body: MyBadPatch) : ArmResponse | ErrorResponse; } @doc("The state of the resource") diff --git a/packages/typespec-client-generator-core/test/decorators.test.ts b/packages/typespec-client-generator-core/test/decorators.test.ts index 3c7002dc70..000bba011c 100644 --- a/packages/typespec-client-generator-core/test/decorators.test.ts +++ b/packages/typespec-client-generator-core/test/decorators.test.ts @@ -2034,16 +2034,16 @@ describe("typespec-client-generator-core: decorators", () => { @service({}) @test namespace MyService { @test - model Model1{} + model Model1{ prop: string } @test - model Model2{} + model Model2{ prop: string } @test - model Model3{} + model Model3{ prop: string } @test - model Model4{} + model Model4 { prop: string } @test @route("/func1") @@ -2088,18 +2088,18 @@ describe("typespec-client-generator-core: decorators", () => { @test @usage(Usage.input | Usage.output) @access(Access.public) - model Model1{} + model Model1{ prop: string } @test - model Model4{} + model Model4{ prop: string } @test @usage(Usage.output) - model Model2{} + model Model2{ prop: string } @test @usage(Usage.input) - model Model3{} + model Model3{ prop: string } @test @route("/func1") From d8921dd11183542b8199f5fa454e7da61b979a68 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Fri, 23 Feb 2024 07:53:53 -0800 Subject: [PATCH 03/14] revert doc change --- core | 2 +- .../typespec-autorest/2022-08-31/openapi.json | 26 +++++----- .../openapi3/openapi.2022-08-31.yaml | 26 +++++----- .../typespec-autorest/openapi.json | 26 +++++----- .../@typespec/openapi3/openapi.yaml | 26 +++++----- .../typespec-autorest/2022-08-31/openapi.json | 2 +- .../openapi3/openapi.2022-08-31.yaml | 2 +- .../typespec-autorest/openapi.json | 24 +++++----- .../@typespec/openapi3/openapi.yaml | 24 +++++----- .../typespec-autorest/openapi.json | 32 ++++++------- .../authoring/@typespec/openapi3/openapi.yaml | 32 ++++++------- .../typespec-autorest/openapi.json | 42 ++++++++-------- .../Raw/@typespec/openapi3/openapi.yaml | 42 ++++++++-------- .../typespec-autorest/2022-08-31/openapi.json | 26 +++++----- .../typespec-autorest/2023-02-07/openapi.json | 26 +++++----- .../openapi3/openapi.2022-08-31.yaml | 26 +++++----- .../openapi3/openapi.2023-02-07.yaml | 26 +++++----- .../typespec-autorest/2022-08-31/openapi.json | 48 +++++++++---------- .../openapi3/openapi.2022-08-31.yaml | 48 +++++++++---------- .../typespec-autorest/openapi.json | 30 ++++++------ .../appconfig/@typespec/openapi3/openapi.yaml | 30 ++++++------ .../typespec-autorest/openapi.json | 2 +- 22 files changed, 284 insertions(+), 284 deletions(-) diff --git a/core b/core index 141010518e..fe18ddf750 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 141010518ebb7fd7e95857c334e196ddb41a4900 +Subproject commit fe18ddf750c26f74b0d586a4abd6891bf34ed7b7 diff --git a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@azure-tools/typespec-autorest/2022-08-31/openapi.json index 3e52adb192..837ba96f12 100644 --- a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -34,7 +34,7 @@ ], "responses": { "200": { - "description": "Paged collection of Manufacturer items", + "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/PagedManufacturer" }, @@ -47,7 +47,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -114,7 +114,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -256,7 +256,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -368,7 +368,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -437,7 +437,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -486,7 +486,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -526,7 +526,7 @@ ], "responses": { "200": { - "description": "Paged collection of Widget items", + "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/PagedWidget" }, @@ -539,7 +539,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -606,7 +606,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -761,7 +761,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -874,7 +874,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -943,7 +943,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, diff --git a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml index 2d1c7878e9..ecef77debb 100644 --- a/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/api-path-parameter/@typespec/openapi3/openapi.2022-08-31.yaml @@ -13,7 +13,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: Paged collection of Manufacturer items + description: The request has succeeded. headers: x-ms-client-request-id: required: false @@ -25,7 +25,7 @@ paths: schema: $ref: '#/components/schemas/PagedManufacturer' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -101,7 +101,7 @@ paths: schema: $ref: '#/components/schemas/Manufacturer' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -154,7 +154,7 @@ paths: schema: $ref: '#/components/schemas/Manufacturer' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -224,7 +224,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -281,7 +281,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -318,7 +318,7 @@ paths: required: - statusString default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -342,7 +342,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: Paged collection of Widget items + description: The request has succeeded. headers: x-ms-client-request-id: required: false @@ -354,7 +354,7 @@ paths: schema: $ref: '#/components/schemas/PagedWidget' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -442,7 +442,7 @@ paths: schema: $ref: '#/components/schemas/Widget' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -495,7 +495,7 @@ paths: schema: $ref: '#/components/schemas/Widget' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -565,7 +565,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -622,7 +622,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false diff --git a/packages/samples/test/output/azure/core/data-plane/confidentialledger/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/core/data-plane/confidentialledger/@azure-tools/typespec-autorest/openapi.json index 0cc7942f71..56d8aadc7c 100644 --- a/packages/samples/test/output/azure/core/data-plane/confidentialledger/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/confidentialledger/@azure-tools/typespec-autorest/openapi.json @@ -81,7 +81,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -110,7 +110,7 @@ "description": "The request has succeeded." }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -139,7 +139,7 @@ "description": "The request has succeeded." }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -168,7 +168,7 @@ "description": "The request has succeeded." }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -200,7 +200,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -249,7 +249,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -291,7 +291,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -330,7 +330,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -369,7 +369,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -404,7 +404,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -444,7 +444,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -500,7 +500,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -535,7 +535,7 @@ "description": "There is no content to send for this request, but the headers may be useful. " }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, diff --git a/packages/samples/test/output/azure/core/data-plane/confidentialledger/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/azure/core/data-plane/confidentialledger/@typespec/openapi3/openapi.yaml index c30a9bb5f1..7d5bee226c 100644 --- a/packages/samples/test/output/azure/core/data-plane/confidentialledger/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/azure/core/data-plane/confidentialledger/@typespec/openapi3/openapi.yaml @@ -21,7 +21,7 @@ paths: items: $ref: '#/components/schemas/Collection' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -43,7 +43,7 @@ paths: '200': description: The request has succeeded. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -65,7 +65,7 @@ paths: '200': description: The request has succeeded. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -87,7 +87,7 @@ paths: '200': description: The request has succeeded. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -113,7 +113,7 @@ paths: schema: $ref: '#/components/schemas/PagedLedgerEntries' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -141,7 +141,7 @@ paths: type: string format: uri default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -175,7 +175,7 @@ paths: schema: $ref: '#/components/schemas/LedgerEntry' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -208,7 +208,7 @@ paths: schema: $ref: '#/components/schemas/LedgerEntry' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -240,7 +240,7 @@ paths: schema: $ref: '#/components/schemas/TransactionReceipt' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -272,7 +272,7 @@ paths: schema: $ref: '#/components/schemas/TransactionStatus' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -302,7 +302,7 @@ paths: '204': description: 'There is no content to send for this request, but the headers may be useful. ' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -335,7 +335,7 @@ paths: schema: $ref: '#/components/schemas/LedgerUser' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -374,7 +374,7 @@ paths: schema: $ref: '#/components/schemas/LedgerUser' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false diff --git a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@azure-tools/typespec-autorest/2022-08-31/openapi.json index 1e08a6fda1..cc9e15912e 100644 --- a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -46,7 +46,7 @@ ], "responses": { "200": { - "description": "Paged collection of Widget items", + "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/PagedWidget" }, diff --git a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml index 679197fe43..42f0686242 100644 --- a/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/custom-error-type/@typespec/openapi3/openapi.2022-08-31.yaml @@ -17,7 +17,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: Paged collection of Widget items + description: The request has succeeded. headers: x-ms-client-request-id: required: false diff --git a/packages/samples/test/output/azure/core/data-plane/formrecognizer/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/core/data-plane/formrecognizer/@azure-tools/typespec-autorest/openapi.json index 73d00dfc2f..6bae9fd02a 100644 --- a/packages/samples/test/output/azure/core/data-plane/formrecognizer/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/formrecognizer/@azure-tools/typespec-autorest/openapi.json @@ -73,7 +73,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -187,7 +187,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -240,7 +240,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -282,7 +282,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -319,7 +319,7 @@ "description": "There is no content to send for this request, but the headers may be useful. " }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -368,7 +368,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -410,7 +410,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -455,7 +455,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -500,7 +500,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -534,7 +534,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -568,7 +568,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -612,7 +612,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, diff --git a/packages/samples/test/output/azure/core/data-plane/formrecognizer/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/azure/core/data-plane/formrecognizer/@typespec/openapi3/openapi.yaml index 49d13f4e66..44b7f29492 100644 --- a/packages/samples/test/output/azure/core/data-plane/formrecognizer/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/azure/core/data-plane/formrecognizer/@typespec/openapi3/openapi.yaml @@ -25,7 +25,7 @@ paths: schema: $ref: '#/components/schemas/PagedModelSummary' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -58,7 +58,7 @@ paths: schema: $ref: '#/components/schemas/ModelSummary' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -86,7 +86,7 @@ paths: '204': description: 'There is no content to send for this request, but the headers may be useful. ' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -125,7 +125,7 @@ paths: schema: $ref: '#/components/schemas/AnalyzeResultOperation' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -178,7 +178,7 @@ paths: schema: type: string default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -245,7 +245,7 @@ paths: schema: type: string default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -278,7 +278,7 @@ paths: schema: $ref: '#/components/schemas/CopyAuthorization' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -313,7 +313,7 @@ paths: schema: type: string default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -348,7 +348,7 @@ paths: schema: type: string default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -381,7 +381,7 @@ paths: schema: $ref: '#/components/schemas/GetInfoResponse' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -408,7 +408,7 @@ paths: schema: $ref: '#/components/schemas/PagedOperationInfo' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -441,7 +441,7 @@ paths: schema: $ref: '#/components/schemas/GetOperationResponse' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false diff --git a/packages/samples/test/output/azure/core/data-plane/language/authoring/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/core/data-plane/language/authoring/@azure-tools/typespec-autorest/openapi.json index cc23588e7c..2ccfe74612 100644 --- a/packages/samples/test/output/azure/core/data-plane/language/authoring/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/language/authoring/@azure-tools/typespec-autorest/openapi.json @@ -72,7 +72,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -113,7 +113,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -181,7 +181,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -244,7 +244,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -290,7 +290,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -333,7 +333,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -385,7 +385,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -424,7 +424,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -472,7 +472,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -544,7 +544,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -614,7 +614,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -667,7 +667,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -719,7 +719,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -764,7 +764,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -805,7 +805,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -848,7 +848,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, diff --git a/packages/samples/test/output/azure/core/data-plane/language/authoring/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/azure/core/data-plane/language/authoring/@typespec/openapi3/openapi.yaml index 758e9efac2..e6c81e819f 100644 --- a/packages/samples/test/output/azure/core/data-plane/language/authoring/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/azure/core/data-plane/language/authoring/@typespec/openapi3/openapi.yaml @@ -21,7 +21,7 @@ paths: schema: $ref: '#/components/schemas/PagedProject' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -49,7 +49,7 @@ paths: schema: $ref: '#/components/schemas/PagedSupportedLanguage' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -77,7 +77,7 @@ paths: schema: $ref: '#/components/schemas/PagedTrainingConfigVersion' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -128,7 +128,7 @@ paths: schema: $ref: '#/components/schemas/Project' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -165,7 +165,7 @@ paths: schema: $ref: '#/components/schemas/Project' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -218,7 +218,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -249,7 +249,7 @@ paths: schema: $ref: '#/components/schemas/PagedDeployment' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -286,7 +286,7 @@ paths: schema: $ref: '#/components/schemas/Deployment' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -342,7 +342,7 @@ paths: schema: $ref: '#/components/schemas/Deployment' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -408,7 +408,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -451,7 +451,7 @@ paths: schema: $ref: '#/components/schemas/DeploymentJob' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -494,7 +494,7 @@ paths: schema: $ref: '#/components/schemas/SwapDeploymentsJob' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -528,7 +528,7 @@ paths: type: string format: uri default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -570,7 +570,7 @@ paths: type: string format: uri default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -604,7 +604,7 @@ paths: type: string format: uri default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -638,7 +638,7 @@ paths: type: string format: uri default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false diff --git a/packages/samples/test/output/azure/core/data-plane/languageqna/Raw/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/core/data-plane/languageqna/Raw/@azure-tools/typespec-autorest/openapi.json index 5f03c880f8..ec0fe43084 100644 --- a/packages/samples/test/output/azure/core/data-plane/languageqna/Raw/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/languageqna/Raw/@azure-tools/typespec-autorest/openapi.json @@ -71,7 +71,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -112,7 +112,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -166,7 +166,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -228,7 +228,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -277,7 +277,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -326,7 +326,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -365,7 +365,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -417,7 +417,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -470,7 +470,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -513,7 +513,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -561,7 +561,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -609,7 +609,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -644,7 +644,7 @@ "description": "There is no content to send for this request, but the headers may be useful. " }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -689,7 +689,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -732,7 +732,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -776,7 +776,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -816,7 +816,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -859,7 +859,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -903,7 +903,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -943,7 +943,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -981,7 +981,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, diff --git a/packages/samples/test/output/azure/core/data-plane/languageqna/Raw/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/azure/core/data-plane/languageqna/Raw/@typespec/openapi3/openapi.yaml index 22d1686219..05e26011e8 100644 --- a/packages/samples/test/output/azure/core/data-plane/languageqna/Raw/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/azure/core/data-plane/languageqna/Raw/@typespec/openapi3/openapi.yaml @@ -21,7 +21,7 @@ paths: schema: $ref: '#/components/schemas/PagedProjectMetadata' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -52,7 +52,7 @@ paths: schema: $ref: '#/components/schemas/DeletionJobState' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -83,7 +83,7 @@ paths: schema: $ref: '#/components/schemas/ProjectMetadata' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -119,7 +119,7 @@ paths: schema: $ref: '#/components/schemas/ProjectMetadata' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -179,7 +179,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -215,7 +215,7 @@ paths: type: string format: uri default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -252,7 +252,7 @@ paths: type: string format: uri default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -284,7 +284,7 @@ paths: schema: $ref: '#/components/schemas/PagedProjectDeployment' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -313,7 +313,7 @@ paths: schema: $ref: '#/components/schemas/PagedSynonymAsset' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -338,7 +338,7 @@ paths: schema: $ref: '#/components/schemas/PagedSynonymAsset' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -387,7 +387,7 @@ paths: type: string format: uri default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -430,7 +430,7 @@ paths: schema: $ref: '#/components/schemas/DeploymentJobState' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -467,7 +467,7 @@ paths: schema: $ref: '#/components/schemas/ExportJobState' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -494,7 +494,7 @@ paths: '204': description: 'There is no content to send for this request, but the headers may be useful. ' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -531,7 +531,7 @@ paths: schema: $ref: '#/components/schemas/JobState' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -560,7 +560,7 @@ paths: schema: $ref: '#/components/schemas/PagedQnaSourceRecord' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -585,7 +585,7 @@ paths: schema: $ref: '#/components/schemas/PagedQnaSourceRecord' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -619,7 +619,7 @@ paths: schema: $ref: '#/components/schemas/JobMetadata' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -648,7 +648,7 @@ paths: schema: $ref: '#/components/schemas/PagedQnaSourceRecord' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -673,7 +673,7 @@ paths: schema: $ref: '#/components/schemas/PagedQnaSourceRecord' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -707,7 +707,7 @@ paths: schema: $ref: '#/components/schemas/JobMetadata' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2022-08-31/openapi.json index c2071eaeb6..598bae4b0e 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -34,7 +34,7 @@ ], "responses": { "200": { - "description": "Paged collection of Manufacturer items", + "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/PagedManufacturer" }, @@ -47,7 +47,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -98,7 +98,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -220,7 +220,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -320,7 +320,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -389,7 +389,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -438,7 +438,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -478,7 +478,7 @@ ], "responses": { "200": { - "description": "Paged collection of Widget items", + "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/PagedWidget" }, @@ -491,7 +491,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -542,7 +542,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -677,7 +677,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -778,7 +778,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -847,7 +847,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2023-02-07/openapi.json b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2023-02-07/openapi.json index 86ee749a55..be1e609371 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2023-02-07/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@azure-tools/typespec-autorest/2023-02-07/openapi.json @@ -34,7 +34,7 @@ ], "responses": { "200": { - "description": "Paged collection of Manufacturer items", + "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/PagedManufacturer" }, @@ -47,7 +47,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -114,7 +114,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -256,7 +256,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -368,7 +368,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -437,7 +437,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -486,7 +486,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -526,7 +526,7 @@ ], "responses": { "200": { - "description": "Paged collection of Widget items", + "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/PagedWidget" }, @@ -539,7 +539,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -606,7 +606,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -761,7 +761,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -874,7 +874,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -943,7 +943,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml index 9daf800022..624d5f4a46 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2022-08-31.yaml @@ -13,7 +13,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: Paged collection of Manufacturer items + description: The request has succeeded. headers: x-ms-client-request-id: required: false @@ -25,7 +25,7 @@ paths: schema: $ref: '#/components/schemas/PagedManufacturer' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -87,7 +87,7 @@ paths: schema: $ref: '#/components/schemas/Manufacturer' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -131,7 +131,7 @@ paths: schema: $ref: '#/components/schemas/Manufacturer' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -197,7 +197,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -254,7 +254,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -291,7 +291,7 @@ paths: required: - statusString default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -315,7 +315,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: Paged collection of Widget items + description: The request has succeeded. headers: x-ms-client-request-id: required: false @@ -327,7 +327,7 @@ paths: schema: $ref: '#/components/schemas/PagedWidget' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -401,7 +401,7 @@ paths: schema: $ref: '#/components/schemas/Widget' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -445,7 +445,7 @@ paths: schema: $ref: '#/components/schemas/Widget' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -511,7 +511,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -568,7 +568,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false diff --git a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml index a3447df7ab..4e58c53855 100644 --- a/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml +++ b/packages/samples/test/output/azure/core/data-plane/trait-versioning/@typespec/openapi3/openapi.2023-02-07.yaml @@ -13,7 +13,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: Paged collection of Manufacturer items + description: The request has succeeded. headers: x-ms-client-request-id: required: false @@ -25,7 +25,7 @@ paths: schema: $ref: '#/components/schemas/PagedManufacturer' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -101,7 +101,7 @@ paths: schema: $ref: '#/components/schemas/Manufacturer' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -154,7 +154,7 @@ paths: schema: $ref: '#/components/schemas/Manufacturer' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -224,7 +224,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -281,7 +281,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -318,7 +318,7 @@ paths: required: - statusString default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -342,7 +342,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: Paged collection of Widget items + description: The request has succeeded. headers: x-ms-client-request-id: required: false @@ -354,7 +354,7 @@ paths: schema: $ref: '#/components/schemas/PagedWidget' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -442,7 +442,7 @@ paths: schema: $ref: '#/components/schemas/Widget' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -495,7 +495,7 @@ paths: schema: $ref: '#/components/schemas/Widget' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -565,7 +565,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -622,7 +622,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false diff --git a/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json index dd3bdb97cd..c810dce66d 100644 --- a/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -34,7 +34,7 @@ ], "responses": { "200": { - "description": "Paged collection of Manufacturer items", + "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/PagedManufacturer" }, @@ -47,7 +47,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -114,7 +114,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -256,7 +256,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -368,7 +368,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -437,7 +437,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -486,7 +486,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -526,7 +526,7 @@ ], "responses": { "200": { - "description": "Paged collection of Widget items", + "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/PagedWidget" }, @@ -539,7 +539,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -606,7 +606,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -761,7 +761,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -874,7 +874,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -994,7 +994,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1059,7 +1059,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1204,7 +1204,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1272,7 +1272,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1307,7 +1307,7 @@ ], "responses": { "200": { - "description": "Paged collection of WidgetPart items", + "description": "The request has succeeded.", "schema": { "$ref": "#/definitions/PagedWidgetPart" }, @@ -1320,7 +1320,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1426,7 +1426,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1497,7 +1497,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1589,7 +1589,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1664,7 +1664,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1778,7 +1778,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, @@ -1843,7 +1843,7 @@ } }, "default": { - "description": "A response containing error details.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Azure.Core.Foundations.ErrorResponse" }, diff --git a/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml index a3f8f459fd..cdfbd44141 100644 --- a/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml @@ -13,7 +13,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: Paged collection of Manufacturer items + description: The request has succeeded. headers: x-ms-client-request-id: required: false @@ -25,7 +25,7 @@ paths: schema: $ref: '#/components/schemas/PagedManufacturer' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -101,7 +101,7 @@ paths: schema: $ref: '#/components/schemas/Manufacturer' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -154,7 +154,7 @@ paths: schema: $ref: '#/components/schemas/Manufacturer' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -224,7 +224,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -281,7 +281,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -318,7 +318,7 @@ paths: required: - statusString default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -342,7 +342,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: Paged collection of Widget items + description: The request has succeeded. headers: x-ms-client-request-id: required: false @@ -354,7 +354,7 @@ paths: schema: $ref: '#/components/schemas/PagedWidget' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -406,7 +406,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -494,7 +494,7 @@ paths: schema: $ref: '#/components/schemas/Widget' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -547,7 +547,7 @@ paths: schema: $ref: '#/components/schemas/Widget' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -617,7 +617,7 @@ paths: description: Error object that describes the error when status is "Failed". description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -664,7 +664,7 @@ paths: schema: $ref: '#/components/schemas/WidgetAnalytics' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -739,7 +739,7 @@ paths: schema: $ref: '#/components/schemas/WidgetAnalytics' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -803,7 +803,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -858,7 +858,7 @@ paths: schema: $ref: '#/components/schemas/Azure.Core.uuid' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -890,7 +890,7 @@ paths: - $ref: '#/components/parameters/Azure.Core.ClientRequestIdHeader' responses: '200': - description: Paged collection of WidgetPart items + description: The request has succeeded. headers: x-ms-client-request-id: required: false @@ -902,7 +902,7 @@ paths: schema: $ref: '#/components/schemas/PagedWidgetPart' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -955,7 +955,7 @@ paths: schema: $ref: '#/components/schemas/WidgetPart' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -1005,7 +1005,7 @@ paths: schema: $ref: '#/components/schemas/Azure.Core.uuid' default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -1068,7 +1068,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -1139,7 +1139,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false @@ -1247,7 +1247,7 @@ paths: description: The result of the operation. description: Provides status details for long running operations. default: - description: A response containing error details. + description: An unexpected error response. headers: x-ms-error-code: required: false diff --git a/packages/samples/test/output/azure/core/misc/appconfig/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/azure/core/misc/appconfig/@azure-tools/typespec-autorest/openapi.json index 2fa259c1b0..33dd5aa703 100644 --- a/packages/samples/test/output/azure/core/misc/appconfig/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/azure/core/misc/appconfig/@azure-tools/typespec-autorest/openapi.json @@ -66,7 +66,7 @@ } }, "default": { - "description": "Azure App Configuration error object.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Error" } @@ -113,7 +113,7 @@ } }, "default": { - "description": "Azure App Configuration error object.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Error" } @@ -192,7 +192,7 @@ } }, "default": { - "description": "Azure App Configuration error object.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Error" } @@ -258,7 +258,7 @@ } }, "default": { - "description": "Azure App Configuration error object.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Error" } @@ -336,7 +336,7 @@ } }, "default": { - "description": "Azure App Configuration error object.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Error" } @@ -402,7 +402,7 @@ } }, "default": { - "description": "Azure App Configuration error object.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Error" } @@ -472,7 +472,7 @@ } }, "default": { - "description": "Azure App Configuration error object.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Error" } @@ -534,7 +534,7 @@ } }, "default": { - "description": "Azure App Configuration error object.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Error" } @@ -579,7 +579,7 @@ } }, "default": { - "description": "Azure App Configuration error object.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Error" } @@ -633,7 +633,7 @@ } }, "default": { - "description": "Azure App Configuration error object.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Error" } @@ -697,7 +697,7 @@ } }, "default": { - "description": "Azure App Configuration error object.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Error" } @@ -752,7 +752,7 @@ } }, "default": { - "description": "Azure App Configuration error object.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Error" } @@ -805,7 +805,7 @@ } }, "default": { - "description": "Azure App Configuration error object.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Error" } @@ -884,7 +884,7 @@ } }, "default": { - "description": "Azure App Configuration error object.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Error" } @@ -931,7 +931,7 @@ } }, "default": { - "description": "Azure App Configuration error object.", + "description": "An unexpected error response.", "schema": { "$ref": "#/definitions/Error" } diff --git a/packages/samples/test/output/azure/core/misc/appconfig/@typespec/openapi3/openapi.yaml b/packages/samples/test/output/azure/core/misc/appconfig/@typespec/openapi3/openapi.yaml index b1dacf90bd..834c2a0a2d 100644 --- a/packages/samples/test/output/azure/core/misc/appconfig/@typespec/openapi3/openapi.yaml +++ b/packages/samples/test/output/azure/core/misc/appconfig/@typespec/openapi3/openapi.yaml @@ -39,7 +39,7 @@ paths: schema: $ref: '#/components/schemas/PagedKey' default: - description: Azure App Configuration error object. + description: An unexpected error response. content: application/problem+json: schema: @@ -71,7 +71,7 @@ paths: schema: type: string default: - description: Azure App Configuration error object. + description: An unexpected error response. content: application/problem+json: schema: @@ -120,7 +120,7 @@ paths: schema: $ref: '#/components/schemas/PagedKeyValue' default: - description: Azure App Configuration error object. + description: An unexpected error response. content: application/problem+json: schema: @@ -159,7 +159,7 @@ paths: schema: type: string default: - description: Azure App Configuration error object. + description: An unexpected error response. content: application/problem+json: schema: @@ -210,7 +210,7 @@ paths: schema: $ref: '#/components/schemas/KeyValue' default: - description: Azure App Configuration error object. + description: An unexpected error response. content: application/problem+json: schema: @@ -239,7 +239,7 @@ paths: type: string format: date default: - description: Azure App Configuration error object. + description: An unexpected error response. content: application/problem+json: schema: @@ -278,7 +278,7 @@ paths: schema: $ref: '#/components/schemas/KeyValue' default: - description: Azure App Configuration error object. + description: An unexpected error response. content: application/problem+json: schema: @@ -340,7 +340,7 @@ paths: schema: $ref: '#/components/schemas/KeyValue' default: - description: Azure App Configuration error object. + description: An unexpected error response. content: application/problem+json: schema: @@ -395,7 +395,7 @@ paths: schema: type: string default: - description: Azure App Configuration error object. + description: An unexpected error response. content: application/problem+json: schema: @@ -435,7 +435,7 @@ paths: schema: $ref: '#/components/schemas/PagedLabel' default: - description: Azure App Configuration error object. + description: An unexpected error response. content: application/problem+json: schema: @@ -476,7 +476,7 @@ paths: schema: type: string default: - description: Azure App Configuration error object. + description: An unexpected error response. content: application/problem+json: schema: @@ -513,7 +513,7 @@ paths: schema: $ref: '#/components/schemas/KeyValue' default: - description: Azure App Configuration error object. + description: An unexpected error response. content: application/problem+json: schema: @@ -549,7 +549,7 @@ paths: schema: $ref: '#/components/schemas/KeyValue' default: - description: Azure App Configuration error object. + description: An unexpected error response. content: application/problem+json: schema: @@ -601,7 +601,7 @@ paths: schema: $ref: '#/components/schemas/PagedKeyValue' default: - description: Azure App Configuration error object. + description: An unexpected error response. content: application/problem+json: schema: @@ -633,7 +633,7 @@ paths: schema: type: string default: - description: Azure App Configuration error object. + description: An unexpected error response. content: application/problem+json: schema: diff --git a/packages/samples/test/output/core/documentation/@azure-tools/typespec-autorest/openapi.json b/packages/samples/test/output/core/documentation/@azure-tools/typespec-autorest/openapi.json index 112c60529a..9d9b9a404a 100644 --- a/packages/samples/test/output/core/documentation/@azure-tools/typespec-autorest/openapi.json +++ b/packages/samples/test/output/core/documentation/@azure-tools/typespec-autorest/openapi.json @@ -98,7 +98,7 @@ } }, "404": { - "description": "Not found", + "description": "The server cannot find the requested resource.", "schema": { "$ref": "#/definitions/NotFoundWithDocsResp" } From 8fc49082357b906e4ac8efe4340d09139b1f7ce0 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Wed, 28 Feb 2024 13:50:07 -0800 Subject: [PATCH 04/14] Reduce breaking changes --- core | 2 +- packages/typespec-autorest/src/openapi.ts | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/core b/core index 836430a844..7353bb857d 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 836430a84415be31bb641e0eb56c2c1feed9d2a5 +Subproject commit 7353bb857d6d124635133ad5c7562a1c83fdff3a diff --git a/packages/typespec-autorest/src/openapi.ts b/packages/typespec-autorest/src/openapi.ts index 5a48d3230e..76de073b80 100644 --- a/packages/typespec-autorest/src/openapi.ts +++ b/packages/typespec-autorest/src/openapi.ts @@ -110,7 +110,6 @@ import { getStatusCodeDescription, getVisibilitySuffix, isContentTypeHeader, - isExplicitBodyValid, isSharedRoute, reportIfNoRoutes, resolveRequestVisibility, @@ -879,8 +878,7 @@ function createOAPIEmitter( ? { type: "file" } : getSchemaOrRef(body.type, { visibility: Visibility.Read, - ignoreMetadataAnnotations: - body.isExplicit && !isExplicitBodyValid(program, body.property!), + ignoreMetadataAnnotations: body.isExplicit && body.containsMetadataAnnotations, }); } @@ -1086,8 +1084,7 @@ function createOAPIEmitter( const schemaContext = { visibility, ignoreMetadataAnnotations: - methodParams.body.isExplicit && - !isExplicitBodyValid(program, methodParams.body.parameter!), + methodParams.body.isExplicit && methodParams.body.containsMetadataAnnotations, }; const schema = isBinary ? { type: "string", format: "binary" } From b6e20911c1a7b8bc59189df14047df116dc0998c Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Wed, 28 Feb 2024 13:54:22 -0800 Subject: [PATCH 05/14] . --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index 7353bb857d..87fc5f32fa 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 7353bb857d6d124635133ad5c7562a1c83fdff3a +Subproject commit 87fc5f32fafa7b1166ead2f3d0b06beb59881fa7 From a02a31a7758a9eb0ab705b0608f09b75244e6669 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 16 Apr 2024 12:22:52 -0700 Subject: [PATCH 06/14] Create uptake-body-consitency-2024-3-16-19-18-52.md --- .../changes/uptake-body-consitency-2024-3-16-19-18-52.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .chronus/changes/uptake-body-consitency-2024-3-16-19-18-52.md diff --git a/.chronus/changes/uptake-body-consitency-2024-3-16-19-18-52.md b/.chronus/changes/uptake-body-consitency-2024-3-16-19-18-52.md new file mode 100644 index 0000000000..af68c7673a --- /dev/null +++ b/.chronus/changes/uptake-body-consitency-2024-3-16-19-18-52.md @@ -0,0 +1,8 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: fix +packages: + - "@azure-tools/typespec-autorest" +--- + +Add support for new `@body` `@bodyRoot` and `@bodyIgnore` decorators From af1b683760b8b0d75e5a7bc38a344908d1f47be7 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 16 Apr 2024 12:23:17 -0700 Subject: [PATCH 07/14] Create uptake-body-consitency-2024-3-16-19-18-53.md --- .../changes/uptake-body-consitency-2024-3-16-19-18-53.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .chronus/changes/uptake-body-consitency-2024-3-16-19-18-53.md diff --git a/.chronus/changes/uptake-body-consitency-2024-3-16-19-18-53.md b/.chronus/changes/uptake-body-consitency-2024-3-16-19-18-53.md new file mode 100644 index 0000000000..40e2bcc6d3 --- /dev/null +++ b/.chronus/changes/uptake-body-consitency-2024-3-16-19-18-53.md @@ -0,0 +1,9 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: fix +packages: + - "@azure-tools/typespec-azure-core" + - "@azure-tools/typespec-azure-resource-manager" +--- + +Update to support new meaning of `@body` From 39bc5f0ba1c36140b73c2a8fcb2189d24e11d3b4 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 16 Apr 2024 13:13:45 -0700 Subject: [PATCH 08/14] update autorest canonical --- core | 2 +- .../reference/data-types.md | 16 +- .../src/openapi.ts | 168 +++++++++++------- .../test/metadata.test.ts | 7 +- .../test/produces-consumes.test.ts | 2 +- .../test/return-types.test.ts | 138 +++++++++----- .../typespec-autorest/test/metadata.test.ts | 30 +--- .../test/return-types.test.ts | 2 +- .../test/resource.test.ts | 1 - tsconfig.ws.json | 1 + 10 files changed, 219 insertions(+), 148 deletions(-) diff --git a/core b/core index 9ece16a357..46c8073b9a 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 9ece16a357340968e5359cc4edcf2aaff775b5d1 +Subproject commit 46c8073b9abe8b774d172265f804bda39b69b3d8 diff --git a/docs/libraries/azure-resource-manager/reference/data-types.md b/docs/libraries/azure-resource-manager/reference/data-types.md index 1dade9c2bd..ab990671e0 100644 --- a/docs/libraries/azure-resource-manager/reference/data-types.md +++ b/docs/libraries/azure-resource-manager/reference/data-types.md @@ -308,10 +308,10 @@ model Azure.ResourceManager.ArmResourceCreatedSyncResponse #### Properties -| Name | Type | Description | -| ---------- | ---------- | --------------------------------------------------- | -| body | `Resource` | The body type of the operation request or response. | -| statusCode | `201` | The status code. | +| Name | Type | Description | +| ---------- | ---------- | ---------------- | +| statusCode | `201` | The status code. | +| body | `Resource` | | ### `ArmResourceExistsResponse` {#Azure.ResourceManager.ArmResourceExistsResponse} @@ -372,10 +372,10 @@ model Azure.ResourceManager.ArmResponse #### Properties -| Name | Type | Description | -| ---------- | -------------- | --------------------------------------------------- | -| statusCode | `200` | The status code. | -| body | `ResponseBody` | The body type of the operation request or response. | +| Name | Type | Description | +| ---------- | -------------- | ---------------- | +| statusCode | `200` | The status code. | +| body | `ResponseBody` | | ### `CustomerManagedKeyEncryption` {#Azure.ResourceManager.CustomerManagedKeyEncryption} diff --git a/packages/typespec-autorest-canonical/src/openapi.ts b/packages/typespec-autorest-canonical/src/openapi.ts index 41ce9918fe..b0483d10c7 100644 --- a/packages/typespec-autorest-canonical/src/openapi.ts +++ b/packages/typespec-autorest-canonical/src/openapi.ts @@ -89,6 +89,7 @@ import { HttpOperation, HttpOperationParameters, HttpOperationResponse, + HttpOperationResponseBody, HttpStatusCodeRange, HttpStatusCodesEntry, MetadataInfo, @@ -146,6 +147,11 @@ import { } from "./types.js"; import { AutorestCanonicalEmitterContext, resolveOperationId } from "./utils.js"; +interface SchemaContext { + readonly visibility: Visibility; + readonly ignoreMetadataAnnotations: boolean; +} + const defaultOptions = { "output-file": "{azure-resource-provider-folder}/{service-name}/{version}/openapi.json", "new-line": "lf", @@ -418,7 +424,10 @@ function createOAPIEmitter( } const parameters: OpenAPI2PathParameter[] = []; for (const prop of server.parameters.values()) { - const param = getOpenAPI2Parameter(prop, "path", Visibility.Read); + const param = getOpenAPI2Parameter(prop, "path", { + visibility: Visibility.Read, + ignoreMetadataAnnotations: false, + }); if ( prop.type.kind === "Scalar" && ignoreDiagnostics( @@ -785,7 +794,7 @@ function createOAPIEmitter( openapiResponse["x-ms-error-response"] = true; } const contentTypes: string[] = []; - let body: Type | undefined; + let body: HttpOperationResponseBody | undefined; for (const data of response.responses) { if (data.headers && Object.keys(data.headers).length > 0) { openapiResponse.headers ??= {}; @@ -795,20 +804,25 @@ function createOAPIEmitter( } if (data.body) { - if (body && body !== data.body.type) { + if (body && body.type !== data.body.type) { reportDiagnostic(program, { code: "duplicate-body-types", target: response.type, }); } - body = data.body.type; + body = data.body; contentTypes.push(...data.body.contentTypes); } } if (body) { - const isBinary = contentTypes.every((t) => isBinaryPayload(body!, t)); - openapiResponse.schema = isBinary ? { type: "file" } : getSchemaOrRef(body, Visibility.Read); + const isBinary = contentTypes.every((t) => isBinaryPayload(body!.type, t)); + openapiResponse.schema = isBinary + ? { type: "file" } + : getSchemaOrRef(body.type, { + visibility: Visibility.Read, + ignoreMetadataAnnotations: body.isExplicit && body.containsMetadataAnnotations, + }); } for (const contentType of contentTypes) { @@ -820,14 +834,17 @@ function createOAPIEmitter( function getResponseHeader(prop: ModelProperty): OpenAPI2HeaderDefinition { const header: any = {}; - populateParameter(header, prop, "header", Visibility.Read); + populateParameter(header, prop, "header", { + visibility: Visibility.Read, + ignoreMetadataAnnotations: false, + }); delete header.in; delete header.name; delete header.required; return header; } - function getSchemaOrRef(type: Type, visibility: Visibility): any { + function getSchemaOrRef(type: Type, schemaContext: SchemaContext): any { if (type.kind === "Scalar" && program.checker.isStdType(type)) { return getSchemaForScalar(type); } @@ -854,14 +871,14 @@ function createOAPIEmitter( } if (type.kind === "ModelProperty") { - return resolveProperty(type, visibility); + return resolveProperty(type, schemaContext); } - type = metadataInfo.getEffectivePayloadType(type, visibility); + type = metadataInfo.getEffectivePayloadType(type, schemaContext.visibility); const name = getOpenAPITypeName(program, type, typeNameOptions); if (shouldInline(program, type)) { - const schema = getSchemaForInlineType(type, name, visibility); + const schema = getSchemaForInlineType(type, name, schemaContext); if (schema === undefined && isErrorType(type)) { // Exit early so that syntax errors are exposed. This error will @@ -876,18 +893,18 @@ function createOAPIEmitter( return schema; } else { // Use shared schema when type is not transformed by visibility from the canonical read visibility. - if (!metadataInfo.isTransformed(type, visibility)) { - visibility = Visibility.Read; + if (!metadataInfo.isTransformed(type, schemaContext.visibility)) { + schemaContext = { ...schemaContext, visibility: Visibility.Read }; } - const pending = pendingSchemas.getOrAdd(type, visibility, () => ({ + const pending = pendingSchemas.getOrAdd(type, schemaContext.visibility, () => ({ type, - visibility, - ref: refs.getOrAdd(type, visibility, () => new Ref()), + visibility: schemaContext.visibility, + ref: refs.getOrAdd(type, schemaContext.visibility, () => new Ref()), })); return { $ref: pending.ref }; } } - function getSchemaForInlineType(type: Type, name: string, visibility: Visibility) { + function getSchemaForInlineType(type: Type, name: string, context: SchemaContext) { if (inProgressInlineTypes.has(type)) { reportDiagnostic(program, { code: "inline-cycle", @@ -897,7 +914,7 @@ function createOAPIEmitter( return {}; } inProgressInlineTypes.add(type); - const schema = getSchemaForType(type, visibility); + const schema = getSchemaForType(type, context); inProgressInlineTypes.delete(type); return schema; } @@ -958,7 +975,12 @@ function createOAPIEmitter( if (httpOpParam.type === "header" && isContentTypeHeader(program, httpOpParam.param)) { continue; } - emitParameter(httpOpParam.param, httpOpParam.type, visibility, httpOpParam.name); + emitParameter( + httpOpParam.param, + httpOpParam.type, + { visibility, ignoreMetadataAnnotations: false }, + httpOpParam.name + ); } if (consumes.length === 0 && methodParams.body) { @@ -974,9 +996,14 @@ function createOAPIEmitter( if (methodParams.body && !isVoidType(methodParams.body.type)) { const isBinary = isBinaryPayload(methodParams.body.type, consumes); + const schemaContext = { + visibility, + ignoreMetadataAnnotations: + methodParams.body.isExplicit && methodParams.body.containsMetadataAnnotations, + }; const schema = isBinary ? { type: "string", format: "binary" } - : getSchemaOrRef(methodParams.body.type, visibility); + : getSchemaOrRef(methodParams.body.type, schemaContext); if (currentConsumes.has("multipart/form-data")) { const bodyModelType = methodParams.body.type; @@ -984,14 +1011,14 @@ function createOAPIEmitter( compilerAssert(bodyModelType.kind === "Model", "Body should always be a Model."); if (bodyModelType) { for (const param of bodyModelType.properties.values()) { - emitParameter(param, "formData", visibility, getJsonName(param)); + emitParameter(param, "formData", schemaContext, getJsonName(param)); } } } else if (methodParams.body.parameter) { emitParameter( methodParams.body.parameter, "body", - visibility, + { visibility, ignoreMetadataAnnotations: false }, getJsonName(methodParams.body.parameter), schema ); @@ -1025,7 +1052,7 @@ function createOAPIEmitter( function emitParameter( param: ModelProperty, kind: OpenAPI2ParameterType, - visibility: Visibility, + schemaContext: SchemaContext, name?: string, typeOverride?: any ) { @@ -1038,17 +1065,17 @@ function createOAPIEmitter( // If the parameter already has a $ref, don't bother populating it if (!("$ref" in ph)) { - populateParameter(ph, param, kind, visibility, name, typeOverride); + populateParameter(ph, param, kind, schemaContext, name, typeOverride); } } function getSchemaForPrimitiveItems( type: Type, - visibility: Visibility, + schemaContext: SchemaContext, paramName: string, multipart?: boolean ): PrimitiveItems | undefined { - const fullSchema = getSchemaForType(type, visibility); + const fullSchema = getSchemaForType(type, schemaContext); if (fullSchema === undefined) { return undefined; } @@ -1066,7 +1093,7 @@ function createOAPIEmitter( function getFormDataSchema( type: Type, - visibility: Visibility, + schemaContext: SchemaContext, paramName: string ): Omit | undefined { if (isBytes(type)) { @@ -1074,7 +1101,7 @@ function createOAPIEmitter( } if (type.kind === "Model" && isArrayModelType(program, type)) { - const schema = getSchemaForPrimitiveItems(type.indexer.value, visibility, paramName, true); + const schema = getSchemaForPrimitiveItems(type.indexer.value, schemaContext, paramName, true); if (schema === undefined) { return undefined; } @@ -1086,7 +1113,7 @@ function createOAPIEmitter( items: schema, }; } else { - const schema = getSchemaForPrimitiveItems(type, visibility, paramName, true); + const schema = getSchemaForPrimitiveItems(type, schemaContext, paramName, true); if (schema === undefined) { return undefined; @@ -1099,7 +1126,7 @@ function createOAPIEmitter( function getOpenAPI2Parameter( param: ModelProperty, kind: T, - visibility: Visibility, + schemaContext: SchemaContext, name?: string, bodySchema?: any ): OpenAPI2Parameter & { in: T } { @@ -1120,7 +1147,7 @@ function createOAPIEmitter( compilerAssert(bodySchema, "bodySchema argument is required to populate body parameter"); ph.schema = bodySchema; } else if (ph.in === "formData") { - Object.assign(ph, getFormDataSchema(param.type, visibility, ph.name)); + Object.assign(ph, getFormDataSchema(param.type, schemaContext, ph.name)); } else { const collectionFormat = ( kind === "query" @@ -1139,12 +1166,12 @@ function createOAPIEmitter( if (param.type.kind === "Model" && isArrayModelType(program, param.type)) { ph.type = "array"; const schema = { - ...getSchemaForPrimitiveItems(param.type.indexer.value, visibility, ph.name), + ...getSchemaForPrimitiveItems(param.type.indexer.value, schemaContext, ph.name), }; delete (schema as any).description; ph.items = schema; } else { - Object.assign(ph, getSchemaForPrimitiveItems(param.type, visibility, ph.name)); + Object.assign(ph, getSchemaForPrimitiveItems(param.type, schemaContext, ph.name)); } } @@ -1162,11 +1189,11 @@ function createOAPIEmitter( ph: OpenAPI2Parameter, param: ModelProperty, kind: OpenAPI2ParameterType, - visibility: Visibility, + schemaContext: SchemaContext, name?: string, bodySchema?: any ) { - Object.assign(ph, getOpenAPI2Parameter(param, kind, visibility, name, bodySchema)); + Object.assign(ph, getOpenAPI2Parameter(param, kind, schemaContext, name, bodySchema)); } function emitParameters() { @@ -1223,7 +1250,10 @@ function createOAPIEmitter( for (const [visibility, pending] of group) { processedSchemas.getOrAdd(type, visibility, () => ({ ...pending, - schema: getSchemaForType(type, visibility), + schema: getSchemaForType(type, { + visibility: visibility, + ignoreMetadataAnnotations: false, + }), })); } pendingSchemas.delete(type); @@ -1234,7 +1264,7 @@ function createOAPIEmitter( function processUnreferencedSchemas() { const addSchema = (type: Type) => { if (!processedSchemas.has(type) && !paramModels.has(type) && !shouldInline(program, type)) { - getSchemaOrRef(type, Visibility.Read); + getSchemaOrRef(type, { visibility: Visibility.Read, ignoreMetadataAnnotations: false }); } }; const skipSubNamespaces = isGlobalNamespace(program, serviceNamespace); @@ -1258,7 +1288,7 @@ function createOAPIEmitter( } } - function getSchemaForType(type: Type, visibility: Visibility): OpenAPI2Schema | undefined { + function getSchemaForType(type: Type, schemaContext: SchemaContext): OpenAPI2Schema | undefined { const builtinType = getSchemaForLiterals(type); if (builtinType !== undefined) { return builtinType; @@ -1268,15 +1298,15 @@ function createOAPIEmitter( case "Intrinsic": return getSchemaForIntrinsicType(type); case "Model": - return getSchemaForModel(type, visibility); + return getSchemaForModel(type, schemaContext); case "ModelProperty": - return getSchemaForType(type.type, visibility); + return getSchemaForType(type.type, schemaContext); case "Scalar": return getSchemaForScalar(type); case "Union": - return getSchemaForUnion(type, visibility); + return getSchemaForUnion(type, schemaContext); case "UnionVariant": - return getSchemaForUnionVariant(type, visibility); + return getSchemaForUnionVariant(type, schemaContext); case "Enum": return getSchemaForEnum(type); case "Tuple": @@ -1377,7 +1407,7 @@ function createOAPIEmitter( return applyIntrinsicDecorators(union, schema); } - function getSchemaForUnion(union: Union, visibility: Visibility): OpenAPI2Schema { + function getSchemaForUnion(union: Union, schemaContext: SchemaContext): OpenAPI2Schema { const nonNullOptions = [...union.variants.values()] .map((x) => x.type) .filter((t) => !isNullType(t)); @@ -1391,7 +1421,7 @@ function createOAPIEmitter( const type = nonNullOptions[0]; // Get the schema for the model type - const schema = getSchemaOrRef(type, visibility); + const schema = getSchemaOrRef(type, schemaContext); if (schema.$ref) { if (type.kind === "Model") { return { type: "object", allOf: [schema], "x-nullable": nullable }; @@ -1425,8 +1455,11 @@ function createOAPIEmitter( ); } - function getSchemaForUnionVariant(variant: UnionVariant, visibility: Visibility): OpenAPI2Schema { - return getSchemaForType(variant.type, visibility)!; + function getSchemaForUnionVariant( + variant: UnionVariant, + schemaContext: SchemaContext + ): OpenAPI2Schema { + return getSchemaForType(variant.type, schemaContext)!; } function getDefaultValue(type: Type): any { @@ -1477,8 +1510,8 @@ function createOAPIEmitter( }); } - function getSchemaForModel(model: Model, visibility: Visibility) { - const array = getArrayType(model, visibility); + function getSchemaForModel(model: Model, schemaContext: SchemaContext) { + const array = getArrayType(model, schemaContext); if (array) { return array; } @@ -1507,14 +1540,14 @@ function createOAPIEmitter( const properties: OpenAPI2Schema["properties"] = {}; if (isRecordModelType(program, model)) { - modelSchema.additionalProperties = getSchemaOrRef(model.indexer.value, visibility); + modelSchema.additionalProperties = getSchemaOrRef(model.indexer.value, schemaContext); } const derivedModels = model.derivedModels.filter(includeDerivedModel); // getSchemaOrRef on all children to push them into components.schemas for (const child of derivedModels) { - getSchemaOrRef(child, visibility); + getSchemaOrRef(child, schemaContext); } const discriminator = getDiscriminator(program, model); @@ -1543,7 +1576,13 @@ function createOAPIEmitter( reportDisallowedDecorator(UnsupportedVersioningDecorators.TypeChangedFrom, prop.type); } - if (!metadataInfo.isPayloadProperty(prop, visibility)) { + if ( + !metadataInfo.isPayloadProperty( + prop, + schemaContext.visibility, + schemaContext.ignoreMetadataAnnotations + ) + ) { continue; } @@ -1565,7 +1604,10 @@ function createOAPIEmitter( } } - if (!metadataInfo.isOptional(prop, visibility) || prop.name === discriminator?.propertyName) { + if ( + !metadataInfo.isOptional(prop, schemaContext.visibility) || + prop.name === discriminator?.propertyName + ) { if (!modelSchema.required) { modelSchema.required = []; } @@ -1573,7 +1615,7 @@ function createOAPIEmitter( } // Apply decorators on the property to the type's schema - properties[jsonName] = resolveProperty(prop, visibility); + properties[jsonName] = resolveProperty(prop, schemaContext); const property: OpenAPI2SchemaProperty = properties[jsonName]; if (jsonName !== clientName) { property["x-ms-client-name"] = clientName; @@ -1623,10 +1665,10 @@ function createOAPIEmitter( ) { // Take the base model schema but carry across the documentation property // that we set before - const baseSchema = getSchemaForType(model.baseModel, visibility); + const baseSchema = getSchemaForType(model.baseModel, schemaContext); Object.assign(modelSchema, baseSchema, { description: modelSchema.description }); } else if (model.baseModel) { - const baseSchema = getSchemaOrRef(model.baseModel, visibility); + const baseSchema = getSchemaOrRef(model.baseModel, schemaContext); modelSchema.allOf = [baseSchema]; } @@ -1652,7 +1694,10 @@ function createOAPIEmitter( return true; } - function resolveProperty(prop: ModelProperty, visibility: Visibility): OpenAPI2SchemaProperty { + function resolveProperty( + prop: ModelProperty, + schemaContext: SchemaContext + ): OpenAPI2SchemaProperty { let propSchema; if (prop.type.kind === "Enum" && prop.default) { propSchema = getSchemaForEnum(prop.type); @@ -1661,10 +1706,10 @@ function createOAPIEmitter( if (asEnum) { propSchema = getSchemaForUnionEnum(prop.type, asEnum); } else { - propSchema = getSchemaOrRef(prop.type, visibility); + propSchema = getSchemaOrRef(prop.type, schemaContext); } } else { - propSchema = getSchemaOrRef(prop.type, visibility); + propSchema = getSchemaOrRef(prop.type, schemaContext); } return applyIntrinsicDecorators(prop, propSchema); @@ -1936,11 +1981,14 @@ function createOAPIEmitter( /** * If the model is an array model return the OpenAPI2Schema for the array type. */ - function getArrayType(typespecType: Model, visibility: Visibility): OpenAPI2Schema | undefined { + function getArrayType(typespecType: Model, context: SchemaContext): OpenAPI2Schema | undefined { if (isArrayModelType(program, typespecType)) { const array: OpenAPI2Schema = { type: "array", - items: getSchemaOrRef(typespecType.indexer.value!, visibility | Visibility.Item), + items: getSchemaOrRef(typespecType.indexer.value!, { + ...context, + visibility: context.visibility | Visibility.Item, + }), }; if (!ifArrayItemContainsIdentifier(program, typespecType as any)) { array["x-ms-identifiers"] = []; diff --git a/packages/typespec-autorest-canonical/test/metadata.test.ts b/packages/typespec-autorest-canonical/test/metadata.test.ts index 9ed6a62078..5ccca863f5 100644 --- a/packages/typespec-autorest-canonical/test/metadata.test.ts +++ b/packages/typespec-autorest-canonical/test/metadata.test.ts @@ -332,7 +332,7 @@ it("puts inapplicable metadata in schema", async () => { @header h: string; } @route("/single") @get op single(...Parameters): string; - @route("/batch") @get op batch(...Body): string; + @route("/batch") @get op batch(@bodyRoot body: Parameters[]): string; ` ); deepStrictEqual(res.paths, { @@ -363,7 +363,6 @@ it("puts inapplicable metadata in schema", async () => { }, parameters: [ { - description: "The body type of the operation request or response.", in: "body", name: "body", required: true, @@ -532,11 +531,11 @@ it("handles cycle in transformed model", async () => { }); }); -it("supports nested metadata and removes emptied properties", async () => { +it("supports nested metadata and removes properties with @bodyIgnore", async () => { const res = await openApiFor( ` model Pet { - headers: { + @bodyIgnore headers: { @header h1: string; moreHeaders: { @header h2: string; diff --git a/packages/typespec-autorest-canonical/test/produces-consumes.test.ts b/packages/typespec-autorest-canonical/test/produces-consumes.test.ts index 14c9f4a1fd..c92024ca12 100644 --- a/packages/typespec-autorest-canonical/test/produces-consumes.test.ts +++ b/packages/typespec-autorest-canonical/test/produces-consumes.test.ts @@ -126,7 +126,7 @@ function createAdlFromConfig(configuration: ProducesConsumesOperation[]): string configuration.forEach((config) => { const opString = config.type === "consumes" - ? `@delete op remove(@body payload : ${config.modelName}) : NoContentResponse;` + ? `@delete op remove(@bodyRoot payload : ${config.modelName}) : NoContentResponse;` : `@get op read() : ${config.modelName};`; const doc = ` ${config.modelDef} diff --git a/packages/typespec-autorest-canonical/test/return-types.test.ts b/packages/typespec-autorest-canonical/test/return-types.test.ts index 9a4a3f6325..60cb421a9b 100644 --- a/packages/typespec-autorest-canonical/test/return-types.test.ts +++ b/packages/typespec-autorest-canonical/test/return-types.test.ts @@ -1,12 +1,30 @@ import { expectDiagnostics } from "@typespec/compiler/testing"; import { deepStrictEqual, ok, strictEqual } from "assert"; -import { describe, it } from "vitest"; +import { describe, expect, it } from "vitest"; import { createAutorestCanonicalTestRunner, ignoreUseStandardOps, openApiFor, } from "./test-host.js"; +it("model used with @body and without shouldn't conflict if it contains no metadata", async () => { + const res = await openApiFor( + ` + model Foo { + name: string; + } + @route("c1") op c1(): Foo; + @route("c2") op c2(): {@body _: Foo}; + ` + ); + deepStrictEqual(res.paths["/c1"].get.responses["200"].schema, { + $ref: "#/definitions/Foo", + }); + deepStrictEqual(res.paths["/c2"].get.responses["200"].schema, { + $ref: "#/definitions/Foo", + }); +}); + it("defines responses with response headers", async () => { const res = await openApiFor( ` @@ -257,34 +275,6 @@ it("defines responses with top-level array type", async () => { strictEqual(res.paths["/"].get.responses["200"].schema.type, "array"); }); -it("return type with no properties should be 200 with empty object as type", async () => { - const res = await openApiFor( - ` - @get op test(): {}; - ` - ); - - const responses = res.paths["/"].get.responses; - ok(responses["200"]); - deepStrictEqual(responses["200"].schema, { - type: "object", - }); -}); - -it("{} return type should produce 200 ", async () => { - const res = await openApiFor( - ` - @get op test(): {}; - ` - ); - - const responses = res.paths["/"].get.responses; - ok(responses["200"]); - deepStrictEqual(responses["200"].schema, { - type: "object", - }); -}); - it("produce additionalProperties schema if response is Record", async () => { const res = await openApiFor( ` @@ -302,7 +292,7 @@ it("produce additionalProperties schema if response is Record", async () => { }); }); -it("return type with only response metadata should be 204 response w/ no content", async () => { +it("return type with only response metadata should be 200 response w/ no content", async () => { const res = await openApiFor( ` @get op delete(): {@header date: string}; @@ -310,23 +300,9 @@ it("return type with only response metadata should be 204 response w/ no content ); const responses = res.paths["/"].get.responses; - ok(responses["204"]); - ok(responses["204"].schema === undefined, "response should have no content"); - ok(responses["200"] === undefined); -}); - -it("defaults status code to 204 when implicit body has no content", async () => { - const res = await openApiFor( - ` - @delete - op delete(): { @header date: string }; - ` - ); - const responses = res.paths["/"].delete.responses; - ok(responses["200"] === undefined); - ok(responses["204"]); - ok(responses["204"].headers["date"]); - ok(responses["204"].schema === undefined); + ok(responses["200"]); + ok(responses["200"].schema === undefined, "response should have no content"); + ok(responses["204"] === undefined); }); it("defaults status code to default when model has @error decorator", async () => { @@ -494,7 +470,73 @@ it("defaults to 204 no content with void response type", async () => { it("defaults to 204 no content with void @body", async () => { const res = await openApiFor(`@get op read(): {@body body: void};`); - ok(res.paths["/"].get.responses["204"]); + ok(res.paths["/"].get.responses["200"]); +}); +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, + #suppress "@typespec/http/metadata-ignored" + @query query: string, + #suppress "@typespec/http/metadata-ignored" + @statusCode code: 201, + } + };`); + expect(res.paths["/"].get.responses["200"].schema).toEqual({ + type: "object", + properties: { + header: { type: "string" }, + query: { type: "string" }, + code: { type: "number", enum: [201] }, + }, + required: ["header", "query", "code"], + }); +}); + +describe("response model resolving to no property in the body produce no body", () => { + it.each(["{}", "{@header prop: string}", `{@visibility("none") prop: string}`])( + "%s", + async (body) => { + const res = await openApiFor(`op test(): ${body};`); + strictEqual(res.paths["/"].get.responses["200"].schema, undefined); + } + ); +}); + +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; + }; + name: string; + };`); + expect(res.paths["/"].get.responses["200"].schema).toEqual({ + type: "object", + properties: { + headers: { type: "object" }, + name: { type: "string" }, + }, + required: ["headers", "name"], + }); +}); + +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; + }; + name: string; + };`); + expect(res.paths["/"].get.responses["200"].schema).toEqual({ + type: "object", + properties: { + name: { type: "string" }, + }, + required: ["name"], + }); }); describe("binary responses", () => { diff --git a/packages/typespec-autorest/test/metadata.test.ts b/packages/typespec-autorest/test/metadata.test.ts index d29c53d1d1..89a31560ba 100644 --- a/packages/typespec-autorest/test/metadata.test.ts +++ b/packages/typespec-autorest/test/metadata.test.ts @@ -334,7 +334,7 @@ describe("typespec-autorest: metadata", () => { @header h: string; } @route("/single") @get op single(...Parameters): string; - @route("/batch") @get op batch(@bodyRoot _: Parameters[]): string; + @route("/batch") @get op batch(@bodyRoot body: Parameters[]): string; ` ); deepStrictEqual(res.paths, { @@ -366,7 +366,7 @@ describe("typespec-autorest: metadata", () => { parameters: [ { in: "body", - name: "_", + name: "body", required: true, schema: { type: "array", @@ -533,11 +533,11 @@ describe("typespec-autorest: metadata", () => { }); }); - it("supports nested metadata and removes emptied properties", async () => { + it("supports nested metadata and removes properties with @bodyIgnore ", async () => { const res = await openApiFor( ` model Pet { - headers: { + @bodyIgnore headers: { @header h1: string; moreHeaders: { @header h2: string; @@ -605,33 +605,15 @@ describe("typespec-autorest: metadata", () => { PetCreate: { type: "object", properties: { - headers: { - type: "object", - properties: { - moreHeaders: { - type: "object", - }, - }, - required: ["moreHeaders"], - }, name: { type: "string", }, }, - required: ["headers", "name"], + required: ["name"], }, Pet: { type: "object", properties: { - headers: { - type: "object", - properties: { - moreHeaders: { - type: "object", - }, - }, - required: ["moreHeaders"], - }, id: { type: "string", }, @@ -639,7 +621,7 @@ describe("typespec-autorest: metadata", () => { type: "string", }, }, - required: ["headers", "id", "name"], + required: ["id", "name"], }, }); }); diff --git a/packages/typespec-autorest/test/return-types.test.ts b/packages/typespec-autorest/test/return-types.test.ts index 919f032c25..543dfd9b63 100644 --- a/packages/typespec-autorest/test/return-types.test.ts +++ b/packages/typespec-autorest/test/return-types.test.ts @@ -289,7 +289,7 @@ describe("typespec-autorest: return types", () => { }); }); - it("return type with only response metadata should be 204 response w/ no content", async () => { + it("return type with only response metadata should be 200 response w/ no content", async () => { const res = await openApiFor( ` @get op delete(): {@header date: string}; diff --git a/packages/typespec-azure-resource-manager/test/resource.test.ts b/packages/typespec-azure-resource-manager/test/resource.test.ts index 274c435997..dd4b72b386 100644 --- a/packages/typespec-azure-resource-manager/test/resource.test.ts +++ b/packages/typespec-azure-resource-manager/test/resource.test.ts @@ -785,7 +785,6 @@ describe("typespec-azure-resource-manager: ARM resource model", () => { version: string, file: string ) { - console.log(">..", openApi.paths[path].get.responses["200"]); assertRef( openApi.paths[path].get.responses["200"].schema, `../../common-types/resource-management/${version}/${file}#/definitions/${defName}` diff --git a/tsconfig.ws.json b/tsconfig.ws.json index 3997f662c2..392a571ce7 100644 --- a/tsconfig.ws.json +++ b/tsconfig.ws.json @@ -2,6 +2,7 @@ "references": [ { "path": "core/tsconfig.ws.json" }, { "path": "packages/typespec-autorest/tsconfig.json" }, + { "path": "packages/typespec-autorest-canonical/tsconfig.json" }, { "path": "packages/typespec-azure-core/tsconfig.json" }, { "path": "packages/typespec-azure-resource-manager/tsconfig.json" }, { "path": "packages/typespec-client-generator-core/tsconfig.json" }, From b6aeb68c2547021dc29a914f05454c97052947f2 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 16 Apr 2024 13:21:13 -0700 Subject: [PATCH 09/14] Create uptake-body-consitency-2024-3-16-20-19-22.md --- .../changes/uptake-body-consitency-2024-3-16-20-19-22.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .chronus/changes/uptake-body-consitency-2024-3-16-20-19-22.md diff --git a/.chronus/changes/uptake-body-consitency-2024-3-16-20-19-22.md b/.chronus/changes/uptake-body-consitency-2024-3-16-20-19-22.md new file mode 100644 index 0000000000..a4b9be13b1 --- /dev/null +++ b/.chronus/changes/uptake-body-consitency-2024-3-16-20-19-22.md @@ -0,0 +1,8 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: fix +packages: + - "@azure-tools/typespec-autorest-canonical" +--- + +Add support for new `@body`, `@bodyRoot` and `@bodyIgnore` From 6bd873bedce56a9b3d56977a996cbc874fe4bb9d Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 16 Apr 2024 13:28:04 -0700 Subject: [PATCH 10/14] fix test --- .../test/rules/arm-post-response-codes.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/typespec-azure-resource-manager/test/rules/arm-post-response-codes.test.ts b/packages/typespec-azure-resource-manager/test/rules/arm-post-response-codes.test.ts index aa5ca857b6..1651b020eb 100644 --- a/packages/typespec-azure-resource-manager/test/rules/arm-post-response-codes.test.ts +++ b/packages/typespec-azure-resource-manager/test/rules/arm-post-response-codes.test.ts @@ -146,7 +146,7 @@ it("Does not emit a warning for a long-running post operation that satisfies the @pollingOperation(Widgets.getStatus, {widgetName: RequestParameter<"name">, statusId: ResponseProperty<"operationId">}) @finalOperation(Widgets.getWidget, {widgetName: RequestParameter<"name">}) @armResourceAction(Widget) - @post create(...KeysOf, @body body: Widget): { + @post create(...KeysOf, @bodyRoot body: Widget): { @statusCode code: "202"; @header("x-ms-operation-id") operationId: string; } | { @@ -192,10 +192,10 @@ it("Emits a warning for a long-running post operation that has a 202 response wi @pollingOperation(Widgets.getStatus, {widgetName: RequestParameter<"name">, statusId: ResponseProperty<"operationId">}) @finalOperation(Widgets.getWidget, {widgetName: RequestParameter<"name">}) @armResourceAction(Widget) - @post create(...KeysOf, @body body: Widget): { + @post create(...KeysOf, @bodyRoot body: Widget): { @statusCode code: "202"; @header("x-ms-operation-id") operationId: string; - @body body: Widget; + @bodyRoot body: Widget; } | ErrorResponse; }` ) @@ -239,7 +239,7 @@ it("Emits a warning for a long-running post operation that has a 200 response wi @pollingOperation(Widgets.getStatus, {widgetName: RequestParameter<"name">, statusId: ResponseProperty<"operationId">}) @finalOperation(Widgets.getWidget, {widgetName: RequestParameter<"name">}) @armResourceAction(Widget) - @post create(...KeysOf, @body body: Widget): { + @post create(...KeysOf, @bodyRoot body: Widget): { @statusCode code: "202"; @header("x-ms-operation-id") operationId: string; } | { @@ -288,7 +288,7 @@ it("Emits a warning for a long-running post operation that has invalid response @pollingOperation(Widgets.getStatus, {widgetName: RequestParameter<"name">, statusId: ResponseProperty<"operationId">}) @finalOperation(Widgets.getWidget, {widgetName: RequestParameter<"name">}) @armResourceAction(Widget) - @post create(...KeysOf, @body body: Widget): { + @post create(...KeysOf, @bodyRoot body: Widget): { @statusCode code: "203"; @header("x-ms-operation-id") operationId: string } | ErrorResponse; From de1a3954d0d625d1773654d3b1743b1d08a0993d Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 16 Apr 2024 13:51:20 -0700 Subject: [PATCH 11/14] fix --- packages/samples/specs/data-plane/widget-manager/main.tsp | 2 +- .../@azure-tools/typespec-autorest/2022-08-31/openapi.json | 6 +----- .../@typespec/openapi3/openapi.2022-08-31.yaml | 6 +----- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/packages/samples/specs/data-plane/widget-manager/main.tsp b/packages/samples/specs/data-plane/widget-manager/main.tsp index 5e34cbb7ed..291bf39d6d 100644 --- a/packages/samples/specs/data-plane/widget-manager/main.tsp +++ b/packages/samples/specs/data-plane/widget-manager/main.tsp @@ -236,7 +236,7 @@ interface WidgetParts { reorderParts is Operations.LongRunningResourceCollectionAction< WidgetPart, WidgetPartReorderRequest, - TypeSpec.Http.AcceptedResponse + {} >; } diff --git a/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json index 8e787b03a9..4274f4e78a 100644 --- a/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -1731,7 +1731,7 @@ "description": "Error object that describes the error when status is \"Failed\"." }, "result": { - "$ref": "#/definitions/TypeSpec.Http.AcceptedResponse", + "type": "object", "description": "The result of the operation." } }, @@ -2061,10 +2061,6 @@ "value" ] }, - "TypeSpec.Http.AcceptedResponse": { - "type": "object", - "description": "The request has been accepted for processing, but processing has not yet completed." - }, "Versions": { "type": "string", "description": "The Contoso Widget Manager service version.", diff --git a/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml index 431ac6acec..f60c34ea91 100644 --- a/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml @@ -1134,8 +1134,7 @@ paths: - $ref: '#/components/schemas/Azure.Core.Foundations.Error' description: Error object that describes the error when status is "Failed". result: - allOf: - - $ref: '#/components/schemas/TypeSpec.Http.AcceptedResponse' + type: object description: The result of the operation. description: Provides status details for long running operations. default: @@ -1512,9 +1511,6 @@ components: - accepted - rejected description: Repeatability Result header options - TypeSpec.Http.AcceptedResponse: - type: object - description: The request has been accepted for processing, but processing has not yet completed. Versions: type: string enum: From 46a4e7c2cd6e6edc51db5040ab0b2c1cdef2147c Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 16 Apr 2024 13:53:30 -0700 Subject: [PATCH 12/14] update core --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index 46c8073b9a..a5d101db25 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 46c8073b9abe8b774d172265f804bda39b69b3d8 +Subproject commit a5d101db258a6a4cec3864c7ce0d87ce07f145ee From 4d3958a988ae1687171de0ee1dface7ffbe22bb4 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 16 Apr 2024 15:16:35 -0700 Subject: [PATCH 13/14] use never --- packages/samples/specs/data-plane/widget-manager/main.tsp | 2 +- .../@azure-tools/typespec-autorest/2022-08-31/openapi.json | 4 ---- .../widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml | 3 --- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/samples/specs/data-plane/widget-manager/main.tsp b/packages/samples/specs/data-plane/widget-manager/main.tsp index 291bf39d6d..e39be4c2bd 100644 --- a/packages/samples/specs/data-plane/widget-manager/main.tsp +++ b/packages/samples/specs/data-plane/widget-manager/main.tsp @@ -236,7 +236,7 @@ interface WidgetParts { reorderParts is Operations.LongRunningResourceCollectionAction< WidgetPart, WidgetPartReorderRequest, - {} + never >; } diff --git a/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json b/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json index 4274f4e78a..807f834437 100644 --- a/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json +++ b/packages/samples/test/output/azure/core/data-plane/widget-manager/@azure-tools/typespec-autorest/2022-08-31/openapi.json @@ -1729,10 +1729,6 @@ "error": { "$ref": "#/definitions/Azure.Core.Foundations.Error", "description": "Error object that describes the error when status is \"Failed\"." - }, - "result": { - "type": "object", - "description": "The result of the operation." } }, "required": [ diff --git a/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml b/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml index f60c34ea91..d9cfb92383 100644 --- a/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml +++ b/packages/samples/test/output/azure/core/data-plane/widget-manager/@typespec/openapi3/openapi.2022-08-31.yaml @@ -1133,9 +1133,6 @@ paths: allOf: - $ref: '#/components/schemas/Azure.Core.Foundations.Error' description: Error object that describes the error when status is "Failed". - result: - type: object - description: The result of the operation. description: Provides status details for long running operations. default: description: An unexpected error response. From f9be3a5eea0e834be0f0889262e11c5bc326aac5 Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Wed, 17 Apr 2024 11:21:33 -0700 Subject: [PATCH 14/14] Use main: --- core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core b/core index a5d101db25..1265330298 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit a5d101db258a6a4cec3864c7ce0d87ce07f145ee +Subproject commit 1265330298d86b648d06bb755e823f2fd383c5e9