Skip to content

ThouCheese/facet-openapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Run the bastard like this:

#[derive(facet_derive::Facet)]
struct ApiResponse {
    status_message: String,
    payload: ApiResponsePayload,
}

#[derive(facet_derive::Facet)]
struct ApiResponsePayload {
    payload_was_useful: bool,
}

println!(
    "{}",
    serde_json::to_string_pretty(&schema::<ApiResponse>()).unwrap()
);

And you will see:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "ApiResponse",
  "type": "object",
  "required": [
    "status_message",
    "payload"
  ],
  "properties": {
    "payload": {
      "$ref": "#/definitions/ApiResponsePayload"
    },
    "status_message": {
      "type": "string"
    }
  },
  "definitions": {
    "ApiResponsePayload": {
      "type": "object",
      "required": [
        "payload_was_useful"
      ],
      "properties": {
        "payload_was_useful": {
          "type": "boolean"
        }
      }
    }
  }
}

About

Generate openapi definitions from types that implement Facet

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages