gnostic
gnostic copied to clipboard
The query FieldOptions custom example parameter does not work, the body succeeds, why?
body (success)
// .proto
// CreateTest
rpc CreateTest(CreateTestRequest) returns (CreateTestReply) {
option (openapi.v3.operation) = {
summary : "CreateTest",
};
option (google.api.http) = {
post : "/test"
body: "*"
};
}
message CreateTestRequest {
// title
string title = 1[
(openapi.v3.property) = { example: { yaml: "213" } }
];
}
message CreateTestReply {
int32 code = 1;
string res = 2;
}
// openapi.yaml
/test:
post:
tags:
- Course
summary: CreateTest
description: CreateTest
operationId: Course_CreateTest
requestBody:
content:
application/json:
schema:
type: object
properties:
title:
example: 213 // success
type: string
description: title
required: true
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/CreateTestReply'
query(fail)
// test
rpc GetTest(GetTestRequest) returns (GetTestReply) {
option (openapi.v3.operation) = {
summary : "test",
parameters: [
{
parameter: { // Too much configuration content
name: 'data',
in: "query",
description: "data",
schema: {
schema: {
type: "string",
example: {
yaml: "ttt"
}
}
}
}
}
]
};
option (google.api.http) = {
get : "/test"
};
}
message GetTestRequest {
// title
string title = 1[
(openapi.v3.property) = {example: {yaml: "213"}} // It looks good, but it's not work
];
}
message GetTestReply {
int32 code = 1;
string res = 2;
}
// openapi.yaml
/test:
get:
tags:
- Course
summary: GetTest
description: GetTest
operationId: Course_GetTest
parameters:
- name: title
in: query
description: title
schema:
type: string // used FieldOptions success
- name: data
in: query
description: data
schema:
example: ttt // used MethodOptions success
type: string
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/GetTestReply'