Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
LaysDragon opened this issue Apr 8, 2021 · 0 comments
Open

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

LaysDragon opened this issue Apr 8, 2021 · 0 comments

Comments

@LaysDragon
Copy link

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,
	      },
      },
},
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant