vertx/src/main/java/eu/internetofus/common/vertx/OpenAPIValidator.java
/**
   * Check that the default value is right.
   *
   * @param future to concatenate.
   * @param env    validation environment to use.
   *
   * @throws ValidationErrorException if it is not an instance of.
   *
   * @return the future that say if the default value is valid or not.
   */
Check that the default value is right.
@param future to concatenate.
@param env    validation environment to use.

@throws ValidationErrorException if it is not an instance of.

@return the future that say if the default value is valid or not.
Check that the default value is right . @param future to concatenate . @param env validation environment to use . @throws ValidationErrorException if it is not an instance of . @return the future that say if the default value is valid or not .
private static Future<SpecificationEnvironment> checkDefault(@NotNull final Future<SpecificationEnvironment> future,
      @NotNull final SpecificationEnvironment env) throws ValidationErrorException {
    final var value = env.specification.getValue("default");
    if (value instanceof String) {
      try {
        final var decoded = Json.decodeValue((String) value);
        return future
            .compose(chain -> validateValue(null, chain.vertx, chain.specification, decoded).transform(validation -> {
              final Promise<SpecificationEnvironment> promise = Promise.promise();
              if (validation.failed()) {
                final var cause = (ValidationErrorException) validation.cause();
                var prefix = "default";
                final var code = cause.getCode();
                if (code != null) {
                  prefix += code;
                }
                promise.fail(chain.notValid(prefix, cause.getMessage()));
              } else {
                promise.complete(chain);
              }
              return promise.future();
            }));
      } catch (final Throwable cause) {
        throw env.notValid("default", "Bad encoded JSON value.", cause);
      }
    } else {
      throw env.notValid("default", "Expecting a 'string' value.");
    }
  }
private static Future < SpecificationEnvironment > checkDefault ( @ NotNull final Future < SpecificationEnvironment > future , @ NotNull final SpecificationEnvironment env ) throws ValidationErrorException { final var value = env . specification . getValue ( "default" ) ; if ( value instanceof String ) { try { final var decoded = Json . decodeValue ( ( String ) value ) ; return future . compose ( chain -> validateValue ( null , chain . vertx , chain . specification , decoded ) . transform ( validation -> { final Promise < SpecificationEnvironment > promise = Promise . promise ( ) ; if ( validation . failed ( ) ) { final var cause = ( ValidationErrorException ) validation . cause ( ) ; var prefix = "default" ; final var code = cause . getCode ( ) ; if ( code != null ) { prefix += code ; } promise . fail ( chain . notValid ( prefix , cause . getMessage ( ) ) ) ; } else { promise . complete ( chain ) ; } return promise . future ( ) ; } ) ) ; } catch ( final Throwable cause ) { throw env . notValid ( "default" , "Bad encoded JSON value." , cause ) ; } } else { throw env . notValid ( "default" , "Expecting a 'string' value." ) ; } }
Check that the default value is right.
Check that the default value is right .