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

Add request and response types #1

Merged
merged 1 commit into from
Dec 2, 2020
Merged

Conversation

findkim
Copy link
Collaborator

@findkim findkim commented Dec 2, 2020

Overview

  • Uses text/template over html/template to avoid special characters escaping. For example the string value " would escape to "
  • Renames BodyType and ReponseType to *Format which describes the format of the request and response
  • Adds new input for BodyType and ResponseType to specify the Go type for request and response bodies
    • Default body type for JSON format remains as map[string]interface{}
    • Default response type for JSON format remains as interface{}
  • Adds support to specify package imports to reference Go types from different packages

Breaking Changes

The JSON input file format changes from

{
  "<funcName>": {
    // endpoint info
    // ...
    "BodyType": "json",
    "ResponseType": "json"
  }
}
{
  "imports": {
    "<pkgName>": "github.com/org/repo/pkg"
  },
  "endpoints": {
    "<funcName>": {
      // ...
      "BodyFormat": "json",
      "BodyType": "*api.ACLLoginParams",
      "ResponseFormat": "json",
      "ResponseType": "*api.ACLToken"
    }
  }
}

@@ -304,6 +322,19 @@ func main() {
return args.Endpoints[i].Name < args.Endpoints[j].Name
})

fmt.Println(input.Imports)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

rm

Copy link
Owner

@mkeeler mkeeler left a comment

Choose a reason for hiding this comment

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

LGTM

@mkeeler mkeeler merged commit 79537a9 into mkeeler:master Dec 2, 2020
@findkim findkim deleted the req-resp-types branch December 2, 2020 23:00
@findkim
Copy link
Collaborator Author

findkim commented Dec 2, 2020

Thanks for the review! I'll take another pass tomorrow to update documentation based on these changes.

findkim added a commit to findkim/mock-http-api that referenced this pull request Dec 3, 2020
findkim added a commit to findkim/mock-http-api that referenced this pull request Dec 3, 2020
findkim added a commit to findkim/mock-http-api that referenced this pull request Dec 3, 2020
@findkim findkim mentioned this pull request Dec 3, 2020
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.

2 participants