Skip to content

[FEATURE] Kafka operations: allow groupId and clientId to be a string or array of strings #303

Description

@ivangsa

Why do we need this improvement?

groupId and clientId are typed as Schema Object. But these are configuration
values, not a data schema. Expressing a consumer group name requires unnecessary
JSON Schema boilerplate when a plain string would do.

# what you have to write today
groupId:
  type: string
  enum: ['payments-consumer-group']
 
# what you actually mean
groupId: 'payments-consumer-group'

How will this change help?

The intent is immediately readable in the document.

Screenshots

No response

How could it be implemented/designed?

Allow groupId and clientId to accept a plain string, an array of strings,
or the existing Schema Object form.

# plain string
groupId: 'payments-consumer-group'
 
# array of strings
groupId:
  - 'payments-consumer-group-1'
  - 'payments-consumer-group-2'
 
# existing Schema Object form, still valid
groupId:
  type: string
  enum: ['payments-consumer-group']

In spec-json-schemas, the property definition becomes a oneOf:

"groupId": {
  "oneOf": [
    { "type": "string" },
    { "type": "array", "items": { "type": "string" }, "minItems": 1 },
    { "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json" }
  ],
  "description": "Id of the consumer group."
}

The same change applies to clientId.

New and updated tooling should resolve the three forms in order: plain string
first, then array of strings, then treat an object as a Schema Object. A plain
string and an array can never be mistaken for a Schema Object, so existing
tooling that only handles the object form continues to work without any changes.

🚧 Breaking changes

No

👀 Have you checked for similar open issues?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue?

Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions