Skip to content

Commit

Permalink
Backport of Merge #135
Browse files Browse the repository at this point in the history
135: Workaround API break on private API in Serde 1.0.119 r=richardwhiuk a=richardwhiuk

We are using a private API in serde, and they've changed the API in a patch release to remind us this is wrong:

serde-rs/serde@dd1f4b4

That's annoying, but there's no easy viable alternative. This API is used by serde_derive on an untagged enum ( see https://github.com/serde-rs/serde/blob/b0c99ed761d638f2ca2f0437522e6c35ad254d93/serde_derive/src/de.rs#L1627-L1645 ), which is basically what we have.

We can't use serde_derive, because we want specific semantics. The only alternative is re-implementing the `ContentRefDeserializer` and `Content` objects, which is clearly worse than depending on this private API.

I've asked in Discord and raised serde-rs/serde#1947 to query the serde devs.

Signed-off-by: Richard Whitehouse <[email protected]>
Co-authored-by: Richard Whitehouse <[email protected]>
  • Loading branch information
bors[bot] and richardwhiuk committed Jan 18, 2021
1 parent c08b031 commit e665af9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ matrix:
- rust: nightly
include:
- rust: stable
env: CLIPPY=1
env: CHECK_CLIPPY=1
before_script:
- rustup component add clippy-preview
script:
Expand All @@ -25,10 +25,11 @@ matrix:
script:
- cargo build --all-features
- rust: stable
env: RUSTFMT=1
env: CHECK_RUSTFMT=1
before_script:
- rustup component add rustfmt-preview
- rustup component add rustfmt
script:
- rustup component list --installed
- cargo fmt -- --check
branches:
only:
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Changed

### Removed
### Fixed
- Fix interop with serde 1.0.119

## [3.4.0] - 2020-05-04
### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ serdejson = ["serde", "serde_json"]
[dependencies]
base64 = "0.10"
mime = { version = "0.3", optional = true }
serde = { version = "1.0", optional = true, features = ["derive"] }
serde = { version = "1.0.119", optional = true, features = ["derive"] }
serde_json = { version = "1.0", optional = true }
hyper = "0.12.25"
hyper-tls = "0.2.1"
Expand Down
2 changes: 1 addition & 1 deletion src/one_any_of.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Implementations of OpenAPI `oneOf` and `anyOf` types, assuming rules are just types
use serde::{
de::Error,
private::de::{Content, ContentRefDeserializer},
Deserialize, Deserializer, Serialize, Serializer,
__private::de::{Content, ContentRefDeserializer},
};
use std::str::FromStr;
use std::string::ToString;
Expand Down
2 changes: 2 additions & 0 deletions src/request_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ pub trait RequestParser<B> {
/// Retrieve the Swagger operation identifier that matches this request.
///
/// Returns `Err(())` if this request does not match any known operation on this API.
// Allow this lint, as changing the signature is a breaking change.
#[allow(clippy::result_unit_err)]
fn parse_operation_id(req: &Request<B>) -> Result<&'static str, ()>;
}

Expand Down

0 comments on commit e665af9

Please sign in to comment.