Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support custom properties #446

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

RolandMa1986
Copy link

@RolandMa1986 RolandMa1986 commented Jul 6, 2022

Support openapi extensions.
https://swagger.io/docs/specification/openapi-extensions/

The extened properties start with "x_" and will be coverted to "x-" in json.

    #[openapi(x_my_property=3)]
    pub some_property: Option<i32>,

Output:

{
      "type": "object",
      "properties": {
          "some_property": {
              "x-my-property": 3,
              "type": "integer",
              "format": "int32"
          }
}

Signed-off-by: Roland Ma <[email protected]>
Signed-off-by: Roland Ma <[email protected]>
Signed-off-by: Roland Ma <[email protected]>
@RolandMa1986
Copy link
Author

@tiagolobocastro would you like to take a look at this PR?

@tiagolobocastro tiagolobocastro changed the title support custorm properties support custom properties Aug 8, 2022
Copy link
Collaborator

@tiagolobocastro tiagolobocastro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RolandMa1986 sorry this has slipped through the nets.
Could you please add a test for custom properties?

@@ -846,6 +880,7 @@ pub fn emit_v2_definition(input: TokenStream) -> TokenStream {
let mut schema = DefaultSchemaRaw {
name: Some(#schema_name.into()),
example: #example,
extensions:#extensions,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add space?

@@ -855,6 +890,7 @@ pub fn emit_v2_definition(input: TokenStream) -> TokenStream {
let mut schema = DefaultSchemaRaw {
name: Some(Self::__paperclip_schema_name()), // Add name for later use.
example: #example,
extensions:#extensions,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add space?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants