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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document about how to mark an arrray field as required in an extra openapi config file? #3806

Open
mousimin opened this issue Dec 12, 2023 · 1 comment

Comments

@mousimin
Copy link

馃摎 Documentation

I have a simple proto file:

message GetTokenRequest {
  string hostname = 1 [(buf.validate.field).required = true, (buf.validate.field).string.hostname = true ];
  repeated string buckets = 2 [(buf.validate.field).repeated.min_items = 1];;
}

And I want to add an extra openapi file to help to generate the swagger file:

openapiOptions:
  field:
    - field: api.user.GetTokenRequest.hostname
      option:
        required: ["hostname"]
    - field: api.user.GetTokenRequest.buckets
      option:
        required: ["buckets"]

After run "buf generate proto" command, I found the hostname field was marked as required, but the buckets field was not, do we have a document which describes how to config an array field as required?
The generated swagger file:

"parameters": [
  {
    "name": "hostname",
    "description": "hostname is the name of which you want to acquire join token",
    "in": "query",
    "required": true,
    "type": "string"
  },
  {
    "name": "buckets",
    "description": "bucket is the name for the cos-agent instance using this token sneds telemetry data to",
    "in": "query",
    "required": false,
    "type": "array",
    "items": {
      "type": "string",
      "required": [
        "buckets"
      ]
    },
    "collectionFormat": "multi"
  }
]
@johanbrandhorst
Copy link
Collaborator

Hm, I don't think so. There might be a bug here, but I'd appreciate if you could dig around a bit to find out. Perhaps this could be a doc contribution or a bug fix, or both :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants