-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate with official schema, sanitize identifiers properly, panic o…
…n duplicate operationId (#39) * validation schema + sanitize all identifiers * panic on duplicate operationIds * renamed sanitized_operation_ids() to sanitize_operation_ids_and_check_duplicate * added LICENSE and NOTICE for validator_schema * revert spec --------- Co-authored-by: Stanislav Kosorin <[email protected]> Co-authored-by: Felix <[email protected]>
- Loading branch information
1 parent
52d0d3a
commit 16143a0
Showing
14 changed files
with
5,416 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
asyncapi: 2.1.0 | ||
info: | ||
title: My_API | ||
version: 1.0.0 | ||
servers: | ||
production: | ||
url: demo.nats.io | ||
protocol: nats | ||
channels: | ||
user/signedup: | ||
subscribe: | ||
operationId: onUserSignup.l;/.,;';.,\n' | ||
summary: User signup notification | ||
message: | ||
payload: | ||
type: object | ||
properties: | ||
userSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUp: | ||
type: string | ||
publish: | ||
operationId: userSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUp | ||
summary: send welcome email to user | ||
message: | ||
payload: | ||
type: string | ||
|
||
user/signedupd: | ||
subscribe: | ||
operationId: onUserSignup.l/.,;';.,\nfdsfsd | ||
summary: User signup notification | ||
message: | ||
payload: | ||
type: object | ||
properties: | ||
userSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUp: | ||
type: string | ||
publish: | ||
operationId: userSing\edUpuserSing\edUpudserSing\edUpuserSfdsing\edfdsUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUpuserSing\edUp | ||
summary: send welcome email to user | ||
message: | ||
payload: | ||
type: string | ||
user/buy: | ||
subscribe: | ||
operationId: userBought | ||
summary: User bought something | ||
message: | ||
payload: | ||
type: string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
mod common; | ||
mod preprocessor; | ||
mod pubsub; | ||
mod resolve_refs; | ||
mod schema_parser; | ||
mod validator; | ||
pub use common::parse_spec_to_model; | ||
pub use pubsub::spec_to_pubsub_template_type; | ||
pub use resolve_refs::resolve_refs; | ||
pub use schema_parser::schema_parser_mapper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use jsonschema::JSONSchema; | ||
|
||
pub fn validate_asyncapi_schema(validator: &serde_json::Value, instance: &serde_json::Value) { | ||
let compiled = JSONSchema::compile(validator).expect("A valid schema"); | ||
let result = compiled.validate(instance); | ||
if let Err(errors) = result { | ||
for error in errors { | ||
println!("Validation error: {}", error); | ||
println!("Instance path: {}", error.instance_path); | ||
} | ||
panic!("Validation failed"); | ||
} else { | ||
println!("Validation succeeded"); | ||
} | ||
} |
Oops, something went wrong.