JSON Schema with discriminator validation
See original GitHub issueWhenever running Portman cliOptionsFile, the Contract tests generated produce two Schema const declarations. The end result is that for every test in my Postman collection, I must either comment out or delete this second declaration because it prevents all other tests from running in Postman. The error is “SyntaxError: Identifier ‘schema’ has already been declared”.
Here’s an example of what the Tests tab includes for the contract tests in Postman:
// Response Validation const schema = {"title":"PageCountryData","description":"Represents one paginated page of results of type CountryData","type":"object","properties":{"items":{"type":"array","uniqueItems":true,"minItems":1,"description":"Contains the results","items":{"title":"Country Data","type":"object","description":"API managed country data for inclusion in addresses for users, organizations and teams","properties":{"id":{"type":"integer","format":"int64","readOnly":true},"name":{"type":"string","readOnly":true},"twoDigitCode":{"type":"string","readOnly":true},"threeDigitCode":{"type":"string","readOnly":true},"positionIndex":{"type":"integer","format":"int32","readOnly":true}},"required":["id","name","twoDigitCode","threeDigitCode","positionIndex"]}},"lastPage":{"type":"boolean"},"totalCount":{"type":"integer","format":"int32"},"pageSize":{"type":"integer","format":"int32"},"page":{"type":"integer","format":"int32"},"facets":{"type":"array","uniqueItems":true,"minItems":1,"items":{"type":"object"}},"actions":{"type":"object"}},"required":["items","lastPage","totalCount","pageSize","page","facets","actions"],"x-examples":{"example-1":{"items":[{"id":0,"name":"string","twoDigitCode":"string","threeDigitCode":"string","positionIndex":0}],"lastPage":true,"totalCount":0,"pageSize":0,"page":0,"facets":[{}],"actions":{}}}}
Below this is the following:
// Response Validation const schema = {"type":"object","properties":{}}
It’s likely there’s an easy way to address this, but I have yet to find one. Thanks for your help!
Issue Analytics
- State:
- Created 2 years ago
- Comments:15 (2 by maintainers)
Thanks for reporting @inoclafsemaj.
Please make sure you’re using the latest version, 1.7.0 as we’ve had an issue similar to this one in the past…
If you create a public repo with your cliOptionsFile, portmanConfigFile and OpenApiSpec we can have a look to try and reproduce.
closing for now, but feel free to re-open if this remains an issue.