title: SpringFox Swagger make Definition properties required with XSD model
body: <p>I have a REST webapp which uses Swagger for the documentation and it's working great except for the body parameter. All the properties of the body are optional</p>
  <p><a href="https://i.stack.imgur.com/udBLk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/udBLk.png" alt="Swagger-ui" /></a></p>
  <p>My Project object is generated with an XSD file and i made sure all the element where <strong>minOccurs=1 maxOccurs=1 or unbounded</strong> and all my attributes are set to <strong>use=required</strong>. This doesn't seem to have any effect on it. The next thing I tried was adding</p>
  <p><strong>@ApiParam(value = &quot;The project body&quot;, required = true) @RequestBody ProjectInfo project</strong></p>
  <p>But this had no effect either because the Project object itself is already required. Is there anyway to tell Swagger that the properties of Project are also required? I'm using the SpringFox dependency for Swagger.</p>
  <h1>Update</h1>
  <p>I managed to get it required by adding <strong>@ApiModel</strong> and <strong>@ApiModelProperty(value = &quot;The unique name of the project&quot;, required = true)</strong> to my generated model.</p>
  <pre><code>//
  // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11 
  // See &lt;a href=&quot;http://java.sun.com/xml/jaxb&quot;&gt;http://java.sun.com/xml/jaxb&lt;/a&gt; 
  // Any modifications to this file will be lost upon recompilation of the source schema. 
  // Generated on: 2016.02.12 at 09:33:59 AM CET 
  //
  
  
  package be.smartask.api.model.post;
  
  import io.swagger.annotations.ApiModel;
  import io.swagger.annotations.ApiModelProperty;
  
  import javax.xml.bind.annotation.*;
  
  
  /**
   * &lt;p&gt;Java class for anonymous complex type.
   * &lt;p&gt;
   * &lt;p&gt;The following schema fragment specifies the expected content contained within this class.
   * &lt;p&gt;
   * &lt;pre&gt;
   * &amp;lt;complexType&amp;gt;
   *   &amp;lt;complexContent&amp;gt;
   *     &amp;lt;restriction base=&quot;{http://www.w3.org/2001/XMLSchema}anyType&quot;&amp;gt;
   *       &amp;lt;attribute name=&quot;name&quot; use=&quot;required&quot; type=&quot;{http://www.w3.org/2001/XMLSchema}string&quot; /&amp;gt;
   *     &amp;lt;/restriction&amp;gt;
   *   &amp;lt;/complexContent&amp;gt;
   * &amp;lt;/complexType&amp;gt;
   * &lt;/pre&gt;
   */
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = &quot;&quot;)
  @XmlRootElement(name = &quot;projectInfo&quot;)
  @ApiModel
  public class ProjectInfo {
  
      @XmlAttribute(name = &quot;name&quot;, required = true)
      protected String name;
  
      /**
       * Gets the value of the name property.
       *
       * @return possible object is
       * {@link String }
       */
      @ApiModelProperty(value = &quot;The unique name of the project&quot;, required = true)
      public String getName() {
          return name;
      }
  
      /**
       * Sets the value of the name property.
       *
       * @param value allowed object is
       *              {@link String }
       */
      public void setName(String value) {
          this.name = value;
      }
  
  }
  </code></pre>
  <p>But now my question changed to <strong>Can I add Swagger annotations in the XSD file so it will generate by itself?</strong></p>