Skip to content

Data and type mismatch found for example of a referenced schema #1526

Closed
@akira28

Description

@akira28

executing:
kiota generate -l csharp -d ./basic.yaml -o ./basic
with this definition:

openapi: 3.0.0
info:
  title: Sample API
  description: Lorem Ipsum
  version: 1.0.0
servers:
  - url: http://api.example.com/v1
    description: Lorem Ipsum
paths:
  /issues:
    get:
      summary: Returns a list of issues.
      description: Lorem Ipsum
      responses:
        "200":
          description: Lorem Ipsum
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/issueData"
              example:
                data:
                  - issuedAt: "2023-10-12"
components:
  schemas:
    issueData:
      type: object
      title: Issue Data
      description: Information about the issue.
      properties:
        issuedAt:
          type: string
          format: date
          description: Lorem Ipsum
          example: "2023-10-12"

I get this warning:

warn: Kiota.Builder.KiotaBuilder[0]
      OpenAPI warning: #/paths/~1issues/get/responses/200/content/application~1json/example/data/0/issuedAt - Data and type mismatch found.

If I dereference it, it works as expected without warnings. I know it's just a warning, but maybe a symptom of some larger issue.

Activity

transferred this issue frommicrosoft/kiotaon Jan 12, 2024
removed this from Kiotaon Jan 12, 2024
added
bug-fix-vNextBug fixes need to be merged into both master and vNext. Use this tag for vNext bug fix PR.
priority:p2Medium. Generally has a work-around and a smaller sub-set of customers is affected. SLA <=30 days
on Jan 12, 2024
baywet

baywet commented on Jan 12, 2024

@baywet
Member

Hi @akira28,
Thanks for using kiota and for reaching out.
I have transferred your issue in the repository this error message originates from.
More specifically, it comes from this line.

Is this something you'd be willing to look into?

baywet

baywet commented on Jan 12, 2024

@baywet
Member

Also, before you spend any time on that, I wanted to double check you're using kiota 1.10.1

akira28

akira28 commented on Jan 15, 2024

@akira28
Author

@baywet I just tried with kiota 1.10.1 and get the same warning. I'll have a look at the code, let's see if I can make a PR. Thanks!

akira28

akira28 commented on Jan 15, 2024

@akira28
Author

@baywet I never touched any C# code, so I'm not comfortable to provide a PR.
Anyway, I think the issue lies here: https://github.com/microsoft/OpenAPI.NET/blob/4de931392d244dd6393417a92173a98ffaa594f2/src/Microsoft.OpenApi/Any/OpenApiPrimitive.cs#L121C56-L121C56
and probably this toString("o") change is not done when it's a reference? Just guessing. Also, I think it would be better to use a custom format instead of substringing it dateValue.Value.ToString("yyyy-MM-dd");

baywet

baywet commented on Jan 15, 2024

@baywet
Member

Thanks for the additional information.
@MaggieKimani1 can you look into that when you have a couple of minutes please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug-fix-vNextBug fixes need to be merged into both master and vNext. Use this tag for vNext bug fix PR.help wantedpriority:p2Medium. Generally has a work-around and a smaller sub-set of customers is affected. SLA <=30 days

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @akira28@baywet@MaggieKimani1

    Issue actions

      Data and type mismatch found for example of a referenced schema · Issue #1526 · microsoft/OpenAPI.NET