{"id":13778,"date":"2024-03-15T07:51:23","date_gmt":"2024-03-15T07:51:23","guid":{"rendered":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/"},"modified":"2025-08-05T23:20:25","modified_gmt":"2025-08-05T23:20:25","slug":"what-is-the-usage-of-apimodelproperty-in-swagger","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/","title":{"rendered":"Swagger @ApiModelProperty Usage Guide"},"content":{"rendered":"<p>The @ApiModelProperty annotation in Swagger is used to provide information about model attributes, such as the attribute name, data type, example value, default value, and whether it is required.<\/p>\n<p>The specific usage is as follows:<\/p>\n<ol>\n<li>Use the @ApiModelProperty annotation on the properties of the model class to specify the description of the property.<\/li>\n<li>Specify the name of the attribute using the value property.<\/li>\n<li>Specify the data type of the property through the dataType attribute.<\/li>\n<li>Specify the example value for the attribute using the example property.<\/li>\n<li>The required attribute specifies whether a property is necessary, with a default value of false.<\/li>\n<li>Specify the default value for a property through the defaultValue attribute.<\/li>\n<\/ol>\n<p>Here is a sample code:<\/p>\n<pre class=\"post-pre\"><code><span class=\"hljs-keyword\">public<\/span> <span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title class_\">User<\/span> {\r\n    <span class=\"hljs-meta\">@ApiModelProperty(value = \"\u7528\u6237ID\", dataType = \"Long\", example = \"1\")<\/span>\r\n    <span class=\"hljs-keyword\">private<\/span> Long id;\r\n  \r\n    <span class=\"hljs-meta\">@ApiModelProperty(value = \"\u7528\u6237\u540d\", dataType = \"String\", required = true)<\/span>\r\n    <span class=\"hljs-keyword\">private<\/span> String username;\r\n  \r\n    <span class=\"hljs-meta\">@ApiModelProperty(value = \"\u5bc6\u7801\", dataType = \"String\")<\/span>\r\n    <span class=\"hljs-keyword\">private<\/span> String password;\r\n  \r\n    <span class=\"hljs-comment\">\/\/ getters and setters<\/span>\r\n}\r\n<\/code><\/pre>\n<p>In the above example, the @ApiModelProperty annotation is used to describe the id, username, and password attributes of the User class. The value property specifies the name of the attribute, the dataType property specifies the data type of the attribute, the example property specifies the example value of the attribute, and the required property specifies whether the attribute is required, with the default value being false.<\/p>\n<p>This way, when generating Swagger documentation, information about model properties can be displayed based on the @ApiModelProperty annotation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The @ApiModelProperty annotation in Swagger is used to provide information about model attributes, such as the attribute name, data type, example value, default value, and whether it is required. The specific usage is as follows: Use the @ApiModelProperty annotation on the properties of the model class to specify the description of the property. Specify the [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[1],"tags":[3423,18437,2740,1289,2722],"class_list":["post-13778","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-api-documentation","tag-apimodelproperty","tag-java-annotations","tag-rest-api","tag-swagger"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Swagger @ApiModelProperty Usage Guide - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"Learn how to use @ApiModelProperty annotation in Swagger to document your API models. Guide covers properties, examples, and implementation.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Swagger @ApiModelProperty Usage Guide\" \/>\n<meta property=\"og:description\" content=\"Learn how to use @ApiModelProperty annotation in Swagger to document your API models. Guide covers properties, examples, and implementation.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-15T07:51:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-05T23:20:25+00:00\" \/>\n<meta name=\"author\" content=\"Sophia Anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:site\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sophia Anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/\"},\"author\":{\"name\":\"Sophia Anderson\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/19a24313de9c988db3d69226b4a40a30\"},\"headline\":\"Swagger @ApiModelProperty Usage Guide\",\"datePublished\":\"2024-03-15T07:51:23+00:00\",\"dateModified\":\"2025-08-05T23:20:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/\"},\"wordCount\":204,\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"keywords\":[\"API Documentation\",\"ApiModelProperty\",\"Java annotations\",\"REST API\",\"Swagger\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/\",\"name\":\"Swagger @ApiModelProperty Usage Guide - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\"},\"datePublished\":\"2024-03-15T07:51:23+00:00\",\"dateModified\":\"2025-08-05T23:20:25+00:00\",\"description\":\"Learn how to use @ApiModelProperty annotation in Swagger to document your API models. Guide covers properties, examples, and implementation.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.silicloud.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Swagger @ApiModelProperty Usage Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"name\":\"Silicon Cloud Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\",\"name\":\"Silicon Cloud Blog\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"contentUrl\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"width\":1024,\"height\":1024,\"caption\":\"Silicon Cloud Blog\"},\"image\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\",\"https:\/\/twitter.com\/SiliCloudGlobal\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/19a24313de9c988db3d69226b4a40a30\",\"name\":\"Sophia Anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c726c09aa40e37115fb5c62d0c3ed62c16ca255d3763e2e3ae83a70ddf8c2175?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c726c09aa40e37115fb5c62d0c3ed62c16ca255d3763e2e3ae83a70ddf8c2175?s=96&d=mm&r=g\",\"caption\":\"Sophia Anderson\"},\"url\":\"https:\/\/www.silicloud.com\/blog\/author\/sophiaanderson\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Swagger @ApiModelProperty Usage Guide - Blog - Silicon Cloud","description":"Learn how to use @ApiModelProperty annotation in Swagger to document your API models. Guide covers properties, examples, and implementation.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/","og_locale":"en_US","og_type":"article","og_title":"Swagger @ApiModelProperty Usage Guide","og_description":"Learn how to use @ApiModelProperty annotation in Swagger to document your API models. Guide covers properties, examples, and implementation.","og_url":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/","og_site_name":"Blog - Silicon Cloud","article_publisher":"https:\/\/www.facebook.com\/SiliCloudGlobal\/","article_published_time":"2024-03-15T07:51:23+00:00","article_modified_time":"2025-08-05T23:20:25+00:00","author":"Sophia Anderson","twitter_card":"summary_large_image","twitter_creator":"@SiliCloudGlobal","twitter_site":"@SiliCloudGlobal","twitter_misc":{"Written by":"Sophia Anderson","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/#article","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/"},"author":{"name":"Sophia Anderson","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/19a24313de9c988db3d69226b4a40a30"},"headline":"Swagger @ApiModelProperty Usage Guide","datePublished":"2024-03-15T07:51:23+00:00","dateModified":"2025-08-05T23:20:25+00:00","mainEntityOfPage":{"@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/"},"wordCount":204,"publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"keywords":["API Documentation","ApiModelProperty","Java annotations","REST API","Swagger"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/","url":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/","name":"Swagger @ApiModelProperty Usage Guide - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/#website"},"datePublished":"2024-03-15T07:51:23+00:00","dateModified":"2025-08-05T23:20:25+00:00","description":"Learn how to use @ApiModelProperty annotation in Swagger to document your API models. Guide covers properties, examples, and implementation.","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-apimodelproperty-in-swagger\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.silicloud.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Swagger @ApiModelProperty Usage Guide"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/blog\/#website","url":"https:\/\/www.silicloud.com\/blog\/","name":"Silicon Cloud Blog","description":"","publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.silicloud.com\/blog\/#organization","name":"Silicon Cloud Blog","url":"https:\/\/www.silicloud.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","contentUrl":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","width":1024,"height":1024,"caption":"Silicon Cloud Blog"},"image":{"@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/SiliCloudGlobal\/","https:\/\/twitter.com\/SiliCloudGlobal"]},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/19a24313de9c988db3d69226b4a40a30","name":"Sophia Anderson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c726c09aa40e37115fb5c62d0c3ed62c16ca255d3763e2e3ae83a70ddf8c2175?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c726c09aa40e37115fb5c62d0c3ed62c16ca255d3763e2e3ae83a70ddf8c2175?s=96&d=mm&r=g","caption":"Sophia Anderson"},"url":"https:\/\/www.silicloud.com\/blog\/author\/sophiaanderson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/13778","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/comments?post=13778"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/13778\/revisions"}],"predecessor-version":[{"id":157785,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/13778\/revisions\/157785"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/media?parent=13778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/categories?post=13778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/tags?post=13778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}