Skip to content

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

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

Closed
akira28 opened this issue Jan 12, 2024 · 5 comments · Fixed by #1530
Closed

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

akira28 opened this issue Jan 12, 2024 · 5 comments · Fixed by #1530
Assignees
Labels
bug-fix-vNext Bug fixes need to be merged into both master and vNext. Use this tag for vNext bug fix PR. help wanted priority:p2 Medium. Generally has a work-around and a smaller sub-set of customers is affected. SLA <=30 days

Comments

@akira28
Copy link

akira28 commented Jan 12, 2024

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.

@baywet baywet transferred this issue from microsoft/kiota Jan 12, 2024
@baywet baywet removed this from Kiota Jan 12, 2024
@baywet baywet added help wanted bug-fix-vNext Bug fixes need to be merged into both master and vNext. Use this tag for vNext bug fix PR. priority:p2 Medium. Generally has a work-around and a smaller sub-set of customers is affected. SLA <=30 days labels Jan 12, 2024
@baywet
Copy link
Member

baywet commented Jan 12, 2024

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
Copy link
Member

baywet commented Jan 12, 2024

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

@akira28
Copy link
Author

akira28 commented Jan 15, 2024

@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
Copy link
Author

akira28 commented Jan 15, 2024

@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
Copy link
Member

baywet commented Jan 15, 2024

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
Labels
bug-fix-vNext Bug fixes need to be merged into both master and vNext. Use this tag for vNext bug fix PR. help wanted priority:p2 Medium. Generally has a work-around and a smaller sub-set of customers is affected. SLA <=30 days
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants