Skip to content

Fixes generating TypeSpec files #1146

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

Merged
merged 1 commit into from
Apr 28, 2025
Merged

Conversation

waldekmastykarz
Copy link
Collaborator

Fixes generating TypeSpec files:

  • adds sanitizing namespaces, and model- and operation names
  • fixes handling null types
  • fixes generating models from array items
  • fixes sanitizing names when using language model

Thanks @tomorgan for reporting these issues and working with us to get them fixed!

@waldekmastykarz waldekmastykarz added the pr-bugfix Fixes a bug label Apr 25, 2025
@waldekmastykarz waldekmastykarz requested a review from a team as a code owner April 25, 2025 08:15
@waldekmastykarz
Copy link
Collaborator Author

@dotnet-policy-service agree

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes issues in generating TypeSpec files by addressing namespace sanitization, model and operation naming, null type handling, and array item model generation.

  • Added logic to merge model properties based on type and existence.
  • Updated properties to allow mutations required for handling null types.
  • Enhanced naming and sanitization flows in request log and language model components.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
dev-proxy-plugins/TypeSpec/TypeSpecExtensions.cs Merges model properties with added handling for string literal "null".
dev-proxy-plugins/TypeSpec/Http.cs Changes ModelProperty.Type from an init-only to a mutable property.
dev-proxy-plugins/RequestLogs/TypeSpecGeneratorPlugin.cs Improves parameter and operation naming as well as array model generation.
dev-proxy-abstractions/LanguageModel/OllamaLanguageModelClient.cs Updates logging messages for clearer output.
Comments suppressed due to low confidence (2)

dev-proxy-plugins/RequestLogs/TypeSpecGeneratorPlugin.cs:174

  • Removing the MakeSingular call when constructing the BodyType for arrays may result in inconsistent naming; please verify that this change is intentional and consistent with other naming conventions used.
res.BodyType = "${rootModel.Name}[]";

dev-proxy-plugins/TypeSpec/TypeSpecExtensions.cs:25

  • Comparing the property's Type to the literal "null" may lead to unexpected behavior if the string value is not intended; please verify that checking against "null" is intentional.
else if (existingProp.Type == "null")

@garrytrinder garrytrinder merged commit 244f105 into dotnet:main Apr 28, 2025
4 checks passed
@waldekmastykarz waldekmastykarz deleted the fix-tsp branch April 28, 2025 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-bugfix Fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants