disneystreaming / smithy-translate

Other
53 stars 12 forks source link

Incorrect Date-Time Format in Examples #214

Closed MoeQuadrat closed 9 months ago

MoeQuadrat commented 9 months ago

Description: When converting an the sample OpenAPI specification to Smithy using smithy-translate, there is an issue with date-time examples.

Expected Behaviour: example: '2017-07-21T17:32:28Z' should be parsed correctly as format: DateTime

Current Behaviour:

Exception in thread "main" scala.MatchError: 2017-07-21T17:32:28Z (of class java.time.OffsetDateTime)
        at smithytranslate.openapi.internals.GetExtensions$.anyToNode(GetExtensions.scala:52)
        at smithytranslate.openapi.internals.OpenApiToIModel.$anonfun$getExamplesHint$1(OpenApiToIModel.scala:571)
        at scala.Option.map(Option.scala:242)
        at smithytranslate.openapi.internals.OpenApiToIModel.getExamplesHint(OpenApiToIModel.scala:571)
        at smithytranslate.openapi.internals.OpenApiToIModel.unfold(OpenApiToIModel.scala:618)
        at smithytranslate.openapi.internals.OpenApiToIModel.unfoldAndAddExts$1(OpenApiToIModel.scala:357)
        at smithytranslate.openapi.internals.OpenApiToIModel.$anonfun$refoldOne$1(OpenApiToIModel.scala:359)

Sample YAML:

openapi: '3.0.'
info:
  title: doc
  version: 1.0.0
paths:
  /test:
    post:
      operationId: testOperationId
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ObjectIn'
      responses:
        '200':
          description: test
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ObjectOut'
components:
  schemas:
    ObjectIn:
      type: object
      properties:
        s:
          type: string
          format: date-time
          example: '2017-07-21T17:32:28Z'
      required:
        - s
    ObjectOut:
      type: object
      properties:
        sNum:
          type: integer
Baccata commented 9 months ago

Okay, this is an actual bug on our side and we should be able to fix it reasonably fast. Thanks for reporting !

lewisjkl commented 9 months ago

The fix will be released by CI shortly: https://github.com/disneystreaming/smithy-translate/releases/tag/v0.3.15