openapi / actix-swagger

Swagger code generator for actix-web framework
https://crates.io/crates/cargo-swagg
MIT License
111 stars 8 forks source link

Custom attributes #11

Open sergeysova opened 4 years ago

sergeysova commented 4 years ago

Single attribute:

schema:
  properties:
    demo:
      type: string
        x-rust-attribute: serde(skip_serializing_if = "Option::is_none")

Should generate something like:

struct Example {
  #[serde(skip_serializing_if = "Option::is_none")]
  demo: String,
}

Multiple attributes:

schema:
  properties:
    demo:
      type: string
        x-rust-attribute:
          - serde(skip_serializing_if = “Option::is_none”)
          - validate(url)

Output:

struct Example {
  #[serde(skip_serializing_if = "Option::is_none")]
  #[validate(url)]
  demo: String,
}