@typespec/http
Advanced tools
@@ -66,4 +66,7 @@ export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{ | ||
"multipart-model": { | ||
readonly default: "Multipart request body must be a model."; | ||
readonly default: "Multipart request body must be a model or a tuple of http parts."; | ||
}; | ||
"no-implicit-multipart": { | ||
readonly default: "Using multipart payloads requires the use of @multipartBody and HttpPart<T> models."; | ||
}; | ||
"multipart-part": { | ||
@@ -82,3 +85,3 @@ readonly default: "Expect item to be an HttpPart model."; | ||
}, Record<string, any>, "file" | "path" | "query" | "authentication" | "header" | "cookie" | "body" | "bodyRoot" | "bodyIgnore" | "multipartBody" | "statusCode" | "verbs" | "patchOptions" | "servers" | "includeInapplicableMetadataInPayload" | "externalInterfaces" | "routeProducer" | "routes" | "sharedRoutes" | "routeOptions" | "httpPart">; | ||
export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "missing-uri-param" | "incompatible-uri-param" | "use-uri-template" | "optional-path-param" | "missing-server-param" | "duplicate-body" | "duplicate-route-decorator" | "operation-param-duplicate-type" | "duplicate-operation" | "multiple-status-codes" | "status-code-invalid" | "content-type-string" | "content-type-ignored" | "metadata-ignored" | "response-cookie-not-supported" | "no-service-found" | "invalid-type-for-auth" | "shared-inconsistency" | "multipart-invalid-content-type" | "multipart-model" | "multipart-part" | "multipart-nested" | "http-file-extra-property" | "formdata-no-part-name", M extends keyof { | ||
export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "missing-uri-param" | "incompatible-uri-param" | "use-uri-template" | "optional-path-param" | "missing-server-param" | "duplicate-body" | "duplicate-route-decorator" | "operation-param-duplicate-type" | "duplicate-operation" | "multiple-status-codes" | "status-code-invalid" | "content-type-string" | "content-type-ignored" | "metadata-ignored" | "response-cookie-not-supported" | "no-service-found" | "invalid-type-for-auth" | "shared-inconsistency" | "multipart-invalid-content-type" | "multipart-model" | "no-implicit-multipart" | "multipart-part" | "multipart-nested" | "http-file-extra-property" | "formdata-no-part-name", M extends keyof { | ||
"http-verb-duplicate": { | ||
@@ -148,4 +151,7 @@ readonly default: import("@typespec/compiler").CallableMessage<["entityName"]>; | ||
"multipart-model": { | ||
readonly default: "Multipart request body must be a model."; | ||
readonly default: "Multipart request body must be a model or a tuple of http parts."; | ||
}; | ||
"no-implicit-multipart": { | ||
readonly default: "Using multipart payloads requires the use of @multipartBody and HttpPart<T> models."; | ||
}; | ||
"multipart-part": { | ||
@@ -228,4 +234,7 @@ readonly default: "Expect item to be an HttpPart model."; | ||
"multipart-model": { | ||
readonly default: "Multipart request body must be a model."; | ||
readonly default: "Multipart request body must be a model or a tuple of http parts."; | ||
}; | ||
"no-implicit-multipart": { | ||
readonly default: "Using multipart payloads requires the use of @multipartBody and HttpPart<T> models."; | ||
}; | ||
"multipart-part": { | ||
@@ -243,3 +252,3 @@ readonly default: "Expect item to be an HttpPart model."; | ||
}; | ||
}, C, M>) => void, createDiagnostic: <C extends "http-verb-duplicate" | "missing-uri-param" | "incompatible-uri-param" | "use-uri-template" | "optional-path-param" | "missing-server-param" | "duplicate-body" | "duplicate-route-decorator" | "operation-param-duplicate-type" | "duplicate-operation" | "multiple-status-codes" | "status-code-invalid" | "content-type-string" | "content-type-ignored" | "metadata-ignored" | "response-cookie-not-supported" | "no-service-found" | "invalid-type-for-auth" | "shared-inconsistency" | "multipart-invalid-content-type" | "multipart-model" | "multipart-part" | "multipart-nested" | "http-file-extra-property" | "formdata-no-part-name", M extends keyof { | ||
}, C, M>) => void, createDiagnostic: <C extends "http-verb-duplicate" | "missing-uri-param" | "incompatible-uri-param" | "use-uri-template" | "optional-path-param" | "missing-server-param" | "duplicate-body" | "duplicate-route-decorator" | "operation-param-duplicate-type" | "duplicate-operation" | "multiple-status-codes" | "status-code-invalid" | "content-type-string" | "content-type-ignored" | "metadata-ignored" | "response-cookie-not-supported" | "no-service-found" | "invalid-type-for-auth" | "shared-inconsistency" | "multipart-invalid-content-type" | "multipart-model" | "no-implicit-multipart" | "multipart-part" | "multipart-nested" | "http-file-extra-property" | "formdata-no-part-name", M extends keyof { | ||
"http-verb-duplicate": { | ||
@@ -309,4 +318,7 @@ readonly default: import("@typespec/compiler").CallableMessage<["entityName"]>; | ||
"multipart-model": { | ||
readonly default: "Multipart request body must be a model."; | ||
readonly default: "Multipart request body must be a model or a tuple of http parts."; | ||
}; | ||
"no-implicit-multipart": { | ||
readonly default: "Using multipart payloads requires the use of @multipartBody and HttpPart<T> models."; | ||
}; | ||
"multipart-part": { | ||
@@ -389,4 +401,7 @@ readonly default: "Expect item to be an HttpPart model."; | ||
"multipart-model": { | ||
readonly default: "Multipart request body must be a model."; | ||
readonly default: "Multipart request body must be a model or a tuple of http parts."; | ||
}; | ||
"no-implicit-multipart": { | ||
readonly default: "Using multipart payloads requires the use of @multipartBody and HttpPart<T> models."; | ||
}; | ||
"multipart-part": { | ||
@@ -393,0 +408,0 @@ readonly default: "Expect item to be an HttpPart model."; |
@@ -131,5 +131,11 @@ import { createTypeSpecLibrary, paramMessage } from "@typespec/compiler"; | ||
messages: { | ||
default: "Multipart request body must be a model.", | ||
default: "Multipart request body must be a model or a tuple of http parts.", | ||
}, | ||
}, | ||
"no-implicit-multipart": { | ||
severity: "error", | ||
messages: { | ||
default: "Using multipart payloads requires the use of @multipartBody and HttpPart<T> models.", | ||
}, | ||
}, | ||
"multipart-part": { | ||
@@ -136,0 +142,0 @@ severity: "error", |
@@ -31,15 +31,6 @@ import { createDiagnosticCollector, filterModelProperties, getDiscriminator, getEncode, getMediaTypeHint, isArrayModelType, navigateType, } from "@typespec/compiler"; | ||
if (body) { | ||
if (body.contentTypes.some((x) => x.startsWith("multipart/")) && body.bodyKind === "single") { | ||
diagnostics.add({ | ||
severity: "warning", | ||
code: "deprecated", | ||
message: `Deprecated: Implicit multipart is deprecated, use @multipartBody instead with HttpPart`, | ||
target: body.property ?? type, | ||
}); | ||
} | ||
if (body.contentTypes.includes("multipart/form-data") && | ||
body.bodyKind === "single" && | ||
body.type.kind !== "Model") { | ||
if (body.contentTypes.some((x) => x.startsWith("multipart/")) && | ||
body.bodyKind !== "multipart") { | ||
diagnostics.add(createDiagnostic({ | ||
code: "multipart-model", | ||
code: "no-implicit-multipart", | ||
target: body.property ?? type, | ||
@@ -46,0 +37,0 @@ })); |
{ | ||
"name": "@typespec/http", | ||
"version": "0.68.0-dev.5", | ||
"version": "0.68.0-dev.6", | ||
"author": "Microsoft Corporation", | ||
@@ -5,0 +5,0 @@ "description": "TypeSpec HTTP protocol binding", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
404764
0.14%5150
0.23%