Re: [PR] fix(openapi): generate enum components and map value schemas [dubbo-go]
AlexStocks merged PR #3609: URL: https://github.com/apache/dubbo-go/pull/3609 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] fix(openapi): generate enum components and map value schemas [dubbo-go]
sonarqubecloud[bot] commented on PR #3609: URL: https://github.com/apache/dubbo-go/pull/3609#issuecomment-5213886931 ## [](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3609) **Quality Gate passed** Issues  [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3609&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3609&issueStatuses=ACCEPTED) Measures  [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3609&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3609&metric=new_coverage&view=list)  [17.9% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3609&metric=new_duplicated_lines_density&view=list) [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3609) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] fix(openapi): generate enum components and map value schemas [dubbo-go]
sonarqubecloud[bot] commented on PR #3609: URL: https://github.com/apache/dubbo-go/pull/3609#issuecomment-5213843404 ## [](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3609) **Quality Gate passed** Issues  [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3609&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3609&issueStatuses=ACCEPTED) Measures  [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3609&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3609&metric=new_coverage&view=list)  [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3609&metric=new_duplicated_lines_density&view=list) [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3609) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] fix(openapi): generate enum components and map value schemas [dubbo-go]
AlexStocks commented on code in PR #3609:
URL: https://github.com/apache/dubbo-go/pull/3609#discussion_r3733584581
##
tools/protoc-gen-triple-openapi/internal/converter/schema/schema.go:
##
@@ -51,27 +52,40 @@ func GenerateFileSchemas(tt protoreflect.FileDescriptor)
*orderedmap.Map[string,
}
}
+ sortedEnums := make([]protoreflect.EnumDescriptor, 0, len(enums))
+ for enum := range enums {
+ sortedEnums = append(sortedEnums, enum)
+ }
+ sort.Slice(sortedEnums, func(i, j int) bool {
+ return sortedEnums[i].FullName() < sortedEnums[j].FullName()
+ })
+
+ for _, enum := range sortedEnums {
+ id, schema := enumToSchema(enum)
+ schemas.Set(id, base.CreateSchemaProxy(schema))
Review Comment:
[P1] 处理 enum component 与内置 ErrorResponse 的 ID 冲突
这里直接以 enum.FullName() 写入 components。合法的无 package proto 如果声明 enum
ErrorResponse,生成的 ID 就是 ErrorResponse,随后 generateComponents 会用同名 Triple
错误对象覆盖它;请求字段仍引用 #/components/schemas/ErrorResponse,最终把 enum 解析成 object。我在 exact
Head 上用该 descriptor 可稳定复现。请为内置错误 schema 使用不可与 protobuf FullName 碰撞的 ID 并同步
response 引用,或在冲突时显式改名/报错;同时补无 package enum/message 的冲突回归测试。
##
tools/protoc-gen-triple-openapi/internal/converter/schema/util.go:
##
@@ -55,11 +55,16 @@ func messageToSchema(tt protoreflect.MessageDescriptor)
(string, *base.Schema) {
func fieldToSchema(parent *base.SchemaProxy, tt protoreflect.FieldDescriptor)
*base.SchemaProxy {
if tt.IsMap() {
- // Handle maps
root := ScalarFieldToSchema(parent, tt, false)
root.Title = string(tt.Name())
root.Type = []string{"object"}
- // TODO: todo
+ value := tt.MapValue()
+ switch value.Kind() {
+ case protoreflect.MessageKind, protoreflect.EnumKind:
Review Comment:
[P1] 为 message/enum map value 补能识别回归的 fixture
当前 golden 只覆盖 map 和普通 enum 字段,没有经过这里的 MessageKind/EnumKind
分支。我在隔离副本中删除该分支、让所有 map value 都生成 scalar schema 后,现有 go test ./... 仍全部通过,因此
message/enum additionalProperties 的 $ref 行为没有测试保护。请在 descriptor/示例 proto 中加入
map 与 map,同时断言 additionalProperties.$ref 和对应
enum component;删除本分支时测试应失败。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
Re: [PR] fix(openapi): generate enum components and map value schemas [dubbo-go]
codecov-commenter commented on PR #3609: URL: https://github.com/apache/dubbo-go/pull/3609#issuecomment-5211980415 ## [Codecov](https://app.codecov.io/gh/apache/dubbo-go/pull/3609?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report :white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 53.87%. Comparing base ([`60d1c2a`](https://app.codecov.io/gh/apache/dubbo-go/commit/60d1c2a949f0ee0da4be3fe09fb79d295491e040?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`ba956a8`](https://app.codecov.io/gh/apache/dubbo-go/commit/ba956a87552d5ad3f38f7b6fb7ee0658b0236ab3?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)). :warning: Report is 895 commits behind head on develop. Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop#3609 +/- ## === + Coverage46.76% 53.87% +7.10% === Files 295 474 +179 Lines1717236388 +19216 === + Hits 803119605 +11574 - Misses828715206+6919 - Partials 854 1577 +723 ``` [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/dubbo-go/pull/3609?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache). :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache). :rocket: New features to boost your workflow: - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
Re: [PR] fix(openapi): generate enum components and map value schemas [dubbo-go]
sonarqubecloud[bot] commented on PR #3609: URL: https://github.com/apache/dubbo-go/pull/3609#issuecomment-5211941434 ## [](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3609) **Quality Gate passed** Issues  [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3609&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-go&pullRequest=3609&issueStatuses=ACCEPTED) Measures  [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-go&pullRequest=3609&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3609&metric=new_coverage&view=list)  [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-go&pullRequest=3609&metric=new_duplicated_lines_density&view=list) [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-go&pullRequest=3609) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
[PR] fix(openapi): generate enum components and map value schemas [dubbo-go]
XiaoFeiASK opened a new pull request, #3609: URL: https://github.com/apache/dubbo-go/pull/3609 ## What this PR does Fixes #3608: generate complete OpenAPI schemas for protobuf enum and map fields in `protoc-gen-triple-openapi`. ## Changes - Collect enum descriptors referenced by service request and response messages. - Generate `components.schemas` entries for referenced protobuf enums. - Preserve map value schemas through `additionalProperties`. - Use schema references for message and enum map values. - Update YAML and JSON golden outputs for enum components and `map` values. ## Verification cd tools/protoc-gen-triple-openapi go test ./... -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] - To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
