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

Open
Viicos wants to merge1 commit intomain
base:main
Choose a base branch
Loading
fromfunc-titles

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-actionsGitHub Actions
Copy link
Contributor

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-hqCodSpeed HQ
Copy link

CodSpeed Performance Report

Merging#11892 willnot alter performance

Comparingfunc-titles (103ed91) withmain (944674a)

Summary

✅ 46 untouched benchmarks

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
relnotes-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
2 participants
@Viicos@DouweM

[8]ページ先頭

©2009-2025 Movatter.jp