diff --git a/CHANGELOG.md b/CHANGELOG.md index a445d54..9919da3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,32 @@ # Change Log +## [2.4.1](https://github.com/networknt/openapi-parser/tree/2.4.1) (2026-10-11) + +**Commits:** + +- upgrade to version 2.4.1 before release in master branch ([ed78857](https://github.com/networknt/openapi-parser/commit/ed7885754e7091caf7f7ec1296527a7f404db2a1)) (by Steve Hu) +- upgrade maven-gpg to 3.2.8 from 3.2.7 ([4ef75bd](https://github.com/networknt/openapi-parser/commit/4ef75bd63ab1f562aa208395546b748b70ad1e8b)) (by Steve Hu) +- build: upgrade JUnit to 6.1.3 ([ed190fc](https://github.com/networknt/openapi-parser/commit/ed190fc8ca4ddd36e428bd435daefca18c8d953e)) (by Steve Hu) +- upgrade logback to 1.6.5 from 1.6.3 ([279a696](https://github.com/networknt/openapi-parser/commit/279a69665064e34bde0c9819cddd974c9bbe3af5)) (by Steve Hu) +- upgrade to version 2.4.1-SNAPSHOT after release in master branch ([a1ff865](https://github.com/networknt/openapi-parser/commit/a1ff86556b469431133bc7e01d87c82d3f5217e6)) (by Steve Hu) + +## [2.4.0](https://github.com/networknt/openapi-parser/tree/2.4.0) (2026-10-07) + +**Commits:** + +- upgrade to version 2.4.0 before release in master branch ([f6da2cd](https://github.com/networknt/openapi-parser/commit/f6da2cddaf0ec2588637bb3586a68b07de3ebd9c)) (by Steve Hu) +- upgrade maven-javadoc to 3.12.0 from 3.4.1 ([ff7cafd](https://github.com/networknt/openapi-parser/commit/ff7cafda325b533fb6983f19c7ebd10fac579ab6)) (by Steve Hu) +- upgrade slf4j to 2.0.20 from 2.0.19 ([a5a5b34](https://github.com/networknt/openapi-parser/commit/a5a5b34b262414809f69734e253f5889b8616ae4)) (by Steve Hu) +- upgrade jackson to 2.22.3 from 2.22.1 ([ecdc9ce](https://github.com/networknt/openapi-parser/commit/ecdc9ce94d806075c2e2071cf65e46f37628818b)) (by Steve Hu) +- upgrade to version 2.3.8-SNAPSHOT after release in master branch ([1121815](https://github.com/networknt/openapi-parser/commit/11218156eb9733567ec794f132b35f80724f75a9)) (by Steve Hu) +- upgrade slf4j to 2.0.19 from 2.0.17 ([128491e](https://github.com/networknt/openapi-parser/commit/128491eef9ea8040aa8541518fafe5cbfaca51bb)) (by Steve Hu) +- upgrade maven-surefire to 3.6.0 ([f090ba5](https://github.com/networknt/openapi-parser/commit/f090ba5209a7b14d0d920dd6fe16fb76ca394a5a)) (by Steve Hu) +- upgrade logback to 1.6.3 from 1.5.37 ([f7c9234](https://github.com/networknt/openapi-parser/commit/f7c9234e71aa49799bbe1bed3880d797d1183195)) (by Steve Hu) +- Remove obsolete javadoc-packagelist-maven-plugin workaround ([8d27648](https://github.com/networknt/openapi-parser/commit/8d27648b861eb433c70cc7fae5a6327d54403b9a)) (by Steve Hu) +- upgrade central-publishing-maven to 0.11.0 from 0.7.0 ([63b8722](https://github.com/networknt/openapi-parser/commit/63b8722a7ebb20268b0771157a9c3cb48aef4e83)) (by Steve Hu) +- fixes #77 fix unstable upstream dependencies for specs ([d24768d](https://github.com/networknt/openapi-parser/commit/d24768d5a5656a1d13ab386402bbd6ffbd4cb429)) (by Steve Hu) +- upgrade to version 2.3.8-SNAPSHOT after release in master branch ([898a9db](https://github.com/networknt/openapi-parser/commit/898a9dbe4b34b9c4ab3888e7b54c6ca0e0cad711)) (by Steve Hu) + ## [2.3.7](https://github.com/networknt/openapi-parser/tree/2.3.7) (2026-08-12) diff --git a/README.md b/README.md index c7e1dad..a70061d 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,64 @@ A light-weight, fast OpenAPI 3.0 parser and validator with minimum third party d It is based on the generated code from [KaiZen OpenAPI Parser](https://github.com/RepreZen/KaiZen-OpenApi-Parser) without dependency on javaparser-core, guava, commons-cli, commons-io, javax.mail and guice. +### Base path compatibility + +OpenAPI path keys are relative to the first server URL. With server `/v1`, use +path key `/pets` to expose `/v1/pets` (endpoint `/v1/pets@get`). Earlier versions +also stripped the server prefix from specification keys, allowing a redundant +key `/v1/pets` to serve that same URL. That rewriting is removed: a key +`/v1/pets` now describes `/v1/v1/pets` with endpoint `/v1/v1/pets@get`. + +Before upgrading, remove redundant server prefixes from path keys if the service +must keep its current URLs and endpoint identifiers. Review endpoint-based Lambda +mappings, security configuration, metrics and dashboards when intentionally +retaining repeated prefixes. A leading segment equal to the server prefix can +also be intentional, so the parser does not guess which form was intended. +Unprefixed request paths remain supported for compatibility. + +Request-prefix strategies use a Caffeine cache with a maximum size of 64 after +maintenance; concurrent activity can temporarily exceed that size. Literal base +paths use string comparisons, while regex base paths use cached patterns. + +### Jackson 3 migration + +This development line uses Jackson 3.2.3 and the migrated json-overlay API. +Public parser and model constructors accepting `JsonNode` now use +`tools.jackson.databind` types. This is a source and binary incompatible change; +downstream users, including light-rest-4j, light-gateway, http-sidecar and +light-codegen, must migrate together. Project versions remain unchanged during +implementation; a next-major version and release decision is required before +publication. + +YAML follows the Jackson 3 SnakeYAML Engine resolver. The spellings +`yes/no/on/off`, `True/TRUE/False/FALSE`, `Null/NULL`, `012`, `0b11`, `0x1F`, +`1_000` and `~` now produce strings. Use lowercase `true`, `false`, `null` and +ordinary decimal numbers without leading zeros for typed values. For example, +`required: True` and `deprecated: FALSE` yield null Boolean overlay values. +The validator reports type errors for parameter `required` and `deprecated`, +request-body `required`, and schema Boolean fields. Path parameters additionally +require `required: true`. Numeric keywords using noncanonical spellings report +type errors; normalize specifications before upgrading. +Enum and example values also retain these spellings as strings. Duplicate keys +remain last-wins. The parser reads only the first YAML document and ignores +subsequent documents. + +Malformed input is wrapped in `OpenApiParserException`, including Jackson 3's +unchecked `JacksonException`. Empty and comment-only specifications are rejected +with `Spec document is empty`. File I/O error handling remains in place. + ### License The OpenAPI Parser is provided under the Eclipse Public License 1.0 following the parent [KaiZen OpenAPI Parser](https://github.com/RepreZen/KaiZen-OpenApi-Parser) + +### Building the migration before release + +The unchanged `com.networknt:json-overlay:2.4.2-SNAPSHOT` coordinate must resolve +to the Jackson 3 implementation merged in json-overlay PR #28. An older cached +or remotely deployed Jackson 2 snapshot is incompatible. For a clean local +build, use an isolated Maven repository, build/install json-overlay's migrated +master first, then build/install openapi-parser with that same Maven repository. +For consumers of remote snapshots, deploy the migrated json-overlay snapshot +before openapi-parser, then migrate downstream consumers. Neither repository +currently defines a GitHub Actions workflow; the reported results are local +validation, not remote CI. This PR does not deploy either artifact. diff --git a/pom.xml b/pom.xml index f420c4f..88a27ac 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ 4.0.0 com.networknt openapi-parser - 2.3.8-SNAPSHOT + 3.0.0-SNAPSHOT A light-weight, fast OpenAPI 3.0 parser and validator https://github.com/networknt/openapi-parser OpenAPIParser @@ -92,28 +92,37 @@ + 0.12.0 25 ${java.version} ${java.version} UTF-8 - 2.3.8-SNAPSHOT - 2.22.1 - 2.0.17 - 1.5.37 - 5.11.4 + 3.0.0-SNAPSHOT + 3.1.8 + 3.3.0 + 2.0.20 + 1.6.8 + 6.1.3 1.5.0 - 33.4.8-jre + 33.7.1-jre 1.3.2 - 1.0.0 - 3.4.1 + 3.12.0 1.7.0 - 3.2.7 + 3.6.1 + 3.2.8 - com.fasterxml.jackson + org.junit + junit-bom + ${version.junit} + pom + import + + + tools.jackson jackson-bom ${version.jackson} pom @@ -123,17 +132,22 @@ + + com.github.ben-manes.caffeine + caffeine + ${version.caffeine} + com.networknt json-overlay ${version.light-4j} - com.fasterxml.jackson.core + tools.jackson.core jackson-core - com.fasterxml.jackson.core + tools.jackson.core jackson-databind @@ -141,7 +155,7 @@ jackson-annotations - com.fasterxml.jackson.dataformat + tools.jackson.dataformat jackson-dataformat-yaml @@ -158,7 +172,6 @@ org.junit.jupiter junit-jupiter - ${version.junit} test @@ -197,19 +210,6 @@ - - com.networknt - javadoc-packagelist-maven-plugin - ${version.javadoc-packagelist-plugin} - - - package - - gen-package-list - - - - org.apache.maven.plugins maven-source-plugin @@ -248,7 +248,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.5.2 + ${version.maven-surefire} @@ -285,7 +285,7 @@ org.apache.maven.plugins maven-surefire-report-plugin - 3.5.2 + ${version.maven-surefire} @@ -318,7 +318,7 @@ org.sonatype.central central-publishing-maven-plugin - 0.7.0 + ${version.central-publishing-maven} true central diff --git a/src/main/java/com/networknt/oas/OpenApi3Parser.java b/src/main/java/com/networknt/oas/OpenApi3Parser.java index 10d0cd8..26d82a5 100755 --- a/src/main/java/com/networknt/oas/OpenApi3Parser.java +++ b/src/main/java/com/networknt/oas/OpenApi3Parser.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.oas.model.OpenApi3; import java.io.File; diff --git a/src/main/java/com/networknt/oas/OpenApiParser.java b/src/main/java/com/networknt/oas/OpenApiParser.java index 8873c7c..4f06165 100755 --- a/src/main/java/com/networknt/oas/OpenApiParser.java +++ b/src/main/java/com/networknt/oas/OpenApiParser.java @@ -10,7 +10,8 @@ *******************************************************************************/ package com.networknt.oas; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.core.JacksonException; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.JsonLoader; import com.networknt.jsonoverlay.ReferenceManager; import com.networknt.oas.model.OpenApi3; @@ -34,7 +35,7 @@ public OpenApi parse(String spec, URL resolutionBase, boolean validate) { JsonNode tree = loader.loadString(resolutionBase, spec); return parse(tree, resolutionBase, validate, loader); - } catch (IOException e) { + } catch (IOException | JacksonException e) { throw new OpenApiParserException("Failed to parse spec as JSON or YAML", e); } } @@ -81,6 +82,9 @@ public OpenApi parse(JsonNode tree, URL resolutionBase, boolean validate) { } public OpenApi parse(JsonNode tree, URL resolutionBase, boolean validate, JsonLoader loader) { + if (tree == null) { + throw new OpenApiParserException("Spec document is empty"); + } ReferenceManager manager = new ReferenceManager(resolutionBase, tree, loader); return parse(manager, validate); } @@ -89,6 +93,9 @@ private OpenApi parse(ReferenceManager manager, boolean validate) { JsonNode tree; try { tree = manager.loadDoc(); + if (tree == null) { + throw new OpenApiParserException("Spec document is empty"); + } if (isVersion3(tree)) { OpenApi3 model = (OpenApi3) OpenApi3Impl.factory.create(tree, null, manager); ((OpenApi3Impl) model)._setCreatingRef(manager.getDocReference()); @@ -100,14 +107,14 @@ private OpenApi parse(ReferenceManager manager, boolean validate) { throw new OpenApiParserException( "Could not determine OpenApi version from model: no 'openapi' property"); } - } catch (IOException e) { + } catch (IOException | JacksonException e) { throw new OpenApiParserException("Failed to parse model", e); } } protected boolean isVersion3(JsonNode tree) { JsonNode versionNode = tree.path("openapi"); - return versionNode.isTextual() && versionNode.asText().startsWith("3."); + return versionNode.isString() && versionNode.asString().startsWith("3."); } public static class OpenApiParserException extends RuntimeException { diff --git a/src/main/java/com/networknt/oas/model/impl/CallbackImpl.java b/src/main/java/com/networknt/oas/model/impl/CallbackImpl.java index 3e358db..9b0b7ad 100755 --- a/src/main/java/com/networknt/oas/model/impl/CallbackImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/CallbackImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.Callback; import com.networknt.oas.model.OpenApi3; diff --git a/src/main/java/com/networknt/oas/model/impl/ContactImpl.java b/src/main/java/com/networknt/oas/model/impl/ContactImpl.java index a5a32db..8d06dd5 100755 --- a/src/main/java/com/networknt/oas/model/impl/ContactImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/ContactImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.Contact; import com.networknt.oas.model.OpenApi3; diff --git a/src/main/java/com/networknt/oas/model/impl/DiscriminatorImpl.java b/src/main/java/com/networknt/oas/model/impl/DiscriminatorImpl.java index 1dbd2fa..7d7ec00 100644 --- a/src/main/java/com/networknt/oas/model/impl/DiscriminatorImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/DiscriminatorImpl.java @@ -11,7 +11,7 @@ package com.networknt.oas.model.impl; import java.util.Map; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.Builder; import com.networknt.jsonoverlay.IJsonOverlay; import com.networknt.jsonoverlay.JsonOverlay; diff --git a/src/main/java/com/networknt/oas/model/impl/EncodingPropertyImpl.java b/src/main/java/com/networknt/oas/model/impl/EncodingPropertyImpl.java index 332d2bf..06d0f8c 100755 --- a/src/main/java/com/networknt/oas/model/impl/EncodingPropertyImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/EncodingPropertyImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.EncodingProperty; import com.networknt.oas.model.OpenApi3; diff --git a/src/main/java/com/networknt/oas/model/impl/ExampleImpl.java b/src/main/java/com/networknt/oas/model/impl/ExampleImpl.java index b1436b8..e18d30a 100644 --- a/src/main/java/com/networknt/oas/model/impl/ExampleImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/ExampleImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.Example; import com.networknt.oas.model.OpenApi3; diff --git a/src/main/java/com/networknt/oas/model/impl/ExternalDocsImpl.java b/src/main/java/com/networknt/oas/model/impl/ExternalDocsImpl.java index 1969dda..8cf46a5 100755 --- a/src/main/java/com/networknt/oas/model/impl/ExternalDocsImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/ExternalDocsImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.ExternalDocs; import com.networknt.oas.model.OpenApi3; diff --git a/src/main/java/com/networknt/oas/model/impl/HeaderImpl.java b/src/main/java/com/networknt/oas/model/impl/HeaderImpl.java index d668048..6561fa4 100755 --- a/src/main/java/com/networknt/oas/model/impl/HeaderImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/HeaderImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.*; import java.util.Map; diff --git a/src/main/java/com/networknt/oas/model/impl/InfoImpl.java b/src/main/java/com/networknt/oas/model/impl/InfoImpl.java index 22abcc1..8ffc5de 100755 --- a/src/main/java/com/networknt/oas/model/impl/InfoImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/InfoImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.Contact; import com.networknt.oas.model.Info; diff --git a/src/main/java/com/networknt/oas/model/impl/LicenseImpl.java b/src/main/java/com/networknt/oas/model/impl/LicenseImpl.java index 40ece0e..7cb132d 100755 --- a/src/main/java/com/networknt/oas/model/impl/LicenseImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/LicenseImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.License; import com.networknt.oas.model.OpenApi3; diff --git a/src/main/java/com/networknt/oas/model/impl/LinkImpl.java b/src/main/java/com/networknt/oas/model/impl/LinkImpl.java index 0d648a6..d14afbb 100755 --- a/src/main/java/com/networknt/oas/model/impl/LinkImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/LinkImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.Link; import com.networknt.oas.model.OpenApi3; diff --git a/src/main/java/com/networknt/oas/model/impl/MediaTypeImpl.java b/src/main/java/com/networknt/oas/model/impl/MediaTypeImpl.java index 9da4061..4f243ba 100755 --- a/src/main/java/com/networknt/oas/model/impl/MediaTypeImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/MediaTypeImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.*; import java.util.Map; diff --git a/src/main/java/com/networknt/oas/model/impl/OAuthFlowImpl.java b/src/main/java/com/networknt/oas/model/impl/OAuthFlowImpl.java index 947dfa3..dbaad0f 100755 --- a/src/main/java/com/networknt/oas/model/impl/OAuthFlowImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/OAuthFlowImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.OAuthFlow; import com.networknt.oas.model.OpenApi3; diff --git a/src/main/java/com/networknt/oas/model/impl/OpenApi3Impl.java b/src/main/java/com/networknt/oas/model/impl/OpenApi3Impl.java index 9a03fcd..d153fd3 100755 --- a/src/main/java/com/networknt/oas/model/impl/OpenApi3Impl.java +++ b/src/main/java/com/networknt/oas/model/impl/OpenApi3Impl.java @@ -10,8 +10,8 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ObjectNode; +import tools.jackson.databind.JsonNode; +import tools.jackson.databind.node.ObjectNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.*; import com.networknt.oas.validator.ValidationContext; diff --git a/src/main/java/com/networknt/oas/model/impl/OperationImpl.java b/src/main/java/com/networknt/oas/model/impl/OperationImpl.java index 8582ecf..5a56c87 100755 --- a/src/main/java/com/networknt/oas/model/impl/OperationImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/OperationImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.*; import java.util.List; diff --git a/src/main/java/com/networknt/oas/model/impl/ParameterImpl.java b/src/main/java/com/networknt/oas/model/impl/ParameterImpl.java index e089649..8e7d459 100755 --- a/src/main/java/com/networknt/oas/model/impl/ParameterImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/ParameterImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.*; import java.util.Map; diff --git a/src/main/java/com/networknt/oas/model/impl/PathImpl.java b/src/main/java/com/networknt/oas/model/impl/PathImpl.java index 136e0ef..13632a1 100755 --- a/src/main/java/com/networknt/oas/model/impl/PathImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/PathImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.*; import java.util.List; diff --git a/src/main/java/com/networknt/oas/model/impl/RequestBodyImpl.java b/src/main/java/com/networknt/oas/model/impl/RequestBodyImpl.java index a1426dd..8b5953a 100755 --- a/src/main/java/com/networknt/oas/model/impl/RequestBodyImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/RequestBodyImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.MediaType; import com.networknt.oas.model.OpenApi3; diff --git a/src/main/java/com/networknt/oas/model/impl/ResponseImpl.java b/src/main/java/com/networknt/oas/model/impl/ResponseImpl.java index e4d8d3d..89aa879 100755 --- a/src/main/java/com/networknt/oas/model/impl/ResponseImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/ResponseImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.*; import java.util.Map; diff --git a/src/main/java/com/networknt/oas/model/impl/SchemaImpl.java b/src/main/java/com/networknt/oas/model/impl/SchemaImpl.java index 0fd4a1c..0f0ef1b 100755 --- a/src/main/java/com/networknt/oas/model/impl/SchemaImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/SchemaImpl.java @@ -10,8 +10,8 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.core.JsonPointer; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.core.JsonPointer; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.*; import java.util.List; diff --git a/src/main/java/com/networknt/oas/model/impl/SecurityParameterImpl.java b/src/main/java/com/networknt/oas/model/impl/SecurityParameterImpl.java index bb5d8bc..df6efff 100755 --- a/src/main/java/com/networknt/oas/model/impl/SecurityParameterImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/SecurityParameterImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.OpenApi3; import com.networknt.oas.model.SecurityParameter; diff --git a/src/main/java/com/networknt/oas/model/impl/SecurityRequirementImpl.java b/src/main/java/com/networknt/oas/model/impl/SecurityRequirementImpl.java index f8c9edf..b4c7a27 100755 --- a/src/main/java/com/networknt/oas/model/impl/SecurityRequirementImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/SecurityRequirementImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.OpenApi3; import com.networknt.oas.model.SecurityParameter; diff --git a/src/main/java/com/networknt/oas/model/impl/SecuritySchemeImpl.java b/src/main/java/com/networknt/oas/model/impl/SecuritySchemeImpl.java index 81deeb7..9756cb5 100755 --- a/src/main/java/com/networknt/oas/model/impl/SecuritySchemeImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/SecuritySchemeImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.OAuthFlow; import com.networknt.oas.model.OpenApi3; diff --git a/src/main/java/com/networknt/oas/model/impl/ServerImpl.java b/src/main/java/com/networknt/oas/model/impl/ServerImpl.java index e60083f..eec32ac 100755 --- a/src/main/java/com/networknt/oas/model/impl/ServerImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/ServerImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.OpenApi3; import com.networknt.oas.model.Server; diff --git a/src/main/java/com/networknt/oas/model/impl/ServerVariableImpl.java b/src/main/java/com/networknt/oas/model/impl/ServerVariableImpl.java index 1b0b401..a6a01eb 100755 --- a/src/main/java/com/networknt/oas/model/impl/ServerVariableImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/ServerVariableImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.OpenApi3; import com.networknt.oas.model.ServerVariable; diff --git a/src/main/java/com/networknt/oas/model/impl/TagImpl.java b/src/main/java/com/networknt/oas/model/impl/TagImpl.java index ffd110d..fcef998 100755 --- a/src/main/java/com/networknt/oas/model/impl/TagImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/TagImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.ExternalDocs; import com.networknt.oas.model.OpenApi3; diff --git a/src/main/java/com/networknt/oas/model/impl/XmlImpl.java b/src/main/java/com/networknt/oas/model/impl/XmlImpl.java index 5dcc80c..22ffa37 100755 --- a/src/main/java/com/networknt/oas/model/impl/XmlImpl.java +++ b/src/main/java/com/networknt/oas/model/impl/XmlImpl.java @@ -10,7 +10,7 @@ *******************************************************************************/ package com.networknt.oas.model.impl; -import com.fasterxml.jackson.databind.JsonNode; +import tools.jackson.databind.JsonNode; import com.networknt.jsonoverlay.*; import com.networknt.oas.model.OpenApi3; import com.networknt.oas.model.Xml; diff --git a/src/main/java/com/networknt/oas/validator/ValidatorBase.java b/src/main/java/com/networknt/oas/validator/ValidatorBase.java index 8f16af6..ff78ebb 100755 --- a/src/main/java/com/networknt/oas/validator/ValidatorBase.java +++ b/src/main/java/com/networknt/oas/validator/ValidatorBase.java @@ -10,8 +10,8 @@ *******************************************************************************/ package com.networknt.oas.validator; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.*; +import tools.jackson.databind.JsonNode; +import tools.jackson.databind.node.*; import com.networknt.jsonoverlay.*; import java.io.IOException; @@ -180,7 +180,8 @@ public Overlay validateNumericField(String name, boolean required, Funct checkMissing(field, required); if (field != null && field.isPresent() && test != null) { Number n = field.get(); - if (!test.apply(n)) { + // A rejected scalar has no numeric overlay value; the type error is already recorded. + if (n != null && !test.apply(n)) { results.addError(msg(NumberConstraint, desc, n), field); } } @@ -378,7 +379,8 @@ public void checkJsonType(Overlay value, Collection } private String getJsonValueType(Class node) { - String type = node.getSimpleName(); + // Keep validation messages stable across Jackson's TextNode -> StringNode rename. + String type = node == StringNode.class ? "TextNode" : node.getSimpleName(); return type.endsWith("Node") ? type.substring(0, type.length() - 4) : type; } @@ -395,11 +397,11 @@ protected Collection> getAllowedJsonTypes(Overlay v private static void createAllowedJsonTypes() { Map, List>> types = new HashMap<>(); - types.put(StringOverlay.class, Arrays.asList(TextNode.class)); + types.put(StringOverlay.class, Arrays.asList(StringNode.class)); types.put(BooleanOverlay.class, Arrays.asList(BooleanNode.class)); types.put(IntegerOverlay.class, Arrays.asList(IntNode.class, ShortNode.class, BigIntegerNode.class)); types.put(NumberOverlay.class, Arrays.asList(NumericNode.class)); - types.put(PrimitiveOverlay.class, Arrays.asList(TextNode.class, NumericNode.class, BooleanNode.class)); + types.put(PrimitiveOverlay.class, Arrays.asList(StringNode.class, NumericNode.class, BooleanNode.class)); types.put(ObjectOverlay.class, Arrays.asList(JsonNode.class)); types.put(MapOverlay.class, Arrays.asList(ObjectNode.class)); types.put(ListOverlay.class, Arrays.asList(ArrayNode.class)); diff --git a/src/main/java/com/networknt/oas/validator/impl/ParameterValidator.java b/src/main/java/com/networknt/oas/validator/impl/ParameterValidator.java index 50f50aa..291389b 100755 --- a/src/main/java/com/networknt/oas/validator/impl/ParameterValidator.java +++ b/src/main/java/com/networknt/oas/validator/impl/ParameterValidator.java @@ -29,6 +29,7 @@ public void runObjectValidations() { Parameter parameter = (Parameter) value.getOverlay(); validateStringField(F_description, false); validateBooleanField(F_deprecated, false); + validateBooleanField(F_required, false); validateBooleanField(F_allowEmptyValue, false); validateBooleanField(F_explode, false); Overlay example = validateField(F_example, false, Object.class, null); diff --git a/src/main/java/com/networknt/oas/validator/impl/SecurityParameterValidator.java b/src/main/java/com/networknt/oas/validator/impl/SecurityParameterValidator.java index 1f6ef5e..9d3819e 100644 --- a/src/main/java/com/networknt/oas/validator/impl/SecurityParameterValidator.java +++ b/src/main/java/com/networknt/oas/validator/impl/SecurityParameterValidator.java @@ -13,8 +13,8 @@ import java.util.Arrays; import java.util.Collection; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; +import tools.jackson.databind.JsonNode; +import tools.jackson.databind.node.ArrayNode; import com.networknt.jsonoverlay.Overlay; import com.networknt.oas.model.SecurityParameter; import com.networknt.oas.validator.ObjectValidatorBase; diff --git a/src/main/java/com/networknt/openapi/ApiNormalisedPath.java b/src/main/java/com/networknt/openapi/ApiNormalisedPath.java index 886401d..c1c279f 100644 --- a/src/main/java/com/networknt/openapi/ApiNormalisedPath.java +++ b/src/main/java/com/networknt/openapi/ApiNormalisedPath.java @@ -18,8 +18,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.github.benmanes.caffeine.cache.Caffeine; +import com.github.benmanes.caffeine.cache.LoadingCache; import java.util.List; +import java.util.function.Function; +import java.util.regex.Pattern; +import java.util.regex.Matcher; import static java.util.Objects.requireNonNull; @@ -30,7 +35,13 @@ * @author Steve Hu */ public class ApiNormalisedPath implements NormalisedPath { - Logger logger = LoggerFactory.getLogger(ApiNormalisedPath.class); + private static final LoadingCache BASE_PREFIXES = prefixCache(BasePrefix::compile); + private static final Logger logger = LoggerFactory.getLogger(ApiNormalisedPath.class); + + static LoadingCache prefixCache(Function loader) { + return Caffeine.newBuilder().maximumSize(64).build(loader::apply); + } + private final List pathParts; private final String original; private final String normalised; @@ -39,9 +50,9 @@ public class ApiNormalisedPath implements NormalisedPath { * Construct normalized path * @param path original path * @param basePath the path you want to overwrite - * - put null will use the base path parsed from {@link OpenApiHelper} + * - must not be null; use the helper base path explicitly * - put "" empty String will not trigger any overwrites - * - put regex will replace the first basePath with empty String + * - put regex will remove a matching leading base path at a segment boundary */ public ApiNormalisedPath(final String path, final String basePath) { if (logger.isDebugEnabled()) logger.debug("path = {}, base path is set to: {}", path, basePath); @@ -86,14 +97,37 @@ public String normalised() { return normalised; } - // case basePath == null, use OpenApiHelper.basePath - // case basePath != null, remove the basePath private String normalise(String requestPath, String basePath) { - requestPath = requestPath.replaceFirst(basePath, ""); + requireNonNull(basePath, "A base path is required; use an empty string for specification paths"); + if ("/".equals(basePath)) { + // Preserve the historical root behavior, including //pets -> /pets. + if (requestPath.startsWith("/")) requestPath = requestPath.substring(1); + } else if (!basePath.isEmpty()) { + requestPath = BASE_PREFIXES.get(basePath).removeFrom(requestPath); + } + return requestPath.startsWith("/") ? requestPath : "/" + requestPath; + } + + record BasePrefix(String literal, Pattern regex) { + static BasePrefix compile(String basePath) { + String prefix = basePath; + while (prefix.endsWith("/")) { + prefix = prefix.substring(0, prefix.length() - 1); + if (prefix.endsWith("\\")) prefix = prefix.substring(0, prefix.length() - 1); + } + boolean literal = prefix.chars().noneMatch(c -> ".[]{}()*+?^$|\\".indexOf(c) >= 0); + return literal ? new BasePrefix(prefix, null) + : new BasePrefix(null, Pattern.compile("^(?:" + prefix + ")(?=/|\\z)")); + } - if (!requestPath.startsWith("/")) { - return "/" + requestPath; + String removeFrom(String path) { + if (regex == null) { + int end = literal.length(); + return path.startsWith(literal) && (end == path.length() || path.charAt(end) == '/') + ? path.substring(end) : path; + } + Matcher matcher = regex.matcher(path); + return matcher.lookingAt() ? path.substring(matcher.end()) : path; } - return requestPath; } } diff --git a/src/main/java/com/networknt/openapi/OpenApiHelper.java b/src/main/java/com/networknt/openapi/OpenApiHelper.java index 06409c4..a45a81f 100644 --- a/src/main/java/com/networknt/openapi/OpenApiHelper.java +++ b/src/main/java/com/networknt/openapi/OpenApiHelper.java @@ -52,6 +52,7 @@ public class OpenApiHelper { public OpenApi3 openApi3; public List oauth2Names; public String basePath; + private final List apiPaths; public OpenApiHelper(String spec) { try { @@ -65,6 +66,11 @@ public OpenApiHelper(String spec) { } else { oauth2Names = getOAuth2Name(); basePath = getBasePath(); + // OpenAPI path keys are relative to servers, even when their first + // segment happens to equal the server base path. Normalize once. + apiPaths = openApi3.getPaths().keySet().stream() + .map(p -> (NormalisedPath) new ApiNormalisedPath(p, "")) + .toList(); } } @@ -111,9 +117,7 @@ public Object apply(Object o, Object i) { public Optional findMatchingApiPath(final NormalisedPath requestPath) { if(openApi3 != null) { - return openApi3.getPaths().keySet() - .stream() - .map(p -> (NormalisedPath) new ApiNormalisedPath(p, basePath)) + return apiPaths.stream() .filter(p -> pathMatches(requestPath, p)) .findFirst(); } else { diff --git a/src/main/java/module-info.j b/src/main/java/module-info.j index 6b0022c..1ab9469 100644 --- a/src/main/java/module-info.j +++ b/src/main/java/module-info.j @@ -4,9 +4,9 @@ module com.networknt.openapi.parser { requires com.networknt.service; requires com.networknt.json.overlay; requires org.slf4j; - requires com.fasterxml.jackson.core; - requires com.fasterxml.jackson.databind; - requires com.fasterxml.jackson.dataformat.yaml; + requires tools.jackson.core; + requires tools.jackson.databind; + requires tools.jackson.dataformat.yaml; requires java.annotation; requires java.mail; } diff --git a/src/test/java/com/networknt/oas/BigParseTest.java b/src/test/java/com/networknt/oas/BigParseTest.java index 9fe92b6..4977081 100755 --- a/src/test/java/com/networknt/oas/BigParseTest.java +++ b/src/test/java/com/networknt/oas/BigParseTest.java @@ -10,9 +10,9 @@ *******************************************************************************/ package com.networknt.oas; -import com.fasterxml.jackson.core.JsonPointer; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; +import tools.jackson.core.JsonPointer; +import tools.jackson.databind.JsonNode; +import tools.jackson.dataformat.yaml.YAMLMapper; import com.networknt.jsonoverlay.JsonOverlay; import com.networknt.jsonoverlay.Overlay; import com.networknt.oas.model.OpenApi3; diff --git a/src/test/java/com/networknt/oas/ExamplesTest.java b/src/test/java/com/networknt/oas/ExamplesTest.java index 6e8e160..d8be35e 100755 --- a/src/test/java/com/networknt/oas/ExamplesTest.java +++ b/src/test/java/com/networknt/oas/ExamplesTest.java @@ -10,76 +10,21 @@ *******************************************************************************/ package com.networknt.oas; -import com.fasterxml.jackson.databind.JsonNode; -import com.networknt.jsonoverlay.JsonLoader; import com.networknt.oas.model.OpenApi3; import com.networknt.oas.validator.ValidationResults.ValidationItem; -import org.junit.jupiter.api.Assumptions; -import org.junit.jupiter.api.Test; -import com.google.common.collect.Lists; -import com.google.common.collect.Queues; - -import java.io.IOException; -import java.net.URL; -import java.util.Collection; -import java.util.Deque; -import java.util.Iterator; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import static org.junit.jupiter.api.Assertions.assertTrue; public class ExamplesTest { - - private static final String SPEC_REPO = "OAI/OpenAPI-specification"; - private static final String EXAMPLES_BRANCH = "main"; - private static final String EXAMPLES_ROOT = "_archive_/schemas/v3.0/pass"; - - private static Collection findExamples() throws IOException { - Collection examples = Lists.newArrayList(); - Deque dirs = Queues.newArrayDeque(); - String auth = System.getenv("GITHUB_AUTH") != null ? System.getenv("GITHUB_AUTH") + "@" : ""; - String request = String.format("https://%sapi.github.com/repos/%s/contents/%s?ref=%s", auth, SPEC_REPO, - EXAMPLES_ROOT, EXAMPLES_BRANCH); - dirs.add(new URL(request)); - while (!dirs.isEmpty()) { - URL url = dirs.remove(); - JsonNode tree = new JsonLoader().load(url); - for (JsonNode result : iterable(tree.elements())) { - String type = result.get("type").asText(); - String path = result.get("path").asText(); - String resultUrl = result.get("url").asText(); - if (type.equals("dir")) { - dirs.add(new URL(resultUrl)); - } else if (type.equals("file") && (path.endsWith(".yaml") || path.endsWith(".json"))) { - String downloadUrl = result.get("download_url").asText(); - examples.add(new Object[] { new URL(downloadUrl), result.get("name").asText() }); - } - } - } - return examples; - } - - @Test - public void exampleCanBeParsed() throws Exception { - Collection examples = findExamples(); - Assumptions.assumeFalse(examples.isEmpty(), "No examples found (GITHUB_AUTH may not be set)"); - for (Object[] example : examples) { - URL exampleUrl = (URL) example[0]; - if (!exampleUrl.toString().contains("callback-example")) { - OpenApi3 model = (OpenApi3) new OpenApiParser().parse(exampleUrl); - for (ValidationItem item : model.getValidationItems()) { - System.out.println(item); - } - assertTrue(model.isValid(), "Example was not valid: " + exampleUrl); - } + @ParameterizedTest(name = "{0}") + @MethodSource("com.networknt.oas.SpecExamples#load") + public void exampleCanBeParsed(SpecExamples.Example example) throws Exception { + OpenApi3 model = (OpenApi3) new OpenApiParser().parse(example.url()); + for (ValidationItem item : model.getValidationItems()) { + System.out.println(item); } - } - - private static Iterable iterable(final Iterator iterator) { - return new Iterable() { - @Override - public Iterator iterator() { - return iterator; - } - }; + assertTrue(model.isValid(), "Example was not valid: " + example.name()); } } diff --git a/src/test/java/com/networknt/oas/Jackson3MigrationTest.java b/src/test/java/com/networknt/oas/Jackson3MigrationTest.java new file mode 100644 index 0000000..fed54cc --- /dev/null +++ b/src/test/java/com/networknt/oas/Jackson3MigrationTest.java @@ -0,0 +1,141 @@ +package com.networknt.oas; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import tools.jackson.core.JacksonException; + +import com.networknt.oas.OpenApiParser.OpenApiParserException; +import com.networknt.oas.model.OpenApi3; +import com.networknt.oas.validator.ValidationResults.Severity; + +import static org.junit.jupiter.api.Assertions.*; + +class Jackson3MigrationTest { + private static java.net.URL resolutionBase() { + try { + return java.net.URI.create("file:/jackson3-migration.yaml").toURL(); + } catch (java.net.MalformedURLException e) { + throw new AssertionError(e); + } + } + + private static final String HEADER = "openapi: 3.0.3\ninfo: {title: migration, version: '1.0'}\n"; + private static final String PATHS = "paths:\n /items:\n get:\n responses:\n '200': {description: ok}\n"; + + @Test + void preservesYaml12StringEnumsAndNumericLookingExamples() { + String spec = HEADER + PATHS + "components:\n schemas:\n Values:\n type: string\n" + + " enum: [yes, no, on, off, True, TRUE, False, FALSE, Null, NULL, 012, 0b11, 0x1F, 1_000, ~]\n" + + " example: 012\n"; + OpenApi3 model = new OpenApi3Parser().parse(spec, resolutionBase()); + assertEquals(List.of("yes", "no", "on", "off", "True", "TRUE", "False", "FALSE", "Null", "NULL", + "012", "0b11", "0x1F", "1_000", "~"), model.getSchema("Values").getEnums()); + assertEquals("012", model.getSchema("Values").getExample()); + assertTrue(model.isValid(), () -> model.getValidationItems().toString()); + } + + private String parameterSpec(String required, String deprecated) { + return HEADER + "paths:\n /items:\n get:\n parameters:\n" + + " - name: query\n in: query\n required: " + required + + "\n deprecated: " + deprecated + "\n schema: {type: string}\n" + + " responses:\n '200': {description: ok}\n"; + } + + @Test + void reportsNonCanonicalBooleanStringsAsValidationErrors() { + OpenApi3 model = new OpenApi3Parser().parse(parameterSpec("True", "FALSE"), resolutionBase()); + var parameter = model.getPath("/items").getOperation("get").getParameter(0); + assertNull(parameter.getRequired()); + assertNull(parameter.getDeprecated()); + assertFalse(model.isValid()); + // Both parameter Boolean fields must report invalid scalar types. + // Text remains the validation label despite Jackson 3's StringNode name. + assertEquals(2, model.getValidationItems().stream().filter(item -> item.getSeverity() == Severity.ERROR + && item.getMsg().contains("Text") && item.getMsg().contains("Boolean")).count()); + } + + @Test + void acceptsCanonicalBooleanValues() { + OpenApi3 model = new OpenApi3Parser().parse(parameterSpec("true", "false"), resolutionBase()); + var parameter = model.getPath("/items").getOperation("get").getParameter(0); + assertEquals(Boolean.TRUE, parameter.getRequired()); + assertEquals(Boolean.FALSE, parameter.getDeprecated()); + assertTrue(model.isValid(), () -> model.getValidationItems().toString()); + } + + @Test + void wrapsUncheckedParseFailuresForStringEntryPoint() { + var failure = assertThrows(OpenApiParserException.class, + () -> new OpenApiParser().parse("openapi: [unterminated", resolutionBase())); + assertEquals("Failed to parse spec as JSON or YAML", failure.getMessage()); + assertInstanceOf(JacksonException.class, failure.getCause()); + } + + @Test + void wrapsUncheckedParseFailuresForFileAndUrlEntryPoints(@TempDir Path directory) throws Exception { + Path file = directory.resolve("invalid.yaml"); + Files.writeString(file, "openapi: [unterminated"); + var parser = new OpenApiParser(); + assertInstanceOf(JacksonException.class, + assertThrows(OpenApiParserException.class, () -> parser.parse(file.toFile())).getCause()); + assertInstanceOf(JacksonException.class, + assertThrows(OpenApiParserException.class, () -> parser.parse(file.toUri().toURL())).getCause()); + } + + @Test + void rejectsEmptyAndCommentOnlyDocumentsWithoutNullDereferences(@TempDir Path directory) throws Exception { + Path file = directory.resolve("empty.yaml"); + for (String document : new String[]{"", "# comment only\n"}) { + Files.writeString(file, document); + for (OpenApiParser parser : new OpenApiParser[]{new OpenApiParser(), new OpenApi3Parser()}) { + assertEquals("Spec document is empty", assertThrows(OpenApiParserException.class, + () -> parser.parse(document, resolutionBase(), false)).getMessage()); + assertEquals("Spec document is empty", assertThrows(OpenApiParserException.class, + () -> parser.parse(file.toUri().toURL(), false)).getMessage()); + } + } + } + @Test + void rejectsNonCanonicalNumericKeywordsWithoutCrashing() { + for (String keyword : List.of("maxLength", "minLength", "minItems", "maxItems", + "minProperties", "maxProperties", "minimum", "maximum", "multipleOf")) { + for (String scalar : List.of("012", "0x10", "1_0")) { + String spec = HEADER + PATHS + "components:\n schemas:\n Value:\n " + + keyword + ": " + scalar + "\n"; + OpenApi3 model = assertDoesNotThrow(() -> new OpenApi3Parser().parse(spec, resolutionBase()), + keyword + ": " + scalar); + assertFalse(model.isValid(), keyword + ": " + scalar); + assertTrue(model.getValidationItems().stream().anyMatch(item -> + item.getSeverity() == Severity.ERROR && item.getMsg().contains("Text")), + () -> model.getValidationItems().toString()); + } + } + } + + @Test + void validatesRequiredTypeForQueryAndHeaderParameters() { + for (String location : List.of("query", "header")) { + for (String scalar : List.of("True", "yes")) { + OpenApi3 model = new OpenApi3Parser().parse( + parameterSpec(scalar, "false").replace("in: query", "in: " + location), resolutionBase()); + assertFalse(model.isValid(), location + ": " + scalar); + assertEquals(1, model.getValidationItems().stream() + .filter(item -> item.getSeverity() == Severity.ERROR).count()); + } + } + } + + @Test + void readsOnlyTheFirstYamlDocument() { + OpenApi3 model = new OpenApi3Parser().parse(HEADER + PATHS + + "---\nopenapi: 2.0\ninfo: {title: ignored}\n", resolutionBase()); + assertEquals("migration", model.getInfo().getTitle()); + assertTrue(model.isValid()); + } + +} diff --git a/src/test/java/com/networknt/oas/JsonTreeWalker.java b/src/test/java/com/networknt/oas/JsonTreeWalker.java index 4a0d9fa..ff190f8 100755 --- a/src/test/java/com/networknt/oas/JsonTreeWalker.java +++ b/src/test/java/com/networknt/oas/JsonTreeWalker.java @@ -10,10 +10,10 @@ *******************************************************************************/ package com.networknt.oas; -import com.fasterxml.jackson.core.JsonPointer; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.ObjectNode; +import tools.jackson.core.JsonPointer; +import tools.jackson.databind.JsonNode; +import tools.jackson.databind.node.ArrayNode; +import tools.jackson.databind.node.ObjectNode; import com.google.common.base.Predicates; import java.util.Iterator; @@ -50,7 +50,7 @@ private void visit(JsonNode node, JsonPointer path) { private void walkChildren(JsonNode node, JsonPointer path) { if (node instanceof ObjectNode) { - for (Entry field : iterable(node.fields())) { + for (Entry field : iterable(node.properties().iterator())) { walk(field.getValue(), childPointer(path, field.getKey())); } } else if (node instanceof ArrayNode) { diff --git a/src/test/java/com/networknt/oas/SimpleSerializationTest.java b/src/test/java/com/networknt/oas/SimpleSerializationTest.java index 1844da6..f1370a8 100644 --- a/src/test/java/com/networknt/oas/SimpleSerializationTest.java +++ b/src/test/java/com/networknt/oas/SimpleSerializationTest.java @@ -10,82 +10,43 @@ *******************************************************************************/ package com.networknt.oas; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; -import com.google.common.collect.Lists; -import com.google.common.collect.Queues; -import com.networknt.jsonoverlay.JsonLoader; +import tools.jackson.databind.JsonNode; +import tools.jackson.databind.ObjectMapper; +import tools.jackson.dataformat.yaml.YAMLMapper; import com.networknt.jsonoverlay.Overlay; import com.networknt.jsonoverlay.SerializationOptions.Option; import com.networknt.oas.model.OpenApi3; import com.networknt.oas.model.Schema; import com.networknt.oas.model.impl.OpenApi3Impl; -import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; -import java.io.IOException; import java.net.URL; -import java.util.Collection; -import java.util.Deque; -import java.util.Iterator; import static org.junit.jupiter.api.Assertions.assertEquals; public class SimpleSerializationTest { - - private static final String SPEC_REPO = "OAI/OpenAPI-Specification"; - private static final String EXAMPLES_BRANCH = "main"; - private static final String EXAMPLES_ROOT = "_archive_/schemas/v3.0/pass"; - private static ObjectMapper mapper = new ObjectMapper(); private static ObjectMapper yamlMapper = new YAMLMapper(); @Nested public class ParameterizedTests { - private static Collection findExamples() throws IOException { - Collection examples = Lists.newArrayList(); - Deque dirs = Queues.newArrayDeque(); - String auth = System.getenv("GITHUB_AUTH") != null ? System.getenv("GITHUB_AUTH") + "@" : ""; - String request = String.format("https://%sapi.github.com/repos/%s/contents/%s?ref=%s", auth, SPEC_REPO, - EXAMPLES_ROOT, EXAMPLES_BRANCH); - dirs.add(new URL(request)); - while (!dirs.isEmpty()) { - URL url = dirs.remove(); - JsonNode tree = new JsonLoader().load(url); - for (JsonNode result : iterable(tree.elements())) { - String type = result.get("type").asText(); - String path = result.get("path").asText(); - String resultUrl = result.get("url").asText(); - if (type.equals("dir")) { - dirs.add(new URL(resultUrl)); - } else if (type.equals("file") && (path.endsWith(".yaml") || path.endsWith(".json"))) { - String downloadUrl = result.get("download_url").asText(); - examples.add(new Object[] { new URL(downloadUrl), result.get("name").asText() }); - } - } - } - return examples; - } - - @Test - public void serializeExamples() throws Exception { - Collection examples = findExamples(); - Assumptions.assumeFalse(examples.isEmpty(), "No examples found (GITHUB_AUTH may not be set)"); - for (Object[] example : examples) { - URL exampleUrl = (URL) example[0]; - if (!exampleUrl.toString().contains("callback-example")) { - OpenApi3 model = (OpenApi3) new OpenApiParser().parse(exampleUrl); - JsonNode serialized = Overlay.toJson((OpenApi3Impl) model); - JsonNode expected = yamlMapper.readTree(exampleUrl); - JSONAssert.assertEquals(mapper.writeValueAsString(expected), mapper.writeValueAsString(serialized), - JSONCompareMode.STRICT); - } + @ParameterizedTest(name = "{0}") + @MethodSource("com.networknt.oas.SpecExamples#serializable") + public void serializeExamples(SpecExamples.Example example) throws Exception { + OpenApi3 model = (OpenApi3) new OpenApiParser().parse(example.url()); + JsonNode serialized = Overlay.toJson((OpenApi3Impl) model); + JsonNode expected; + try (var input = example.url().openStream()) { + expected = yamlMapper.readTree(input); } + JSONAssert.assertEquals(mapper.writeValueAsString(expected), mapper.writeValueAsString(serialized), + JSONCompareMode.STRICT); } } @@ -119,12 +80,4 @@ private static OpenApi3 parseLocalModel(String name) throws Exception { return (OpenApi3) new OpenApiParser().parse(url); } - private static Iterable iterable(final Iterator iterator) { - return new Iterable() { - @Override - public Iterator iterator() { - return iterator; - } - }; - } } diff --git a/src/test/java/com/networknt/oas/SpecExamples.java b/src/test/java/com/networknt/oas/SpecExamples.java new file mode 100644 index 0000000..9d2745c --- /dev/null +++ b/src/test/java/com/networknt/oas/SpecExamples.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2017 ModelSolv, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * ModelSolv, Inc. - initial API and implementation and/or initial documentation + *******************************************************************************/ +package com.networknt.oas; + +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +/** Pinned upstream examples shared by parsing and serialization tests. */ +final class SpecExamples { + private SpecExamples() { } + + record Example(String name, URL url) { + @Override + public String toString() { + return name; + } + } + + static Stream load() throws IOException { + var examples = new ArrayList(); + for (String name : List.of("api-with-examples.yaml", "callback-example.yaml", + "link-example.yaml", "petstore-expanded.yaml", "petstore.yaml", "uspto.yaml")) { + URL resource = SpecExamples.class.getResource("/oai-examples/" + name); + if (resource == null) { + throw new IOException("Missing bundled OpenAPI example: " + name); + } + examples.add(new Example(name, resource)); + } + return examples.stream(); + } + static Stream serializable() throws IOException { + // The callback fixture parses successfully, but its final block scalar's + // trailing newline differs between JsonLoader and YAMLMapper. Keep it in + // parsing coverage until that existing round-trip discrepancy is fixed. + return load().filter(example -> !example.name().equals("callback-example.yaml")); + } + +} diff --git a/src/test/java/com/networknt/openapi/ApiNormalisedPathBoundaryTest.java b/src/test/java/com/networknt/openapi/ApiNormalisedPathBoundaryTest.java new file mode 100644 index 0000000..c461c2b --- /dev/null +++ b/src/test/java/com/networknt/openapi/ApiNormalisedPathBoundaryTest.java @@ -0,0 +1,95 @@ +package com.networknt.openapi; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class ApiNormalisedPathBoundaryTest { + @Test + void removesOnlyLeadingCompleteSegments() { + assertEquals("/pets", new ApiNormalisedPath("/v1/pets", "/v1").normalised()); + assertEquals("/", new ApiNormalisedPath("/v1", "/v1").normalised()); + assertEquals("/pets/v1", new ApiNormalisedPath("/pets/v1", "/v1").normalised()); + assertEquals("/v10/pets", new ApiNormalisedPath("/v10/pets", "/v1").normalised()); + assertEquals("/pets", new ApiNormalisedPath("/pets", "/v1").normalised()); + assertEquals("/pets", new ApiNormalisedPath("/v1/pets", "/v1/").normalised()); + assertEquals("/pets", new ApiNormalisedPath("/v1/pets", "\\/v1\\/").normalised()); + } + + @Test + void aFinalLineTerminatorIsNotASegmentBoundary() { + for (String end : new String[]{"\n", "\r", "\r\n", "\u0085", "\u2028", "\u2029"}) { + assertEquals("/v1" + end, new ApiNormalisedPath("/v1" + end, "/v1").normalised()); + assertEquals("/v1" + end, new ApiNormalisedPath("/v1" + end, "/v[0-9]+").normalised()); + } + } + + @Test + void pathKeysThatEmbedTheServerPrefixAreStillRelativeToThatServer() { + OpenApiHelper helper = new OpenApiHelper(""" + {"openapi":"3.0.0","info":{"title":"test","version":"1"}, + "servers":[{"url":"/v1"}],"paths":{ + "/v1/pets":{"get":{"responses":{"200":{"description":"OK"}}}} + }} + """); + assertTrue(helper.findMatchingApiPath(new ApiNormalisedPath("/v1/pets", helper.basePath)).isEmpty()); + NormalisedPath operation = helper.findMatchingApiPath( + new ApiNormalisedPath("/v1/v1/pets", helper.basePath)).orElseThrow(); + assertEquals("/v1/pets", operation.original()); + assertEquals("/v1/v1/pets@get", helper.basePath + operation.normalised() + "@get"); + } + + @Test + void preservesRegexBasePathsAndChecksTheirBoundary() { + assertEquals("/pets", new ApiNormalisedPath("/v12/pets", "/v[0-9]+").normalised()); + assertEquals("/v12suffix/pets", new ApiNormalisedPath("/v12suffix/pets", "/v[0-9]+").normalised()); + assertEquals("/pets/v12", new ApiNormalisedPath("/pets/v12", "/v[0-9]+").normalised()); + assertEquals("/pets", new ApiNormalisedPath("/v2/pets", "/v1|/v2").normalised()); + } + + @Test + void rootAndEmptyBasePathsPreservePaths() { + for (String base : new String[]{"", "/"}) { + assertEquals("/pets", new ApiNormalisedPath("/pets", base).normalised()); + assertEquals("/", new ApiNormalisedPath("/", base).normalised()); + } + } + + @Test + void preservesRootDoubleSlashCompatibilityAndRejectsNullBaseExplicitly() { + assertEquals("/pets", new ApiNormalisedPath("//pets", "/").normalised()); + assertThrows(NullPointerException.class, () -> new ApiNormalisedPath("/pets", null)); + } + + @Test + void specificationPathsAreNeverStrippedEvenWhenTheyStartWithTheBase() { + OpenApiHelper helper = new OpenApiHelper(""" + {"openapi":"3.0.0","info":{"title":"test","version":"1"}, + "servers":[{"url":"/pets"}],"paths":{ + "/pets":{"get":{"responses":{"200":{"description":"OK"}}}}, + "/pets/{petId}":{"get":{"responses":{"200":{"description":"OK"}}}} + }} + """); + assertEquals("/pets/{petId}", helper.findMatchingApiPath( + new ApiNormalisedPath("/pets/pets/42", helper.basePath)).orElseThrow().normalised()); + assertEquals("/pets", helper.findMatchingApiPath( + new ApiNormalisedPath("/pets/pets", helper.basePath)).orElseThrow().normalised()); + assertTrue(helper.findMatchingApiPath(new ApiNormalisedPath("/pets/42", helper.basePath)).isEmpty()); + } + + @Test + void doesNotCollapseAnOperationOrParameterContainingTheBasePath() { + OpenApiHelper helper = new OpenApiHelper(""" + {"openapi":"3.0.0","info":{"title":"test","version":"1"}, + "servers":[{"url":"/v1"}],"paths":{ + "/pets":{"get":{"responses":{"200":{"description":"OK"}}}}, + "/pets/{petId}":{"get":{"responses":{"200":{"description":"OK"}}}}, + "/reports/v1":{"get":{"responses":{"200":{"description":"OK"}}}} + }} + """); + assertEquals("/pets/{petId}", helper.findMatchingApiPath( + new ApiNormalisedPath("/pets/v1", helper.basePath)).orElseThrow().original()); + assertEquals("/reports/v1", helper.findMatchingApiPath( + new ApiNormalisedPath("/v1/reports/v1", helper.basePath)).orElseThrow().normalised()); + } +} diff --git a/src/test/java/com/networknt/openapi/ApiNormalisedPathConcurrencyTest.java b/src/test/java/com/networknt/openapi/ApiNormalisedPathConcurrencyTest.java new file mode 100644 index 0000000..ffb34c1 --- /dev/null +++ b/src/test/java/com/networknt/openapi/ApiNormalisedPathConcurrencyTest.java @@ -0,0 +1,107 @@ +package com.networknt.openapi; + +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +import static org.junit.jupiter.api.Assertions.*; + +class ApiNormalisedPathConcurrencyTest { + @Test + void slowLoadsDoNotBlockCachedPrefixesOrUnrelatedLoads() throws Exception { + CountDownLatch loading = new CountDownLatch(1); + CountDownLatch release = new CountDownLatch(1); + var cache = ApiNormalisedPath.prefixCache(base -> { + if (base.equals("/slow")) { + loading.countDown(); + try { + if (!release.await(10, TimeUnit.SECONDS)) throw new AssertionError("loader timed out"); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new AssertionError(e); + } + } + return ApiNormalisedPath.BasePrefix.compile(base); + }); + cache.get("/hot"); + try (var executor = Executors.newFixedThreadPool(3)) { + Future slow = executor.submit(() -> cache.get("/slow")); + try { + assertTrue(loading.await(5, TimeUnit.SECONDS)); + assertEquals("/pets", executor.submit(() -> cache.get("/hot").removeFrom("/hot/pets")) + .get(5, TimeUnit.SECONDS)); + assertEquals("/pets", executor.submit(() -> cache.get("/other").removeFrom("/other/pets")) + .get(5, TimeUnit.SECONDS)); + } finally { + release.countDown(); + } + slow.get(5, TimeUnit.SECONDS); + } + } + + @Test + void frequentlyUsedRegexPrefixesSurviveOneOffChurn() { + AtomicInteger hotLoads = new AtomicInteger(); + var cache = ApiNormalisedPath.prefixCache(base -> { + if (base.startsWith("/hot-")) hotLoads.incrementAndGet(); + return ApiNormalisedPath.BasePrefix.compile(base); + }); + for (int round = 0; round < 20; round++) { + for (int i = 0; i < 63; i++) cache.get("/hot-" + i + "(?:)"); + cache.cleanUp(); + } + int before = hotLoads.get(); + int hotRequests = 0; + for (int i = 0; i < 20000; i++) { + if (i % 10 == 0) { + cache.get("/one-off-" + i + "(?:)"); + } else { + int key = i % 63; + String base = "/hot-" + key; + assertEquals("/pets", cache.get(base + "(?:)").removeFrom(base + "/pets")); + hotRequests++; + } + cache.cleanUp(); + } + int reloads = hotLoads.get() - before; + assertTrue(reloads < hotRequests / 10, "hot prefix reloads: " + reloads + "/" + hotRequests); + cache.cleanUp(); + assertTrue(cache.estimatedSize() <= 64); + } + + @Test + void concurrentMissesAndEvictionsKeepResultsCorrectAndCacheBounded() throws Exception { + var cache = ApiNormalisedPath.prefixCache(ApiNormalisedPath.BasePrefix::compile); + CountDownLatch ready = new CountDownLatch(8); + CountDownLatch start = new CountDownLatch(1); + try (var executor = Executors.newFixedThreadPool(8)) { + var results = new ArrayList>(); + for (int worker = 0; worker < 8; worker++) { + int offset = worker; + results.add(executor.submit(() -> { + ready.countDown(); + assertTrue(start.await(5, TimeUnit.SECONDS)); + for (int i = 0; i < 256; i++) { + String base = "/concurrent-" + ((i + offset) % 128); + var prefix = cache.get(base); + assertEquals("/pets", prefix.removeFrom(base + "/pets")); + assertEquals(base + "suffix/pets", prefix.removeFrom(base + "suffix/pets")); + } + return null; + })); + } + assertTrue(ready.await(5, TimeUnit.SECONDS)); + start.countDown(); + for (Future result : results) result.get(20, TimeUnit.SECONDS); + } finally { + start.countDown(); + } + cache.cleanUp(); + assertTrue(cache.estimatedSize() <= 64); + } +} diff --git a/src/test/resources/oai-examples/LICENSE b/src/test/resources/oai-examples/LICENSE new file mode 100644 index 0000000..23b34fd --- /dev/null +++ b/src/test/resources/oai-examples/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright The Linux Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/src/test/resources/oai-examples/README.txt b/src/test/resources/oai-examples/README.txt new file mode 100644 index 0000000..89e68c4 --- /dev/null +++ b/src/test/resources/oai-examples/README.txt @@ -0,0 +1,6 @@ +OpenAPI Initiative examples, copied without modification from +https://github.com/OAI/OpenAPI-Specification/tree/4f86429f134f7e48b6351563549b4502fc69de52/_archive_/schemas/v3.0/pass + +Copyright The Linux Foundation. Licensed under Apache-2.0; see LICENSE. +These fixtures keep parser and serialization tests independent of GitHub API +rate limits, network availability, and changes to the upstream main branch. diff --git a/src/test/resources/oai-examples/api-with-examples.yaml b/src/test/resources/oai-examples/api-with-examples.yaml new file mode 100644 index 0000000..18726a5 --- /dev/null +++ b/src/test/resources/oai-examples/api-with-examples.yaml @@ -0,0 +1,170 @@ +openapi: "3.0.0" +info: + title: Simple API overview + version: 2.0.0 +paths: + /: + get: + operationId: listVersionsv2 + summary: List API versions + responses: + '200': + description: |- + 200 response + content: + application/json: + examples: + foo: + value: + { + "versions": [ + { + "status": "CURRENT", + "updated": "2011-01-21T11:33:21Z", + "id": "v2.0", + "links": [ + { + "href": "http://127.0.0.1:8774/v2/", + "rel": "self" + } + ] + }, + { + "status": "EXPERIMENTAL", + "updated": "2013-07-23T11:33:21Z", + "id": "v3.0", + "links": [ + { + "href": "http://127.0.0.1:8774/v3/", + "rel": "self" + } + ] + } + ] + } + '300': + description: |- + 300 response + content: + application/json: + examples: + foo: + value: | + { + "versions": [ + { + "status": "CURRENT", + "updated": "2011-01-21T11:33:21Z", + "id": "v2.0", + "links": [ + { + "href": "http://127.0.0.1:8774/v2/", + "rel": "self" + } + ] + }, + { + "status": "EXPERIMENTAL", + "updated": "2013-07-23T11:33:21Z", + "id": "v3.0", + "links": [ + { + "href": "http://127.0.0.1:8774/v3/", + "rel": "self" + } + ] + } + ] + } + /v2: + get: + operationId: getVersionDetailsv2 + summary: Show API version details + responses: + '200': + description: |- + 200 response + content: + application/json: + examples: + foo: + value: + { + "version": { + "status": "CURRENT", + "updated": "2011-01-21T11:33:21Z", + "media-types": [ + { + "base": "application/xml", + "type": "application/vnd.openstack.compute+xml;version=2" + }, + { + "base": "application/json", + "type": "application/vnd.openstack.compute+json;version=2" + } + ], + "id": "v2.0", + "links": [ + { + "href": "http://127.0.0.1:8774/v2/", + "rel": "self" + }, + { + "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf", + "type": "application/pdf", + "rel": "describedby" + }, + { + "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl", + "type": "application/vnd.sun.wadl+xml", + "rel": "describedby" + }, + { + "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl", + "type": "application/vnd.sun.wadl+xml", + "rel": "describedby" + } + ] + } + } + '203': + description: |- + 203 response + content: + application/json: + examples: + foo: + value: + { + "version": { + "status": "CURRENT", + "updated": "2011-01-21T11:33:21Z", + "media-types": [ + { + "base": "application/xml", + "type": "application/vnd.openstack.compute+xml;version=2" + }, + { + "base": "application/json", + "type": "application/vnd.openstack.compute+json;version=2" + } + ], + "id": "v2.0", + "links": [ + { + "href": "http://23.253.228.211:8774/v2/", + "rel": "self" + }, + { + "href": "http://docs.openstack.org/api/openstack-compute/2/os-compute-devguide-2.pdf", + "type": "application/pdf", + "rel": "describedby" + }, + { + "href": "http://docs.openstack.org/api/openstack-compute/2/wadl/os-compute-2.wadl", + "type": "application/vnd.sun.wadl+xml", + "rel": "describedby" + } + ] + } + } diff --git a/src/test/resources/oai-examples/callback-example.yaml b/src/test/resources/oai-examples/callback-example.yaml new file mode 100644 index 0000000..262b8df --- /dev/null +++ b/src/test/resources/oai-examples/callback-example.yaml @@ -0,0 +1,61 @@ +openapi: 3.0.0 +info: + title: Callback Example + version: 1.0.0 +paths: + /streams: + post: + description: subscribes a client to receive out-of-band data + parameters: + - name: callbackUrl + in: query + required: true + description: | + the location where data will be sent. Must be network accessible + by the source server + schema: + type: string + format: uri + example: https://tonys-server.com + responses: + '201': + description: subscription successfully created + content: + application/json: + schema: + description: subscription information + required: + - subscriptionId + properties: + subscriptionId: + description: this unique identifier allows management of the subscription + type: string + example: 2531329f-fb09-4ef7-887e-84e648214436 + callbacks: + # the name `onData` is a convenience locator + onData: + # when data is sent, it will be sent to the `callbackUrl` provided + # when making the subscription PLUS the suffix `/data` + '{$request.query.callbackUrl}/data': + post: + requestBody: + description: subscription payload + content: + application/json: + schema: + type: object + properties: + timestamp: + type: string + format: date-time + userData: + type: string + responses: + '202': + description: | + Your server implementation should return this HTTP status code + if the data was received successfully + '204': + description: | + Your server should return this HTTP status code if no longer interested + in further updates diff --git a/src/test/resources/oai-examples/link-example.yaml b/src/test/resources/oai-examples/link-example.yaml new file mode 100644 index 0000000..5837d70 --- /dev/null +++ b/src/test/resources/oai-examples/link-example.yaml @@ -0,0 +1,203 @@ +openapi: 3.0.0 +info: + title: Link Example + version: 1.0.0 +paths: + /2.0/users/{username}: + get: + operationId: getUserByName + parameters: + - name: username + in: path + required: true + schema: + type: string + responses: + '200': + description: The User + content: + application/json: + schema: + $ref: '#/components/schemas/user' + links: + userRepositories: + $ref: '#/components/links/UserRepositories' + /2.0/repositories/{username}: + get: + operationId: getRepositoriesByOwner + parameters: + - name: username + in: path + required: true + schema: + type: string + responses: + '200': + description: repositories owned by the supplied user + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/repository' + links: + userRepository: + $ref: '#/components/links/UserRepository' + /2.0/repositories/{username}/{slug}: + get: + operationId: getRepository + parameters: + - name: username + in: path + required: true + schema: + type: string + - name: slug + in: path + required: true + schema: + type: string + responses: + '200': + description: The repository + content: + application/json: + schema: + $ref: '#/components/schemas/repository' + links: + repositoryPullRequests: + $ref: '#/components/links/RepositoryPullRequests' + /2.0/repositories/{username}/{slug}/pullrequests: + get: + operationId: getPullRequestsByRepository + parameters: + - name: username + in: path + required: true + schema: + type: string + - name: slug + in: path + required: true + schema: + type: string + - name: state + in: query + schema: + type: string + enum: + - open + - merged + - declined + responses: + '200': + description: an array of pull request objects + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/pullrequest' + /2.0/repositories/{username}/{slug}/pullrequests/{pid}: + get: + operationId: getPullRequestsById + parameters: + - name: username + in: path + required: true + schema: + type: string + - name: slug + in: path + required: true + schema: + type: string + - name: pid + in: path + required: true + schema: + type: string + responses: + '200': + description: a pull request object + content: + application/json: + schema: + $ref: '#/components/schemas/pullrequest' + links: + pullRequestMerge: + $ref: '#/components/links/PullRequestMerge' + /2.0/repositories/{username}/{slug}/pullrequests/{pid}/merge: + post: + operationId: mergePullRequest + parameters: + - name: username + in: path + required: true + schema: + type: string + - name: slug + in: path + required: true + schema: + type: string + - name: pid + in: path + required: true + schema: + type: string + responses: + '204': + description: the PR was successfully merged +components: + links: + UserRepositories: + # returns array of '#/components/schemas/repository' + operationId: getRepositoriesByOwner + parameters: + username: $response.body#/username + UserRepository: + # returns '#/components/schemas/repository' + operationId: getRepository + parameters: + username: $response.body#/owner/username + slug: $response.body#/slug + RepositoryPullRequests: + # returns '#/components/schemas/pullrequest' + operationId: getPullRequestsByRepository + parameters: + username: $response.body#/owner/username + slug: $response.body#/slug + PullRequestMerge: + # executes /2.0/repositories/{username}/{slug}/pullrequests/{pid}/merge + operationId: mergePullRequest + parameters: + username: $response.body#/author/username + slug: $response.body#/repository/slug + pid: $response.body#/id + schemas: + user: + type: object + properties: + username: + type: string + uuid: + type: string + repository: + type: object + properties: + slug: + type: string + owner: + $ref: '#/components/schemas/user' + pullrequest: + type: object + properties: + id: + type: integer + title: + type: string + repository: + $ref: '#/components/schemas/repository' + author: + $ref: '#/components/schemas/user' diff --git a/src/test/resources/oai-examples/petstore-expanded.yaml b/src/test/resources/oai-examples/petstore-expanded.yaml new file mode 100644 index 0000000..7e5bff0 --- /dev/null +++ b/src/test/resources/oai-examples/petstore-expanded.yaml @@ -0,0 +1,158 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore + description: A sample API that uses a petstore as an example to demonstrate features in the OpenAPI 3.0 specification + termsOfService: http://swagger.io/terms/ + contact: + name: Swagger API Team + email: apiteam@swagger.io + url: http://swagger.io + license: + name: Apache 2.0 + url: https://www.apache.org/licenses/LICENSE-2.0.html +servers: + - url: https://petstore.swagger.io/v2 +paths: + /pets: + get: + description: | + Returns all pets from the system that the user has access to + Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia. + + Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien. + operationId: findPets + parameters: + - name: tags + in: query + description: tags to filter by + required: false + style: form + schema: + type: array + items: + type: string + - name: limit + in: query + description: maximum number of results to return + required: false + schema: + type: integer + format: int32 + responses: + '200': + description: pet response + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/Pet' + default: + description: unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + post: + description: Creates a new pet in the store. Duplicates are allowed + operationId: addPet + requestBody: + description: Pet to add to the store + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/NewPet' + responses: + '200': + description: pet response + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + default: + description: unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + /pets/{id}: + get: + description: Returns a user based on a single ID, if the user does not have access to the pet + operationId: find pet by id + parameters: + - name: id + in: path + description: ID of pet to fetch + required: true + schema: + type: integer + format: int64 + responses: + '200': + description: pet response + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + default: + description: unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + delete: + description: deletes a single pet based on the ID supplied + operationId: deletePet + parameters: + - name: id + in: path + description: ID of pet to delete + required: true + schema: + type: integer + format: int64 + responses: + '204': + description: pet deleted + default: + description: unexpected error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' +components: + schemas: + Pet: + allOf: + - $ref: '#/components/schemas/NewPet' + - type: object + required: + - id + properties: + id: + type: integer + format: int64 + + NewPet: + type: object + required: + - name + properties: + name: + type: string + tag: + type: string + + Error: + type: object + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string diff --git a/src/test/resources/oai-examples/petstore.yaml b/src/test/resources/oai-examples/petstore.yaml new file mode 100644 index 0000000..7ed987f --- /dev/null +++ b/src/test/resources/oai-examples/petstore.yaml @@ -0,0 +1,119 @@ +openapi: "3.0.0" +info: + version: 1.0.0 + title: Swagger Petstore + license: + name: MIT +servers: + - url: http://petstore.swagger.io/v1 +paths: + /pets: + get: + summary: List all pets + operationId: listPets + tags: + - pets + parameters: + - name: limit + in: query + description: How many items to return at one time (max 100) + required: false + schema: + type: integer + maximum: 100 + format: int32 + responses: + '200': + description: A paged array of pets + headers: + x-next: + description: A link to the next page of responses + schema: + type: string + content: + application/json: + schema: + $ref: "#/components/schemas/Pets" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: Create a pet + operationId: createPets + tags: + - pets + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + required: true + responses: + '201': + description: Null response + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /pets/{petId}: + get: + summary: Info for a specific pet + operationId: showPetById + tags: + - pets + parameters: + - name: petId + in: path + required: true + description: The id of the pet to retrieve + schema: + type: string + responses: + '200': + description: Expected response to a valid request + content: + application/json: + schema: + $ref: "#/components/schemas/Pet" + default: + description: unexpected error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" +components: + schemas: + Pet: + type: object + required: + - id + - name + properties: + id: + type: integer + format: int64 + name: + type: string + tag: + type: string + Pets: + type: array + maxItems: 100 + items: + $ref: "#/components/schemas/Pet" + Error: + type: object + required: + - code + - message + properties: + code: + type: integer + format: int32 + message: + type: string diff --git a/src/test/resources/oai-examples/uspto.yaml b/src/test/resources/oai-examples/uspto.yaml new file mode 100644 index 0000000..d301152 --- /dev/null +++ b/src/test/resources/oai-examples/uspto.yaml @@ -0,0 +1,210 @@ +openapi: 3.0.1 +servers: + - url: '{scheme}://developer.uspto.gov/ds-api' + variables: + scheme: + description: 'The Data Set API is accessible via https and http' + enum: + - 'https' + - 'http' + default: 'https' +info: + description: >- + The Data Set API (DSAPI) allows the public users to discover and search + USPTO exported data sets. This is a generic API that allows USPTO users to + make any CSV based data files searchable through API. With the help of GET + call, it returns the list of data fields that are searchable. With the help + of POST call, data can be fetched based on the filters on the field names. + Please note that POST call is used to search the actual data. The reason for + the POST call is that it allows users to specify any complex search criteria + without worry about the GET size limitations as well as encoding of the + input parameters. + version: 1.0.0 + title: USPTO Data Set API + contact: + name: Open Data Portal + url: 'https://developer.uspto.gov' + email: developer@uspto.gov +tags: + - name: metadata + description: Find out about the data sets + - name: search + description: Search a data set +paths: + /: + get: + tags: + - metadata + operationId: list-data-sets + summary: List available data sets + responses: + '200': + description: Returns a list of data sets + content: + application/json: + schema: + $ref: '#/components/schemas/dataSetList' + example: + { + "total": 2, + "apis": [ + { + "apiKey": "oa_citations", + "apiVersionNumber": "v1", + "apiUrl": "https://developer.uspto.gov/ds-api/oa_citations/v1/fields", + "apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/oa_citations.json" + }, + { + "apiKey": "cancer_moonshot", + "apiVersionNumber": "v1", + "apiUrl": "https://developer.uspto.gov/ds-api/cancer_moonshot/v1/fields", + "apiDocumentationUrl": "https://developer.uspto.gov/ds-api-docs/index.html?url=https://developer.uspto.gov/ds-api/swagger/docs/cancer_moonshot.json" + } + ] + } + /{dataset}/{version}/fields: + get: + tags: + - metadata + summary: >- + Provides the general information about the API and the list of fields + that can be used to query the dataset. + description: >- + This GET API returns the list of all the searchable field names that are + in the oa_citations. Please see the 'fields' attribute which returns an + array of field names. Each field or a combination of fields can be + searched using the syntax options shown below. + operationId: list-searchable-fields + parameters: + - name: dataset + in: path + description: 'Name of the dataset.' + required: true + example: "oa_citations" + schema: + type: string + - name: version + in: path + description: Version of the dataset. + required: true + example: "v1" + schema: + type: string + responses: + '200': + description: >- + The dataset API for the given version is found and it is accessible + to consume. + content: + application/json: + schema: + type: string + '404': + description: >- + The combination of dataset name and version is not found in the + system or it is not published yet to be consumed by public. + content: + application/json: + schema: + type: string + /{dataset}/{version}/records: + post: + tags: + - search + summary: >- + Provides search capability for the data set with the given search + criteria. + description: >- + This API is based on Solr/Lucene Search. The data is indexed using + SOLR. This GET API returns the list of all the searchable field names + that are in the Solr Index. Please see the 'fields' attribute which + returns an array of field names. Each field or a combination of fields + can be searched using the Solr/Lucene Syntax. Please refer + https://lucene.apache.org/core/3_6_2/queryparsersyntax.html#Overview for + the query syntax. List of field names that are searchable can be + determined using above GET api. + operationId: perform-search + parameters: + - name: version + in: path + description: Version of the dataset. + required: true + schema: + type: string + default: v1 + - name: dataset + in: path + description: 'Name of the dataset. In this case, the default value is oa_citations' + required: true + schema: + type: string + default: oa_citations + responses: + '200': + description: successful operation + content: + application/json: + schema: + type: array + items: + type: object + additionalProperties: + type: object + '404': + description: No matching record found for the given criteria. + requestBody: + content: + application/x-www-form-urlencoded: + schema: + type: object + properties: + criteria: + description: >- + Uses Lucene Query Syntax in the format of + propertyName:value, propertyName:[num1 TO num2] and date + range format: propertyName:[yyyyMMdd TO yyyyMMdd]. In the + response please see the 'docs' element which has the list of + record objects. Each record structure would consist of all + the fields and their corresponding values. + type: string + default: '*:*' + start: + description: Starting record number. Default value is 0. + type: integer + default: 0 + rows: + description: >- + Specify number of rows to be returned. If you run the search + with default values, in the response you will see 'numFound' + attribute which will tell the number of records available in + the dataset. + type: integer + default: 100 + required: + - criteria +components: + schemas: + dataSetList: + type: object + properties: + total: + type: integer + apis: + type: array + items: + type: object + properties: + apiKey: + type: string + description: To be used as a dataset parameter value + apiVersionNumber: + type: string + description: To be used as a version parameter value + apiUrl: + type: string + format: uriref + description: "The URL describing the dataset's fields" + apiDocumentationUrl: + type: string + format: uriref + description: A URL to the API console for each API