Repository navigation
"Model name must be alphanumeric" with namespaced models #12451
Replies: 1 comment 3 replies
|
You can keep the TypeSpec namespaces and give the emitted schema an explicit alphanumeric name with import "@typespec/http";
import "@typespec/openapi3";
using TypeSpec.Http;
@service
namespace Demo {
namespace MyNamespace {
@friendlyName("MyNamespaceUser")
model User {
id: string;
}
}
@get
@route("/users")
op listUsers(): MyNamespace.User[];
}I compiled this minimal example with $ref: '#/components/schemas/MyNamespaceUser'The emitter's shared schema-naming helper uses the friendly name before falling back to the namespace-qualified TypeSpec name. Give other referenced models unique alphanumeric names as needed; simply removing dots can introduce collisions between different namespaces. AWS documents the alphanumeric restriction under API Gateway's REST API import limitations. This fixes the name in the generated OpenAPI document; I have not tested importing your full schema into AWS, which has other OpenAPI restrictions too. |
Uh oh!
There was an error while loading. Please reload this page.
We have an OpenAPI schema that's passed to API Gateway in AWS. I'm trying to rewrite it with TypeSpec. I wrote the schema to utilize namespaces, so the OpenAPI schema contains models like
MyNamespace.User. When I upload this to AWS, I get "Model name must be alphanumeric". Is it possible to do this, or am I forced to flatten all my namespaces?All reactions