Skip to content

op-reference-container-route

Id
@typespec/http/op-reference-container-route

Check for referenced (op is) operations which have a @route on one of their containers.

When referencing an operation with op is, only the data on the operation itself is carried over; anything on the parent container is lost. This results in unexpected behavior where information such as the route prefix is silently dropped. As a best practice the route should be provided on the operation itself.

namespace Library {
@route("/pets")
interface Pets {
@route("/read") read(): string;
}
}
@service
namespace Service {
interface PetStore {
readPet is Library.Pets.read;
}
}
namespace Library {
interface Pets {
@route("/pets/read") read(): string;
}
}
@service
namespace Service {
interface PetStore {
readPet is Library.Pets.read;
}
}