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

$ref: keywords such as default used on a ref affect all instances #1321

Open
abemedia opened this issue Oct 4, 2024 · 0 comments
Open

$ref: keywords such as default used on a ref affect all instances #1321

abemedia opened this issue Oct 4, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@abemedia
Copy link
Contributor

abemedia commented Oct 4, 2024

What version of ogen are you using?

$ go list -m github.com/ogen-go/ogen
github.com/ogen-go/ogen v1.4.1

Can this issue be reproduced with the latest version?

Yes

What did you do?

Creating a custom type and referencing that with $ref, then using keywords such as default, x-ogen-name, minimum etc. will apply these keywords to all instances.

See the following example where I create the custom type Decimal and then use this for both price and gratuity, but only set a default value on gratuity.

components:
  schemas:
    Decimal:
      type: string
      pattern: ^-?\d+(\.\d*)?$
    Transaction:
      gratuity:
        $ref: '#/components/schemas/Decimal'
        default: '5.00'
      price:
        $ref: '#/components/schemas/Decimal'

What did you expect to see?

I expected gratuity to have the default value 5.00 and price to not have a default value.

What did you see instead?

Both price and gratuity have the default value 5.00.

@abemedia abemedia added the bug Something isn't working label Oct 4, 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
Projects
None yet
Development

No branches or pull requests

2 participants
@abemedia and others