Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Respect custom title in functions JSON Schema#11892

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Viicos merged 2 commits intomainfromfunc-titles
Sep 5, 2025
Merged

Conversation

@Viicos
Copy link
Member

Change Summary

Fixes#11728.

I think we should also check if the title needs to be set, as it is done currently for model fields with (field_title_should_be_set() L1395):

def_named_required_fields_schema(
self,named_required_fields:Sequence[tuple[str,bool,CoreSchemaField]]
)->JsonSchemaValue:
properties:dict[str,JsonSchemaValue]= {}
required_fields:list[str]= []
forname,required,fieldinnamed_required_fields:
ifself.by_alias:
name=self._get_alias_name(field,name)
try:
field_json_schema=self.generate_inner(field).copy()
exceptPydanticOmit:
continue
if'title'notinfield_json_schemaandself.field_title_should_be_set(field):
title=self.get_title_from_name(name)

frompydanticimportBaseModelclassModel(BaseModel): ...classMain(BaseModel):m:ModelMain.model_json_schema(){│'$defs': {'Model': {'properties': {},'title':'Model','type':'object'}},│'properties': {'m': {'$ref':'#/$defs/Model'}},# no title'required': ['m'],│'title':'Main',│'type':'object'}deffunc(m:Model):passTypeAdapter(func).json_schema(){│'$defs': {'Model': {'properties': {},'title':'Model','type':'object'}},│'additionalProperties':False,│'properties': {'m': {'$ref':'#/$defs/Model','title':'M'}},# duplicate title'required': ['m'],│'type':'object'}

thoughts@dmontagu?

Related issue number

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review,please add a comment including the phrase "please review" to assign reviewers

@github-actionsgithub-actionsbot added the relnotes-fixUsed for bugfixes. labelMay 20, 2025
@github-actions
Copy link
Contributor

github-actionsbot commentedMay 20, 2025
edited
Loading

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pydantic
  json_schema.py
Project Total 

This report was generated bypython-coverage-comment-action

@codspeed-hq
Copy link

codspeed-hqbot commentedMay 20, 2025
edited
Loading

CodSpeed Performance Report

Merging#11892 willnot alter performance

Comparingfunc-titles (be5d4f0) withmain (e31885e)

Summary

✅ 46 untouched benchmarks

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pagesbot commentedSep 5, 2025
edited
Loading

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit:be5d4f0
Status: ✅  Deploy successful!
Preview URL:https://d489993e.pydantic-docs.pages.dev
Branch Preview URL:https://func-titles.pydantic-docs.pages.dev

View logs

@ViicosViicosenabled auto-merge (squash)September 5, 2025 14:05
@ViicosViicos merged commit8a62354 intomainSep 5, 2025
61 checks passed
@ViicosViicos deleted the func-titles branchSeptember 5, 2025 14:10
@ViicosViicos added the needs-blogpost-entryThis PR needs to be documented in the release notes blog post labelSep 5, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@DouweMDouweMDouweM approved these changes

Assignees

No one assigned

Labels

needs-blogpost-entryThis PR needs to be documented in the release notes blog postrelnotes-fixUsed for bugfixes.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Title generator not applied for functions

3 participants

@Viicos@DouweM

[8]ページ先頭

©2009-2025 Movatter.jp