nats-io / jwt.net

JWT tokens signed using NKeys for Ed25519 for NATS .NET
Apache License 2.0
2 stars 5 forks source link

Should NatsExport.Type be a string rather than an int? #7

Closed darkwatchuk closed 3 weeks ago

darkwatchuk commented 3 weeks ago

Observed behavior

When creating an account the NSC tool uses a string for type when doing an export

"nats": {
    "exports": [
      {
        "name": "account-monitoring-streams",
        "subject": "$SYS.ACCOUNT.*.>",
        "type": "stream",
        "account_token_position": 3,
        "description": "Account specific monitoring stream",
        "info_url": "https://docs.nats.io/nats-server/configuration/sys_accounts"
      },

Currently in this library it's defined as an int

   /// <summary>
    /// Gets or sets the type property.
    /// </summary>
    [JsonPropertyName("type")]
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
    public int Type { get; set; }

Expected behavior

Should be able to set a string for export type.

Library version

1.0.0 preview 3

Host environment

No response

Steps to reproduce

No response

mtmk commented 3 weeks ago

Looks like it should've been an enum: https://github.com/nats-io/jwt/blob/ed3fbfa49a16cf4aced84aed9d527be532730ad4/v2/types.go#L55-L64

// ExportType defines the type of import/export.
type ExportType int

const (
    // Unknown is used if we don't know the type
    Unknown ExportType = iota
    // Stream defines the type field value for a stream "stream"
    Stream
    // Service defines the type field value for a service "service"
    Service
)

edit: fix is on its way

darkwatchuk commented 3 weeks ago

That's great - many thanks.