forked from Azure/azure-sdk-for-rust
-
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.
* copy of ctaggart/autorust_openapi@fc2f579 * build autorust * cd services/autorust * use base_dir * remove custom path * $GITHUB_WORKSPACE * echo pwd * echo pwd * echo $PWD * specify paths * use separate paths for repositories * test openapi_spec_examples too * Copyright (c) 2020 Cameron Taggart * set major.minor versions * versions for dev-dependencies * name: test AutoRust * add NOTICE.txt for https://github.com/softprops/openapi/blob/master/LICENSE https://github.com/glademiller/openapiv3/blob/master/LICENSE-MIT
- Loading branch information
Showing
36 changed files
with
1,554 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
azure-sdk-for-rust | ||
|
||
NOTICES AND INFORMATION | ||
Do Not Translate or Localize | ||
|
||
This software incorporates material from third parties. Microsoft makes certain | ||
open source code available at https://3rdpartysource.microsoft.com, or you may | ||
send a check or money order for US $5.00, including the product name, the open | ||
source component name, and version number, to: | ||
|
||
Source Code Compliance Team | ||
Microsoft Corporation | ||
One Microsoft Way | ||
Redmond, WA 98052 | ||
USA | ||
|
||
Notwithstanding any other terms, you may reverse engineer this software to the | ||
extent required to debug changes to any libraries licensed under the GNU Lesser | ||
General Public License. | ||
|
||
------------------------------------------------------------------------------ | ||
|
||
Azure SDK for Rust uses third-party libraries or other resources that may be | ||
distributed under licenses different than the Azure SDK for Rust software. | ||
|
||
In the event that we accidentally failed to list a required notice, please | ||
bring it to our attention. Post an issue. | ||
|
||
The attached notices are provided for information only. | ||
|
||
License notice for softprops/openapi | ||
------------------------------------------------------------------------------ | ||
|
||
Copyright (c) 2017 Doug Tangren | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
License notice for glademiller/openapiv3 | ||
------------------------------------------------------------------------------ | ||
|
||
Permission is hereby granted, free of charge, to any | ||
person obtaining a copy of this software and associated | ||
documentation files (the "Software"), to deal in the | ||
Software without restriction, including without | ||
limitation the rights to use, copy, modify, merge, | ||
publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software | ||
is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice | ||
shall be included in all copies or substantial portions | ||
of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF | ||
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED | ||
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | ||
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR | ||
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
members = [ | ||
"autorust", | ||
"codegen", | ||
"openapi", | ||
] |
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,3 @@ | ||
target | ||
Cargo.lock | ||
*.bk |
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,53 @@ | ||
# 0.2 | ||
* forked as autorust_openapi | ||
* removed OpenAPI v3 support. Use openapiv3 crate | ||
* moved v2 module to be the root module | ||
* removed serde_yaml, url, serde_url, semver, error-chain, & failure dependencies | ||
* switched CI from Travis CI to GitHub Actions | ||
* removed pretty_assertions dev-dependencies | ||
* added serde_ignored dev-dependency | ||
* added integration tests for OpenAPI v2 specification examples | ||
* added integration tests for azure-rest-api-specs specifications | ||
* added --example ignored | ||
* add `ReferenceOr<T>` from openapiv3 | ||
* replace `ParameterOrRef` with `ReferenceOr<Parameter>` | ||
* rename `Spec` to `OpenAPI` to match openapiv3 | ||
* replace `Option<Vec<T>>` with `Vec<T>` and skip if `is_empty` like openapiv3 | ||
* add dependency on `indexmap` like openapiv3 | ||
* use `is_empty` on `IndexMap` instead of wrapping in `Option<T>` like openapiv3 | ||
* added missing Schema Object & Parameter Object fields | ||
* added StatusCode based on openapiv3 | ||
|
||
* expose security definition as an enum type | ||
* Adds License object | ||
* Adds Contact object | ||
* Derives Default for all structs | ||
* Derives Clone for all structs | ||
* Changes the order of the output to be more similar to OpenAPI examples | ||
* switch to 2018 edition | ||
|
||
# 0.1.5 | ||
|
||
* expose other schema types as public interfaces | ||
* re-export Result and ResultExt as top level interfaces | ||
|
||
# 0.1.4 | ||
|
||
* added operational `parameters` field to `Operations` object | ||
|
||
# 0.1.3 | ||
|
||
* added optional `required` and `enum_values` fields to `Schema` object | ||
|
||
# 0.1.2 | ||
|
||
* added optional `format` fields to `Parameter` object | ||
|
||
# 0.1.1 | ||
|
||
* added optional `summary` field to `Operation` object | ||
* made schemes and tags optional fields on `Operation` object | ||
|
||
# 0.1.0 | ||
|
||
* initial release |
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,20 @@ | ||
[package] | ||
name = "autorust_openapi" | ||
version = "0.2.0" | ||
authors = ["Cameron Taggart <[email protected]>", "softprops <[email protected]>"] | ||
description = "Rust bindings for OpenAPI v2 as needed by autorust" | ||
documentation = "https://docs.rs/autorust_openapi" | ||
homepage = "https://github.com/ctaggart/autorust_openapi" | ||
repository = "https://github.com/ctaggart/autorust_openapi" | ||
keywords = ["openapi", "swagger", "AutoRest", "autorust"] | ||
license = "MIT" | ||
edition = "2018" | ||
|
||
[dependencies] | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_json = "1.0" | ||
indexmap = {version = "1.0", features = ["serde-1"]} | ||
|
||
[dev-dependencies] | ||
assert-json-diff = "2.0" | ||
serde_yaml = "0.8" |
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,21 @@ | ||
Copyright (c) 2020 Cameron Taggart | ||
Copyright (c) 2017 Doug Tangren | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,17 @@ | ||
# autorust_openapi [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg)](LICENSE) | ||
|
||
Rust crate for deserializing [OpenAPI](http://swagger.io/specification/) documents as needed by [autorust](https://github.com/ctaggart/autorust/), an AutoRest extension. The goal is to be able to deserialize all of the documents found in [Azure/azure-rest-api-specs/specification](https://github.com/Azure/azure-rest-api-specs/tree/master/specification). They follow [OpenAPI Specfication Version 2.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameter-object) and use several [extensions](https://github.com/Azure/autorest/blob/master/docs/extensions/readme.md). | ||
|
||
## Install | ||
|
||
Add the following to your `Cargo.toml` file: | ||
|
||
```toml | ||
[dependencies] | ||
autorust_openapi = { git = "https://github.com/ctaggart/autorust_openapi" } | ||
``` | ||
|
||
## Similar Crates | ||
|
||
- This is a fork of the [openapi crate](https://crates.io/crates/openapi), maintained at [softprops/openapi](https://github.com/softprops/openapi). It was created by Doug Tangren (softprops) in 2017. | ||
- The [openapiv3 crate](https://github.com/glademiller/openapiv3) was created by Glade Miller in 2019 and is maintained at [glademiller/openapiv3](https://github.com/glademiller/openapiv3). |
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,43 @@ | ||
// Print the operation IDs alphabetically | ||
// cargo run --example operation_ids -- ../azure-rest-api-specs/specification/vmware/resource-manager/Microsoft.AVS/stable/2020-03-20/vmware.json | ||
|
||
use autorust_openapi::*; | ||
use std::{ | ||
fs::{self}, | ||
path::Path, | ||
process::exit, | ||
}; | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
match std::env::args().nth(1) { | ||
None => { | ||
eprintln!("Please pass in the spec path."); | ||
exit(1); | ||
} | ||
Some(file_in) => { | ||
let file_in = Path::new(&file_in); | ||
let bytes = fs::read(file_in)?; | ||
let api: OpenAPI = serde_json::from_slice(&bytes)?; | ||
|
||
let mut operation_ids = Vec::new(); | ||
for (_path, item) in &api.paths { | ||
match item { | ||
ReferenceOr::Reference { .. } => (), | ||
ReferenceOr::Item(item) => { | ||
for op in item.operations() { | ||
if let Some(operation_id) = &op.operation_id { | ||
operation_ids.push(operation_id); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
operation_ids.sort(); | ||
for operation_id in operation_ids { | ||
println!("{}", operation_id); | ||
} | ||
} | ||
} | ||
Ok(()) | ||
} |
Oops, something went wrong.