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

Support enum type #11

Merged
merged 3 commits into from
Oct 26, 2017
Merged

Support enum type #11

merged 3 commits into from
Oct 26, 2017

Conversation

KeitaMoromizato
Copy link
Contributor

Parse enum properties.

yaml

status:
  type: string
  enum:
    - active
    - inactive

generated flow file.

type Hoge = {
  status: "active" | "inactive"
}

src/index.js Outdated
@@ -34,6 +34,11 @@ const typeFor = (property: any): string => {
}
return `Array<${typeMapping[property.items.type]}>`;
}
else if (property.type === 'string' && 'enum' in property) {
return property.enum.reduce((acc: string, e: string) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing.
As a minor staff, probably slice(1) seems a bit tricky.
You would be able to replace with below statement.

return property.enum.map(a => `'${a}'`).join(" | ");        

Thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for comment.

I fixed this. Please review again.

@yayoc
Copy link
Owner

yayoc commented Oct 26, 2017

Thank you for updating. will merge this PR.

@yayoc yayoc merged commit 71c344e into yayoc:master Oct 26, 2017
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

Successfully merging this pull request may close these issues.

None yet

2 participants