vertx/src/main/java/eu/internetofus/common/vertx/OpenAPIValidator.java
/**
   * Check that the enum filed is right.
   *
   * @param futureToCompose to compose.
   * @param env             validation environment to use.
   *
   * @throws ValidationErrorException if it is not an instance of.
   *
   * @return the future to check the enum values.
   */
Check that the enum filed is right.
@param futureToCompose to compose.
@param env             validation environment to use.

@throws ValidationErrorException if it is not an instance of.

@return the future to check the enum values.
Check that the enum filed is right . @param futureToCompose to compose . @param env validation environment to use . @throws ValidationErrorException if it is not an instance of . @return the future to check the enum values .
private static Future<SpecificationEnvironment> checkEnum(
      @NotNull final Future<SpecificationEnvironment> futureToCompose, @NotNull final SpecificationEnvironment env)
      throws ValidationErrorException {
    var future = futureToCompose;
    final var value = env.specification.getValue("enum");
    if (value instanceof JsonArray) {
      final var array = (JsonArray) value;
      final var max = array.size();
      if (max == 0) {
        throw env.notValid("enum", "Expecting at least one value in the array.");
      } else {
        for (var i = 0; i < max; i++) {
          final var element = array.getValue(i);
          for (var j = i + 1; j < max; j++) {
            final var other = array.getValue(j);
            if (element == other || element != null && element.equals(other)) {
              throw env.notValid("enum[" + j + "]", "Duplicated enum value.");
            }
          }
          final var elementPrefix = "enum[" + i + "]";
          future = future
              .compose(chain -> validateValue(chain.prefixFor(elementPrefix), chain.vertx, chain.specification, element)
                  .map(any -> chain));
        }
      }
    } else {
      throw env.notValid("enum", "Expecting a 'JsonArray' value.");
    }
    return future;
  }
private static Future < SpecificationEnvironment > checkEnum ( @ NotNull final Future < SpecificationEnvironment > futureToCompose , @ NotNull final SpecificationEnvironment env ) throws ValidationErrorException { var future = futureToCompose ; final var value = env . specification . getValue ( "enum" ) ; if ( value instanceof JsonArray ) { final var array = ( JsonArray ) value ; final var max = array . size ( ) ; if ( max == 0 ) { throw env . notValid ( "enum" , "Expecting at least one value in the array." ) ; } else { for ( var i = 0 ; i < max ; i ++ ) { final var element = array . getValue ( i ) ; for ( var j = i + 1 ; j < max ; j ++ ) { final var other = array . getValue ( j ) ; if ( element == other || element != null && element . equals ( other ) ) { throw env . notValid ( "enum[" + j + "]" , "Duplicated enum value." ) ; } } final var elementPrefix = "enum[" + i + "]" ; future = future . compose ( chain -> validateValue ( chain . prefixFor ( elementPrefix ) , chain . vertx , chain . specification , element ) . map ( any -> chain ) ) ; } } } else { throw env . notValid ( "enum" , "Expecting a 'JsonArray' value." ) ; } return future ; }
Check that the enum filed is right.
Check that the enum filed is right .