Skip to content

example-value-no-mapping

Id
@azure-tools/typespec-client-generator-core/example-value-no-mapping

Severity: warning

This diagnostic is issued when a value from an example file cannot be matched to the TypeSpec definition.

  • Area: Example value conversion. Generation continues, but the mismatched example value is not mapped into SDK example data for the operation.
  • Not affected: The operation signature and generated client method are unchanged.
@service
namespace TestClient {
@route("/{b}")
op parametersDiagnostic(
// example file provides unmapped parameter `test` for this operation
@header a: string,
@path b: string,
@query c: string,
@body d: string,
): void;
}

TCGC reports:

Value in example file 'parametersDiagnostic.json' does not follow its definition:
{"test":"a"}

Update the example value or the TypeSpec definition so parameters, request bodies, and responses follow the declared shapes.

@service
namespace TestClient {
@route("/{b}")
op parametersDiagnostic(
@header a: string,
@path b: string,
@query c: string,
@query test: string,
@body d: string,
): void;
}

This diagnostic should not be suppressed. Fix the example so its values map to the TypeSpec definition.