Skip to content

Conversation

@jtrobles-cdd
Copy link
Member

Attempting to generate a JSON Schema using pydantic.BaseModel.model_json_schema() or pydantic.TypeAdapter.json_schema() fails with the following error message:

pydantic.errors.PydanticInvalidForJsonSchema:
  Cannot generate a JsonSchema for core_schema.PlainValidatorFunctionSchema ({
    'type': 'no-info',
    'function': <function _RutPydanticAnnotation.__get_pydantic_core_schema__.<locals>.validate_from_str at 0x…>
  })

This commit fixes the above error by implementing __get_pydantic_json_schema__ to override the generated JSON Schema.

@jtrobles-cdd jtrobles-cdd added bug Something isn't working component: rut labels Oct 25, 2024
@jtrobles-cdd jtrobles-cdd self-assigned this Oct 25, 2024
@jtrobles-cdd jtrobles-cdd requested a review from a team as a code owner October 25, 2024 23:42
@codecov
Copy link

codecov bot commented Oct 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.67%. Comparing base (9fc64b3) to head (dee3fa7).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #725      +/-   ##
===========================================
+ Coverage    87.65%   87.67%   +0.02%     
===========================================
  Files           38       38              
  Lines         3142     3149       +7     
  Branches       386      386              
===========================================
+ Hits          2754     2761       +7     
  Misses         246      246              
  Partials       142      142              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Attempting to generate a JSON Schema using
`pydantic.BaseModel.model_json_schema()` or
`pydantic.TypeAdapter.json_schema()` fails with the following error message:

> pydantic.errors.PydanticInvalidForJsonSchema:
>   Cannot generate a JsonSchema for core_schema.PlainValidatorFunctionSchema ({
>     'type': 'no-info',
>     'function': <function _RutPydanticAnnotation.__get_pydantic_core_schema__.<locals>.validate_from_str at 0x…>
>   })

This commit fixes the above error by implementing `__get_pydantic_json_schema__`
to override the generated JSON Schema.
@jtrobles-cdd jtrobles-cdd force-pushed the bugfix/pydantic-rut-json-schema-generation-fails branch from a8989fa to dee3fa7 Compare October 26, 2024 00:45
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
B Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

@jtrobles-cdd jtrobles-cdd merged commit 07f1255 into develop Oct 28, 2024
19 of 20 checks passed
@jtrobles-cdd jtrobles-cdd deleted the bugfix/pydantic-rut-json-schema-generation-fails branch October 28, 2024 12:15
@fpinto-cdd fpinto-cdd mentioned this pull request Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working component: rut

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants