Skip to content

Commit

Permalink
[+] support integer64 as string option (google#355)
Browse files Browse the repository at this point in the history
* [+] support integer64 as string option
* [!] make int64/uint64/fixed64 as string default
  • Loading branch information
ppaanngggg committed May 10, 2022
1 parent 8f7dee9 commit c62333b
Show file tree
Hide file tree
Showing 21 changed files with 40 additions and 73 deletions.
6 changes: 2 additions & 4 deletions cmd/protoc-gen-openapi/examples/tests/mapfields/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
label:
type: string
GoogleProtobufAny:
Expand Down Expand Up @@ -91,8 +90,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
label:
type: string
Status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
label:
type: string
GoogleProtobufAny:
Expand Down Expand Up @@ -91,8 +90,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
label:
type: string
Status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
label:
type: string
tests.mapfields.message.v1.Message:
Expand Down Expand Up @@ -107,8 +106,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
label:
type: string
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
label:
type: string
GoogleProtobufAny:
Expand Down Expand Up @@ -91,8 +90,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
label:
type: string
Status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
label:
type: string
GoogleProtobufAny:
Expand Down Expand Up @@ -91,8 +90,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
label:
type: string
Status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
label:
type: string
Status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
label:
type: string
Status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
label:
type: string
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
label:
type: string
Status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
label:
type: string
Status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
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,8 +61,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
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,8 +77,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
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,8 +61,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
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,8 +61,7 @@ components:
type: object
properties:
id:
type: integer
format: int64
type: string
label:
title: this is an overriden field schema title
maxLength: 255
Expand Down
9 changes: 3 additions & 6 deletions cmd/protoc-gen-openapi/examples/tests/pathparams/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ paths:
- name: user_id
in: query
schema:
type: integer
format: uint64
type: string
responses:
"200":
description: OK
Expand Down Expand Up @@ -74,8 +73,7 @@ paths:
in: path
required: true
schema:
type: integer
format: uint64
type: string
- name: message_id
in: path
required: true
Expand Down Expand Up @@ -110,8 +108,7 @@ components:
message_id:
type: string
user_id:
type: integer
format: uint64
type: string
content:
type: string
maybe:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ paths:
- name: userId
in: query
schema:
type: integer
format: uint64
type: string
responses:
"200":
description: OK
Expand Down Expand Up @@ -74,8 +73,7 @@ paths:
in: path
required: true
schema:
type: integer
format: uint64
type: string
- name: messageId
in: path
required: true
Expand Down Expand Up @@ -110,8 +108,7 @@ components:
messageId:
type: string
userId:
type: integer
format: uint64
type: string
content:
type: string
maybe:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ paths:
- name: userId
in: query
schema:
type: integer
format: uint64
type: string
responses:
"200":
description: OK
Expand Down Expand Up @@ -74,8 +73,7 @@ paths:
in: path
required: true
schema:
type: integer
format: uint64
type: string
- name: messageId
in: path
required: true
Expand Down Expand Up @@ -126,8 +124,7 @@ components:
messageId:
type: string
userId:
type: integer
format: uint64
type: string
content:
type: string
maybe:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ paths:
- name: userId
in: query
schema:
type: integer
format: uint64
type: string
responses:
"200":
description: OK
Expand Down Expand Up @@ -74,8 +73,7 @@ paths:
in: path
required: true
schema:
type: integer
format: uint64
type: string
- name: messageId
in: path
required: true
Expand Down Expand Up @@ -110,8 +108,7 @@ components:
messageId:
type: string
userId:
type: integer
format: uint64
type: string
content:
type: string
maybe:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ paths:
- name: userId
in: query
schema:
type: integer
format: uint64
type: string
responses:
"200":
description: OK
Expand Down Expand Up @@ -74,8 +73,7 @@ paths:
in: path
required: true
schema:
type: integer
format: uint64
type: string
- name: messageId
in: path
required: true
Expand Down Expand Up @@ -110,8 +108,7 @@ components:
messageId:
type: string
userId:
type: integer
format: uint64
type: string
content:
type: string
maybe:
Expand Down
8 changes: 5 additions & 3 deletions cmd/protoc-gen-openapi/generator/reflector.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,13 @@ func (r *OpenAPIv3Reflector) schemaOrReferenceForField(field protoreflect.FieldD
kindSchema = wk.NewStringSchema()

case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Uint32Kind,
protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Uint64Kind,
protoreflect.Sfixed32Kind, protoreflect.Fixed32Kind, protoreflect.Sfixed64Kind,
protoreflect.Fixed64Kind:
protoreflect.Sfixed32Kind, protoreflect.Fixed32Kind:
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 c62333b

Please sign in to comment.