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

Add support for example/xml keywords #17

Closed
nebehr opened this issue Jan 25, 2021 · 5 comments
Closed

Add support for example/xml keywords #17

nebehr opened this issue Jan 25, 2021 · 5 comments
Labels
enhancement New feature or request
Milestone

Comments

@nebehr
Copy link

nebehr commented Jan 25, 2021

According to Swagger v2.0 spec each schema object can have fields like example, xml and some others. Currently the validator complains about them in warnings about unknown fields. Can these keywords be incorporated in the schema library to be simply ignored?

@bjansen bjansen added this to the v1.0.0 milestone Jan 25, 2021
@bjansen bjansen added the enhancement New feature or request label Jan 25, 2021
bjansen added a commit that referenced this issue Jan 27, 2021
@nebehr
Copy link
Author

nebehr commented Jan 29, 2021

@bjansen sorry for being nosey but example keyword should accept all kinds of nodes, not just NodeType.OBJECT. Examples can also be strings, numbers etc.

@bjansen
Copy link
Owner

bjansen commented Jan 29, 2021

Ah, I think you're right, I read "A free-form property" and assumed it was an object, but type is actually Any. Thanks for pointing it out, I'll fix it later today :)

If you have 10 minutes, it would be great if you could build the snapshot version and test the feature (and perhaps also the fix I did for #19) and let me know if it works for your use-cases. Thanks!

@nebehr
Copy link
Author

nebehr commented Jan 29, 2021

It seems to consume my current spec properly although on initial merge with master it did produce some weird results. For want of a better option I have used super("example", NodeType.STRING, NodeType.values()) for ExampleKeyword.

Regarding #19, are you intentionally performing transformations twice in SwaggerValidator constructor? Why not combine them in a single map and do it once? Also I think it might be useful to add a shortcut for empty transformations map, so it does not have to traverse the whole tree needlessly.

Is the next release with these changes planned in the nearest future?

@bjansen
Copy link
Owner

bjansen commented Jan 29, 2021

are you intentionally performing transformations twice in SwaggerValidator constructor?

I was doing it so that what's transformed by your custom transformations can possibly be transformed again by the built-in transformations. Your particular use-case was renaming x-oneof to x-oneOf, but x-oneOf has to be renamed again to oneOf because that's what is supported by json-schema-validator.

It turns out that the same thing can be done in a single pass using a LinkedHashMap that stores merged transformations in the correct order (or so my unit tests say 😄).

Is the next release with these changes planned in the nearest future?

Yes, as soon as I'm done with what's left in https://github.com/bjansen/swagger-schema-validator/milestone/2. At the moment it's only this issue, but I think I should also add support for everything else listed under the section that says Other than the JSON Schema subset fields, the following fields may be used for further schema documentation. in the specs .

bjansen added a commit that referenced this issue Jan 30, 2021
@bjansen bjansen closed this as completed Jan 31, 2021
@bjansen
Copy link
Owner

bjansen commented Feb 2, 2021

1.0.0 landed on Maven Central this morning :)

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

No branches or pull requests

2 participants