@@ -20,24 +20,23 @@ import (
2020 "github.com/googleapis/librarian/internal/sidekick/internal/api"
2121)
2222
23- func makeMessageFields (model * api.API , messageID string , schema * schema ) ([]* api.Field , error ) {
24- var fields []* api.Field
23+ func makeMessageFields (model * api.API , message * api.Message , schema * schema ) error {
2524 for _ , input := range schema .Properties {
26- field , err := makeField (model , messageID , input )
25+ field , err := makeField (model , message , input )
2726 if err != nil {
28- return nil , err
27+ return err
2928 }
3029 if field == nil {
3130 continue
3231 }
33- fields = append (fields , field )
32+ message . Fields = append (message . Fields , field )
3433 }
35- return fields , nil
34+ return nil
3635}
3736
38- func makeField (model * api.API , messageID string , input * property ) (* api.Field , error ) {
37+ func makeField (model * api.API , message * api. Message , input * property ) (* api.Field , error ) {
3938 if input .Schema .Type == "array" {
40- return makeArrayField (model , messageID , input )
39+ return makeArrayField (model , message , input )
4140 }
4241 if input .Schema .AdditionalProperties != nil {
4342 // TODO(#2283) - handle map fields
@@ -47,38 +46,33 @@ func makeField(model *api.API, messageID string, input *property) (*api.Field, e
4746 // TODO(#2265) - handle inline object...
4847 return nil , nil
4948 }
50- return makeScalarField (model , messageID , input )
49+ return makeScalarField (model , message , input . Name , input . Schema )
5150}
5251
53- func makeArrayField (model * api.API , messageID string , input * property ) (* api.Field , error ) {
52+ func makeArrayField (model * api.API , message * api. Message , input * property ) (* api.Field , error ) {
5453 if input .Schema .ItemSchema .Type == "object" && input .Schema .ItemSchema .Properties != nil {
5554 // TODO(#2265) - handle inline object...
5655 return nil , nil
5756 }
58- typez , typezID , err := scalarType (model , messageID , input .Name , input .Schema .ItemSchema )
57+ field , err := makeScalarField (model , message , input .Name , input .Schema .ItemSchema )
5958 if err != nil {
6059 return nil , err
6160 }
62- return & api.Field {
63- Name : input .Name ,
64- JSONName : input .Name , // OpenAPI field names are always camelCase
65- Documentation : input .Schema .Description ,
66- Typez : typez ,
67- TypezID : typezID ,
68- Repeated : true ,
69- // TODO(#2268) - deprecated fields?
70- }, nil
61+ field .Documentation = input .Schema .Description
62+ field .Repeated = true
63+ field .Optional = false
64+ return field , nil
7165}
7266
73- func makeScalarField (model * api.API , messageID string , input * property ) (* api.Field , error ) {
74- typez , typezID , err := scalarType (model , messageID , input . Name , input . Schema )
67+ func makeScalarField (model * api.API , message * api. Message , name string , schema * schema ) (* api.Field , error ) {
68+ typez , typezID , err := scalarType (model , message . ID , name , schema )
7569 if err != nil {
7670 return nil , err
7771 }
7872 return & api.Field {
79- Name : input . Name ,
80- JSONName : input . Name , // OpenAPI field names are always camelCase
81- Documentation : input . Schema .Description ,
73+ Name : name ,
74+ JSONName : name , // OpenAPI field names are always camelCase
75+ Documentation : schema .Description ,
8276 Typez : typez ,
8377 TypezID : typezID ,
8478 // TODO(#2268) - deprecated fields?
0 commit comments