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

Datetime format in Http Client is Blank #1755

Closed
scprek opened this issue Sep 4, 2024 · 2 comments · Fixed by #1756
Closed

Datetime format in Http Client is Blank #1755

scprek opened this issue Sep 4, 2024 · 2 comments · Fixed by #1756

Comments

@scprek
Copy link
Contributor

scprek commented Sep 4, 2024

Is this user error? There appears to be a template for @Format() in https://github.com/micronaut-projects/micronaut-openapi/blob/6.12.x/openapi-generator/src/main/resources/templates/kotlin-micronaut/client/params/type.mustache

Expected Behavior

Maybe 2 issues

  1. Format
  2. Pattern

Format

Give this openapi spec

{
  "paths": {
    "/api/{version}/unassigned-orders": {
      "get": {
        "operationId": "asdfasdf",
        "parameters": [
          {
            "name": "before",
            "in": "query",
            "description": "The date to search before (ATOM format)",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Returns unassigned orders"
          }
        }
      }
    }
  }
}

I'd expect some default format string.

@QueryValue("before") @NotNull @Format(<some default for ZonedDateTime?>) before: ZonedDateTime,

Pattern

Specifying a customer pattern in the "pattern": openapi spec like

            "schema": {
              "type": "string",
              "format": "date-time",
              "pattern": "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
            }

Should add to the format, not a new @Pattern annotation?

@QueryValue("before") @NotNull @Format("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") before: ZonedDateTime,

Actual Behaviour

Format

Format is empty

@QueryValue("before") @NotNull @Format("") before: ZonedDateTime,

Pattern

But if I supply an openapi spec "pattern": it will create a jakarta.validation.constraints; @Pattern along with the empty format.

@QueryValue("before") @NotNull @Pattern(regexp =  "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'") @Format("") before: ZonedDateTime,

Steps To Reproduce

Query param (probably others path, normal variable, etc)

"type": "string",
"format": "date-time",

Environment Information

  • 6.12.0 openapi version

Example Application

No response

Version

4.5.1

@altro3
Copy link
Collaborator

altro3 commented Sep 5, 2024

Fixed it here: #1756

Check it, please

altro3 added a commit to altro3/micronaut-openapi that referenced this issue Sep 5, 2024
altro3 added a commit to altro3/micronaut-openapi that referenced this issue Sep 5, 2024
@scprek
Copy link
Contributor Author

scprek commented Sep 5, 2024

Looks good (know it got merged already). Thanks for the fastest turn around!

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 a pull request may close this issue.

2 participants