Skip to content

smd type generate incorrect for type base on primitive types #55

@LaysDragon

Description

@LaysDragon

If I declare the type base on string to use as enum type. Generator will identify its as Object, but its incorrect and would cursed Json Unmarshal failed during processing request. It should be smd.String.

type Category string

const (
	CategoryLatest  Category = "latest"
	CategoryNews             = "news"
)

func (s DataService) GetRecommendStreams(category Category) ([]string, error) {
}
...
GetRecommendStreams": {
      Description: `TODO: deal with type problem,to made zenrpc support string enum or similar problem`,
      Parameters: []smd.JSONSchema{
	      {
		      Name:        "category",
		      Optional:    false,
		      Description: ``,
		      Type:        smd.Object, //<--- Problem here
		      Properties:  map[string]smd.Property{},
	      },
      },
      Returns: smd.JSONSchema{
	      Description: ``,
	      Optional:    false,
	      Type:        smd.Array,
	      Items: map[string]string{
		      "type": smd.String,
	      },
      },
},
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions