Skip to content
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

JsonSchema.fromZSchema includes refs when refType = SchemaStyle.Inline #3168

Open
guersam opened this issue Sep 25, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@guersam
Copy link
Contributor

guersam commented Sep 25, 2024

Describe the bug
JsonSchema.fromZSchema includes refs when refType = SchemaStyle.Inline.

To Reproduce
Steps to reproduce the behaviour:

  1. Define nested case classes with Schema
  2. Convert the outer one's schema using JsonSchema.fromZSchema with refType = SchemaStyle.Inline
  3. Serialize the generated JsonSchema into a JSON string

scastie

Expected behaviour

All properties are inlined i.e. there are no $ref

Actual behavior

Nested object is still referenced by name

{
  "type" : 
    "object",
  "properties" : {
    "bar" : {
      "$ref" : "#/components/schemas/Bar"
    }
  },
  "required" : [
    "bar"
  ]
}

Additional context

It's needed for structured output when using OpenAI.

@guersam guersam added the bug Something isn't working label Sep 25, 2024
@guersam
Copy link
Contributor Author

guersam commented Sep 26, 2024

I tried simply replacing the hardcoded refType arguments in JsonSchema.fromZSchema with the outer refType, but it causes another bug that flattens nested case classes in properties field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant