Skip to content

Commit

Permalink
Revert "[+] support integer64 as string option (#355)"
Browse files Browse the repository at this point in the history
This reverts commit c62333b.

The original change conflated the guidance for encoding protobuf
messages as json objects with generating an OpenAPI v3 spec file.
OpenAPI v3 explicitly allows for integer types of int64
(https://swagger.io/docs/specification/data-models/data-types/#numbers).
The OpenAPI v3 spec generated by this tool will then usually be fed into
language specific generators which will determine how they want to
handle each of the types depending on the specific target language.
  • Loading branch information
ajorgensen committed Mar 7, 2024
1 parent ad271d5 commit a123d58
Show file tree
Hide file tree
Showing 21 changed files with 73 additions and 40 deletions.
6 changes: 4 additions & 2 deletions cmd/protoc-gen-openapi/examples/tests/mapfields/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
type: string
GoogleProtobufAny:
Expand Down Expand Up @@ -90,7 +91,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
type: string
Status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
type: string
GoogleProtobufAny:
Expand Down Expand Up @@ -90,7 +91,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
type: string
Status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
type: string
tests.mapfields.message.v1.Message:
Expand Down Expand Up @@ -106,7 +107,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
type: string
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
type: string
GoogleProtobufAny:
Expand Down Expand Up @@ -90,7 +91,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
type: string
Status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
type: string
GoogleProtobufAny:
Expand Down Expand Up @@ -90,7 +91,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
type: string
Status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
type: string
Status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
type: string
Status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
type: string
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
type: string
Status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
type: string
Status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
title: this is an overriden field schema title
maxLength: 255
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
title: this is an overriden field schema title
maxLength: 255
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
title: this is an overriden field schema title
maxLength: 255
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
title: this is an overriden field schema title
maxLength: 255
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ components:
type: object
properties:
id:
type: string
type: integer
format: int64
label:
title: this is an overriden field schema title
maxLength: 255
Expand Down
9 changes: 6 additions & 3 deletions cmd/protoc-gen-openapi/examples/tests/pathparams/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ paths:
- name: user_id
in: query
schema:
type: string
type: integer
format: uint64
responses:
"200":
description: OK
Expand Down Expand Up @@ -73,7 +74,8 @@ paths:
in: path
required: true
schema:
type: string
type: integer
format: uint64
- name: message_id
in: path
required: true
Expand Down Expand Up @@ -108,7 +110,8 @@ components:
message_id:
type: string
user_id:
type: string
type: integer
format: uint64
content:
type: string
maybe:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ paths:
- name: userId
in: query
schema:
type: string
type: integer
format: uint64
responses:
"200":
description: OK
Expand Down Expand Up @@ -73,7 +74,8 @@ paths:
in: path
required: true
schema:
type: string
type: integer
format: uint64
- name: messageId
in: path
required: true
Expand Down Expand Up @@ -108,7 +110,8 @@ components:
messageId:
type: string
userId:
type: string
type: integer
format: uint64
content:
type: string
maybe:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ paths:
- name: userId
in: query
schema:
type: string
type: integer
format: uint64
responses:
"200":
description: OK
Expand Down Expand Up @@ -73,7 +74,8 @@ paths:
in: path
required: true
schema:
type: string
type: integer
format: uint64
- name: messageId
in: path
required: true
Expand Down Expand Up @@ -124,7 +126,8 @@ components:
messageId:
type: string
userId:
type: string
type: integer
format: uint64
content:
type: string
maybe:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ paths:
- name: userId
in: query
schema:
type: string
type: integer
format: uint64
responses:
"200":
description: OK
Expand Down Expand Up @@ -73,7 +74,8 @@ paths:
in: path
required: true
schema:
type: string
type: integer
format: uint64
- name: messageId
in: path
required: true
Expand Down Expand Up @@ -108,7 +110,8 @@ components:
messageId:
type: string
userId:
type: string
type: integer
format: uint64
content:
type: string
maybe:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ paths:
- name: userId
in: query
schema:
type: string
type: integer
format: uint64
responses:
"200":
description: OK
Expand Down Expand Up @@ -73,7 +74,8 @@ paths:
in: path
required: true
schema:
type: string
type: integer
format: uint64
- name: messageId
in: path
required: true
Expand Down Expand Up @@ -108,7 +110,8 @@ components:
messageId:
type: string
userId:
type: string
type: integer
format: uint64
content:
type: string
maybe:
Expand Down
8 changes: 3 additions & 5 deletions cmd/protoc-gen-openapi/generator/reflector.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,11 @@ func (r *OpenAPIv3Reflector) schemaOrReferenceForField(field protoreflect.FieldD
kindSchema = wk.NewStringSchema()

case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Uint32Kind,
protoreflect.Sfixed32Kind, protoreflect.Fixed32Kind:
protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Uint64Kind,
protoreflect.Sfixed32Kind, protoreflect.Fixed32Kind, protoreflect.Sfixed64Kind,
protoreflect.Fixed64Kind:
kindSchema = wk.NewIntegerSchema(kind.String())

case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Uint64Kind,
protoreflect.Sfixed64Kind, protoreflect.Fixed64Kind:
kindSchema = wk.NewStringSchema()

case protoreflect.EnumKind:
kindSchema = wk.NewEnumSchema(*&r.conf.EnumType, field)

Expand Down

0 comments on commit a123d58

Please sign in to comment.