Skip to content

Add pattern and format check for Strings in one/any/allOf  #449

Closed
@fjtirado

Description

@fjtirado

String patterns are currently ignored for strings that are an option in anyOf/allOf/oneOf construct

This means that, for example, ErrorInstance section of the schema

 instance:
        title: ErrorInstance
        description: A JSON Pointer used to reference the component the error originates from.
        oneOf:
          - title: LiteralErrorInstance
            description: The literal error instance.
            type: string
            format: json-pointer
          - $ref: '#/$defs/runtimeExpression'
            title: ExpressionErrorInstance
            description: An expression based error instance.

is currently translated to class

public class ErrorInstance
    implements OneOfValueProvider
{

    private Object value;
    private String literalErrorInstance;
    private String expressionErrorInstance;

    public ErrorInstance(String literalErrorInstance) {
        this.value = literalErrorInstance;
        this.literalErrorInstance = literalErrorInstance;
        this.value = literalErrorInstance;
        this.expressionErrorInstance = literalErrorInstance;
    }

    public ErrorInstance() {
    }

    @Override
    public Object get() {
        return value;
    }

    public String getLiteralErrorInstance() {
        return literalErrorInstance;
    }

    public String getExpressionErrorInstance() {
        return expressionErrorInstance;
    }

}

The generated constructor should be

    public ErrorInstance(String erroString) {

        if (fulfillsRuntimeExpressionPattern(errorString)) {
               this.expressionErrorInstance = errorString;
        } else { 
              this.literalErrorInstance = errorString;
       }
        this.value = errorString;
    }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions