Skip to content

Commit bd218a9

Browse files
Merge pull request #96 from ogen-go/refactor/camel-cased-query
refactor: use json name for query
2 parents f2f5407 + 13d7b2d commit bd218a9

4 files changed

+13
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"openapi":"3.1.0","info":{"title":"","version":""},"paths":{"/api/v1/{id}":{"get":{"operationId":"getMethod","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"query","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"service.v1.Service.GetMethod response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Response"}}}}}}}},"components":{"schemas":{"Response":{"type":"object"}}}}
1+
{"openapi":"3.1.0","info":{"title":"","version":""},"paths":{"/api/v1/{id}":{"get":{"operationId":"getMethod","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"query","in":"query","schema":{"type":"string"}},{"name":"queryParam","in":"query","schema":{"type":"string"}}],"responses":{"200":{"description":"service.v1.Service.GetMethod response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Response"}}}}}}}},"components":{"schemas":{"Response":{"type":"object"}}}}

internal/gen/_golden/path_n_query_param_for_get_method.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ paths:
1616
in: query
1717
schema:
1818
type: string
19+
- name: queryParam
20+
in: query
21+
schema:
22+
type: string
1923
responses:
2024
"200":
2125
description: service.v1.Service.GetMethod response

internal/gen/_testdata/path_n_query_param_for_get_method.textproto

+7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ proto_file: {
1717
type: TYPE_STRING
1818
json_name: "query"
1919
}
20+
field: {
21+
name: "query_param"
22+
number: 3
23+
label: LABEL_OPTIONAL
24+
type: TYPE_STRING
25+
json_name: "queryParam"
26+
}
2027
}
2128
message_type: {
2229
name: "Response"

internal/gen/generator.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func (g *Generator) mkQueryParameters(op *ogen.Operation, fields map[string]*pro
300300
walkFields = func(prefix string, fields []*protogen.Field) error {
301301
for _, f := range fields {
302302
fd := f.Desc
303-
name := prefix + fd.TextName()
303+
name := prefix + fd.JSONName()
304304

305305
switch kind := fd.Kind(); kind {
306306
case protoreflect.MessageKind:

0 commit comments

Comments
 (0)