Commit Graph

47 Commits

Author SHA1 Message Date
Calvin Lobo
9ab482ac9b Instead of using "root.yaml" as a theoretical root, use the real filename of the root spec (often openapi.yaml). This fixes issues with resolving references in rules such as unsused-components. 2024-09-09 23:56:54 +01:00
Emilien Puget
cbe1201cbd removed golang x package in favour of the std lib 2024-07-08 10:13:23 -04:00
quobix
5d49ae0267 cleaning up experience when using libopenapi via vacuum.
now most of the big bugs are out of the way, we can focus on refinement.

Signed-off-by: quobix <dave@quobix.com>
2024-02-16 09:46:31 -05:00
quobix
0eea21b150 added parent node to model for references.
Signed-off-by: quobix <dave@quobix.com>
2024-02-08 10:39:02 -05:00
quobix
43860f4e3c Added some new getters to the index
Also added map conversion utilities based on reported vacuum error https://github.com/daveshanley/vacuum/issues/417
also prevented the bundler from inlining root references.

Signed-off-by: quobix <dave@quobix.com>
2024-01-18 15:11:39 -05:00
quobix
2bc6e9f028 Added ‘bundler’ module
resolves a v3 document or a model into a single document.

Signed-off-by: quobix <dave@quobix.com>
2024-01-18 15:11:39 -05:00
Tristan Cartledge
c2b4b662ba Merge branch 'main' into ordered-libopenapi 2023-12-04 22:38:26 +00:00
quobix
909646cff1 removed debug code.
Signed-off-by: quobix <dave@quobix.com>

Move original ref resolving to end of resolving run

this prevents mid-recursion shifting of nodes.

Signed-off-by: quobix <dave@quobix.com>
2023-12-04 16:13:13 -05:00
Tristan Cartledge
2b128cb465 fix: data race 2023-12-04 18:08:02 +00:00
quobix
ee2783e6e7 more coverage bumps
Signed-off-by: quobix <dave@quobix.com>
2023-11-25 10:10:51 -05:00
quobix
5d14ef226b Adding more tests to bump coverage
Signed-off-by: quobix <dave@quobix.com>
2023-11-25 10:10:51 -05:00
quobix
7d63fe3262 Added new node map capability
Signed-off-by: quobix <dave@quobix.com>
2023-11-25 10:10:51 -05:00
quobix
e624efbf84 addressed issue #195
Resolving and indexing has changed, new code is required and this isue highlighted a glitch introduced with the addition of the rolodex when resolving.

Signed-off-by: quobix <dave@quobix.com>
2023-11-08 12:36:08 -05:00
quobix
f3094d0b14 Cleanup, sweep-up and tuneup
Signed-off-by: quobix <dave@quobix.com>
2023-11-04 09:38:33 -04:00
quobix
fa0b315756 Enabling deep array circular reference checking
Signed-off-by: quobix <dave@quobix.com>
2023-11-03 09:49:02 -04:00
quobix
80b2b2d0b5 More cleaning and added docs.
We’re ready for review

Signed-off-by: quobix <dave@quobix.com>
2023-11-01 16:14:11 -04:00
quobix
3c27c43ec0 Added cache set/get for index
It’s required to be able to ensire full coverage to test things that can’t be tested without a huge amount of test rigging.

Signed-off-by: quobix <dave@quobix.com>
2023-11-01 11:38:16 -04:00
quobix
9746f51a0e bumping up coverage of the rolodex
Signed-off-by: quobix <dave@quobix.com>
2023-10-31 11:30:39 -04:00
quobix
8717b3cd33 An enormous amount of surgery on the low level model.
Every `Build()` method now requires a `context.Context`. This is so the rolodex knows where to resolve from when locating relative links. Without knowing where we are, there is no way to resolve anything. This new mechanism allows the model to recurse across as many files as required to locate references, without loosing track of where we are in the process.

Signed-off-by: quobix <dave@quobix.com>
2023-10-23 15:04:34 -04:00
quobix
3bf830c2b3 Another round of cleaning.
Signed-off-by: quobix <dave@quobix.com>
2023-10-21 18:41:53 -04:00
quobix
28047d08d2 First sweep at cleaning up dead code
first round of a number I am sure, lots to clean.

Signed-off-by: quobix <dave@quobix.com>
2023-10-21 18:26:21 -04:00
quobix
be7e477529 index tests all pass! now time to clean.
Signed-off-by: quobix <dave@quobix.com>
2023-10-21 17:29:53 -04:00
quobix
b295e8fd5c bashing through usecases and updating tests as we go.
so many things that can go wrong. have to catch them all.

Signed-off-by: quobix <dave@quobix.com>
2023-10-19 15:18:33 -04:00
quobix
9ee1afe1f3 digital ocean now running correctly
Sucking in all the files!

Signed-off-by: quobix <dave@quobix.com>
2023-10-18 16:52:32 -04:00
quobix
51971762a9 Another massive surgical strike with the rolodex and index reshuffle.
Signed-off-by: quobix <dave@quobix.com>
2023-10-18 09:29:26 -04:00
quobix
cea7bb0cc8 chopping through index changes, basic design works.
seems to be holding, more tests to change.

Signed-off-by: quobix <dave@quobix.com>
2023-10-16 14:56:58 -04:00
quobix
d5f72a2a2e a first working engine of the new design.
There is a horrible amount of work to be done to clean this up, and wire in remote support. but so far, this is working as expected and is now a much cleaner design, (once everything has been cleaned up that is)

Signed-off-by: quobix <dave@quobix.com>
2023-10-16 13:36:30 -04:00
quobix
8e08110b11 Added numeric version to SpecInfo
It’s easier to determine now which version is which.

Signed-off-by: quobix <dave@quobix.com>
2023-10-08 12:27:52 -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
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
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
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
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
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
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
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
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