Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !325

[Golang][client] fix RFC-3339 date-time query param

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/grokify/3.1.x into 3.1.x Jun 15, 2018
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 12

Created by: grokify

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 3.1.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

@antihax @bvwells

Description of the PR

The OpenAPI 3.0 Spec and Swagger 2.0 Spec define the date-time string format as:

dateTime | string | date-time | As defined by date-time - RFC3339

  • Spec 3.0: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md
  • Spec 2.0: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md

An example of RFC-3339 date-time format is 2017-07-21T17:32:28Z. Here is the full spec:

  • RFC-3339: https://tools.ietf.org/html/rfc3339#section-5.6

The current SDK will create in an incorrectly formatted time for a query parameter. This happens because client.go parameterToString function uses fmt.Sprintf("%v", obj) which produces the following time format which is not a RFC-3339 time:

2018-01-01 00:00:00 +0000 UTC

This can be resolved by adding the following code to parameterToString(obj interface{}, collectionFormat string) string.

} else if t, ok := obj.(time.Time); ok {
    return t.Format(time.RFC3339)
}

This approach for testing time has been verified to work and is mentioned here:

https://stackoverflow.com/questions/41483505/golang-check-if-a-data-is-time-time

An example is on Go Playground here: https://play.golang.org/p/Jq16Shapio8

A test is not provided because it appears a date-time format string query parameter does not exist in the current Petstore API.

This is a breaking change since the date time format produced by the Client SDK changes.

More info can be seen here where the issue was encountered:

  • https://github.com/grokify/go-ringcentral/issues/19
  • https://github.com/swagger-api/swagger-codegen/issues/8039

This PR updates client.mustache. Other changed files are from a re-built go-petstore SDK in the sample folder.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/grokify/3.1.x