Skip to content

Update base TypeSpec to generate clients in their corresponding nested namespaces #721

@ShivangiReja

Description

@ShivangiReja

Currently, there is only one namespace, namespace OpenAI;, in the base TypeSpec. We need to be able to generate clients in their corresponding nested namespaces (e.g., ChatClientOpenAI.Chat, OpenAIResponseClientOpenAI.Responses, and any new feature → OpenAI.<Feature>).

My understanding is that TypeSpec has a feature that could help with this: 🔗 https://typespec.io/docs/language-basics/namespaces/

The solution might be to write our base TypeSpec files (models.tsp, operations.tsp..etc) in a way that leverages this feature so that each sub-client goes into its own namespace.

By doing this,

  • We don’t have to write custom code for each type, just to update the namespace.
  • This will also enable us to apply decorators at the namespace level in client.tsp. Currently, we can’t scope a decorator to a specific subclient(like Response or Chat) via namespace, so the only option is annotating each target model individually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: architectureThis item is related to general architecture of the OpenAI client library.blocked: specThis issue is blocked on a needed REST API spec update.team-work-item

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions