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

feat(*): sync examples to v0.8 spec #100

Merged
merged 1 commit into from
Oct 24, 2022
Merged

feat(*): sync examples to v0.8 spec #100

merged 1 commit into from
Oct 24, 2022

Conversation

lsytj0413
Copy link
Collaborator

Signed-off-by: lsytj0413 511121939@qq.com

Many thanks for submitting your Pull Request ❤️!

What this PR does / why we need it:

  • sync the v0.8 specification examples

Special notes for reviewers:

Additional information (if needed):

@lsytj0413
Copy link
Collaborator Author

  1. we should keep the examples in a independent directory, and don't modify it, so we can synced the examples from specification repo easy
  2. add a tool to convert json & yaml


// TODO: optimize this
// In the specification, we can declared independently definitions with another file format, so
// we must convert the independently yaml source to json before unmarshal.
Copy link
Member

Choose a reason for hiding this comment

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

@lsytj0413 wdyt about opening an issue for this one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nice advice, i will open an issue and fix it in another PR.

"operation": "file://myapis/emailapis.json#paymentInsufficientFunds"
}
]
}
Copy link
Member

Choose a reason for hiding this comment

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

Can't we move these files to testdata directory?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the paymentconfirmation.json file, workflow definition refs functionsdefs.json as functiondefs.json; so if we change move this files to testdata, we must:

  1. modify the example definitions refs to another value, this will make sync the examples from specification difficulty. (some example's definitions must be modify, because it refs other file with abs path, ex file://books/lending/functions.json)
  2. change the root path of not absolute file to testdata directory (currently it's parser directory)

wdyt we can do?

Copy link
Member

Choose a reason for hiding this comment

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

I think "2" could be a better option then because having these files lying in the package smells. At least in the testdata directory, we add purpose.

parser/parser_test.go Outdated Show resolved Hide resolved
model/states.go Outdated
@@ -139,8 +140,8 @@ type OperationState struct {

// OperationStateTimeout ...
type OperationStateTimeout struct {
StateExecTimeout StateExecTimeout `json:"stateExecTimeout,omitempty"`
ActionExecTimeout string `json:"actionExecTimeout,omitempty" validate:"omitempty,min=1"`
StateExecTimeout *StateExecTimeout `json:"stateExecTimeout,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

maybe you can revert this change as the timeouts will be fixed as part of #104

@spolti spolti added this to the Spec 0.8 Support milestone Oct 19, 2022
@spolti
Copy link
Member

spolti commented Oct 19, 2022

small fixes for #70

@spolti
Copy link
Member

spolti commented Oct 20, 2022

@lsytj0413 can you please fix the conflicts?

@lsytj0413
Copy link
Collaborator Author

@lsytj0413 can you please fix the conflicts?

#105 should be merge first, i will resolve this conflict after 105 have merged.

cc @ricardozanini

@ricardozanini
Copy link
Member

@lsytj0413 can you please fix the conflicts?

#105 should be merge first, i will resolve this conflict after 105 have merged.

cc @ricardozanini

It was merged, but we still have one file to solve the conflict.

Signed-off-by: lsytj0413 <511121939@qq.com>
@lsytj0413
Copy link
Collaborator Author

lsytj0413 commented Oct 22, 2022

It was merged, but we still have one file to solve the conflict.

Fixed,PTAL.

There are following actions:

I will fix this in another PR.

if err := json.Unmarshal(eventBasedSwitch["timeouts"], &j.Timeouts); err != nil {
return err
eventBaseTimeoutsRawMessage, ok := eventBasedSwitch["timeouts"]
if ok {
Copy link
Member

Choose a reason for hiding this comment

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

I think it is not needed, right?

Copy link
Member

Choose a reason for hiding this comment

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

Why not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We must have this because the timeouts field is optional. If we don't have it, checkcarvitals.json and eventbasedswitchstate.json will failed with unexpected end of JSON input because we try to unmarshal empty string.

Copy link
Member

@spolti spolti left a comment

Choose a reason for hiding this comment

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

just a minor comment.

@ricardozanini ricardozanini merged commit 5a0a34f into serverlessworkflow:main Oct 24, 2022
@lsytj0413 lsytj0413 deleted the update-example-to-v0.8 branch October 24, 2022 13:55
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

3 participants