Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tcgc] language's emitter should report tcgc's diagnostics #1487

Open
tadelesh opened this issue Sep 5, 2024 · 1 comment
Open

[tcgc] language's emitter should report tcgc's diagnostics #1487

tadelesh opened this issue Sep 5, 2024 · 1 comment
Labels
feature New feature or request lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Comments

@tadelesh
Copy link
Member

tadelesh commented Sep 5, 2024

After emitter use TCGC createSdkContext, the returned SdkContext value contains all the diagnostics found when generating SDK interfaces in TCGC: diagnostics: readonly Diagnostic[];, language's emitter should report them when they use TCGC using the code: program.reportDiagnostics(sdkContext.diagnostics);

Current diagnostics in TCGC listed as follows:

"example-loading": {
  severity: "warning",
  messages: {
	default: paramMessage`Skipped loading invalid example file: ${"filename"}. Error: ${"error"}`,
	noDirectory: paramMessage`Skipping example loading from ${"directory"} because there was an error reading the directory.`,
	noOperationId: paramMessage`Skipping example file ${"filename"} because it does not contain an operationId and/or title.`,
  },
},
"duplicate-example-file": {
  severity: "error",
  messages: {
	default: paramMessage`Example file ${"filename"} uses duplicate title '${"title"}' for operationId '${"operationId"}'`,
  },
},
"example-value-no-mapping": {
  severity: "warning",
  messages: {
	default: paramMessage`Value in example file '${"relativePath"}' does not follow its definition:\n${"value"}`,
  },
},
"unexpected-http-param-type": {
  severity: "error",
  messages: {
	default: paramMessage`Expected parameter "${"paramName"}" to be of type "${"expectedType"}", but instead it is of type "${"actualType"}"`,
  },
},
"multiple-response-types": {
  severity: "warning",
  messages: {
	default: paramMessage`Multiple response types found in operation ${"operation"}. Only one response type is supported, so we will choose the first one ${"response"}`,
  },
},
"no-corresponding-method-param": {
  severity: "error",
  messages: {
	default: paramMessage`Missing "${"paramName"}" method parameter in method "${"methodName"}", when "${"paramName"}" must be sent to the service. Add a parameter named "${"paramName"}" to the method.`,
  },
},
"no-emitter-name": {
  severity: "warning",
  messages: {
	default: "Can not find name for your emitter, please check your emitter name.",
  },
},
"unsupported-generic-decorator-arg-type": {
  severity: "warning",
  messages: {
	default: paramMessage`Can not parse the arg type for decorator "${"decoratorName"}".`,
  },
},
"unsupported-protocol": {
  severity: "error",
  messages: {
	default: "Currently we only support HTTP and HTTPS protocols",
  },
},
"server-param-not-path": {
  severity: "error",
  messages: {
	default: paramMessage`Template argument ${"templateArgumentName"} is not a path parameter, it is a ${"templateArgumentType"}. It has to be a path.`,
  },
},
"multiple-services": {
  severity: "warning",
  messages: {
	default: paramMessage`Multiple services found in definition. Only one service is supported, so we will choose the first one ${"service"}`,
  },
},
"union-null": {
  severity: "error",
  messages: {
	default: "Cannot have a union containing only null types.",
  },
},
"discriminator-not-constant": {
  severity: "error",
  messages: {
	default: paramMessage`Discriminator ${"discriminator"} has to be constant`,
  },
},
"discriminator-not-string": {
  severity: "warning",
  messages: {
	default: paramMessage`Value of discriminator ${"discriminator"} has to be a string, not ${"discriminatorValue"}`,
  },
},
"unsupported-kind": {
  severity: "warning",
  messages: {
	default: paramMessage`Unsupported kind ${"kind"}`,
  },
},
"encoding-multipart-bytes": {
  severity: "error",
  messages: {
	default:
	  "Encoding should not be applied to bytes content in a multipart request. This is semi-incompatible with how multipart works in HTTP.",
  },
},
"conflict-usage-override": {
  severity: "warning",
  messages: {
	default: `@usage override conflicts with the usage calculated from operation or other @usage override.`,
  },
},
"conflict-access-override": {
  severity: "warning",
  messages: {
	default: `@access override conflicts with the access calculated from operation or other @access override.`,
  },
},
"conflicting-multipart-model-usage": {
  severity: "error",
  messages: {
	default: "Invalid encoding",
	wrongType: paramMessage`Model '${"modelName"}' cannot be used as both multipart/form-data input and regular body input. You can create a separate model with name 'model ${"modelName"}FormData' extends ${"modelName"} {}`,
  },
}
@tadelesh tadelesh added lib:tcgc Issues for @azure-tools/typespec-client-generator-core library feature New feature or request and removed needs-area labels Sep 5, 2024
@weidongxu-microsoft
Copy link
Member

blocked by #1510

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request lib:tcgc Issues for @azure-tools/typespec-client-generator-core library
Projects
None yet
Development

No branches or pull requests

2 participants