JsonApiDotNetCore icon indicating copy to clipboard operation
JsonApiDotNetCore copied to clipboard

openapi: support validation attributes

Open verdie-g opened this issue 1 year ago • 4 comments

Closes #1055

QUALITY CHECKLIST

  • [ ] Changes implemented in code
  • [ ] Complies with our contributing guidelines
  • [ ] Adapted tests
  • [ ] Documentation updated

verdie-g avatar Feb 24 '24 01:02 verdie-g

@bkoelman could you give a preliminary review on just that?

verdie-g avatar Feb 24 '24 01:02 verdie-g

@verdie-g Do you still intend to complete this?

bkoelman avatar Mar 11 '24 02:03 bkoelman

Unfortunately I don't think I'll find the time.

verdie-g avatar Mar 12 '24 17:03 verdie-g

I pushed some old changes that were still on my machine in case someone wants to continue the PR.

verdie-g avatar Apr 11 '24 17:04 verdie-g

Hi @bkoelman, I'll try finishing that PR. Could you have a pass on its current state, I'll add tests for Kiota once the one for NSwag start looking okay. Also, is there anything worth adding to the doc regarding this change?

verdie-g avatar May 27 '24 22:05 verdie-g

Hi @bkoelman, I'll try finishing that PR. Could you have a pass on its current state, I'll add tests for Kiota once the one for NSwag start looking okay. Also, is there anything worth adding to the doc regarding this change?

Cool! Sure, I'll take a look. I don't expect the docs need to be updated, unless there are pitfalls users should know about. For kiota, it's worth removing the --log-level Error switch temporarily to see what comes up. However, kiota is pretty rigid and inflexible, so don't worry too much about its quirks.

bkoelman avatar May 28 '24 07:05 bkoelman

I'll resume the work in a few days

verdie-g avatar Jun 04 '24 14:06 verdie-g

I've completed the table except the EF Core column which I think is out-of-scope for this PR.

verdie-g avatar Jun 10 '24 02:06 verdie-g

For kiota, it's worth removing the --log-level Error switch temporarily to see what comes up.

#/paths/~1socialMediaAccounts/post/responses/201/headers/Location/schema - The format uri is not supported by Kiota and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInPatchRequest/properties/creditCard - The format credit-card is not supported by Kiota for the type string and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInPatchRequest/properties/email - The format email is not supported by Kiota and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInPatchRequest/properties/phone - The format tel is not supported by Kiota for the type string and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInPatchRequest/properties/profilePicture - The format uri is not supported by Kiota and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInPatchRequest/properties/backgroundPicture - The format uri is not supported by Kiota and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInPatchRequest/properties/nextRevalidation - The format date-span is not supported by Kiota for the type string and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInPostRequest/properties/creditCard - The format credit-card is not supported by Kiota for the type string and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInPostRequest/properties/email - The format email is not supported by Kiota and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInPostRequest/properties/phone - The format tel is not supported by Kiota for the type string and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInPostRequest/properties/profilePicture - The format uri is not supported by Kiota and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInPostRequest/properties/backgroundPicture - The format uri is not supported by Kiota and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInPostRequest/properties/nextRevalidation - The format date-span is not supported by Kiota for the type string and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInResponse/properties/creditCard - The format credit-card is not supported by Kiota for the type string and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInResponse/properties/email - The format email is not supported by Kiota and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInResponse/properties/phone - The format tel is not supported by Kiota for the type string and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInResponse/properties/profilePicture - The format uri is not supported by Kiota and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInResponse/properties/backgroundPicture - The format uri is not supported by Kiota and the string type will be used.
#/components/schemas/socialMediaAccountAttributesInResponse/properties/nextRevalidation - The format date-span is not supported by Kiota for the type string and the string type will be used.

Kiota doesn't support the formats uri and date-span :/

verdie-g avatar Jun 11 '24 02:06 verdie-g

I've completed the table except the EF Core column which I think is out-of-scope for this PR.

I've mentioned earlier that the goal of writing end-to-end tests is to assess the overall experience our users will face. This doesn't mean we need to write tests for EF Core features in this PR, but we do need to check for oddities and possibly create separate issues to address them, or document things to watch out for. So I disagree that it's out of scope. Otherwise, I wouldn't have added the EF Core column in the first place.

bkoelman avatar Jun 12 '24 06:06 bkoelman

Here is the single SQL statement to create the table

CREATE TABLE "SocialMediaAccounts" (
    "Id" uuid NOT NULL,
    "AlternativeId" uuid,
    "FirstName" text,
    "LastName" text NOT NULL,
    "UserName" character varying(18),
    "CreditCard" text,
    "Email" text,
    "Password" text,
    "Phone" text,
    "Age" double precision,
    "ProfilePicture" text,
    "BackgroundPicture" text,
    "Tags" text[],
    "CountryCode" text,
    "Planet" text,
    "NextRevalidation" interval,
    "ValidatedAt" timestamp with time zone,
    "ValidatedAtDate" date,
    "ValidatedAtTime" time without time zone,
    CONSTRAINT "PK_SocialMediaAccounts" PRIMARY KEY ("Id")
);

I've updated the table accordingly.

verdie-g avatar Jun 13 '24 02:06 verdie-g

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 91.30%. Comparing base (459ced3) to head (54fedf2).

Additional details and impacted files
@@           Coverage Diff            @@
##           openapi    #1477   +/-   ##
========================================
  Coverage    91.30%   91.30%           
========================================
  Files          396      396           
  Lines        12834    12834           
  Branches      2028     2028           
========================================
  Hits         11718    11718           
  Misses         725      725           
  Partials       391      391           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jun 15 '24 20:06 codecov[bot]

The table update isn't correct. The Y/N columns need to move. image

The same applies to: [Compare], [AllowedValues], [DeniedValues], [Remote], and [ValidateNever].

bkoelman avatar Jun 20 '24 07:06 bkoelman

The Y/N columns need to move.

I used N to specify that it's not supported. I can use - instead.

verdie-g avatar Jun 20 '24 12:06 verdie-g

Both (remove culture and change assertions) haven't been addressed yet.

I'm not able to access the comment to answer but I could you clarify what you are expecting here.

verdie-g avatar Jun 21 '24 16:06 verdie-g

Both (remove culture and change assertions) haven't been addressed yet.

I'm not able to access the comment to answer but I could you clarify what you are expecting here.

Using the dollar sign and putting literal values in there, so it becomes culture-insensitive.

bkoelman avatar Jun 21 '24 16:06 bkoelman