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

protoc-gen-openapi: google.protobuf.Duration not string #351

Closed
jan-sykora opened this issue Apr 27, 2022 · 2 comments · Fixed by #401
Closed

protoc-gen-openapi: google.protobuf.Duration not string #351

jan-sykora opened this issue Apr 27, 2022 · 2 comments · Fixed by #401
Assignees

Comments

@jan-sykora
Copy link

Why is the google.protobuf.Duration converted into OpenAPI as a custom object and not as a string (the JSON format)?
I would expect it to be represented by type: string. Especially when the google.protobuf.Timestamp (which holds the same structure as google.protobuf.Duration) is converted into string (JSON format) as well.

For instance:

message Baz {
  google.protobuf.Timestamp baz_time = 1;
  google.protobuf.Duration baz_duration = 2;
}

// package google.protobuf
message Timestamp {
  int64 seconds = 1;
  int32 nanos = 2;
}

// package google.protobuf
message Duration {
  int64 seconds = 1;
  int32 nanos = 2;
} 

is converted by protoc-gen-openapi into

openapi: 3.0.3
components:
  schemas:
    Baz:
      properties:
        bazTime:
          type: string
          format: date-time
        barDuration:
          $ref: '#/components/schemas/Duration'
    Duration:
      type: object
      properties:
        seconds:
          type: integer
          format: int64
        nanos:
          type: integer
          format: int32

See google.protobuf.Duration JSON description and google.protobuf.Timestamp JSON description for more info.

@timburks
Copy link
Contributor

That seems like an oversight. We probably just need to hook up something like this.

nightlyone added a commit to nightlyone/gnostic that referenced this issue Aug 6, 2023
by reporting the data types and formats that are actually used

TODO:
 * [ ] Find out why it is different than expected when durations are used in
       a query parameter. What parts of gnostic work different here?

Fixes: google#351
nightlyone added a commit to nightlyone/gnostic that referenced this issue Aug 6, 2023
by reporting the data types and formats that are actually used

Fixes: google#351
@nightlyone
Copy link
Contributor

FYI: @timburks I took a stab at this in PR #401 and welcome any feedback you have.

@timburks timburks self-assigned this Aug 25, 2023
timburks pushed a commit that referenced this issue Aug 25, 2023
by reporting the data types and formats that are actually used

Fixes: #351
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

Successfully merging a pull request may close this issue.

3 participants