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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatten example values in schema generation #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alampros
Copy link

When using joi.any.example(), the generated schema contains a map with a value prop. This PR flattens the example properties to only the value of the value property.

Given this joi schema:

const responseSchema = Joi.object().keys({
  responseObjectKey: Joi.string().example('some example string'),
})

Diff of Generated Model Definition With This Change:

...
"definitions": {
  "SomeModel": {
       "properties": {
         "responseObjectKey": {
           "type": "string",
-          "example": {
-            "value": "some example string"
-          }
+          "example": "some example string"
         }
       }
     }
  }
}
...

PS - Thank you for the amazing work on this project! 馃ぉ

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 99.357% when pulling c9643ed on alampros:fix/flatten-example-values into f725498 on z0mt3c:master.

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

Successfully merging this pull request may close these issues.

None yet

2 participants