Commit Graph

99 Commits

Author SHA1 Message Date
Tristan Cartledge
d4dabca04f fix: correctly handling of extracting enums for index 2023-10-05 09:31:16 -04:00
Tristan Cartledge
2723ed974d fix: test 2023-10-05 09:31:16 -04:00
quobix
f0a968bce4 Added polymorphic/array ignore to document config.
Now a document can be pre-configured to ignore polymorphic circular references, and array references.

Signed-off-by: quobix <dave@quobix.com>
2023-09-21 06:01:23 -04:00
quobix
8699cf4910 Added a little coverage and working on config design
adding new properties to top level configs should work nicely.

Signed-off-by: quobix <dave@quobix.com>
2023-09-21 06:01:23 -04:00
quobix
715bfc3052 Added support for configurable levels of circular reference checking #113 #130
Signed-off-by: quobix <dave@quobix.com>
2023-09-21 06:01:23 -04:00
quobix
e58aeb7860 Ensuring tests pass with updated code.
Signed-off-by: quobix <dave@quobix.com>
2023-09-16 11:39:32 -04:00
quobix
fcc12cb7dc Properties named ‘enum’ were being indexed as enums
An edge case reported in https://github.com/daveshanley/vacuum/issues/339 shows up when enums are being indexed when they are actually a property of a schema called ‘enum’.

This has been fixed.

Signed-off-by: quobix <dave@quobix.com>
2023-09-16 11:39:32 -04:00
quobix
43bf162e0c Added new Render method to top level document.
Like `RenderAndReload` this method will render / print out the document, however it won’t read it back in and reload the model from the ground up. This is a non-destructive method that does not reload the model from the rendered document.

If you don’t use the low model or you don’t care that the high level model and low-level models are out of sync? No problem. Otherwise keep this in mind that the low level model will only represent the original un-mutated document, as will the index.

Signed-off-by: quobix <dave@quobix.com>
2023-09-14 07:30:03 -04:00
Tristan Cartledge
74c7a3f632 fix: improves the ability to get all inline schemas and identify inline object schemas (#154)
* fix: improves the ability to get all inline schemas and identify inline object schemas

* fix

* fix

* fix

* fix
2023-08-22 06:40:00 -04:00
Dave Shanley
976ca0905a Added line sorting back in for GetAllSchemas
Signed-off-by: Dave Shanley <dave@quobix.com>
2023-08-09 07:40:24 -04:00
Dave Shanley
f7ab737f0a Updated index to count schemas, even if they are refs.
This was brought up in chat, that the expectation is that all schemas are included, refs or not. This update fixes that for the index and adds in a new individual property to count just the references `GetAllReferenceSchemas `

Signed-off-by: Dave Shanley <dave@quobix.com>
2023-08-09 07:40:24 -04:00
zak905
f7a6c9dbcc add additional test for covering file referece case 2023-07-28 16:42:31 -04:00
Zakaria Amine
6b0cae741c add unit tests 2023-07-28 16:42:31 -04:00
zak905
29a44e405a path unescape url when resolving remote reference 2023-07-28 16:42:31 -04:00
Dave Shanley
25d8de9b0e Added more support for YAML merge nodes, anchors and aliases
And added deeper support for Aliases. Also added in local file handling through renamed `FSHandler` configuration property for the index.

Also re-ran `go fmt`

Signed-off-by: Dave Shanley <dave@quobix.com>
2023-07-16 11:45:18 -04:00
Dave Shanley
3b7cbacc44 Add support for custom io.FS remote handler in index #85
A new configuration option is available to the index, a `RemoteHandler` of type  `fs.FS`. If set, will be used as an override to all other remote fetching code.

Signed-off-by: Dave Shanley <dave@quobix.com>
2023-07-16 11:45:18 -04:00
Federico Bevione
fa9fa5a0f6 add issue link 2023-06-30 13:24:16 -04:00
Federico Bevione
572130c666 add test, fix RemoteURLHandler field name 2023-06-30 13:24:16 -04:00
Federico Bevione
c99d552d9e remove unused fields 2023-06-30 13:24:16 -04:00
Federico Bevione
0c0399abbe expose optional function to resolve remote files 2023-06-30 13:24:16 -04:00
Dave Shanley
a4b7a01c43 Extracting index building code to be run optionally
This is to allow the correct operation of local/remote lookups to be correctly indexed (after the resolver has run). Addresses an issue in vacuum https://github.com/daveshanley/vacuum/issues/294

Signed-off-by: Dave Shanley <dave@quobix.com>
2023-06-17 14:12:27 -04:00
Dave Shanley
c3cf5f1e38 Added support for unevaluatedProperties as Schema and bool #118
Also ran `gofmt` across the entire project. Things need cleaning up.

Signed-off-by: Dave Shanley <dave@quobix.com>
2023-06-17 14:12:27 -04:00
Dave Shanley
148822fa2a Added support for references with brackets #112
Brackets in names are now supported. For example `’#/components/schemas/CoffeeCup[Black]’

Signed-off-by: Dave Shanley <dave@quobix.com>
2023-06-17 14:12:27 -04:00
Tristan Cartledge
06f6b243a8 fix: add missing path and parent node to paths index references 2023-05-30 09:20:56 -04:00
Dave Shanley
08f596058f Cleaning up some tests after ancestor lookup code added.
Signed-off-by: Dave Shanley <dave@quobix.com>
2023-05-16 17:03:02 -04:00
Dave Shanley
f629c0ff58 fix for resolving looping relative references
In vacuum, a usecase was reported where an infinite loop occurred due to re-parsing the same reference over and over in a loop. It was re-creatable and it was because the loop happened before the index was ready.

This should be resolved now, at least for this use case. To be sure, I have included the specs as a new test.

https://github.com/daveshanley/vacuum/issues/268
Signed-off-by: Dave Shanley <dave@quobix.com>
2023-05-16 17:03:02 -04:00
Dave Shanley
eec0c71092 Added some URL checking to index URL extraction.
In the case of relative files, the first arg won’t be a URL, so this ensures both relatitve and full references work.
2023-04-22 09:50:44 -04:00
Dave Shanley
24d094ca7b Corrected remote document lookup behavior
When remote documents are requested and there is no way to know the base URL, the index will now try and determine the base path from the way the spec was loaded (if it comes in remote, we use the base URL of the spec)
2023-04-22 09:50:44 -04:00
Dave Shanley
3544ed0303 Churning through v3 models now.
mutations everywhere, for everyone!
2023-03-26 06:10:31 -04:00
Dave Shanley
cb5f2da4d3 Fixed race conditions in index #91
Different race conditions popped up at different times, depending on how complex the nesting of indexes was. After running tests with `-race` I've knocked out all the concurrency issues being reported and now there are no race conditions reported by the tests. This should knock out all known race conditions with some targeted mutex locks.

Non breaking change.
2023-03-08 09:26:10 -05:00
Dave Shanley
1ac5fbe9fc Bumped coverage on utility methods
fallen slightly, bumpy bump.
2023-03-06 13:18:28 -05:00
Dave Shanley
581423016f Added another test to validate #88
Code is behaving correctly, according to the design.
2023-03-06 13:18:28 -05:00
Dave Shanley
b72c1fce40 Cleaned up a few lines
review looked a bit gappy.
2023-03-06 13:18:28 -05:00
Dave Shanley
0f2ac08567 Fixed async isues with index #91
The index runs async everywhere, it's kinda impossible to know which path with resolve first, so testing is hard. Sometimes a race condition is hit, well, it was. Now that map has a mutex on it.

Also fully fixed handling files with relative links. A basepath property has been added to the index configuration to allow a local root to be set when resolving files.

Added a full checkout test for digital ocean so that full remote and full local testing is performed.
2023-03-06 13:18:28 -05:00
Dave Shanley
0850ceb272 added null check for paramRef when scanning operation params.
this issue was discovered in https://github.com/daveshanley/vacuum/issues/240, this provides a resolution to the problem.
2023-02-27 11:05:18 -05:00
Dave Shanley
4901813e88 Updated test to reflect new inline schema count
Looks like we were missing a ton!
2023-02-27 11:05:18 -05:00
Dave Shanley
6d384b2732 updated: a fix for #50
properties are now checked as part of the inline schemas. paths updated also to ensure correctness.
2023-02-27 11:05:18 -05:00
Dave Shanley
4a378de02e Fix: bug in index with description handling.
Issue for description being incorrectly picked up, is because index was collecting all descriptions, even if they were labels on schemas as reported in https://github.com/daveshanley/vacuum/issues/239
2023-02-27 11:05:18 -05:00
Dave Shanley
bc1d8c5454 fix: Issue #82
The index can now accept multiple parameters with the same name, as long as they have different `in` types.
2023-02-22 09:14:27 -05:00
Dave Shanley
5481353994 removed error check on unescape. nothing to be done. 2023-02-22 09:14:27 -05:00
Dave Shanley
d8a7b6c21d Ensure encoded paths are handled in lookup. #84
This partially resolves a whacky path ref lookup in the index mentioned in #84, but it's not a full fix, that requires the build out of a resolved spec. The design needs thought and care.
2023-02-22 09:14:27 -05:00
Dave Shanley
fa59b5d21d Aligned CheckForCircularErrors and Resolve
the two methods were doing different things, now they are not.
2023-02-22 09:14:27 -05:00
Dave Shanley
c5e9dbc360 Bumping coverage on 0.6.0 2023-02-22 09:14:27 -05:00
Dave Shanley
e6626fe22e Support for relative links now in place #73
Tests all passing, runs super fast, pulls in every single DigitalOcean spec and parses it. There may be some issues deeper down in the models, but for now high level tests all pass.
2023-02-22 09:14:27 -05:00
Dave Shanley
e19b7d2bf1 Working through fix #73
Quite a bit of surgery required.
2023-02-22 09:14:27 -05:00
Dave Shanley
1df5f44e6f Working through fix-73 and v0.6.0 2023-02-22 09:14:27 -05:00
Dave Shanley
545dbc88c4 fix: panic when schema used as non-label #76
a small oversight in 0.5.0 means that using a `schema` anywhere other than a label, caused the index to get upset. This has now been resolved.
2023-02-02 05:22:56 -05:00
Dave Shanley
6d77716c9a feat: add index for getting all "schema" objects #50
There is new code that looks for inline `schema` definitions and collects them, as well as a futher subset of references that are specifically `object` or `array` types. This is a breaking change because the `index.GetAllSchemas()` method now returns a slice of *Reference pointers, rather than a map of them. The original behavior of `GetAllSchemas()` has been replaced with `GetAllComponentSchemas()` which retains the signature.

Two new additional methods `GetAllInlineSchemas()` and `GetAllInlineSchemaObjects()`. The former will return everything in the spec marked with `schema` that is not a reference. The latter will return everything the former does, except filtered down by `object` or `array` types.

Also the index is now bubbled up through the document model. There isn't a simple way to get access to it, small non breaking change that attaches a reference to the index, returned by `DocumentModel`
2023-01-28 14:09:11 -05:00
Benjamin Nolan (TwoWholeWorms)
cd63f66efe fix: Check for direct reference in IsPropertyNodeRequired 2023-01-11 05:47:06 -05:00
Benjamin Nolan (TwoWholeWorms)
1f2709fef3 fix: Handle direct reference loops as required 2023-01-11 05:47:06 -05:00