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

Issue with reference when refContent is not of type date #103

Open
edunfq opened this issue Dec 9, 2024 · 0 comments
Open

Issue with reference when refContent is not of type date #103

edunfq opened this issue Dec 9, 2024 · 0 comments

Comments

@edunfq
Copy link

edunfq commented Dec 9, 2024

Problem Description

I am encountering issues when using the reference type in configurations where the refContent generator is not of type date. Specifically, when refContent uses generators like enum, constant, or int with min and max, the following problems occur:

  1. Field duplication behavior: In the generated JSON, the referenced field appears duplicated with the same value, while the original field name disappears.

  2. Validation failure: Sometimes, the system throws an error claiming that refContent is empty, even though it is properly defined.

Minimal Reproducible Example

Input Configuration

Configuration file sent to mgodatagen:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "Reference Issue Example",
    "type": "object",
    "content": {
        "originalField": {
            "type": "reference",
             "id": 1
        },
        "referencedField": {
            "type": "reference",
            "id": 1,
            "refContent": {
                "type": "constant",
                "constVal": "ConstantValue"
            }
        }
    }
}

Expected Output

{
    "originalField": "ConstantValue",
    "referencedField": "ConstantValue"
}

Actual Output

{
    "referencedField": "ConstantValue",
    "referencedField": "ConstantValue"
}

Observed Errors

When refContent is not of type date, mgodatagen produces the following error in some cases:

Error: invalid generator for field 'referencedField'
cause: 'refContent' can't be null or empty

In other cases, the generated JSON contains a duplicated field, and the original field is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant