Skip to content

Commit d1b2b06

Browse files
update snapshot test. Fix typos
1 parent 2abb6a4 commit d1b2b06

File tree

12 files changed

+86
-14
lines changed

12 files changed

+86
-14
lines changed

cli/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct SwiftParams {
3434
pub prefix: String,
3535
pub default_decorators: Vec<String>,
3636
pub default_generic_constraints: Vec<String>,
37-
/// The contraints to apply to `CodableVoid`.
37+
/// The constraints to apply to `CodableVoid`.
3838
pub codablevoid_constraints: Vec<String>,
3939
pub type_mappings: HashMap<String, String>,
4040
}
@@ -55,7 +55,7 @@ pub struct GoParams {
5555
pub type_mappings: HashMap<String, String>,
5656
}
5757

58-
/// The paramters that are used to configure the behaviour of typeshare
58+
/// The parameters that are used to configure the behaviour of typeshare
5959
/// from the configuration file `typeshare.toml`
6060
#[derive(Serialize, Deserialize, Default, Debug, PartialEq)]
6161
#[serde(default)]

core/data/tests/excluded_by_target_os/input.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,14 @@ pub struct AndroidExcluded;
8080
#[typeshare]
8181
#[cfg(all(feature = "my-feature", not(target_os = "ios")))]
8282
pub struct NestedNotTarget1;
83+
84+
/// A struct with no target_os. Should be generated when
85+
/// we use --target-os.
86+
#[typeshare]
87+
pub struct AlwaysAccept;
88+
89+
#[typeshare]
90+
pub enum AlwaysAcceptEnum {
91+
Variant1,
92+
Variant2,
93+
}

core/data/tests/excluded_by_target_os/output.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ package proto
22

33
import "encoding/json"
44

5+
// A struct with no target_os. Should be generated when
6+
// we use --target-os.
7+
type AlwaysAccept struct {
8+
}
59
type DefinedTwice struct {
610
Field1 string `json:"field1"`
711
}
@@ -15,6 +19,11 @@ type NestedNotTarget1 struct {
1519
}
1620
type OtherExcluded struct {
1721
}
22+
type AlwaysAcceptEnum string
23+
const (
24+
AlwaysAcceptEnumVariant1 AlwaysAcceptEnum = "Variant1"
25+
AlwaysAcceptEnumVariant2 AlwaysAcceptEnum = "Variant2"
26+
)
1827
type SomeEnum string
1928
const (
2029
)

core/data/tests/excluded_by_target_os/output.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ package com.agilebits.onepassword
33
import kotlinx.serialization.Serializable
44
import kotlinx.serialization.SerialName
55

6+
/// A struct with no target_os. Should be generated when
7+
/// we use --target-os.
8+
@Serializable
9+
object AlwaysAccept
10+
611
@Serializable
712
data class DefinedTwice (
813
val field1: String
@@ -23,6 +28,14 @@ object NestedNotTarget1
2328
@Serializable
2429
object OtherExcluded
2530

31+
@Serializable
32+
enum class AlwaysAcceptEnum(val string: String) {
33+
@SerialName("Variant1")
34+
Variant1("Variant1"),
35+
@SerialName("Variant2")
36+
Variant2("Variant2"),
37+
}
38+
2639
@Serializable
2740
enum class SomeEnum(val string: String) {
2841
}

core/data/tests/excluded_by_target_os/output.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ package com.agilebits
22

33
package onepassword {
44

5+
// A struct with no target_os. Should be generated when
6+
// we use --target-os.
7+
class AlwaysAccept extends Serializable
8+
59
case class DefinedTwice (
610
field1: String
711
)
@@ -16,6 +20,18 @@ class NestedNotTarget1 extends Serializable
1620

1721
class OtherExcluded extends Serializable
1822

23+
sealed trait AlwaysAcceptEnum {
24+
def serialName: String
25+
}
26+
object AlwaysAcceptEnum {
27+
case object Variant1 extends AlwaysAcceptEnum {
28+
val serialName: String = "Variant1"
29+
}
30+
case object Variant2 extends AlwaysAcceptEnum {
31+
val serialName: String = "Variant2"
32+
}
33+
}
34+
1935
sealed trait SomeEnum {
2036
def serialName: String
2137
}

core/data/tests/excluded_by_target_os/output.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import Foundation
22

3+
/// A struct with no target_os. Should be generated when
4+
/// we use --target-os.
5+
public struct AlwaysAccept: Codable {
6+
public init() {}
7+
}
8+
39
public struct DefinedTwice: Codable {
410
public let field1: String
511

@@ -28,6 +34,11 @@ public struct OtherExcluded: Codable {
2834
public init() {}
2935
}
3036

37+
public enum AlwaysAcceptEnum: String, Codable {
38+
case variant1 = "Variant1"
39+
case variant2 = "Variant2"
40+
}
41+
3142
public enum SomeEnum: String, Codable {
3243
}
3344

core/data/tests/excluded_by_target_os/output.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/**
2+
* A struct with no target_os. Should be generated when
3+
* we use --target-os.
4+
*/
5+
export interface AlwaysAccept {
6+
}
7+
18
export interface DefinedTwice {
29
field1: string;
310
}
@@ -17,6 +24,11 @@ export interface NestedNotTarget1 {
1724
export interface OtherExcluded {
1825
}
1926

27+
export enum AlwaysAcceptEnum {
28+
Variant1 = "Variant1",
29+
Variant2 = "Variant2",
30+
}
31+
2032
export enum SomeEnum {
2133
}
2234

core/src/language/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub type SortedCrateNames<'a> = &'a CrateName;
8888
/// A sorted type name ref.
8989
pub type SortedTypeNames<'a> = BTreeSet<&'a str>;
9090

91-
/// Refence types by crate that are scoped for a given output module.
91+
/// Reference types by crate that are scoped for a given output module.
9292
pub type ScopedCrateTypes<'a> = BTreeMap<SortedCrateNames<'a>, SortedTypeNames<'a>>;
9393

9494
/// All supported programming languages.

core/src/language/swift.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ pub struct Swift {
150150
/// Whether or not to exclude the version header that normally appears at the top of generated code.
151151
/// If you aren't generating a snapshot test, this setting can just be left as a default (false)
152152
pub no_version_header: bool,
153-
/// Are we generating mutliple modules?
153+
/// Are we generating multiple modules?
154154
pub multi_file: bool,
155-
/// The contraints to apply to `CodableVoid`.
155+
/// The constraints to apply to `CodableVoid`.
156156
pub codablevoid_constraints: Vec<String>,
157157
}
158158

@@ -501,7 +501,7 @@ impl Language for Swift {
501501
writeln!(w, "}}")
502502
}
503503

504-
// TODO: This will be addded in the future.
504+
// TODO: This will be added in the future.
505505
// fn write_imports(
506506
// &mut self,
507507
// w: &mut dyn Write,
@@ -753,7 +753,7 @@ impl Swift {
753753
.chain(self.default_decorators.iter().map(|s| s.as_str()))
754754
}
755755

756-
/// When using mulitple file generation we write this into a separate module vs at the
756+
/// When using multiple file generation we write this into a separate module vs at the
757757
/// end of the generated file.
758758
fn write_codable_file(&self, output_folder: &str) -> std::io::Result<()> {
759759
let mut w = File::create(Path::new(output_folder).join("Codable.swift"))?;
@@ -789,7 +789,7 @@ impl Swift {
789789
decorator_map: &'a DecoratorMap,
790790
generic_types: &'a [String],
791791
) -> String {
792-
let swift_generic_contraints_annotated = decorator_map
792+
let swift_generic_constraints_annotated = decorator_map
793793
.get(&DecoratorKind::SwiftGenericConstraints)
794794
.map(|generic_constraints| {
795795
generic_constraints
@@ -814,7 +814,7 @@ impl Swift {
814814
generic_types
815815
.iter()
816816
.map(
817-
|type_name| match swift_generic_contraints_annotated.get(type_name.as_str()) {
817+
|type_name| match swift_generic_constraints_annotated.get(type_name.as_str()) {
818818
// Use constraints from swiftGenericConstraints decorator.
819819
Some(constraints) => (type_name, Either::Left(constraints.iter().copied())),
820820
// Use the default generic constraints if it is not part of a swiftGenericConstraints decorator.

core/src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub enum ParseError {
8080
/// Error with it's related data.
8181
#[derive(Debug)]
8282
pub struct ErrorInfo {
83-
/// The crate where this error occured.
83+
/// The crate where this error occurred.
8484
pub crate_name: CrateName,
8585
/// The file name being parsed.
8686
pub file_name: String,

0 commit comments

Comments
 (0)