Skip to content

no-openapi

Full name
@azure-tools/typespec-azure-core/no-openapi

Azure services should not be using decorators from the OpenAPIs libraries(@azure-tools/openapi, @azure-tools/typespec-autorest or @azure-tools/openapi3) in their spec. Using those decorators is usually a sign that the spec is either not following the correct Azure or trying to match exactly a particular OpenAPI spec which should be a non-goal.

Those decorators are only meant to be read by the openapi emitters which means this might achieve the correct OpenAPI output but other emitters(client SDK, service, etc.) will not be able to understand them and will see a broken representation of the spec.

OpenAPI DecoratorAlternative
@exampleSee examples doc
@extension("x-ms-examples", See examples doc
@extension("x-ms-client-flatten", TCGC @flattenProperty
@extension("x-ms-mutability", Use @visibility decorator
@extension("x-ms-enum", Enum extensibility doc
@extension("x-ms-identifiers", Use @identifiers
@operationIdName your interface and operation accordingly
@useRefThis should not be used, define the types correctly in TypeSpec. For ARM common types read the Arm docs
@infoUse versioning library for version and @service for title
@extension(
"x-ms-enum",
{
name: "PetKind",
modelAsString: true,
}
)
enum PetKind {
Cat,
Dog,
}
union PetKind {
Cat: "Cat",
Dog: "Dog",
string,
}
model Pet {
@extension("x-ms-mutability", #["read", "create"])
name: string;
}
model Pet {
@extension("x-ms-identifiers", #["customId"])
names: Name[];
}
model Name {
customId: string;
}
model Pet {
@identifiers(#["customId"])
names: Name[];
}
model Name {
customId: string;
}
@operationId("Pet_Get")
op getPet(): Pet;
interface Pet {
get(): Pet;
}