Skip to content

Commit

Permalink
feat: enhancement kcl import go struct with schema name and doc field
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Aug 12, 2024
1 parent 0ecd8eb commit 1dd374f
Show file tree
Hide file tree
Showing 5 changed files with 1,509 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pkg/tools/gen/genkcl.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

type GenKclOptions struct {
Mode Mode
CastingOption castingOption
CastingOption CastingOption
UseIntegersForNumbers bool
}

Expand Down
7 changes: 3 additions & 4 deletions pkg/tools/gen/genkcl_gostruct.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ func (ctx *genKclTypeContext) convertSchemaFromGoPackage() ([]convertResult, err
name := s.name
if _, ok := ctx.resultMap[name]; !ok {
result := convertResult{IsSchema: true}
ctx.resultMap[name] = result
result.schema.Name = name
result.schema.Description = s.doc
for _, field := range s.fields {
typeName := ctx.typeName(name, field.name, field.ty)
fieldName := formatName(field.name)
Expand All @@ -192,15 +193,13 @@ func (ctx *genKclTypeContext) convertSchemaFromGoPackage() ([]convertResult, err
fieldName = tagName
typeName = tagTy
}
result.schema.Name = name
result.schema.Description = s.doc
result.schema.Properties = append(result.Properties, property{
Name: fieldName,
Type: typeName,
Description: s.fieldDocs[field.name],
})
ctx.resultMap[name] = result
}
ctx.resultMap[name] = result
}
}
// Append anonymous structs
Expand Down
Loading

0 comments on commit 1dd374f

Please sign in to comment.