Uploaded image for project: 'netconf'
  1. netconf
  2. NETCONF-1312

Openapi: Add ability to limit string example length

XMLWordPrintable

      According to RFC 7950: The YANG 1.1 Data Modeling Language we can use the length parameter together with the pattern, e.g:

      type string {
             length "0..4";
             pattern "[0-9a-fA-F]*";
           }
      

      Currently, restconf-openapi generates string examples without considering length parameter and just follows regex.

      https://git.opendaylight.org/gerrit/c/netconf/+/111698 patch demonstrates that Automaton#getShortestExample generate empty string which is correct in terms of regex, but incorrect if we consider min length parameter.

      We can adapt Generex#prepareRandom in our logic, but without generating random examples as this will break OpenApi integration tests.

            yaroslav.lastivka Yaroslav Lastivka
            yaroslav.lastivka Yaroslav Lastivka
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: