Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[protobuf] Support setting fileName in TypeSpec.Protobuf.PackageDetails #5462

Open
3 tasks done
kolaworld opened this issue Dec 29, 2024 · 0 comments
Open
3 tasks done
Assignees
Labels
design:needed A design request has been raised that needs a proposal emitter:protobuf The protobuf emitter triaged:core
Milestone

Comments

@kolaworld
Copy link

kolaworld commented Dec 29, 2024

Clear and concise description of the problem

The TypeSpec.Protobuf.package decorator name property results in a generated file rather than a directory matching the package name.

Current State

Given the following:

import "@typespec/protobuf";

using TypeSpec.Protobuf;

@package({
    name: "my.example.v1",
    options: {
        go_package: "github.com/org/repo/go/my/example/v1",
    },
})
namespace Example;

The protobuf emitter emits a file /my/example/v1.proto, see playground.

I would expect /my/example/v1/generated.proto

Problem

This prevents the ability to add multiple manual .proto files along side the generated proto under the same package "my.example.v1".

  • Given /my/example/v1.proto, I cannot add /my/example/v1/non-generated.proto

This also breaks the linter for the popular bufbuild tool which expects the package name to match a directory path minus a filename - "my.example.v1" -> /my/example/v1/.

Solution (non-breaking)

Add a property fileName to the TypeSpec.Protobuf.PackageDetails to allow generating proto files with a specific filename.

If no fileName is provided, maintain backwards compatibility by emitting the current state.

Example with fileName would result in emitted file: /my/example/v1/cool.proto

@package({
    name: "my.example.v1",
    fileName: "cool"
    options: {
        go_package: "github.com/org/repo/go/my/example/v1",
    },
})
namespace Example;

Other considerations

I imagine it is better to add a new property fileName to TypeSpec.Protobuf.PackageDetails rather than a new protobuf emitter --option="@typespec/protobuf.file-name=xxx" as the former would persist the file name to support .proto import directives.

Checklist

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@markcowl markcowl added design:needed A design request has been raised that needs a proposal emitter:protobuf The protobuf emitter triaged:core labels Jan 7, 2025
@markcowl markcowl added this to the Backlog milestone Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design:needed A design request has been raised that needs a proposal emitter:protobuf The protobuf emitter triaged:core
Projects
None yet
Development

No branches or pull requests

3 participants