Commit Graph

37 Commits

Author SHA1 Message Date
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
Benjamin Nolan (TwoWholeWorms)
7338a614d0 refactor: FindKeyNode -> FindKeyNodeTop 2023-01-11 05:47:06 -05:00
Benjamin Nolan (TwoWholeWorms)
ee504c543a feat: Allow circular references when the properties are not marked as required 2023-01-11 05:47:06 -05:00
Dave Shanley
6b28e414bd fix: Index incorrectly handling file references on the local file system.
This was reported in https://github.com/daveshanley/vacuum/issues/225, it's a continuation of the issue found in https://github.com/pb33f/libopenapi/issues/37. This fix allows the full import of the file (not just a path/component) to be imported.

Signed-off-by: Dave Shanley <dave@quobix.com>
2023-01-04 06:47:48 -05:00
Tristan Cartledge
36f5999d66 feat: add an index for object schemas with properties and add additional info to enum reference 2022-12-20 16:43:43 -05:00
Tristan Cartledge
c75a1bfaf4 fix: add paths/parent nodes to schemas as well 2022-12-16 16:09:59 -05:00
Tristan Cartledge
53789cbc1b feat: add parent nodes and paths to server index references 2022-12-16 16:09:59 -05:00
Dave Shanley
27001e083b Small glitches for vacuum.
A couple of slight bugs were causing big issues in vacuum.
2022-12-16 13:40:18 -05:00
Dave Shanley
635877da1d Small cleanup on some commented code. 2022-12-15 16:31:32 -05:00
Dave Shanley
32f48385f2 (enhancement): Improved resolving/lookup code for #45 2022-12-15 16:31:32 -05:00
Tristan Cartledge
48467b60d7 fix: didn't remove setting map before checking 2022-12-15 15:11:28 -05:00
Tristan Cartledge
09fcf334b6 fix: call out duplicate reference in parameters list 2022-12-15 15:11:28 -05:00
Tristan Cartledge
d7b9ded8bb feat: add path to references and parameters 2022-12-15 15:11:28 -05:00
Dave Shanley
05eb4ffec9 (patch): Some crazy references are causing panics. #48 #45
This patch bumps up support for creating valid JSON paths from references. It addresses #48 and makes invalid specs, valid! This addresses issues #48 and #45 that report references cannot be found. Now `libopenapi` can support much more funky lookups.
2022-12-15 09:47:23 -05:00
Dave Shanley
9ccd3bc8b7 (fix): Remote references with no components now supported by index #37
If a remote reference is used that does not contain a component ID (http://something.com/somefile.json#/components/something). The index would throw an error. This is not the correct behavior as the raw file can be the root, thus no componentID is required.

The bulk of the code is expecting that componentID, so this fix will prepare any component-less remote reference, to be treated properly.

Signed-off-by: Dave Shanley <dave@quobix.com>
2022-12-05 09:18:44 -05:00
Dave Shanley
1c98ae170a fix: panic thrown when paths is wrapped in an array #4
When paths are wrapped in an array, the index throws an error because it's expecting them to be supplied as a map. Now paths can be wrapped or unwrapped, the index won't care.
2022-11-07 08:09:22 -05:00
Dave Shanley
0d4e8bf3f8 Added securityRequirement reference tracking to index.
Swagger docs define securityDefinitions, however they are not tracked by the index, and vacuum needs to know about them, so now the index collects these references.
2022-10-21 17:38:39 -04:00
Dave Shanley
8533ea9bdc Fixed a small couple of glitches that appeared during load testing. 2022-09-26 14:22:48 -04:00
Dave Shanley
57622b26e5 Docs, examples and new logo! 2022-09-26 10:52:09 -04:00
Dave Shanley
0de0c16c0c 99.9 % coverage & full OpenAPI v3 support
A single line that tries to read an HTTP response body and fails is very hard to test without mocking, and the mock does not add value to a single line of code to check for an error that can rarely ever be triggered. Going to settle for 99.9% for now.
2022-08-31 10:04:39 -04:00
Dave Shanley
62a7c88631 Bumping coverage on spec index.
cleaning up the left-over untested code from recent development.
2022-08-30 10:05:48 -04:00
Dave Shanley
2398f051b8 building out tests for extraction functions.
Same functions will power every other model. Found some opprotunities to add control over circular references, when and how to fire errors and what not. All in all, some robust code additions will improve the library significantly.
2022-08-28 13:21:57 -04:00
Dave Shanley
6c2de6c151 The resolver just got an upgrade, polymorphic circular reference checking.
Building out models that have circular references is tricky. Particularly when they are polymorphic ones. The resolver now searches the polymorphic references for circular references as well (which is returning much more valuable results now). The low level model is now sensitive to this and will avoid building out anything that is circular.
2022-08-22 09:24:23 -04:00
Dave Shanley
75c7c83e31 Bumping coverage on schema to 100%
I think it should be pretty much bullet proof at the moment (until the next failure). Also added external index lookups from main index for external docs. found this bug after refining lookups in schemas.
2022-08-17 08:09:01 -04:00
Dave Shanley
10bf40ad97 Paths test coverage is completed.
Found some good gaps a holes in existing overage.
2022-08-15 17:52:32 -04:00
Dave Shanley
1c9f6bbfcc adding tests, fixing bugs, validating model.
Amazing what you find when you really test the fuck out of things.
2022-08-14 08:18:27 -04:00
Dave Shanley
c320b2b9f1 Operating at speed now.
Stripe API is slowest to build at about 1.2s, the depth of the schemas on that spec are insane. The only way to speed things up here is to NOT wait for threads to finish before returning the model, and this creates a broken guarantee as the model won't be finished building by the time its returned to the consumer. When running tests against this - they fail randomly. depending on which thread reaches the finish first, before trying to be read.

This isn't an option, so for now, this is as fast as she will get, which is pretty good. 5ms for petstore and about 250ms for k8s.
2022-08-12 09:41:03 -04:00
Dave Shanley
392d217c4e index glitch found, should smash pipline failures.
whoops!
2022-08-12 07:20:15 -04:00
Dave Shanley
a8623ceec4 Test is borked in pipeline, works fine locally.
trying to play whack-a-mole now to determine the failures.
2022-08-12 07:04:20 -04:00
Dave Shanley
248b4daa80 We-worked model to remove resolver.
lookups are performed inline now. keeps things simpler, however it has a performance knock, so it's time to refine async building were possible.
2022-08-11 14:54:25 -04:00
Dave Shanley
a4012594de Building out model some more.
everything is holding up well.
2022-07-31 16:15:01 -04:00
Dave Shanley
0665855605 Fixed bug with 'anyOf' being triggered with 'allOf' is used.
'allOf' is not an issue in any version.
2022-07-21 10:50:35 -04:00
Dave Shanley
3d1f5beeaa Breaking change with index, sibling nodes are being chomped by the resolver.
sibling nodes with references were being destroyed when resolved. Copies are now made instead of using pointers for this specific item, as the fidelity is lost when using the resolver (the refs are resolved and there is no way to re-locate the original positon of the reference.
2022-07-21 09:23:16 -04:00
Dave Shanley
df710cb49d Moved index into its own package
removed non generic code used by vacuum.
2022-07-18 08:40:28 -04:00